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 static function countForOrder(PluginOrderOrder $item) { return countElementsInTable('glpi_plugin_order_orders_items', "`plugin_order_orders_id` = '" . $item->getID() . "'"); }
public static function countForOrder(PluginOrderOrder $item) { return countElementsInTable('glpi_plugin_order_orders_items', "`plugin_order_orders_id` = '" . $item->getID() . "' " . "AND `states_id` = '" . PluginOrderOrder::ORDER_DEVICE_DELIVRED . "'"); }