public function showForm($ID, $options = array()) { $plugin_order_orders_id = -1; if (isset($options['plugin_order_orders_id'])) { $plugin_order_orders_id = $options['plugin_order_orders_id']; } $this->initForm($ID, $options); if (strpos($_SERVER['PHP_SELF'], "order_supplier")) { echo "showTabs()"; $this->showTabs($options); } $this->showFormHeader($options); $PluginOrderOrder = new PluginOrderOrder(); $PluginOrderOrder->getFromDB($plugin_order_orders_id); echo "<input type='hidden' name='plugin_order_orders_id' value='{$plugin_order_orders_id}'>"; echo "<input type='hidden' name='entities_id' value='" . $PluginOrderOrder->getEntityID() . "'>"; echo "<input type='hidden' name='is_recursive' value='" . $PluginOrderOrder->isRecursive() . "'>"; echo "<tr class='tab_bg_1'>"; echo "<td>" . __("Supplier") . ": </td>"; $supplier = $PluginOrderOrder->fields["suppliers_id"]; if ($ID > 0) { $supplier = $this->fields["suppliers_id"]; } echo "<td>"; $link = Toolbox::getItemTypeFormURL('Supplier'); echo "<a href=\"" . $link . "?id=" . $supplier . "\">" . Dropdown::getDropdownName("glpi_suppliers", $supplier) . "</a></td>"; echo "<input type='hidden' name='suppliers_id' value='" . $supplier . "'>"; echo "</td>"; /* number of quote */ echo "<td>" . __("Quote number", "order") . ": </td><td>"; Html::autocompletionTextField($this, "num_quote"); echo "</td>"; echo "</tr>"; echo "<tr class='tab_bg_1'>"; echo "</td><td colspan='2'></td>"; /* num order supplier */ echo "<td>" . __("Order number") . ": </td><td>"; Html::autocompletionTextField($this, "num_order"); echo "</tr>"; $options['candel'] = false; $this->showFormButtons($options); return true; }
public function addDetails($ref_id, $itemtype, $orders_id, $quantity, $price, $discounted_price, $taxes_id) { $order = new PluginOrderOrder(); if ($quantity > 0 && $order->getFromDB($orders_id)) { for ($i = 0; $i < $quantity; $i++) { $input["plugin_order_orders_id"] = $orders_id; $input["plugin_order_references_id"] = $ref_id; $input["plugin_order_ordertaxes_id"] = $taxes_id; $input["itemtype"] = $itemtype; $input["entities_id"] = $order->getEntityID(); $input["is_recursive"] = $order->isRecursive(); $input["price_taxfree"] = $price; $input["price_discounted"] = $price - $price * ($discounted_price / 100); $input["states_id"] = PluginOrderOrder::ORDER_DEVICE_NOT_DELIVRED; $input["price_ati"] = $this->getPricesATI($input["price_discounted"], Dropdown::getDropdownName("glpi_plugin_order_ordertaxes", $taxes_id)); $input["discount"] = $discounted_price; $this->add($input); } } }
public static function showOrdersItems(PluginOrderBill $bill) { global $DB, $CFG_GLPI; $reference = new PluginOrderReference(); $order = new PluginOrderOrder(); $order->getFromDB($bill->fields['plugin_order_orders_id']); //Can write orders, and order is not already paid $canedit = $order->can($order->getID(), UPDATE) && !$order->isPaid() && !$order->isCanceled(); $query_ref = "SELECT `glpi_plugin_order_orders_items`.`id` AS IDD, " . "`glpi_plugin_order_orders_items`.`plugin_order_references_id` AS id, " . "`glpi_plugin_order_references`.`name`, " . "`glpi_plugin_order_references`.`itemtype`, " . "`glpi_plugin_order_references`.`manufacturers_id` " . "FROM `glpi_plugin_order_orders_items`, `glpi_plugin_order_references` " . "WHERE `plugin_order_orders_id` = '" . $order->getID() . "' " . "AND `glpi_plugin_order_orders_items`.`plugin_order_references_id` = `glpi_plugin_order_references`.`id` " . "GROUP BY `glpi_plugin_order_orders_items`.`plugin_order_references_id` " . "ORDER BY `glpi_plugin_order_references`.`name`"; $result_ref = $DB->query($query_ref); while ($data_ref = $DB->fetch_array($result_ref)) { echo "<div class='center'><table class='tab_cadre_fixe'>"; if (!$DB->numrows($result_ref)) { echo "<tr><th>" . __("No item to take delivery of", "order") . "</th></tr></table></div>"; } else { $order_item = new PluginOrderOrder_Item(); $rand = mt_rand(); $itemtype = $data_ref["itemtype"]; $item = new $itemtype(); echo "<tr><th><ul><li>"; echo "<a href=\"javascript:showHideDiv('generation{$rand}','generation_img{$rand}', '" . $CFG_GLPI['root_doc'] . "/pics/plus.png','" . $CFG_GLPI['root_doc'] . "/pics/moins.png');\">"; echo "<img alt='' name='generation_img{$rand}' src=\"" . $CFG_GLPI['root_doc'] . "/pics/plus.png\">"; echo "</a>"; echo "</li></ul></th>"; echo "<th>" . __("Type") . "</th>"; echo "<th>" . __("Manufacturer") . "</th>"; echo "<th>" . __("Product reference", "order") . "</th>"; echo "</tr>"; echo "<tr class='tab_bg_1 center'>"; echo "<td></td>"; echo "<td align='center'>" . $item->getTypeName() . "</td>"; //Entity echo "<td align='center'>"; echo Dropdown::getDropdownName('glpi_entities', $order->getEntityID()); echo "</td>"; echo "<td>" . $reference->getReceptionReferenceLink($data_ref) . "</td>"; echo "</tr></table>"; echo "<div class='center' id='generation{$rand}' style='display:none'>"; echo "<form method='post' name='bills_form{$rand}' id='bills_form{$rand}'\n action='" . Toolbox::getItemTypeFormURL('PluginOrderBill') . "'>"; echo "<input type='hidden' name='plugin_order_orders_id' value='" . $order->getID() . "'>"; echo "<table class='tab_cadre_fixe'>"; echo "<th></th>"; echo "<th>" . __("Reference") . "</th>"; echo "<th>" . __("Type") . "</th>"; echo "<th>" . __("Model") . "</th>"; echo "<th>" . __("Bill", "order") . "</th>"; echo "<th>" . __("Bill status", "order") . "</th>"; echo "</tr>"; $results = $order_item->queryBills($order->getID(), $data_ref['id']); while ($data = $DB->fetch_array($results)) { echo "<tr class='tab_bg_1'>"; if ($canedit) { echo "<td width='10'>"; $sel = ""; if (isset($_GET["select"]) && $_GET["select"] == "all") { $sel = "checked"; } echo "<input type='checkbox' name='item[" . $data["IDD"] . "]' value='1' {$sel}>"; echo "<input type='hidden' name='plugin_order_orders_id' value='" . $order->getID() . "'>"; echo "</td>"; } //Reference echo "<td align='center'>"; echo $reference->getReceptionReferenceLink($data); echo "</td>"; //Type echo "<td align='center'>"; if (file_exists($CFG_GLPI['root_doc'] . "/inc/" . strtolower($data["itemtype"]) . "type.class.php")) { echo Dropdown::getDropdownName(getTableForItemType($data["itemtype"] . "Type"), $data["types_id"]); } echo "</td>"; //Model echo "<td align='center'>"; if (file_exists($CFG_GLPI['root_doc'] . "/inc/" . strtolower($data["itemtype"]) . "model.class.php")) { echo Dropdown::getDropdownName(getTableForItemType($data["itemtype"] . "Model"), $data["models_id"]); } $bill = new PluginOrderBill(); echo "<td align='center'>"; if ($data["plugin_order_bills_id"] > 0) { if ($bill->can($data['plugin_order_bills_id'], READ)) { echo "<a href='" . $bill->getLinkURL() . "'>" . $bill->getName(true) . "</a>"; } else { echo $bill->getName(); } } echo "</td>"; echo "<td align='center'>"; echo Dropdown::getDropdownName(getTableForItemType('PluginOrderBillState'), $data['plugin_order_billstates_id']); echo "</td>"; echo "</tr>"; } } echo "</table>"; if ($canedit) { echo "<div class='center'>"; echo "<table width='950px' class='tab_glpi'>"; echo "<tr><td><img src=\"" . $CFG_GLPI["root_doc"] . "/pics/arrow-left.png\" alt=''></td><td class='center'>"; echo "<a onclick= \"if ( markCheckboxes('bills_form{$rand}') ) " . "return false;\" href='#'>" . __("Check all") . "</a></td>"; echo "<td>/</td><td class='center'>"; echo "<a onclick= \"if ( unMarkCheckboxes('bills_form{$rand}') ) " . "return false;\" href='#'>" . __("Uncheck all") . "</a>"; echo "</td><td align='left' width='80%'>"; echo "<input type='hidden' name='plugin_order_orders_id' value='" . $order->getID() . "'>"; $order_item->dropdownBillItemsActions($order->getID()); echo "</td>"; echo "</table>"; echo "</div>"; } Html::closeForm(); echo "</div>"; } echo "<br>"; }
public function showForm($ID, $options = array()) { if (!self::canView()) { return false; } $plugin_order_orders_id = -1; if (isset($options['plugin_order_orders_id'])) { $plugin_order_orders_id = $options['plugin_order_orders_id']; } if ($ID > 0) { $this->check($ID, READ); } else { // Create item $input = array('plugin_order_orders_id' => $options['plugin_order_orders_id']); $this->check(-1, UPDATE, $input); } $this->initForm($ID, $options); $options['colspan'] = 1; $this->showFormHeader($options); $order = new PluginOrderOrder(); $order->getFromDB($plugin_order_orders_id); echo "<input type='hidden' name='plugin_order_orders_id' value='{$plugin_order_orders_id}'>"; echo "<input type='hidden' name='entities_id' value='" . $order->getEntityID() . "'>"; echo "<input type='hidden' name='is_recursive' value='" . $order->isRecursive() . "'>"; echo "<tr class='tab_bg_1'><td>" . __("Supplier") . ": </td><td>"; $suppliers_id = $order->fields["suppliers_id"]; if ($ID > 0) { $suppliers_id = $this->fields["suppliers_id"]; } $link = Toolbox::getItemTypeFormURL('Supplier'); echo "<a href=\"" . $link . "?id=" . $suppliers_id . "\">" . Dropdown::getDropdownName("glpi_suppliers", $suppliers_id) . "</a>"; echo "<input type='hidden' name='suppliers_id' value='" . $suppliers_id . "'>"; echo "</td>"; echo "</tr>"; echo "<tr class='tab_bg_1'><td>" . __("Administrative followup quality (contracts, bills, mail, etc.)", "order") . ": </td><td>"; $this->addNotation("answer1", $this->fields["answer1"]); echo "</td>"; echo "</tr>"; echo "<tr class='tab_bg_1'><td>" . __("Commercial followup quality, visits, responseness", "order") . ": </td><td>"; $this->addNotation("answer2", $this->fields["answer2"]); echo "</td>"; echo "</tr>"; echo "<tr class='tab_bg_1'><td>" . __("Contacts availability", "order") . ": </td><td>"; $this->addNotation("answer3", $this->fields["answer3"]); echo "</td>"; echo "</tr>"; echo "<tr class='tab_bg_1'><td>" . __("Quality of supplier intervention", "order") . ": </td><td>"; $this->addNotation("answer4", $this->fields["answer4"]); echo "</td>"; echo "</tr>"; echo "<tr class='tab_bg_1'><td>" . __("Reliability about annouced delays", "order") . ": </td><td>"; $this->addNotation("answer5", $this->fields["answer5"]); echo "</td>"; echo "</tr>"; echo "<tr class='tab_bg_1'><td>"; //comments of order echo __("Comments") . ": </td>"; echo "<td>"; echo "<textarea cols='80' rows='4' name='comment'>" . $this->fields["comment"] . "</textarea>"; echo "</td>"; echo "</tr>"; if ($ID > 0) { echo "<tr><th><div align='left'>" . __("Average mark up to 10 (X points / 5)", "order") . ": </div></th><th><div align='left'>"; $total = $this->getTotalNotation($this->fields["plugin_order_orders_id"]); echo Html::formatNumber($total) . " / 10"; echo "</div></th>"; echo "</tr>"; } $this->showFormButtons($options); return true; }