Ejemplo n.º 1
0
 public static function search($values = array())
 {
     /* This function returns an array of item copy objects if the results have many item copies,
           		else returns a single object.
     
           */
     $item_copies = array();
     $result1 = DB::getInstance()->search("item_copy", $values);
     if (count($result1) != 0) {
         for ($x = 0; $x < count($result1); $x++) {
             $item_copy_data = array("owner" => $result1[$x]["item_copy_owner"], "status" => $result1[$x]["item_copy_status"], "barcode" => $result1[$x]["item_copy_barcode"], "price" => $result1[$x]["item_copy_unit_price"], "installed_date" => $result1[$x]["item_copy_installed_date"], "condition" => $result1[$x]["item_copy_condition"], "no" => $result1[$x]["item_copy_no"], "item_id" => $result1[$x]["item_id"], "supplier" => $result1[$x]["supplier_id"], "id" => $result1[$x]["item_copy_id"]);
             $new_item_copy = new ItemCopy();
             $new_item_copy->create($item_copy_data);
             $item_copies[] = $new_item_copy;
         }
         if (count($item_copies) == 1) {
             return $item_copies[0];
         } else {
             return $item_copies;
         }
     } else {
         return null;
     }
 }
Ejemplo n.º 2
0
<?php

require_once 'core/init.php';
if (count($_POST) > 0) {
    $item_copy_data = array("id" => null, "no" => null, "owner" => $_POST["copy_owner"], "status" => 1, "barcode" => $_POST["barcode"], "price" => $_POST["price"], "installed_date" => date('Y-m-d'), "condition" => "Working Properly", "supplier" => $_POST["supplier"], "item_id" => $_POST['itemId']);
    $_SESSION['form_data'] = $item_copy_data;
    $new_item_copy = new ItemCopy();
    $new_item_copy->createNew($_SESSION["form_data"]);
    if ($new_item_copy->register()) {
        $parentItem = item::search(array("item_id" => $_POST['itemId']));
        $parentItem->count_up(1);
        $message = "You have successfully Inserted an Item Copy!!";
        echo $message;
    } else {
        $message = "The Item Copy insertion was unsuccessful.";
        echo $message;
    }
    unset($_SESSION["form_data"]);
}
?>








Ejemplo n.º 3
0
<?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!";
}
<?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 !";
    }
}
Ejemplo n.º 5
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>";
Ejemplo n.º 6
0
            } 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";