Exemplo n.º 1
0
 public static function updateDelivryStatus($orders_id)
 {
     global $DB;
     $config = PluginOrderConfig::getConfig();
     $order = new PluginOrderOrder();
     $order->getFromDB($orders_id);
     $query = "SELECT `states_id`\n                FROM `glpi_plugin_order_orders_items`\n                WHERE `plugin_order_orders_id` = '{$orders_id}'";
     $result = $DB->query($query);
     $number = $DB->numrows($result);
     $delivery_status = 0;
     $is_delivered = 1;
     //Except order to be totally delivered
     if ($number) {
         while ($data = $DB->fetch_array($result)) {
             if ($data["states_id"] == PluginOrderOrder::ORDER_DEVICE_DELIVRED) {
                 $delivery_status = 1;
             } else {
                 $is_delivered = 0;
             }
         }
     }
     //Are all items delivered ?
     if ($is_delivered && !$order->isDelivered()) {
         $order->updateOrderStatus($orders_id, $config->getDeliveredState());
         //At least one item is delivered
     } else {
         if ($delivery_status) {
             $order->updateOrderStatus($orders_id, $config->getPartiallyDeliveredState());
         }
     }
 }
Exemplo n.º 2
0
         $id = $_POST['id'];
     } else {
         $id = $_GET['id'];
     }
     $pluginOrderOrder->check($id, 'w');
     $pluginOrderOrder->delete(array('id' => $id), 1);
     $pluginOrderOrder->redirectToList();
 } else {
     if (isset($_POST["update"])) {
         $pluginOrderOrder->check($_POST['id'], 'w');
         $pluginOrderOrder->update($_POST);
         Html::redirect($_SERVER['HTTP_REFERER']);
     } else {
         if (isset($_POST["validate"])) {
             if (PluginOrderOrder::canView() && (PluginOrderOrder::canValidate() || !$config->useValidation())) {
                 $pluginOrderOrder->updateOrderStatus($_POST["id"], $config->getApprovedState(), $_POST["comment"]);
                 PluginOrderReception::updateDelivryStatus($_POST["id"]);
                 Session::addMessageAfterRedirect(__("Order is validated", "order"));
             }
             Html::redirect($_SERVER['HTTP_REFERER']);
         } else {
             if (isset($_POST["waiting_for_approval"])) {
                 if (pluginOrderOrder::canCreate()) {
                     $pluginOrderOrder->updateOrderStatus($_POST["id"], $config->getWaitingForApprovalState(), $_POST["comment"]);
                     Session::addMessageAfterRedirect(__("Order validation successfully requested", "order"));
                 }
                 Html::redirect($_SERVER['HTTP_REFERER']);
             } else {
                 if (isset($_POST["cancel_waiting_for_approval"])) {
                     if (pluginOrderOrder::canView() && pluginOrderOrder::canCancel()) {
                         $pluginOrderOrder->updateOrderStatus($_POST["id"], $config->getDraftState(), $_POST["comment"]);