<?php

require_once 'core/init.php';
$member_role = $_SESSION['roles'];
if (in_array("Laboratory Administrator", $member_role) || in_array("Related Lecturer", $member_role)) {
} else {
    header('location:restricted_page.php');
}
$itemCopyId = $_POST['itemCopyId'];
$new_copy_num = $_POST['new_copy_num'];
//echo $new_copy_num;
$item_copy = ItemCopy::search(array("item_copy_id" => $itemCopyId));
$prev_num = $item_copy->get_no();
$array = explode("_", $prev_num);
$new_num = $array[0] . "_" . $new_copy_num;
//echo $new_num;
if ($item_copy->update_item_copy_no($new_num)) {
    echo "Item number updated.";
} else {
    echo "Sorry, Update failed. Given ID already exists!";
}
Esempio n. 2
0
			</table>

        	</div>
          <input hidden name="condition[]">
          <input hidden name="returned[]">
        	<h3>Borrowed Items</h3>
        	<div class="datagrid">

        	<?php 
echo "<table>";
echo "<thead><th>Item Copy No</th><th>Return Status</th><th>Condition/Status</th></thead><tbody>";
$result = $value->getTransactions();
foreach ($result as $key => $value) {
    $itemCopyId = $value->getItemCopyId();
    $itemCopy = ItemCopy::search(["item_copy_id" => $itemCopyId]);
    $itemCopyNo = $itemCopy->get_no();
    $bcon = $value->getBorrowedQuantity();
    $rcon = $value->getReturnedQuantity();
    $k = $itemCopyId . $itemCopyId;
    echo "<tr><td>{$itemCopyNo}</td>";
    //echo "<td>$bcon</td>";
    //echo "<td><input type='number' class='large text' value='$bcon'/></td>";
    echo "<td><input onclick='changeSelect(this.id);' type='checkbox' name='returned[]' value='{$itemCopyId}' id='{$itemCopyId}'/><label for='{$itemCopyId}'><span class='ui'></span></label></td>";
    echo "<td>";
    echo "<select class='large select' disabled='disabled' id='{$k}' name='condition[]' required='required'>";
    echo "<option value='' selected='selected'>Select</option>";
    echo "<option value='Working Properly'>Working Properly</option>";
    echo "<option value='Working With defects'>Working With defects</option>";
    echo "<option value='Not Working'>Not Working</option>";
    echo "<option value='Misplaced'>Misplaced</option>";
<?php 
require_once 'core/init.php';
$member_role = $_SESSION['roles'];
if (in_array("Laboratory Assistant", $member_role)) {
} else {
    header('location:restricted_page.php');
}
$copy_no = $_GET["copy_no"];
if (!isset($_SESSION["items"])) {
    $_SESSION["items"] = array();
    print "one";
} else {
    if (in_array($copy_no, $_SESSION["items"])) {
        $key = array_search($copy_no, $_SESSION["items"]);
        unset($_SESSION["items"][$key]);
        unset($_SESSION["basket"][$key]);
        print "You removed the item from the basket successfully !";
    } else {
        array_push($_SESSION["items"], $copy_no);
        $itemCopy = ItemCopy::search(["item_copy_no" => $copy_no]);
        $data = array("item_copy_id" => $itemCopy->get_id(), "item_copy_no" => $itemCopy->get_no(), "item_copy_name" => $itemCopy->get_item_name(), "quantity" => 1, "condition" => $itemCopy->get_condition());
        array_push($_SESSION["basket"], $data);
        print "You have added the item to the basket successfully !";
    }
}
            } else {
                $bgcolour = "#F23400";
                $draggable = "false";
                $status = "Not Available";
                $type = "hidden";
            }
            echo "<li class='node'><div id='" . $itemCopyNo . "' draggable=" . $draggable . " ondragstart=\"drag(event);\" style='border:1px solid #000000;padding:10px;background:" . $bgcolour . ";margin-right:30px;margin-top:5px;margin-left:30px'><img src='img/items/" . $itemName . ".png' height='80' width='80' align='left'/><b> Item Copy Name : </b>{$itemName}<br/><b> Item Copy No : </b>{$itemCopyNo}<br/><b> Condition : </b>{$itemCopyCondition}<br/><b>Status : </b>{$status}<br/><input type='" . $type . "' id='" . $itemCopyNo . "' value='Add to Basket' onclick='addToBasket(this.id);'/></div></li>";
        }
        echo "</ul>";
    } else {
        echo "No item copies for this item.";
    }
} else {
    if (array_key_exists("copy_no", $_GET)) {
        $value = $_GET["copy_no"];
        $itemCopy = ItemCopy::search(array("item_copy_no" => $value));
        if ($itemCopy != NULL) {
            $itemCopyId = $itemCopy->get_id();
            $itemCopyNo = $itemCopy->get_no();
            $itemCopyStatus = $itemCopy->get_status();
            $itemCopyCondition = $itemCopy->get_condition();
            $itemName = $itemCopy->get_item_name();
            //$GLOBALS[$itemCopyNo]="";
            //unset($GLOBALS[$itemCopyNo]);
            if ($itemCopyStatus == 1 && !in_array($itemCopyNo, $_SESSION["items"])) {
                $bgcolour = "#B3F5C2";
                $draggable = "true";
                $status = "Available";
                $type = "button";
            } else {
                $bgcolour = "#F23400";