echo $branch->prepareName() . " / " . "<span id=\"branchId\">" . $production->prepareBranchId() . "</span>";
        ?>
<br />
		<table id="formContent">
			<thead>
				<tr><th>No</th>
					<th>Item Code</th><th width="400">Description</th><th>Quantity</th><th>UOM</th><th>Remarks</th><th>Icons</th></tr>
			</thead>
			<tbody>
				<?php 
        $hideCancel = false;
        $counter = 1;
        foreach ($production_details as $production_detail) {
            echo "<tr id=\"rowNo" . $counter . "\"><td id=\"detailId\" class=\"hideFirst\">" . $production_detail->getId() . "</td><td>" . $counter . "</td><td id=\"itemCode\">" . $production_detail->prepareItemId() . "</td>";
            $item = new Inv_item($production_detail->getItemId());
            echo "<td class=\"itemDesc\">" . $item->prepareDescription() . "</td>\n\t\t\t\t\t\t\t\t<td id=\"itemQuan\">" . $production_detail->prepareQuantity() . "</td>\n\t\t\t\t\t\t\t \t<td>" . $item->prepareUnitOfMeasure() . "</td><td>" . $production_detail->prepareRemark() . "</td>";
            if ($production_detail->getStatus() == "pending") {
                echo "<td id=\"iconCell\"><ul id=\"icons\" class=\"ui-widget ui-helper-clearfix\">\n\t\t\t\t\t\t\t\t<li id=\"save\" title=\"Save\" class=\"ui-state-default ui-corner-all\">\n\t\t\t\t\t\t\t\t\t<span class=\"ui-icon ui-icon-disk\"></span>\n\t\t\t\t\t\t\t\t\t<span class=\"text-icon\">Save</span>\n\t\t\t\t\t\t\t\t</li>\n\t\t\t\t\t\t\t\t<li title=\"Loading\" class=\"hideFirst ui-corner-all\">\n\t\t\t\t\t\t\t\t\t<img src=\"./img/layout/ajax-loader2.gif\" />\n\t\t\t\t\t\t\t\t</li></ul></td></tr>";
            } else {
                echo "<td id=\"iconCell\"><ul id=\"icons\" class=\"ui-widget ui-helper-clearfix\"><li title=\"Complete\" class=\"ui-state-default ui-corner-all\"><span class=\"ui-icon ui-icon-check\"></span></li><li title=\"Loading\" class=\"hideFirst ui-corner-all\"><img src=\"./img/layout/ajax-loader2.gif\" /></li></ul></td></tr>";
                $hideCancel = true;
            }
            $counter++;
        }
        ?>
			</tbody>
		</table>
		<label>Notes</label><br /><?php 
        echo $production->prepareNotes();
        ?>
<br />
	<div id="main" class="span-24 last">
		<h2>Administration</h2><h3>Stock</h3>
		<br />
		<form action = "admin-stock.php" method = "get">
			<label for="inv_item">Choose Inventory Item: </label>
			<span id="inv_item">
				<input id="autocompleteItem" name="item"></input>
			</span>
			<input id="submitBTN" type="submit" value="Submit" />
		</form>
		<?php 
if (isset($_GET['item'])) {
    try {
        $inv_stocks = Inv_stock::findByItem($_GET['item']);
        $item = new Inv_item($_GET['item']);
        printf("<br /><h3>%s - %s</h3><table><thead><tr><th>Branch</th><th>Quantity</th><th width=\"100\">Update</th></tr></thead><tbody>", $item->prepareId(), $item->prepareDescription());
        foreach ($inv_stocks as $inv_stock) {
            $branch = new Branch($inv_stock->getBranchId());
            printf("<tr><td>%s</td><td><input type=\"text\" value=\"%s\" /> %s</td><td><input class=\"updateBTN\" id=\"%s\" type=\"button\" value=\"Update\"/></td></tr>", $branch->prepareName() . " [" . $branch->prepareId() . "]", $inv_stock->getQuantity(), $item->prepareUnitOfMeasure(), $inv_stock->getId());
        }
        echo "</tbody></table>";
    } catch (fExpectedException $e) {
        echo $e->printMessage();
    }
}
?>
	</div>
</div>
<div id="messageBox" style="display: none;">Loading</div>
<?php 
$tmpl->place('footer');
        }
        ?>
			</div>
		<table id="formContent">
			<thead>
				<tr><th>No</th>
					<th>Item Code</th><th width="300px">Description</th><th>Quantity</th><th>UOM</th><th>Unit Price</th><th>Extended Price</th></tr>
			</thead>
			<tbody>
				<?php 
        $counter = 1;
        $totalchecker = 0;
        foreach ($purchase_details as $purchase_detail) {
            echo "<tr><td>" . $counter . "</td><td>" . $purchase_detail->prepareItemId() . "</td>";
            $item = new Inv_item($purchase_detail->getItemId());
            echo "<td>" . $purchase_detail->prepareDescription() . "</td><td>" . $purchase_detail->prepareQuantity() . "</td>\n\t\t\t\t\t\t\t \t<td>" . $item->prepareUnitOfMeasure() . "</td><td>" . $purchase_detail->prepareUnitPrice() . "</td>\n\t\t\t\t\t\t\t\t<td>" . $purchase_detail->prepareExtendedPrice() . "</td></tr>";
            $totalchecker = $totalchecker + $purchase_detail->getExtendedPrice();
            $counter++;
        }
        ?>
			</tbody>
			<?php 
        $totalchecker = $totalchecker - $purchase->getDiscount();
        if ($totalchecker != $purchase->getTotal()) {
            $purchaseNu = new Purchase($_GET['id']);
            $purchaseNu->setTotal($totalchecker);
            $purchaseNu->store();
        }
        ?>
			<tfoot>
				<tr><td colspan="5"></td><td>Discount</td><td><?php 
                                try {
                                    $uploader = new fUpload();
                                    $uploader->setMIMETypes(array('image/gif', 'image/jpeg', 'image/pjpeg', 'image/png'), 'The file uploaded is not an image');
                                    $uploader->enableOverwrite();
                                    $file = $uploader->move($uploadDirectory, 'file');
                                    $inv_item = new Inv_item($_POST['hiddenId']);
                                    $inv_item->setImageUrl('storage/image/' . $_POST['hiddenId'] . '/' . $file->getFilename());
                                    $inv_item->store();
                                    echo "Image uploaded";
                                } catch (fExpectedException $e) {
                                    echo $e->printMessage();
                                }
                            }
                        }
                    }
                }
            }
        }
    }
} else {
    if (isset($_GET['type'])) {
        if ($_GET['type'] == "uom") {
            try {
                $inv_item = new Inv_item($_GET['key']);
                echo $inv_item->prepareUnitOfMeasure();
            } catch (fExpectedException $e) {
                echo $e->printMessage();
            }
        }
    }
}
				</table>
				</div>
			</div>
		<table id="formContent">
			<thead>
				<tr><th>No</th>
					<th>Item Code</th><th width="300px">Description</th><th>Quantity</th><th>UOM</th><th>Remarks</th><th>(A)</th></tr>
			</thead>
			<!--
			<tbody>
				<?php 
        $counter = 1;
        foreach ($grn_details as $grn_detail) {
            echo "<tr><td>" . $counter . "</td><td>" . $grn_detail->prepareItemId() . "</td>";
            $item = new Inv_item($grn_detail->getItemId());
            echo "<td>" . $item->prepareDescription() . "</td><td>" . $grn_detail->prepareQuantity() . "</td>\n\t\t\t\t\t\t\t \t<td>" . $item->prepareUnitOfMeasure() . "</td><td>" . $grn_detail->prepareRemark() . "</td>\n\t\t\t\t\t\t\t\t<td class=\"assessText\">" . $grn_detail->prepareAssessment() . "</td></tr>";
            $counter++;
        }
        ?>
			</tbody>
			-->
			<tbody>
			</tbody>
			<tfoot>
				<tr><td colspan="7">
					<p>
						<label>Assesment Of Condition (A)</label><br />
						<b>OK</b> : Item received in good condition<br />
						<b>NG</b> : Item is in damaged condition<br />
						<b>Q </b> : Quantity supplied did not match DO quantity<br />
						<b>X </b> : Item sent is different from PO description
        }
        printf("<table><thead><tr><th>Item ID</th><th>Description</th><th>Quantity</th></tr></thead><tbody>");
        foreach ($inv_stocks as $inv_stock) {
            $inv_item = new Inv_item($inv_stock->getItemId());
            printf("<tr><td>%s</td><td>%s</td><td>%s</td></tr>", $inv_item->prepareId(), $inv_item->prepareDescription(), $inv_stock->prepareQuantity() . " " . $inv_item->prepareUnitOfMeasure());
        }
        echo "</tbody></table>";
    } catch (fExpectedException $e) {
        echo $e->printMessage() . $inv_stock->getItemId();
    }
} else {
    if (isset($_GET['item'])) {
        try {
            $inv_stocks = Inv_stock::findByItem($_GET['item']);
            $item = new Inv_item($_GET['item']);
            printf("<br /><h3>%s - %s</h3><table><thead><tr><th>Branch</th><th>Quantity</th></tr></thead><tbody>", $item->prepareId(), $item->prepareDescription());
            foreach ($inv_stocks as $inv_stock) {
                $branch = new Branch($inv_stock->getBranchId());
                printf("<tr><td>%s</td><td>%s</td></tr>", $branch->prepareName() . " [" . $branch->prepareId() . "]", $inv_stock->prepareQuantity() . " " . $item->prepareUnitOfMeasure());
            }
            echo "</tbody></table>";
        } catch (fExpectedException $e) {
            echo $e->printMessage();
        }
    }
}
?>
	</div>
</div>
<?php 
$tmpl->place('footer');
<br />
		<table id="formContent">
			<thead>
				<tr><th>No</th>
					<th>Item Code</th><th width="300px">Description</th><th>Quantity</th><th>UOM</th><th>Remarks</th><th>In <?php 
        echo $fromBranch->getId();
        ?>
</th><th width="75px">Receiver</th></tr>
			</thead>
			<tbody>
				<?php 
        $counter = 1;
        foreach ($mattrans_details as $mattrans_detail) {
            echo "<tr class=\"jsonRow\"><td>" . $counter . "</td><td class=\"itemCode\">" . $mattrans_detail->prepareItemId() . "<input class=\"itemId\" type=\"hidden\" value=\"" . $mattrans_detail->getId() . "\"></input></td>";
            $item = new Inv_item($mattrans_detail->getItemId());
            echo "<td>" . $item->prepareDescription() . "</td><td class=\"itemQuan\">" . $mattrans_detail->prepareQuantity() . "</td>\n\t\t\t\t\t\t\t \t<td>" . $item->prepareUnitOfMeasure() . "</td><td>" . $mattrans_detail->prepareRemark() . "</td>";
            $tempRecords = Inv_stock::findStockByBranch($mattrans_detail->getItemId(), $mattrans->getBranchFrom());
            $quanRow = 0;
            foreach ($tempRecords as $tempRecord) {
                $quanRow = $tempRecord->getQuantity();
            }
            echo "<td>" . $quanRow . "</td>";
            if (fAuthorization::checkAuthLevel('admin')) {
                echo "<td><span class=\"loader hideFirst\"><img src=\"./img/layout/ajax-loader2.gif\" /></span>";
                if ($mattrans_detail->getStatus() == "pending" && $quanRow >= $mattrans_detail->getQuantity()) {
                    echo "<input type=\"button\" value=\"Transit\" \n\t\t\t\t\t\t\t\t\t\tkey=\"" . $mattrans_detail->getId() . "\" class=\"transitBTN\"></input></td>";
                } else {
                    if ($mattrans_detail->getStatus() == "transit") {
                        echo "<input type=\"button\" value=\"Reject\" \n\t\t\t\t\t\t\t\t\t\tkey=\"" . $mattrans_detail->getId() . "\" class=\"rejectBTN\"></input>";
                        echo "<input type=\"button\" value=\"Accept\" \n\t\t\t\t\t\t\t\t\t\tkey=\"" . $mattrans_detail->getId() . "\" class=\"acceptBTN\"></input>";
                        echo "</td>";