示例#1
0
 public function showForm($ID, $options = array())
 {
     $this->initForm($ID, $options);
     $this->showFormHeader($options);
     $order_order = new PluginOrderOrder();
     $order_order->getFromDB($this->getOrdersID());
     $order_reference = new PluginOrderReference();
     $order_reference->getFromDB($this->fields["plugin_order_references_id"]);
     $canedit = $order_order->can($this->getOrdersID(), UPDATE) && !$order_order->canUpdateOrder() && !$order_order->isCanceled();
     echo "<input type='hidden' name='plugin_order_orders_id' value='" . $this->getOrdersID() . "'>";
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . __("Reference") . ": </td>";
     echo "<td>";
     $data = array();
     $data["id"] = $this->fields["plugin_order_references_id"];
     $data["name"] = $order_reference->fields["name"];
     echo $order_reference->getReceptionReferenceLink($data);
     echo "</td>";
     echo "<td>" . __("Taken delivery", "order") . "</td>";
     echo "<td>";
     Dropdown::showYesNo('states_id', $this->fields['states_id']);
     echo "</td>";
     echo "</tr>";
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . __("Delivery form") . ": </td>";
     echo "<td>";
     if ($canedit) {
         Html::autocompletionTextField($this, "delivery_number");
     } else {
         echo $this->fields["delivery_number"];
     }
     echo "</td>";
     echo "<td>" . __("Delivery date") . ": </td>";
     echo "<td>";
     if ($canedit) {
         Html::showDateFormItem("delivery_date", $this->fields["delivery_date"], true, 1);
     } else {
         echo Html::convDate($this->fields["delivery_date"]);
     }
     echo "</td>";
     echo "</tr>";
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . __("Delivery status", "order") . ": </td>";
     echo "<td>";
     if ($canedit) {
         PluginOrderDeliveryState::Dropdown(array('name' => "plugin_order_deliverystates_id", 'value' => $this->fields["plugin_order_deliverystates_id"]));
     } else {
         echo Dropdown::getDropdownName("glpi_plugin_order_deliverystates", $this->fields["plugin_order_deliverystates_id"]);
     }
     echo "</td>";
     echo "<td>" . __("Bill", "order") . "</td>";
     echo "<td>";
     if (Session::haveRight("plugin_order_bill", UPDATE)) {
         PluginOrderBill::Dropdown(array('name' => "plugin_order_bills_id", 'value' => $this->fields["plugin_order_bills_id"]));
     } elseif (Session::haveRight("plugin_order_bill", UPDATE)) {
         echo Dropdown::getDropdownName("glpi_plugin_order_bills", $this->fields["plugin_order_bills_id"]);
     }
     echo "</td>";
     echo "</tr>";
     echo "<tr class='tab_bg_1'><td>";
     //comments of order
     echo __("Comments") . ": </td>";
     echo "<td colspan='3'>";
     if ($canedit) {
         echo "<textarea cols='100' rows='4' name='delivery_comment'>" . $this->fields["delivery_comment"] . "</textarea>";
     } else {
         echo $this->fields["delivery_comment"];
     }
     echo "</td>";
     echo "</tr>";
     $options['candel'] = false;
     $this->showFormButtons($options);
     return true;
 }
示例#2
0
 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>";
 }
示例#3
0
 public static function showOrderSupplierInfos($ID)
 {
     //TODO : en cours
     global $DB;
     $order = new PluginOrderOrder();
     $order->getFromDB($ID);
     $suppliers_id = $order->fields["suppliers_id"];
     Session::initNavigateListItems(__CLASS__, __("Order", "order") . " = " . $order->fields["name"]);
     $candelete = $order->can($ID, UPDATE);
     $rand = mt_rand();
     $link = Toolbox::getItemTypeFormURL(__CLASS__);
     echo "<form method='post' name='show_supplierinfos{$rand}' id='show_supplierinfos{$rand}' " . "action=\"" . $link . "\">";
     echo "<div class='center'>";
     echo "<input type='hidden' name='plugin_order_orders_id' value='" . $ID . "'>";
     $table = getTableForItemType(__CLASS__);
     $nb_elements = countElementsInTable($table, "`plugin_order_orders_id` = '{$ID}'");
     if ($nb_elements > 0) {
         echo "<table class='tab_cadre_fixe'>";
         echo "<tr><th colspan='4'>" . __("Supplier Detail", "order") . "</th></tr>";
         echo "<tr>";
         echo "<th>&nbsp;</th>";
         echo "<th>" . __("Supplier") . "</th>";
         echo "<th>" . __("Quote number", "order") . "</th>";
         echo "<th>" . __("Order number") . "</th>";
         echo "</tr>";
         $datas = getAllDatasFromTable($table, "`plugin_order_orders_id` = '{$ID}'");
         foreach ($datas as $data) {
             Session::addToNavigateListItems(__CLASS__, $data['id']);
             echo "<input type='hidden' name='item[" . $data["id"] . "]' value='" . $ID . "'>";
             echo "<tr class='tab_bg_1 center'>";
             echo "<td>";
             if ($candelete) {
                 echo "<input type='checkbox' name='check[" . $data["id"] . "]'";
                 if (isset($_POST['check']) && $_POST['check'] == 'all') {
                     echo " checked ";
                 }
                 echo ">";
             }
             echo "</td>";
             echo "<td><a href='" . $link . "?id=" . $data["id"] . "&plugin_order_orders_id=" . $ID . "'>" . Dropdown::getDropdownName("glpi_suppliers", $data["suppliers_id"]) . "</a></td>";
             echo "<td>" . $data["num_quote"] . "</td>";
             echo "<td>" . $data["num_order"] . "</td>";
             echo "</tr>";
         }
         echo "</table></div>";
         if ($candelete) {
             Html::openArrowMassives("show_supplierinfos{$rand}", true);
             Html::closeArrowMassives(array('delete' => __("Delete permanently")));
         }
     }
     Html::closeForm();
 }
示例#4
0
 public static function showOrderSupplierSurvey($ID)
 {
     global $DB, $CFG_GLPI;
     $order = new PluginOrderOrder();
     $order->getFromDB($ID);
     $survey = new self();
     $table = getTableForItemType(__CLASS__);
     Session::initNavigateListItems(__CLASS__, __("Order", "order") . " = " . $order->fields["name"]);
     $candelete = $order->can($ID, DELETE);
     $query = "SELECT * FROM `{$table}` WHERE `plugin_order_orders_id` = '{$ID}' ";
     $result = $DB->query($query);
     $rand = mt_rand();
     echo "<div class='center'>";
     echo "<form method='post' name='show_suppliersurvey{$rand}' id='show_suppliersurvey{$rand}' " . " action=\"" . Toolbox::getItemTypeFormURL(__CLASS__) . "\">";
     echo "<input type='hidden' name='plugin_order_orders_id' value='" . $ID . "'>";
     echo "<table class='tab_cadre_fixe'>";
     echo "<tr><th colspan='5'>" . __("Supplier quality", "order") . "</th></tr>";
     echo "<tr><th>&nbsp;</th>";
     echo "<th>" . __("Supplier") . "</th>";
     echo "<th>" . __("Note", "order") . "</th>";
     echo "<th>" . __("Comment on survey", "order") . "</th>";
     echo "</tr>";
     if ($DB->numrows($result) > 0) {
         while ($data = $DB->fetch_array($result)) {
             Session::addToNavigateListItems(__CLASS__, $data['id']);
             echo "<input type='hidden' name='item[" . $data["id"] . "]' value='" . $ID . "'>";
             echo "<tr class='tab_bg_1 center'>";
             echo "<td>";
             if ($candelete) {
                 echo "<input type='checkbox' name='check[" . $data["id"] . "]'";
                 if (isset($_POST['check']) && $_POST['check'] == 'all') {
                     echo " checked ";
                 }
                 echo ">";
             }
             echo "</td>";
             $link = Toolbox::getItemTypeFormURL(__CLASS__);
             echo "<td><a href='" . $link . "?id=" . $data["id"] . "&plugin_order_orders_id=" . $ID . "'>" . Dropdown::getDropdownName("glpi_suppliers", $data["suppliers_id"]) . "</a></td>";
             echo "<td>";
             $total = $survey->getTotalNotation($ID);
             echo $total . " / 10";
             echo "</td>";
             echo "<td>";
             echo $data["comment"];
             echo "</td>";
             echo "</tr>";
         }
         echo "</table>";
         if ($candelete) {
             echo "<div class='center'>";
             Html::openArrowMassives("show_suppliersurvey{$rand}", true);
             Html::closeArrowMassives(array("delete" => __("Delete permanently")));
             echo "</div>";
         }
     } else {
         echo "</table>";
     }
     Html::closeForm();
     echo "</div>";
 }