updatePedido($decoded->pedido);
                } else {
                    if ($decoded->function == 'updatePedidoDetalle') {
                        updatePedidoDetalle($decoded->pedido_detalle);
                    } else {
                        if ($decoded->function == 'updateStock') {
                            updateStock($decoded->stock);
                        } else {
                            if ($decoded->function == 'removePedido') {
                                removePedido($decoded->pedido_id);
                            } else {
                                if ($decoded->function == 'removePedidoDetalle') {
                                    removePedidoDetalle($decoded->pedido_detalle_id);
                                } else {
                                    if ($decoded->function == 'removeStock') {
                                        removeStock($decoded->stock_id);
                                    } else {
                                        if ($decoded->function == 'trasladar') {
                                            trasladar($decoded->origen_id, $decoded->destino_id, $decoded->producto_id, $decoded->cantidad);
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
    }
} else {
    $function = $_GET["function"];
<?php

/**
 * Created by PhpStorm.
 * User: Buddhi
 * Date: 12/28/2015
 * Time: 4:59 PM
 */
if (file_exists('../mysql_connector.php')) {
    include '../mysql_connector.php';
}
if (isset($_POST['remove'])) {
    removeStock($_POST['stockId']);
    header('Location: http://localhost/PharmacyDB/adminpanel.php?option=4');
}
function removeStock($stockId)
{
    $link = getConnection();
    $sql = "DELETE FROM fstock WHERE StockId='" . $stockId . "'";
    $resultset = mysqli_query($link, $sql);
    mysqli_close($link);
    return $resultset;
}
function isItemInStock($medicineid)
{
    $link = getConnection();
    $sql = "SELECT Quantity FROM fstock WHERE MedicineId = '" . $medicineid . "'";
    $totalQuantity = 0;
    $resultset = mysqli_query($link, $sql);
    $quantity = "OUT OF STOCK";
    if ($resultset != null) {