public function showForm($ID, $options = array()) { global $CFG_GLPI, $DB; $this->initForm($ID, $options); $this->showFormHeader($options); $rand = mt_rand(); $config = PluginOrderConfig::getConfig(); $user = new User(); if (isset($options['withtemplate']) && $options['withtemplate'] == 2) { $template = "newcomp"; $datestring = sprintf(__('Created on %s'), Html::convDateTime($_SESSION["glpi_currenttime"])); } elseif (isset($options['withtemplate']) && $options['withtemplate'] == 1) { $template = "newtemplate"; $datestring = sprintf(__('Created on %s'), Html::convDateTime($_SESSION["glpi_currenttime"])); } else { $template = false; $datestring = sprintf(__('Last update on %s'), Html::convDateTime($this->fields["date_mod"])); } $canedit = $this->canUpdateOrder() && $this->canUpdate() && !$this->isCanceled(); $cancancel = self::canCancel() && $this->can($ID, UPDATE) && $this->isCanceled(); $options['canedit'] = $canedit; $options['candel'] = $cancancel; if ($template) { $this->fields['order_date'] = NULL; } // Displaying OVER BUDGET ALERT if ($this->fields['budgets_id'] > 0) { self::displayAlertOverBudget(self::isOverBudget($ID)); } //Display without inside table /* title */ echo "<tr class='tab_bg_1'><td>" . __("Order name", "order") . "*: </td>"; echo "<td>"; if ($canedit) { $objectName = autoName($this->fields["name"], "name", $template === "newcomp", $this->getType(), $this->fields["entities_id"]); Html::autocompletionTextField($this, "name", array('value' => $objectName)); } else { echo $this->fields["name"]; } echo "</td>"; /* date of order */ echo "<td>" . __("Date of order", "order") . ":</td><td>"; if ($canedit) { if ($this->fields["order_date"] == NULL) { Html::showDateFormItem("order_date", date("Y-m-d"), true, true); } else { Html::showDateFormItem("order_date", $this->fields["order_date"], true, true); } } else { echo Html::convDate($this->fields["order_date"]); } echo "</td></tr>"; /* num order */ echo "<tr class='tab_bg_1'><td>" . __("Order number", "order"); if ($ID > 0) { echo "*"; } else { echo " <span class='red'>*</span>"; } echo ": </td>"; echo "<td>"; if ($canedit) { $objectOrder = autoName($this->fields["num_order"], "num_order", $template === "newcomp", $this->getType(), $this->fields["entities_id"]); Html::autocompletionTextField($this, "num_order", array('value' => $objectOrder)); } else { echo $this->fields["num_order"]; } echo "</td>"; /* type order */ echo "<td>" . __("Type") . ": </td><td>"; if ($canedit) { PluginOrderOrderType::Dropdown(array('name' => "plugin_order_ordertypes_id", 'value' => $this->fields["plugin_order_ordertypes_id"])); } else { echo Dropdown::getDropdownName("glpi_plugin_order_ordertypes", $this->fields["plugin_order_ordertypes_id"]); } echo "</td></tr>"; /* state */ echo "<tr class='tab_bg_1'><td>" . __("Order status", "order") . ": </td>"; echo "<td>"; if (!$this->getID()) { $state = $config->getDraftState(); } else { $state = $this->fields["plugin_order_orderstates_id"]; } if ($canedit) { PluginOrderOrderState::Dropdown(array('name' => "plugin_order_orderstates_id", 'value' => $state)); } else { echo Dropdown::getDropdownName("glpi_plugin_order_orderstates", $this->getState()); } echo "</td>"; /* budget */ echo "<td>" . __("Budget") . ": </td>"; echo "<td>"; if ($canedit) { if ($config->canHideInactiveBudgets()) { $restrict = " (`end_date` IS NULL) OR (`end_date`> '" . date("Y-m-d") . "')"; } else { $restrict = ""; } Budget::Dropdown(array('name' => "budgets_id", 'value' => $this->fields["budgets_id"], 'entity' => $this->fields["entities_id"], 'comments' => true, 'condition' => $restrict, 'width' => '150px')); } else { $budget = new Budget(); if ($this->fields["budgets_id"] > 0 && $budget->can($this->fields["budgets_id"], READ)) { echo $budget->getLink(); } else { echo Dropdown::getDropdownName("glpi_budgets", $this->fields["budgets_id"]); } } echo "</td></tr>"; /* location */ echo "<tr class='tab_bg_1'><td>" . __("Delivery location", "order") . ": </td>"; echo "<td>"; if ($canedit) { Location::Dropdown(array('name' => "locations_id", 'value' => $this->fields["locations_id"], 'entity' => $this->fields["entities_id"])); } else { echo Dropdown::getDropdownName("glpi_locations", $this->fields["locations_id"]); } echo "</td>"; /* payment */ echo "<td>" . __("Payment conditions", "order") . ": </td><td>"; if ($canedit) { PluginOrderOrderPayment::Dropdown(array('name' => "plugin_order_orderpayments_id", 'value' => $this->fields["plugin_order_orderpayments_id"])); } else { echo Dropdown::getDropdownName("glpi_plugin_order_orderpayments", $this->fields["plugin_order_orderpayments_id"]); } echo "</td>"; echo "</tr>"; /* supplier of order */ echo "<tr class='tab_bg_1'><td>" . __("Supplier") . ": </td>"; echo "<td>"; if ($canedit && !$this->checkIfDetailExists($ID)) { $rand = mt_rand(); Supplier::dropdown(array('name' => "suppliers_id", 'rand' => $rand, 'value' => $this->fields["suppliers_id"], 'entity' => $this->fields["entities_id"])); $params = array('suppliers_id' => '__VALUE__', 'fieldname' => 'contacts_id'); Ajax::updateItemOnSelectEvent("dropdown_suppliers_id{$rand}", "show_contacts_id{$rand}", "../ajax/dropdownSupplier.php", $params); } else { $supplier = new Supplier(); if ($supplier->can($this->fields['suppliers_id'], READ)) { echo $supplier->getLink(); } else { echo Dropdown::getDropdownName("glpi_suppliers", $this->fields["suppliers_id"]); } } echo "</td>"; /* port price */ echo "<td>" . __("Postage", "order") . ": </td>"; echo "<td>"; if ($canedit) { echo "<input type='number' step='" . PLUGIN_ORDER_NUMBER_STEP . "' name='port_price' size='5'" . " value=\"" . Html::formatNumber($this->fields["port_price"], true) . "\">"; } else { echo Html::formatNumber($this->fields["port_price"]); } echo "</td>"; echo "</tr>"; /* linked contact of the supplier of order */ echo "<tr class='tab_bg_1'><td>" . __("Contact") . ": </td>"; echo "<td><span id='show_contacts_id'>"; if ($canedit) { echo "<span id='show_contacts_id{$rand}'>"; // Make a select box $query = "SELECT c.`id`, c.`name`, c.`firstname`\n FROM `glpi_contacts` c\n LEFT JOIN `glpi_contacts_suppliers` s ON (s.`contacts_id` = c.`id`)\n WHERE s.`suppliers_id` = '{$this->fields['suppliers_id']}'\n ORDER BY c.`name`"; $result = $DB->query($query); $number = $DB->numrows($result); $values = array(0 => Dropdown::EMPTY_VALUE); if ($number) { while ($data = $DB->fetch_assoc($result)) { $values[$data['id']] = formatUserName('', '', $data['name'], $data['firstname']); } } Dropdown::showFromArray("contacts_id", $values, array('value' => $this->fields['contacts_id'], 'rand' => $rand)); echo "</span>\n"; } else { echo Dropdown::getDropdownName("glpi_contacts", $this->fields["contacts_id"]); } echo "</span></td>"; /* tva port price */ echo "<td>" . __("VAT", "order") . " " . __("Postage", "order") . ": </td><td>"; $PluginOrderConfig = new PluginOrderConfig(); $default_taxes = $PluginOrderConfig->getDefaultTaxes(); $taxes = empty($ID) || $ID < 0 ? $default_taxes : $this->fields["plugin_order_ordertaxes_id"]; if ($canedit) { PluginOrderOrderTax::Dropdown(array('name' => "plugin_order_ordertaxes_id", 'value' => $taxes, 'display_emptychoice' => true, 'emptylabel' => __("No VAT", "order"))); } else { echo Dropdown::getDropdownName("glpi_plugin_order_ordertaxes", $taxes); } echo "</td>"; echo "</tr>"; echo "<tr class='tab_bg_1'>"; echo "<td>" . __("Associable to a ticket") . " :</td><td>"; if ($canedit) { Dropdown::showYesNo('is_helpdesk_visible', $this->fields['is_helpdesk_visible']); } else { echo Dropdown::getYesNo($this->fields['is_helpdesk_visible']); } echo "</td>"; echo "<td>"; echo __("Estimated due date", "order") . ":"; if ($this->isDelivered() && $this->fields['deliverydate']) { echo "<br/>" . __("Delivery date") . ":"; } echo " </td><td>"; if ($canedit) { if ($this->fields["duedate"] == NULL) { Html::showDateFormItem("duedate", '', true, true); } else { Html::showDateFormItem("duedate", $this->fields["duedate"], true, true); } } else { echo Html::convDate($this->fields["duedate"]); } if ($this->shouldBeAlreadyDelivered()) { echo "<br/><span class='red'>" . __("Due date overtaken", "order") . "</span>"; } if ($this->isDelivered() && $this->fields['deliverydate']) { echo "<br/>" . Html::convDate($this->fields['deliverydate']); } echo "</td>"; echo "</tr>"; echo "<tr class='tab_bg_1'>"; echo "<td colspan='2' class='center'>" . $datestring; if (!$template && !empty($this->fields['template_name'])) { echo "<span class='small_space'>(" . __("Template name") . " : " . $this->fields['template_name'] . ")</span>"; } echo "</td><td colspan='2'></td>"; echo "</tr>"; echo "<tr class='tab_bg_1'>"; //comments of order echo "<td>" . __("Comments") . ": </td>"; echo "<td colspan='3' align='center'>"; if ($canedit) { echo "<textarea cols='40' rows='3' name='comment'>" . $this->fields["comment"] . "</textarea>"; } else { echo $this->fields["comment"]; } echo "</td></tr>"; echo "<tr class='tab_bg_1'>"; echo "<th colspan='2'>" . __("Actor") . "</th>"; if ($ID > 0 && !$template) { echo "<th colspan='2'>" . __("Cost") . "</th></tr>"; } else { echo "<th colspan='2'></th>"; } echo "</tr>"; echo "<tr class='tab_bg_1'>"; echo "<td colspan='2'>"; echo "<table class='format'>"; echo "<tr class='tab_bg_1'><td>" . __("Author") . ":</td><td style='width: 170px;'>"; if ($canedit) { if ($template == 'newcomp') { $value = Session::getLoginUserID(); } else { $value = $this->fields['users_id']; } User::Dropdown(array('name' => 'users_id', 'value' => $value, 'right' => 'interface', 'entity' => $this->fields["entities_id"], 'width' => '150px')); } else { if ($this->fields['users_id']) { $output = ""; if ($user->getFromDB($this->fields['users_id'])) { $output = formatUserName($this->fields['users_id'], $user->fields['name'], $user->fields['realname'], $user->fields['firstname']); } echo $output; } } echo "</td>"; echo "<td>" . __("Author group", "order") . ":</td>"; echo "<td style='width: 180px;'>"; if ($canedit) { if (empty($ID) || $ID < 0) { if (!empty($this->fields['groups_id'])) { $groups_id = $this->fields['groups_id']; } else { $groups_id = $config->getDefaultAuthorGroup(); } } else { $groups_id = $this->fields['groups_id']; } Group::Dropdown(array('value' => $groups_id, 'width' => '150px')); } else { echo Dropdown::getDropdownName('glpi_groups', $this->fields['groups_id']); } echo "</td></tr>"; echo "<tr class='tab_bg_1'>"; echo "<td>" . __("Recipient") . ":</td>"; echo "<td style='width: 170px;'>"; if ($canedit) { if (empty($ID) || $ID < 0) { if (!empty($this->fields['users_id_delivery'])) { $users_id = $this->fields['users_id_delivery']; } else { $users_id = $config->getDefaultRecipient(); } } else { $users_id = $this->fields['users_id_delivery']; } User::Dropdown(array('name' => 'users_id_delivery', 'value' => $users_id, 'right' => 'all', 'entity' => $this->fields["entities_id"], 'width' => '150px')); } else { if ($this->fields['users_id_delivery']) { $user->getFromDB($this->fields['users_id_delivery']); $output = formatUserName($this->fields['users_id'], $user->fields['name'], $user->fields['realname'], $user->fields['firstname']); echo $output; } } echo "</td>"; echo "<td>" . __("Recipient group", "order") . ":</td>"; echo "<td style='width: 180px;'>"; if ($canedit) { if (empty($ID) || $ID < 0) { if (!empty($this->fields['groups_id_delivery'])) { $groups_id = $this->fields['groups_id_delivery']; } else { $groups_id = $config->getDefaultRecipientGroup(); } } else { $groups_id = $this->fields['groups_id_delivery']; } Group::Dropdown(array('name' => 'groups_id_delivery', 'value' => $groups_id, 'width' => '150px')); } else { echo Dropdown::getDropdownName('glpi_groups', $this->fields['groups_id_delivery']); } echo "</td>"; echo "</tr></table></td>"; echo "<td colspan='2'>"; if ($ID > 0 && !$template) { $PluginOrderOrder_Item = new PluginOrderOrder_Item(); $prices = $PluginOrderOrder_Item->getAllPrices($ID); echo "<table class='format'>"; echo "<tr>"; echo "<td>" . __("Price tax free", "order") . "</td>"; echo "<td>" . Html::formatNumber($prices["priceHT"]) . "</td>"; echo "</tr>"; // total price (with postage) $postagewithTVA = $PluginOrderOrder_Item->getPricesATI($this->fields["port_price"], Dropdown::getDropdownName("glpi_plugin_order_ordertaxes", $this->fields["plugin_order_ordertaxes_id"])); $priceHTwithpostage = $prices["priceHT"] + $this->fields["port_price"]; echo "<tr>"; echo "<td>" . __("Price tax free with postage", "order") . "</td>"; echo "<td>" . Html::formatNumber($priceHTwithpostage) . "</td>"; echo "</tr>"; // total price (with taxes) $total = $prices["priceTTC"] + $postagewithTVA; echo "<tr>"; echo "<td>" . __("Price ATI", "order") . "</td>"; echo "<td>" . Html::formatNumber($total) . "</td>"; echo "</tr>"; // total TVA $total_tva = $prices["priceTVA"] + ($postagewithTVA - $this->fields["port_price"]); echo "<tr>"; echo "<td>" . __("VAT", "order") . "</td>"; echo "<td>" . Html::formatNumber($total_tva) . "</td>"; echo "</tr>"; echo "</table>"; } echo "</td>"; echo "</tr>"; if ($canedit || $cancancel) { $this->showFormButtons($options); } else { echo "</table></div>"; Html::closeForm(); } return true; }
/** * Print an HTML array with contracts associated to the enterprise * * @since version 0.84 * * @param $supplier Supplier object * * @return Nothing (display) **/ static function showForSupplier(Supplier $supplier) { global $DB, $CFG_GLPI; $ID = $supplier->fields['id']; if (!Session::haveRight("contract", "r") || !$supplier->can($ID, 'r')) { return false; } $canedit = $supplier->can($ID, 'w'); $rand = mt_rand(); $query = "SELECT `glpi_contracts`.*,\n `glpi_contracts_suppliers`.`id` AS assocID,\n `glpi_entities`.`id` AS entity\n FROM `glpi_contracts_suppliers`, `glpi_contracts`\n LEFT JOIN `glpi_entities` ON (`glpi_entities`.`id`=`glpi_contracts`.`entities_id`)\n WHERE `glpi_contracts_suppliers`.`suppliers_id` = '{$ID}'\n AND `glpi_contracts_suppliers`.`contracts_id`=`glpi_contracts`.`id`" . getEntitiesRestrictRequest(" AND", "glpi_contracts", '', '', true) . "\n ORDER BY `glpi_entities`.`completename`,\n `glpi_contracts`.`name`"; $result = $DB->query($query); $contracts = array(); $used = array(); if ($number = $DB->numrows($result)) { while ($data = $DB->fetch_assoc($result)) { $contracts[$data['assocID']] = $data; $used[$data['id']] = $data['id']; } } if ($canedit) { echo "<div class='firstbloc'>"; echo "<form name='contractsupplier_form{$rand}' id='contractsupplier_form{$rand}' method='post'\n action='" . Toolbox::getItemTypeFormURL(__CLASS__) . "'>"; echo "<input type='hidden' name='suppliers_id' value='{$ID}'>"; 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 class='right'>"; Contract::dropdown(array('used' => $used, 'entity' => $supplier->fields["entities_id"], 'entity_sons' => $supplier->fields["is_recursive"], 'nochecklimit' => true)); 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); Html::showMassiveActions(__CLASS__, $massiveactionparams); } echo "<table class='tab_cadre_fixe'>"; echo "<tr>"; if ($canedit && $number) { echo "<th width='10'>" . Html::getCheckAllAsCheckbox('mass' . __CLASS__ . $rand) . "</th>"; } echo "<th>" . __('Name') . "</th>"; echo "<th>" . __('Entity') . "</th>"; echo "<th>" . _x('phone', 'Number') . "</th>"; echo "<th>" . __('Contract type') . "</th>"; echo "<th>" . __('Start date') . "</th>"; echo "<th>" . __('Initial contract period') . "</th>"; echo "</tr>"; $used = array(); foreach ($contracts as $data) { $cID = $data["id"]; $used[$cID] = $cID; $assocID = $data["assocID"]; echo "<tr class='tab_bg_1" . ($data["is_deleted"] ? "_2" : "") . "'>"; if ($canedit) { echo "<td>"; Html::showMassiveActionCheckBox(__CLASS__, $data["assocID"]); echo "</td>"; } $name = $data["name"]; if ($_SESSION["glpiis_ids_visible"] || empty($data["name"])) { $name = sprintf(__('%1$s (%2$s)'), $name, $data["id"]); } echo "<td class='center b'>\n <a href='" . $CFG_GLPI["root_doc"] . "/front/contract.form.php?id={$cID}'>" . $name . "</a>"; echo "</td>"; echo "<td class='center'>" . Dropdown::getDropdownName("glpi_entities", $data["entity"]); echo "</td><td class='center'>" . $data["num"] . "</td>"; echo "<td class='center'>" . Dropdown::getDropdownName("glpi_contracttypes", $data["contracttypes_id"]) . "</td>"; echo "<td class='center'>" . Html::convDate($data["begin_date"]) . "</td>"; echo "<td class='center'>"; sprintf(_n('%d month', '%d months', $data["duration"]), $data["duration"]); if ($data["begin_date"] != '' && !empty($data["begin_date"])) { echo " -> " . Infocom::getWarrantyExpir($data["begin_date"], $data["duration"], 0, true); } echo "</td>"; echo "</tr>"; } echo "</table>"; if ($canedit && $number) { $paramsma['ontop'] = false; Html::showMassiveActions(__CLASS__, $paramsma); Html::closeForm(); } echo "</div>"; }
/** * 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("&", "&", $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>"; }
function showPluginFromSupplier($ID, $withtemplate = '') { global $DB, $CFG_GLPI; $item = new Supplier(); $canread = $item->can($ID, 'r'); $canedit = $item->can($ID, 'w'); $query = "SELECT `glpi_plugin_databases_databases`.* " . "FROM `glpi_plugin_databases_databases` " . " LEFT JOIN `glpi_entities` ON (`glpi_entities`.`id` = `glpi_plugin_databases_databases`.`entities_id`) " . " WHERE `suppliers_id` = '{$ID}' " . getEntitiesRestrictRequest(" AND ", "glpi_plugin_databases_databases", '', '', $this->maybeRecursive()); $query .= " ORDER BY `glpi_plugin_databases_databases`.`name` "; $result = $DB->query($query); $number = $DB->numrows($result); if (Session::isMultiEntitiesMode()) { $colsup = 1; } else { $colsup = 0; } if ($withtemplate != 2) { echo "<form method='post' action=\"" . $CFG_GLPI["root_doc"] . "/plugins/databases/front/database.form.php\">"; } echo "<div align='center'><table class='tab_cadre_fixe'>"; echo "<tr><th colspan='" . (4 + $colsup) . "'>" . _n('Database associated', 'Databases associated', 2, 'databases') . "</th></tr>"; echo "<tr><th>" . __('Name') . "</th>"; if (Session::isMultiEntitiesMode()) { echo "<th>" . __('Entity') . "</th>"; } echo "<th>" . PluginDatabasesDatabaseCategory::getTypeName(1) . "</th>"; echo "<th>" . __('Type') . "</th>"; echo "<th>" . __('Comments') . "</th>"; echo "</tr>"; while ($data = $DB->fetch_array($result)) { echo "<tr class='tab_bg_1" . ($data["is_deleted"] == '1' ? "_2" : "") . "'>"; if ($withtemplate != 3 && $canread && (in_array($data['entities_id'], $_SESSION['glpiactiveentities']) || $data["is_recursive"])) { echo "<td class='center'><a href='" . $CFG_GLPI["root_doc"] . "/plugins/databases/front/database.form.php?id=" . $data["id"] . "'>" . $data["name"]; if ($_SESSION["glpiis_ids_visible"]) { echo " (" . $data["id"] . ")"; } echo "</a></td>"; } else { echo "<td class='center'>" . $data["name"]; if ($_SESSION["glpiis_ids_visible"]) { echo " (" . $data["id"] . ")"; } echo "</td>"; } echo "</a></td>"; if (Session::isMultiEntitiesMode()) { echo "<td class='center'>" . Dropdown::getDropdownName("glpi_entities", $data['entities_id']) . "</td>"; } echo "<td>" . Dropdown::getDropdownName("glpi_plugin_databases_databasetypes", $data["plugin_databases_databasetypes_id"]) . "</td>"; echo "<td>" . Dropdown::getDropdownName("glpi_plugin_databases_servertypes", $data["plugin_databases_servertypes_id"]) . "</td>"; echo "<td>" . $data["comment"] . "</td></tr>"; } echo "</table></div>"; Html::closeForm(); }
function showForm($ID, $options = array()) { global $CFG_GLPI; $config = PluginOrderConfig::getConfig(); $user = new User(); if (!self::canView()) { return false; } if ($ID > 0) { $this->check($ID, 'r'); } else { // Create item $this->check(-1, 'w'); $this->getEmpty(); } if (isset($options['withtemplate']) && $options['withtemplate'] == 2) { $template = "newcomp"; $datestring = sprintf(__('Created on %s'), Html::convDateTime($_SESSION["glpi_currenttime"])); } else { if (isset($options['withtemplate']) && $options['withtemplate'] == 1) { $template = "newtemplate"; $datestring = sprintf(__('Created on %s'), Html::convDateTime($_SESSION["glpi_currenttime"])); } else { $datestring = sprintf(__('Last update on %s'), Html::convDateTime($this->fields["date_mod"])); $template = false; } } $canedit = $this->canUpdateOrder() && $this->can($ID, 'w') && !$this->isCanceled(); $cancancel = self::canCancel() && $this->can($ID, 'w') && $this->isCanceled(); $options['canedit'] = $canedit; $options['candel'] = $cancancel; if ($template) { $this->fields['order_date'] = NULL; } // Displaying OVER BUDGET ALERT if ($this->fields['budgets_id'] > 0) { self::displayAlertOverBudget(self::isOverBudget($ID)); } $this->showTabs($options); $this->showFormHeader($options); //Display without inside table /* title */ echo "<tr class='tab_bg_1'><td>" . __("Order name", "order") . "*: </td>"; echo "<td>"; if ($canedit) { $objectName = autoName($this->fields["name"], "name", $template === "newcomp", $this->getType(), $this->fields["entities_id"]); Html::autocompletionTextField($this, "name", array('value' => $objectName)); } else { echo $this->fields["name"]; } echo "</td>"; /* date of order */ echo "<td>" . __("Date of order", "order") . ":</td><td>"; if ($canedit) { if ($this->fields["order_date"] == NULL) { Html::showDateFormItem("order_date", date("Y-m-d"), true, true); } else { Html::showDateFormItem("order_date", $this->fields["order_date"], true, true); } } else { echo Html::convDate($this->fields["order_date"]); } echo "</td></tr>"; /* num order */ echo "<tr class='tab_bg_1'><td>" . __("Order number", "order") . "*: </td>"; echo "<td>"; if ($canedit) { $objectOrder = autoName($this->fields["num_order"], "num_order", $template === "newcomp", $this->getType(), $this->fields["entities_id"]); Html::autocompletionTextField($this, "num_order", array('value' => $objectOrder)); } else { echo $this->fields["num_order"]; } echo "</td>"; /* type order */ echo "<td>" . __("Type") . ": </td><td>"; if ($canedit) { PluginOrderOrderType::Dropdown(array('name' => "plugin_order_ordertypes_id", 'value' => $this->fields["plugin_order_ordertypes_id"])); } else { echo Dropdown::getDropdownName("glpi_plugin_order_ordertypes", $this->fields["plugin_order_ordertypes_id"]); } echo "</td></tr>"; /* state */ echo "<tr class='tab_bg_1'><td>" . __("Order status", "order") . ": </td>"; echo "<td>"; if (!$this->getID()) { $state = $config->getDraftState(); } else { $state = $this->fields["plugin_order_orderstates_id"]; } if ($canedit) { PluginOrderOrderState::Dropdown(array('name' => "plugin_order_orderstates_id", 'value' => $state)); } else { echo Dropdown::getDropdownName("glpi_plugin_order_orderstates", $this->getState()); } echo "</td>"; /* budget */ echo "<td>" . __("Budget") . ": </td><td>"; if ($canedit) { Budget::Dropdown(array('name' => "budgets_id", 'value' => $this->fields["budgets_id"], 'entity' => $this->fields["entities_id"], 'comments' => true)); } else { $budget = new Budget(); if ($this->fields["budgets_id"] > 0 && $budget->can($this->fields["budgets_id"], 'r')) { echo "<a href='" . $budget->getLinkURL() . "'>" . $budget->getName(1) . "</a>"; } else { echo Dropdown::getDropdownName("glpi_budgets", $this->fields["budgets_id"]); } } echo "</td></tr>"; /* location */ echo "<tr class='tab_bg_1'><td>" . __("Delivery location", "order") . ": </td>"; echo "<td>"; if ($canedit) { Location::Dropdown(array('name' => "locations_id", 'value' => $this->fields["locations_id"], 'entity' => $this->fields["entities_id"])); } else { echo Dropdown::getDropdownName("glpi_locations", $this->fields["locations_id"]); } echo "</td>"; /* payment */ echo "<td>" . __("Payment conditions", "order") . ": </td><td>"; if ($canedit) { PluginOrderOrderPayment::Dropdown(array('name' => "plugin_order_orderpayments_id", 'value' => $this->fields["plugin_order_orderpayments_id"])); } else { echo Dropdown::getDropdownName("glpi_plugin_order_orderpayments", $this->fields["plugin_order_orderpayments_id"]); } echo "</td>"; echo "</tr>"; /* supplier of order */ echo "<tr class='tab_bg_1'><td>" . __("Supplier") . ": </td>"; echo "<td>"; if ($canedit && !$this->checkIfDetailExists($ID)) { $this->dropdownSuppliers("suppliers_id", $this->fields["suppliers_id"], $this->fields["entities_id"]); } else { $supplier = new Supplier(); if ($supplier->can($this->fields['suppliers_id'], 'r')) { echo $supplier->getLink(); } else { echo Dropdown::getDropdownName("glpi_suppliers", $this->fields["suppliers_id"]); } } echo "</td>"; /* port price */ echo "<td>" . __("Postage", "order") . ": </td>"; echo "<td>"; if ($canedit) { echo "<input type='text' name='port_price' value=\"" . Html::formatNumber($this->fields["port_price"], true) . "\" size='5'>"; } else { echo Html::formatNumber($this->fields["port_price"]); } echo "</td>"; echo "</tr>"; /* linked contact of the supplier of order */ echo "<tr class='tab_bg_1'><td>" . __("Contact") . ": </td>"; echo "<td><span id='show_contacts_id'>"; if ($canedit && $ID > 0) { $this->dropdownContacts($this->fields["suppliers_id"], $this->fields["contacts_id"], $this->fields["entities_id"]); } else { echo Dropdown::getDropdownName("glpi_contacts", $this->fields["contacts_id"]); } echo "</span></td>"; /* tva port price */ echo "<td>" . __("VAT", "order") . " " . __("Postage", "order") . ": </td><td>"; $PluginOrderConfig = new PluginOrderConfig(); $default_taxes = $PluginOrderConfig->getDefaultTaxes(); if (empty($ID) || $ID < 0) { $taxes = $default_taxes; } else { $taxes = $this->fields["plugin_order_ordertaxes_id"]; } if ($canedit) { PluginOrderOrderTaxe::Dropdown(array('name' => "plugin_order_ordertaxes_id", 'value' => $taxes, 'display_emptychoice' => true, 'emptylabel' => __("No VAT", "order"))); } else { echo Dropdown::getDropdownName("glpi_plugin_order_ordertaxes", $taxes); } echo "</td>"; echo "</tr>"; echo "<tr class='tab_bg_1'>"; echo "<td>" . __("Associable to a ticket") . " :</td><td>"; if ($canedit) { Dropdown::showYesNo('is_helpdesk_visible', $this->fields['is_helpdesk_visible']); } else { echo Dropdown::getYesNo($this->fields['is_helpdesk_visible']); } echo "</td>"; echo "<td>"; echo __("Estimated due date", "order") . ":"; if ($this->isDelivered() && $this->fields['deliverydate']) { echo "<br/>" . __("Delivery date") . ":"; } echo " </td><td>"; if ($canedit) { if ($this->fields["duedate"] == NULL) { Html::showDateFormItem("duedate", '', true, true); } else { Html::showDateFormItem("duedate", $this->fields["duedate"], true, true); } } else { echo Html::convDate($this->fields["duedate"]); } if ($this->shouldBeAlreadyDelivered()) { echo "<br/><span class='red'>" . __("Due date overtaken", "order") . "</span>"; } if ($this->isDelivered() && $this->fields['deliverydate']) { echo "<br/>" . Html::convDate($this->fields['deliverydate']); } echo "</td>"; echo "</tr>"; echo "<tr class='tab_bg_1'>"; echo "<td colspan='2' class='center'>" . $datestring; if (!$template && !empty($this->fields['template_name'])) { echo "<span class='small_space'>(" . __("Template name") . " : " . $this->fields['template_name'] . ")</span>"; } echo "</td><td colspan='2'></td>"; echo "</tr>"; echo "<tr class='tab_bg_1'>"; //comments of order echo "<td>" . __("Comments") . ": </td>"; echo "<td colspan='3' align='center'>"; if ($canedit) { echo "<textarea cols='40' rows='3' name='comment'>" . $this->fields["comment"] . "</textarea>"; } else { echo $this->fields["comment"]; } echo "</td></tr>"; echo "<tr class='tab_bg_1'>"; echo "<th colspan='2'>" . __("Actor") . "</th>"; if ($ID > 0 && !$template) { echo "<th colspan='2'>" . __("Cost") . "</th></tr>"; } else { echo "<th colspan='2'></th>"; } echo "</tr><tr class='tab_bg_1'>"; echo "<td colspan='2'>"; echo "<table class='format'>"; echo "<tr class='tab_bg_1'><td>" . __("Author") . ":</td><td>"; if ($canedit) { if ($template == 'newcomp') { $value = Session::getLoginUserID(); } else { $value = $this->fields['users_id']; } User::Dropdown(array('name' => 'users_id', 'value' => $value, 'right' => 'interface', 'entity' => $this->fields["entities_id"])); } else { if ($this->fields['users_id']) { $user->getFromDB($this->fields['users_id']); $output = formatUserName($this->fields['users_id'], $user->fields['name'], $user->fields['realname'], $user->fields['firstname']); echo $output; } } echo "</td>"; echo "<td>" . __("Author group", "order") . ":</td><td>"; if ($canedit) { if (empty($ID) || $ID < 0) { $groups_id = $config->getDefaultAuthorGroup(); } else { $groups_id = $this->fields['groups_id']; } Group::Dropdown(array('value' => $groups_id)); } else { echo Dropdown::getDropdownName('glpi_groups', $this->fields['groups_id']); } echo "</td></tr>"; echo "<tr class='tab_bg_1'><td>" . __("Recipient") . ":</td><td>"; if ($canedit) { if (empty($ID) || $ID < 0) { $users_id = $config->getDefaultRecipient(); } else { $users_id = 0; } User::Dropdown(array('name' => 'users_id_delivery', 'value' => $users_id, 'right' => 'all', 'entity' => $this->fields["entities_id"])); } else { if ($this->fields['users_id_delivery']) { $user->getFromDB($this->fields['users_id_delivery']); $output = formatUserName($this->fields['users_id'], $user->fields['name'], $user->fields['realname'], $user->fields['firstname']); echo $output; } } echo "</td>"; echo "<td>" . __("Recipient group", "order") . ":</td><td>"; if ($canedit) { if (empty($ID) || $ID < 0) { $groups_id = $config->getDefaultRecipientGroup(); } else { $groups_id = $this->fields['groups_id_delivery']; } Group::Dropdown(array('name' => 'groups_id_delivery', 'value' => $groups_id)); } else { echo Dropdown::getDropdownName('glpi_groups', $this->fields['groups_id_delivery']); } echo "</td>"; echo "</tr></table></td>"; echo "<td colspan='2'>"; if ($ID > 0 && !$template) { echo "<table class='format'>"; $PluginOrderOrder_Item = new PluginOrderOrder_Item(); $prices = $PluginOrderOrder_Item->getAllPrices($ID); echo "<tr><td>" . __("Price tax free", "order") . "</td>"; echo "<td>" . Html::formatNumber($prices["priceHT"]) . "</td></tr>"; // total price (with postage) $postagewithTVA = $PluginOrderOrder_Item->getPricesATI($this->fields["port_price"], Dropdown::getDropdownName("glpi_plugin_order_ordertaxes", $this->fields["plugin_order_ordertaxes_id"])); echo "<tr><td>" . __("Price tax free with postage", "order") . "</td>"; $priceHTwithpostage = $prices["priceHT"] + $this->fields["port_price"]; echo "<td>" . Html::formatNumber($priceHTwithpostage) . "</td></tr>"; // total price (with taxes) echo "<tr><td>" . __("Price ATI", "order") . "</td>"; $total = $prices["priceTTC"] + $postagewithTVA; echo "<td>" . Html::formatNumber($total) . "</td></tr>"; // total TVA echo "<tr><td>" . __("VAT", "order") . "</td>"; echo "<td>"; $total_tva = $prices["priceTVA"] + ($postagewithTVA - $this->fields["port_price"]); echo Html::formatNumber($total_tva) . "</td></tr>"; echo "</table>"; } echo "</td></tr>"; if ($canedit || $cancancel) { $this->showFormButtons($options); } else { echo "</table></div>"; Html::closeForm(); } $this->addDivForTabs(); return true; }
exit; } if (!isset($_REQUEST['glpi_tab'])) { exit; } if (!isset($_POST["start"])) { $_POST["start"] = 0; } if (!isset($_POST["sort"])) { $_POST["sort"] = ""; } if (!isset($_POST["order"])) { $_POST["order"] = ""; } $supplier = new Supplier(); if ($_POST["id"] > 0 && $supplier->can($_POST["id"], 'r')) { switch ($_REQUEST['glpi_tab']) { case -1: $supplier->showContacts(); $supplier->showContracts(); Document::showAssociated($supplier); Ticket::showListForSupplier($_POST["id"]); Link::showForItem('Supplier', $_POST["id"]); Plugin::displayAction($supplier, $_REQUEST['glpi_tab']); break; case 4: $supplier->showContracts(); break; case 5: Document::showAssociated($supplier); break;