public function showForm() { $this->getFromDB(1); echo "<div class='center'>"; echo "<form name='form' method='post' action='" . $this->getFormURL() . "'>"; echo "<input type='hidden' name='id' value='1'>"; echo "<table class='tab_cadre_fixe'>"; echo "<tr><th colspan='2'>" . __("Plugin configuration", "order") . "</th></tr>"; echo "<tr class='tab_bg_1' align='center'>"; echo "<td>" . __("Default VAT", "order") . "</td>"; echo "<td>"; PluginOrderOrderTax::Dropdown(array('name' => "default_taxes", 'value' => $this->fields["default_taxes"], 'display_emptychoice' => true, 'emptylabel' => __("No VAT", "order"))); echo "</td>"; echo "</tr>"; echo "<tr class='tab_bg_1' align='center'>"; echo "<td>" . __("Use validation process", "order") . "</td>"; echo "<td>"; Dropdown::showYesNo("use_validation", $this->fields["use_validation"]); echo "</td>"; echo "</tr>"; echo "<tr class='tab_bg_1' align='center'>"; echo "<td>" . __("Order generation in ODT", "order") . "</td><td>"; Dropdown::showYesNo("generate_order_pdf", $this->fields["generate_order_pdf"]); echo "</td>"; echo "</tr>"; echo "<tr class='tab_bg_1' align='center'>"; echo "<td>" . __("Activate suppliers quality satisfaction", "order") . "</td>"; echo "<td>"; Dropdown::showYesNo("use_supplier_satisfaction", $this->fields["use_supplier_satisfaction"]); echo "</td>"; echo "</tr>"; echo "<tr class='tab_bg_1' align='center'>"; echo "<td>" . __("Display order's suppliers informations", "order") . "</td><td>"; Dropdown::showYesNo("use_supplier_informations", $this->fields["use_supplier_informations"]); echo "</td>"; echo "</tr>"; echo "<tr class='tab_bg_1' align='center'>"; echo "<td>" . __("Color to be displayed when order due date is overtaken", "order") . "</td>"; echo "<td>"; echo "<input type='color' name='shoudbedelivered_color'\n value='" . $this->fields['shoudbedelivered_color'] . "'>"; echo "</td>"; echo "</tr>"; echo "<tr class='tab_bg_1' align='center'>"; echo "<td>" . __("Copy order documents when a new item is created", "order") . "</td>"; echo "<td>"; Dropdown::showYesNo("copy_documents", $this->fields["copy_documents"]); echo "</td>"; echo "</tr>"; echo "<tr class='tab_bg_1' align='center'>"; echo "<td>" . __("Default heading when adding a document to an order", "order") . "</td>"; echo "<td>"; DocumentCategory::Dropdown(array('value' => $this->fields["documentcategories_id"])); echo "</td>"; echo "</tr>"; echo "<tr class='tab_bg_1' align='center'>"; echo "<td>" . __("Author group", "order") . ' (' . __("Default values") . ")</td>"; echo "<td>"; Group::Dropdown(array('value' => $this->fields["groups_id_author"], 'name' => 'groups_id_author')); echo "</td>"; echo "</tr>"; echo "<tr class='tab_bg_1' align='center'>"; echo "<td>" . __("Recipient group", "order") . ' (' . __("Default values") . ")</td>"; echo "<td>"; Group::Dropdown(array('value' => $this->fields["groups_id_recipient"], 'name' => 'groups_id_recipient')); echo "</td>"; echo "</tr>"; echo "<tr class='tab_bg_1' align='center'>"; echo "<td>" . __("Recipient") . ' (' . __("Default values") . ")</td>"; echo "<td>"; User::Dropdown(array('name' => 'users_id_recipient', 'value' => $this->fields["users_id_recipient"], 'right' => 'all', 'entity' => 0)); echo "</td>"; echo "</tr>"; echo "<tr class='tab_bg_1' align='center'>"; echo "<td>" . __("Hide inactive budgets", 'order') . "</td>"; echo "<td>"; Dropdown::showYesNo("hide_inactive_budgets", $this->fields["hide_inactive_budgets"]); echo "</td>"; echo "</tr>"; echo "<tr class='tab_bg_1' align='center'>"; echo "<td>" . __("Transmit budget change to linked assets", 'order') . "</td>"; echo "<td>"; Dropdown::showYesNo("transmit_budget_change", $this->fields["transmit_budget_change"]); echo "</td>"; echo "</tr>"; // Automatic actions echo "<tr class='tab_bg_1' align='center'>"; echo "<th colspan='2'>" . __("Automatic actions when delivery", "order") . "</th>"; echo "</tr>"; // ASSETS echo "<tr class='tab_bg_1' align='center'>"; echo "<th colspan='2'>" . __('Item') . "</th>"; echo "</tr>"; echo "<tr class='tab_bg_1' align='center'>"; echo "<td>" . __("Enable automatic generation", "order") . "</td>"; echo "<td>"; Dropdown::showYesNo("generate_assets", $this->canGenerateAsset()); echo "</td>"; echo "</tr>"; echo "<tr class='tab_bg_1' align='center'>"; echo "<td>" . __("Default state", "order") . "</td>"; echo "<td>"; State::Dropdown(array('name' => 'default_asset_states_id', 'value' => $this->fields["default_asset_states_id"], 'entity' => $_SESSION["glpiactiveentities"])); echo "</td>"; echo "</tr>"; echo "<tr class='tab_bg_1' align='center'>"; echo "<td>" . __("Add order location to item", "order") . "</td>"; echo "<td>"; Dropdown::showYesNo("add_location", $this->canAddLocation()); echo "</td>"; echo "</tr>"; echo "<tr class='tab_bg_1' align='center'>"; echo "<td>" . __("Add billing details to item", "order") . "</td><td>"; Dropdown::showYesNo("add_bill_details", $this->canAddBillDetails()); echo "</td>"; echo "</tr>"; if ($this->canGenerateAsset()) { echo "<tr class='tab_bg_1' align='center'>"; echo "<td>" . __("Default name", "order") . "</td>"; echo "<td>"; Html::autocompletionTextField($this, "generated_name"); echo "</td>"; echo "</tr>"; echo "<tr class='tab_bg_1' align='center'>"; echo "<td>" . __("Default serial number", "order") . "</td>"; echo "<td>"; Html::autocompletionTextField($this, "generated_serial"); echo "</td>"; echo "</tr>"; echo "<tr class='tab_bg_1' align='center'>"; echo "<td>" . __("Default inventory number", "order") . "</td>"; echo "<td>"; Html::autocompletionTextField($this, "generated_otherserial"); echo "</td>"; echo "</tr>"; // TICKETS echo "<tr class='tab_bg_1' align='center'>"; echo "<th colspan='2'>" . __("Ticket") . "</th>"; echo "</tr>"; echo "<tr class='tab_bg_1' align='center'>"; echo "<td>" . TicketTemplate::getTypeName(1) . "</td>"; echo "<td>"; Dropdown::show('TicketTemplate', array('name' => 'tickettemplates_id_delivery', 'value' => $this->fields['tickettemplates_id_delivery'])); echo "</td>"; echo "</tr>"; } /* Workflow */ echo "<tr class='tab_bg_1' align='center'>"; echo "<th colspan='2'>" . __("Order lifecycle", "order") . "</th>"; echo "</tr>"; echo "<tr class='tab_bg_1' align='center'>"; echo "<td>" . __("State before validation", "order") . "</td>"; echo "<td>"; PluginOrderOrderState::Dropdown(array('name' => 'order_status_draft', 'value' => $this->fields["order_status_draft"])); echo "</td>"; echo "</tr>"; echo "<tr class='tab_bg_1' align='center'>"; echo "<td>" . __("Waiting for validation state", "order") . "</td>"; echo "<td>"; PluginOrderOrderState::Dropdown(array('name' => 'order_status_waiting_approval', 'value' => $this->fields["order_status_waiting_approval"])); echo "</td>"; echo "</tr>"; echo "<tr class='tab_bg_1' align='center'>"; echo "<td>" . __("Validated order state", "order") . "</td>"; echo "<td>"; PluginOrderOrderState::Dropdown(array('name' => 'order_status_approved', 'value' => $this->fields["order_status_approved"])); echo "</td>"; echo "</tr>"; echo "<tr class='tab_bg_1' align='center'>"; echo "<td>" . __("Order being delivered state", "order") . "</td>"; echo "<td>"; PluginOrderOrderState::Dropdown(array('name' => 'order_status_partially_delivred', 'value' => $this->fields["order_status_partially_delivred"])); echo "</td>"; echo "</tr>"; echo "<tr class='tab_bg_1' align='center'>"; echo "<td>" . __("Order delivered state", "order") . "</td>"; echo "<td>"; PluginOrderOrderState::Dropdown(array('name' => 'order_status_completly_delivered', 'value' => $this->fields["order_status_completly_delivered"])); echo "</td>"; echo "</tr>"; echo "<tr class='tab_bg_1' align='center'>"; echo "<td>" . __("Order paied state", "order") . "</td>"; echo "<td>"; PluginOrderOrderState::Dropdown(array('name' => 'order_status_paid', 'value' => $this->fields["order_status_paid"])); echo "</td>"; echo "</tr>"; echo "<tr class='tab_bg_1' align='center'>"; echo "<td>" . __("Canceled order state", "order") . "</td>"; echo "<td>"; PluginOrderOrderState::Dropdown(array('name' => 'order_status_canceled', 'value' => $this->fields["order_status_canceled"])); echo "</td>"; echo "</tr>"; echo "<tr class='tab_bg_1' align='center'>"; echo "<td colspan='2' align='center'>"; echo "<input type='submit' name='update' value=\"" . _sx("button", "Post") . "\" class='submit' >"; echo "</td>"; echo "</tr>"; echo "</table>"; Html::closeForm(); echo "</div>"; }
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; }
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; }