Example #1
0
 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") . "&nbsp;:</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") . "&nbsp;: " . $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;
 }
Example #2
0
 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") . "&nbsp;:</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") . "&nbsp;: " . $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;
 }