Index: trunk/grails-app/views/inventoryItemDetailed/show.gsp
===================================================================
--- trunk/grails-app/views/inventoryItemDetailed/show.gsp	(revision 435)
+++ trunk/grails-app/views/inventoryItemDetailed/show.gsp	(revision 441)
@@ -43,4 +43,5 @@
                     <richui:tabLabel selected="${showTab.detail}" title="Detail" />
                     <richui:tabLabel selected="${showTab.movement}" title="Movement" />
+                    <richui:tabLabel selected="${showTab.purchasing}" title="Purchasing" />
                 </richui:tabLabels>
 
@@ -384,7 +385,142 @@
 <!-- End Movement tab -->
 
+<!-- Start Purchases tab -->
+                    <richui:tabContent>
+
+                        <g:if test="${inventoryItemPurchases.isEmpty()}">
+                            <br />
+                            No Inventory Purchases.
+                            <br />
+                            <br />
+
+                            <div class="buttons">
+                                <g:form controller="inventoryItemPurchaseDetailed">
+                                    <g:hiddenField name="inventoryItem.id" value="${inventoryItemInstance.id}" />
+                                    <span class="button"><g:actionSubmit action="create" class="add" value="Order" /></span>
+                                </g:form>
+                            </div>
+
+                        </g:if>
+                        <g:else>
+
+                            <div class="list">
+                                <table>
+                                    <thead>
+                                        <tr>
+                                            <g:sortableColumn action="show" property="purchaseOrderNumber"
+                                                                                title="Order #" params="[paginate: 'purchases']"  />
+                                            <g:sortableColumn action="show"  property="dateEntered"
+                                                                                title="Date" params="[paginate: 'purchases']" />
+                                            <g:sortableColumn action="show"  property="costCode"
+                                                                                title="Cost Code" params="[paginate: 'purchases']" />
+                                            <g:sortableColumn action="show"  property="quantity"
+                                                                                title="Quantity" params="[paginate: 'purchases']" />
+                                            <g:sortableColumn action="show"  property="orderValueAmount"
+                                                                                title="Order \$" params="[paginate: 'purchases']" />
+                                            <g:sortableColumn action="show"  property="invoiceNumber"
+                                                                                title="Invoice Number" params="[paginate: 'purchases']" />
+                                            <g:sortableColumn action="show"  property="inventoryItemPurchaseType"
+                                                                                title="Type" params="[paginate: 'purchases']" />
+                                            <th>
+                                                <img  src="${resource(dir:'images/skin',file:'database_go_grey.png')}" alt="Show" title="Show" />
+                                            </th>
+                                            <th>
+                                                <img  src="${resource(dir:'images/skin',file:'basket_put_grey.png')}" alt="Receive" title="Receive" />
+                                            </th>
+                                            <th>
+                                                <img  src="${resource(dir:'images/skin',file:'tick_grey.png')}" alt="Approve" title="Approve Payment" />
+                                            </th>
+                                        </tr>
+                                    </thead>
+                                    <tbody>
+                                        <g:each in="${inventoryItemPurchases}" status="i" var="purchase">
+                                            <tr class="${(i % 2) == 0 ? 'clickableOdd' : 'clickableEven'}"/>
+
+                                                <td onclick='window.location = "${request.getContextPath()}/inventoryItemPurchaseDetailed/show/${purchase.id}"'>
+                                                    ${fieldValue(bean:purchase, field:'purchaseOrderNumber')}
+                                                </td>
+                                                <td onclick='window.location = "${request.getContextPath()}/inventoryItemPurchaseDetailed/show/${purchase.id}"'>
+                                                    <g:formatDate date="${purchase.dateEntered}" format="EEE, dd-MMM-yyyy"/>
+                                                </td>
+                                                <td onclick='window.location = "${request.getContextPath()}/inventoryItemPurchaseDetailed/show/${purchase.id}"'>
+                                                    ${fieldValue(bean:purchase, field:'costCode')}
+                                                </td>
+                                                <td onclick='window.location = "${request.getContextPath()}/inventoryItemPurchaseDetailed/show/${purchase.id}"'>
+                                                    ${fieldValue(bean:purchase, field:'quantity')}
+                                                </td>
+                                                <td onclick='window.location = "${request.getContextPath()}/inventoryItemPurchaseDetailed/show/${purchase.id}"'>
+                                                    ${fieldValue(bean:purchase, field:'orderValueAmount')}
+                                                    ${fieldValue(bean:purchase, field:'orderValueCurrency')}
+                                                </td>
+                                                <td onclick='window.location = "${request.getContextPath()}/inventoryItemPurchaseDetailed/show/${purchase.id}"'>
+                                                    ${fieldValue(bean:purchase, field:'invoiceNumber')}
+                                                </td>
+                                                <td onclick='window.location = "${request.getContextPath()}/inventoryItemPurchaseDetailed/show/${purchase.id}"'>
+                                                    ${fieldValue(bean:purchase, field:'inventoryItemPurchaseType')}
+                                                </td>
+                                                <td>
+                                                    <g:link controller="inventoryItemPurchaseDetailed" action="show" id="${purchase.id}">
+                                                        <img  src="${resource(dir:'images/skin',file:'database_go.png')}" alt="Show" title="Show" />
+                                                    </g:link>
+                                                </td>
+                                                <g:if test="${purchase.inventoryItemPurchaseType.id == 1}">
+                                                    <g:if test="${!purchase.receivedComplete}">
+                                                        <td>
+                                                            <g:link controller="inventoryItemPurchaseDetailed" action="receive" id="${purchase.id}">
+                                                                <img  src="${resource(dir:'images/skin',file:'basket_put.png')}" alt="Receive" title="Receive" />
+                                                            </g:link>
+                                                        </td>
+                                                    </g:if>
+                                                    <g:else>
+                                                        <td>
+                                                        </td>
+                                                    </g:else>
+                                                    <g:if test="${!purchase.invoicePaymentApproved}">
+                                                        <td>
+                                                            <g:link controller="inventoryItemPurchaseDetailed" action="approveInvoicePayment" id="${purchase.id}">
+                                                                <img  src="${resource(dir:'images/skin',file:'tick.png')}" alt="Approve" title="Approve Payment" />
+                                                            </g:link>
+                                                        </td>
+                                                    </g:if>
+                                                    <g:else>
+                                                        <td>
+                                                        </td>
+                                                    </g:else>
+                                                </g:if>
+                                                <g:else>
+                                                    <td>
+                                                    </td>
+                                                    <td>
+                                                    </td>
+                                                </g:else>
+
+                                            </tr>
+                                        </g:each>
+                                    </tbody>
+                                </table>
+                            </div>
+
+                            <div class="buttons">
+                                <g:form controller="inventoryItemPurchaseDetailed">
+                                    <g:hiddenField name="inventoryItem.id" value="${inventoryItemInstance.id}" />
+                                    Results: ${inventoryItemPurchases.size()} / ${inventoryItemPurchasesTotal}
+                                    <span class="button"><g:actionSubmit action="create" class="add" value="Order" /></span>
+                                </g:form>
+                            </div>
+
+                            <div class="paginateButtons">
+                                <g:paginate action="show"
+                                                        id="${inventoryItemInstance?.id}"
+                                                        total="${inventoryItemPurchasesTotal}"
+                                                        params="[paginate: 'purchases']" />
+                            </div>
+
+                        </g:else>
+
+                    </richui:tabContent>
+<!-- End Movement tab -->
+
                 </richui:tabContents>
             </richui:tabView>
-
 
         </div>
