$mattrans->setStatus("pending");
             }
         }
         $mattrans->store();
     } catch (fExpectedException $e) {
         echo $e->printMessage();
     }
 } else {
     if ($_POST['type'] == "accept") {
         try {
             $mattrans_detail = new Material_transfer_detail($_POST['key']);
             $mattrans = new Material_transfer($mattrans_detail->getDocNumber());
             if ($mattrans_detail->getStatus() != "transit") {
                 throw new fProgrammerException('Status Overidden: ' . $mattrans_detail->getStatus());
             }
             Inv_stock::moveTransit($mattrans_detail->getItemId(), $mattrans->getBranchFrom(), $mattrans->getBranchTo(), $mattrans_detail->getQuantity());
             $mattrans_detail->setStatus("completed");
             $mattrans_detail->setReceiver($_POST['user']);
             $mattrans_detail->store();
             $mat_details = Material_transfer_detail::findDetail($mattrans->getDocNumber());
             foreach ($mat_details as $mat_detail) {
                 if ($mat_detail->getStatus() == "completed") {
                     $mattrans->setStatus("completed");
                 } else {
                     $mattrans->setStatus("pending");
                 }
             }
             $mattrans->store();
         } catch (fExpectedException $e) {
             echo $e->printMessage();
         }
        echo $mattrans->prepareDocDate("j F Y");
        ?>
<br />
		<label for="doc_type">Document Type </label>
			<?php 
        echo $mattrans->prepareDocType();
        ?>
<br />
		<label for="branch_id">From Branch </label>
				<?php 
        $fromBranch = new Branch($mattrans->getBranchFrom());
        echo $fromBranch->prepareName();
        ?>
		<label for="branch_id"> To Branch </label>
			<?php 
        $toBranch = new Branch($mattrans->getBranchTo());
        echo $toBranch->prepareName();
        ?>
<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) {