public function showBillsItems(PluginOrderOrder $order) { global $DB, $CFG_GLPI; $reference = new PluginOrderReference(); echo "<div class='center'><table class='tab_cadre_fixe'>"; echo "<tr class='tab_bg_1'><th colspan='2'>" . __("Bills", "order") . "</th></tr>"; echo "<tr class='tab_bg_1'><td class='center'>" . __("Payment status", "order") . ": </td>"; echo "<td>"; echo PluginOrderBillState::getState($order->fields['plugin_order_billstates_id']); echo "</td></tr></table>"; if (countElementsInTable(getTableForItemType(__CLASS__), "`plugin_order_orders_id`='" . $order->getID() . "' GROUP BY `plugin_order_bills_id`")) { echo "<table class='tab_cadre_fixe'>"; echo "<tr class='tab_bg_1'><th>" . __("Name") . "</th>"; echo "<th>" . __("Status") . "</th>"; echo "<th>" . __("Value") . "</th>"; echo "<th>" . __("Paid value", "order") . "</th></tr>"; $bill = new PluginOrderBill(); foreach ($DB->request(getTableForItemType(__CLASS__), "`plugin_order_orders_id`='" . $order->getID() . "' GROUP BY `plugin_order_bills_id`") as $item) { if (isset($item->fields['plugin_order_bills_id']) && $item->fields['plugin_order_bills_id']) { echo "<tr class='tab_bg_1'><td class='center'>"; if ($bill->can($item->fields['plugin_order_bills_id'], READ)) { echo "<td><a href='" . $item->getURL() . "'>" . $bill->getName() . "</a></td>"; } else { echo "<td>" . $bill->getName() . "</td>"; } echo "</td>"; echo "<td>"; echo Dropdown::getDropdownName(getTableForItemType('PluginOrderBillState'), $bill->fields['plugin_order_billstates_id']); echo "</td></tr>"; } } echo "</tr></table>"; } echo "</div>"; //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 { $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', $this->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}' " . "action='" . Toolbox::getItemTypeFormURL('PluginOrderBill') . "'>"; echo "<input type='hidden' name='plugin_order_orders_id'\n 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 = $this->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(GLPI_ROOT . "/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(GLPI_ROOT . "/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() . "'>"; $this->dropdownBillItemsActions($order->getID()); echo "</td>"; echo "</table>"; echo "</div>"; } Html::closeForm(); echo "</div>"; } echo "<br>"; }
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with GLPI; along with Order. If not, see <http://www.gnu.org/licenses/>. -------------------------------------------------------------------------- @package order @author the order plugin team @copyright Copyright (c) 2010-2011 Order plugin team @license GPLv2+ http://www.gnu.org/licenses/gpl.txt @link https://forge.indepnet.net/projects/order @link http://www.glpi-project.org/ @since 2009 ---------------------------------------------------------------------- */ include "../../../inc/includes.php"; header("Content-Type: text/html; charset=UTF-8"); Html::header_nocache(); if (!defined('GLPI_ROOT')) { die("Can not acces directly to this file"); } if (isset($_POST["action"])) { switch ($_POST["action"]) { case "bill": echo " <input type='hidden' name='plugin_order_orders_id' " . " value='" . $_POST["plugin_order_orders_id"] . "'>"; PluginOrderBill::Dropdown(array('condition' => "`plugin_order_orders_id`='" . $_POST['plugin_order_orders_id'] . "'")); break; } PluginOrderBillState::Dropdown(array('comments' => true)); echo " <input type='submit' name='action' class='submit' " . " value='" . __("Post") . "'>"; }