Index: /trunk/grails-app/conf/Config.groovy
===================================================================
--- /trunk/grails-app/conf/Config.groovy	(revision 594)
+++ /trunk/grails-app/conf/Config.groovy	(revision 595)
@@ -375,4 +375,12 @@
             [order:91, controller:'unitOfMeasureDetailed', title:'Edit', action:'edit', isVisible: { params.action == 'edit' }]
         ]
+    ],
+    [order:220, controller:'inventoryItemPurchaseDetailed', title:'inventoryItemPurchase', action:'search',
+        subItems: [
+            [order:10, controller:'inventoryItemPurchaseDetailed', title:'Purchase Search', action:'search', isVisible: { true }],
+            [order:20, controller:'inventoryItemPurchaseDetailed', title:'Order', action:'create', isVisible: { true }],
+            [order:90, controller:'inventoryItemPurchaseDetailed', title:'Show', action:'show', isVisible: { params.action == 'show' }],
+            [order:91, controller:'inventoryItemPurchaseDetailed', title:'Edit', action:'edit', isVisible: { params.action == 'edit' }]
+        ]
     ]
 ]
Index: /trunk/grails-app/controllers/InventoryItemPurchaseDetailedController.groovy
===================================================================
--- /trunk/grails-app/controllers/InventoryItemPurchaseDetailedController.groovy	(revision 594)
+++ /trunk/grails-app/controllers/InventoryItemPurchaseDetailedController.groovy	(revision 595)
@@ -75,12 +75,10 @@
         }
         else {
-            params.sort = "purchaseOrderNumber"
-            params.order = "desc"
+            params.sort = "id"
+            params.order = "asc"
         }
 
         if(isFilterApplied) {
             // filterPane:
-            params.sort = params.sort ?: "id"
-            params.order = params.order ?: "desc"
             //if(params.sort == "attentionFlag") // See ticket #64 in Trac.
                 //params.sort = "id"
@@ -175,4 +173,5 @@
     def show = {
         def inventoryItemPurchaseInstance = InventoryItemPurchase.read( params.id )
+        params.returnTo = params.returnTo ?: 'inventoryItem'
 
         if(!inventoryItemPurchaseInstance) {
@@ -188,8 +187,13 @@
         if(!result.error) {
             flash.message = g.message(code: "default.delete.success", args: ["InventoryItemPurchase", params.id])
-            redirect(controller: 'inventoryItemDetailed',
-                            action: 'show',
-                            id: result.inventoryItemId,
-                            params: [showTab: "showPurchasingTab"])
+            if(params.returnTo == 'inventoryItem') {
+                redirect(controller: 'inventoryItemDetailed',
+                                action: 'show',
+                                id: result.inventoryItemId,
+                                params: [showTab: "showPurchasingTab"])
+            }
+            else {
+                redirect(action: 'search')
+            }
             return
         }
@@ -207,4 +211,5 @@
     def edit = {
         def result = inventoryPurchaseService.edit(params)
+        params.returnTo = params.returnTo ?: 'inventoryItem'
 
         if(!result.error)
@@ -236,4 +241,5 @@
         def inventoryItemPurchaseInstance = new InventoryItemPurchase()
         inventoryItemPurchaseInstance.properties = params
+        params.returnTo = params.returnTo ?: 'inventoryItem'
 
         if(!inventoryItemPurchaseInstance.inventoryItem) {
@@ -251,8 +257,13 @@
         if(!result.error) {
             flash.message = g.message(code: "default.create.success", args: ["Inventory Purchase", ''])
-            redirect(controller: 'inventoryItemDetailed',
-                            action: 'show',
-                            id: result.inventoryItemId,
-                            params: [showTab: "showPurchasingTab"])
+            if(params.returnTo == 'inventoryItem') {
+                redirect(controller: 'inventoryItemDetailed',
+                                action: 'show',
+                                id: result.inventoryItemId,
+                                params: [showTab: "showPurchasingTab"])
+            }
+            else {
+                redirect(action: 'search')
+            }
             return
         }
@@ -271,4 +282,5 @@
 
         inventoryItemPurchaseInstance.properties = params
+        params.returnTo = params.returnTo ?: 'inventoryItem'
         def calcQuantities = inventoryPurchaseService.calcQuantities(inventoryItemPurchaseInstance)
         inventoryItemPurchaseInstance.quantity = calcQuantities.thisOrderRemaining
@@ -282,8 +294,13 @@
         if(!result.error) {
             flash.message = g.message(code: "default.create.success", args: ["Inventory Purchase", ''])
-            redirect(controller: 'inventoryItemDetailed',
-                            action: 'show',
-                            id: result.inventoryItemId,
-                            params: [showTab: "showPurchasingTab"])
+            if(params.returnTo == 'inventoryItem') {
+                redirect(controller: 'inventoryItemDetailed',
+                                action: 'show',
+                                id: result.inventoryItemId,
+                                params: [showTab: "showPurchasingTab"])
+            }
+            else {
+                redirect(action: 'search')
+            }
             return
         }
@@ -311,4 +328,5 @@
 
         inventoryItemPurchaseInstance.properties = params
+        params.returnTo = params.returnTo ?: 'inventoryItem'
         return ['inventoryItemPurchaseInstance':inventoryItemPurchaseInstance,
                         'orderId': inventoryItemPurchaseInstance.id]
@@ -320,8 +338,13 @@
         if(!result.error) {
             flash.message = g.message(code: "default.create.success", args: ["Inventory Purchase", ''])
-            redirect(controller: 'inventoryItemDetailed',
-                            action: 'show',
-                            id: result.inventoryItemId,
-                            params: [showTab: "showPurchasingTab"])
+            if(params.returnTo == 'inventoryItem') {
+                redirect(controller: 'inventoryItemDetailed',
+                                action: 'show',
+                                id: result.inventoryItemId,
+                                params: [showTab: "showPurchasingTab"])
+            }
+            else {
+                redirect(action: 'search')
+            }
             return
         }
Index: /trunk/grails-app/views/inventoryItemDetailed/show.gsp
===================================================================
--- /trunk/grails-app/views/inventoryItemDetailed/show.gsp	(revision 594)
+++ /trunk/grails-app/views/inventoryItemDetailed/show.gsp	(revision 595)
@@ -502,19 +502,28 @@
                                                     </g:link>
                                                 </td>
+
                                                 <g:if test="${purchase.inventoryItemPurchaseType.id == 1}">
                                                     <g:if test="${!purchase.receivedComplete}">
                                                         <td class="notClickable">
-                                                            <g:link controller="inventoryItemPurchaseDetailed" action="receive" id="${purchase.id}">
+                                                            <g:link controller="inventoryItemPurchaseDetailed" action="receive" params="[id: purchase.id, returnTo: 'inventoryItem']">
                                                                 <img  src="${resource(dir:'images/skin',file:'basket_put.png')}" alt="Receive" title="Receive" />
                                                             </g:link>
                                                         </td>
+                                                        <td class="notClickable">
+                                                        </td>
                                                     </g:if>
                                                     <g:else>
                                                         <td class="notClickable">
                                                         </td>
+                                                        <td class="notClickable">
+                                                        </td>
                                                     </g:else>
+                                                </g:if>
+                                                <g:elseif test="${(purchase.inventoryItemPurchaseType.id == 2)||(purchase.inventoryItemPurchaseType.id == 3)}">
                                                     <g:if test="${!purchase.invoicePaymentApproved}">
                                                         <td class="notClickable">
-                                                            <g:link controller="inventoryItemPurchaseDetailed" action="approveInvoicePayment" id="${purchase.id}">
+                                                        </td>
+                                                        <td class="notClickable">
+                                                            <g:link controller="inventoryItemPurchaseDetailed" action="approveInvoicePayment" params="[id: purchase.id, returnTo: 'inventoryItem']">
                                                                 <img  src="${resource(dir:'images/skin',file:'tick.png')}" alt="Approve" title="Approve Payment" />
                                                             </g:link>
@@ -524,6 +533,8 @@
                                                         <td class="notClickable">
                                                         </td>
+                                                        <td class="notClickable">
+                                                        </td>
                                                     </g:else>
-                                                </g:if>
+                                                </g:elseif>
                                                 <g:else>
                                                     <td class="notClickable">
Index: /trunk/grails-app/views/inventoryItemPurchaseDetailed/approveInvoicePayment.gsp
===================================================================
--- /trunk/grails-app/views/inventoryItemPurchaseDetailed/approveInvoicePayment.gsp	(revision 594)
+++ /trunk/grails-app/views/inventoryItemPurchaseDetailed/approveInvoicePayment.gsp	(revision 595)
@@ -21,4 +21,5 @@
                 <g:hiddenField name="inventoryItem.id" value="${inventoryItemPurchaseInstance.inventoryItem?.id}" />
                 <g:hiddenField name="orderId" value="${orderId}" />
+                <g:hiddenField name="returnTo" value="${params.returnTo}" />
                 <div class="dialog">
                     <table>
Index: /trunk/grails-app/views/inventoryItemPurchaseDetailed/create.gsp
===================================================================
--- /trunk/grails-app/views/inventoryItemPurchaseDetailed/create.gsp	(revision 594)
+++ /trunk/grails-app/views/inventoryItemPurchaseDetailed/create.gsp	(revision 595)
@@ -6,4 +6,5 @@
         <meta name="layout" content="main" />
         <title>Create InventoryItemPurchase</title>
+        <nav:resources override="true"/>
     </head>
     <body>
@@ -20,4 +21,5 @@
             <g:form action="save" method="post" >
                 <g:hiddenField name="inventoryItem.id" value="${inventoryItemPurchaseInstance?.inventoryItem?.id}" />
+                <g:hiddenField name="returnTo" value="${params.returnTo}" />
                 <div class="dialog">
                     <table>
Index: /trunk/grails-app/views/inventoryItemPurchaseDetailed/receive.gsp
===================================================================
--- /trunk/grails-app/views/inventoryItemPurchaseDetailed/receive.gsp	(revision 594)
+++ /trunk/grails-app/views/inventoryItemPurchaseDetailed/receive.gsp	(revision 595)
@@ -6,4 +6,5 @@
         <meta name="layout" content="main" />
         <title>Receive InventoryItemPurchase</title>
+        <nav:resources override="true"/>
     </head>
     <body>
@@ -21,4 +22,5 @@
                 <g:hiddenField name="inventoryItem.id" value="${inventoryItemPurchaseInstance.inventoryItem?.id}" />
                 <g:hiddenField name="orderId" value="${orderId}" />
+                <g:hiddenField name="returnTo" value="${params.returnTo}" />
                 <div class="dialog">
                     <table>
Index: /trunk/grails-app/views/inventoryItemPurchaseDetailed/search.gsp
===================================================================
--- /trunk/grails-app/views/inventoryItemPurchaseDetailed/search.gsp	(revision 594)
+++ /trunk/grails-app/views/inventoryItemPurchaseDetailed/search.gsp	(revision 595)
@@ -10,5 +10,5 @@
     <body>
         <div class="nav">
-            <h1>Inventory Purchases</h1>
+            <nav:renderSubItems group="navAlt"/>
         </div>
 
@@ -110,46 +110,55 @@
                                 <tr class="${(i % 2) == 0 ? 'clickableOdd' : 'clickableEven'}"/>
 
-                                    <td onclick='window.location = "${request.getContextPath()}/inventoryItemPurchaseDetailed/show/${purchase.id}"'>
+                                    <td onclick='window.location = "${request.getContextPath()}/inventoryItemPurchaseDetailed/show/${purchase.id}?returnTo=search"'>
                                         ${fieldValue(bean:purchase, field:'purchaseOrderNumber')}
                                     </td>
-                                    <td onclick='window.location = "${request.getContextPath()}/inventoryItemPurchaseDetailed/show/${purchase.id}"'>
+                                    <td onclick='window.location = "${request.getContextPath()}/inventoryItemPurchaseDetailed/show/${purchase.id}?returnTo=search"'>
                                         <g:formatDate date="${purchase.dateEntered}" format="EEE, dd-MMM-yyyy"/>
                                     </td>
-                                    <td onclick='window.location = "${request.getContextPath()}/inventoryItemPurchaseDetailed/show/${purchase.id}"'>
+                                    <td onclick='window.location = "${request.getContextPath()}/inventoryItemPurchaseDetailed/show/${purchase.id}?returnTo=search"'>
                                         ${fieldValue(bean:purchase, field:'costCode')}
                                     </td>
-                                    <td onclick='window.location = "${request.getContextPath()}/inventoryItemPurchaseDetailed/show/${purchase.id}"'>
+                                    <td onclick='window.location = "${request.getContextPath()}/inventoryItemPurchaseDetailed/show/${purchase.id}?returnTo=search"'>
                                         ${fieldValue(bean:purchase, field:'quantity')}
                                     </td>
-                                    <td onclick='window.location = "${request.getContextPath()}/inventoryItemPurchaseDetailed/show/${purchase.id}"'>
+                                    <td onclick='window.location = "${request.getContextPath()}/inventoryItemPurchaseDetailed/show/${purchase.id}?returnTo=search"'>
                                         ${fieldValue(bean:purchase, field:'orderValueAmount')}
                                         ${fieldValue(bean:purchase, field:'orderValueCurrency')}
                                     </td>
-                                    <td onclick='window.location = "${request.getContextPath()}/inventoryItemPurchaseDetailed/show/${purchase.id}"'>
+                                    <td onclick='window.location = "${request.getContextPath()}/inventoryItemPurchaseDetailed/show/${purchase.id}?returnTo=search"'>
                                         ${fieldValue(bean:purchase, field:'invoiceNumber')}
                                     </td>
-                                    <td onclick='window.location = "${request.getContextPath()}/inventoryItemPurchaseDetailed/show/${purchase.id}"'>
+                                    <td onclick='window.location = "${request.getContextPath()}/inventoryItemPurchaseDetailed/show/${purchase.id}?returnTo=search"'>
                                         ${fieldValue(bean:purchase, field:'inventoryItemPurchaseType')}
                                     </td>
                                     <td class="notClickable">
-                                        <g:link controller="inventoryItemPurchaseDetailed" action="show" id="${purchase.id}">
+                                        <g:link controller="inventoryItemPurchaseDetailed" action="show" params="[id: purchase.id, returnTo: 'search']">
                                             <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 class="notClickable">
-                                                <g:link controller="inventoryItemPurchaseDetailed" action="receive" id="${purchase.id}">
+                                                <g:link controller="inventoryItemPurchaseDetailed" action="receive" params="[id: purchase.id, returnTo: 'search']">
                                                     <img  src="${resource(dir:'images/skin',file:'basket_put.png')}" alt="Receive" title="Receive" />
                                                 </g:link>
                                             </td>
+                                            <td class="notClickable">
+                                            </td>
                                         </g:if>
                                         <g:else>
                                             <td class="notClickable">
                                             </td>
+                                            <td class="notClickable">
+                                            </td>
                                         </g:else>
+                                    </g:if>
+                                    <g:elseif test="${(purchase.inventoryItemPurchaseType.id == 2)||(purchase.inventoryItemPurchaseType.id == 3)}">
                                         <g:if test="${!purchase.invoicePaymentApproved}">
                                             <td class="notClickable">
-                                                <g:link controller="inventoryItemPurchaseDetailed" action="approveInvoicePayment" id="${purchase.id}">
+                                            </td>
+                                            <td class="notClickable">
+                                                <g:link controller="inventoryItemPurchaseDetailed" action="approveInvoicePayment" params="[id: purchase.id, returnTo: 'search']">
                                                     <img  src="${resource(dir:'images/skin',file:'tick.png')}" alt="Approve" title="Approve Payment" />
                                                 </g:link>
@@ -159,6 +168,8 @@
                                             <td class="notClickable">
                                             </td>
+                                            <td class="notClickable">
+                                            </td>
                                         </g:else>
-                                    </g:if>
+                                    </g:elseif>
                                     <g:else>
                                         <td class="notClickable">
Index: /trunk/grails-app/views/inventoryItemPurchaseDetailed/show.gsp
===================================================================
--- /trunk/grails-app/views/inventoryItemPurchaseDetailed/show.gsp	(revision 594)
+++ /trunk/grails-app/views/inventoryItemPurchaseDetailed/show.gsp	(revision 595)
@@ -6,8 +6,9 @@
         <meta name="layout" content="main" />
         <title>Show InventoryItemPurchase</title>
+        <nav:resources override="true"/>
     </head>
     <body>
         <div class="nav">
-            <h1>Show InventoryItemPurchase</h1>
+            <nav:renderSubItems group="navAlt"/>
         </div>
         <div class="body">
@@ -108,5 +109,6 @@
             <div class="buttons">
                 <g:form>
-                    <input type="hidden" name="id" value="${inventoryItemPurchaseInstance?.id}" />
+                    <g:hiddenField name="id" value="${inventoryItemPurchaseInstance?.id}" />
+                    <g:hiddenField name="returnTo" value="${params.returnTo}" />
                     <span class="button"><g:actionSubmit class="edit" value="Edit" /></span>
                     <span class="button"><g:actionSubmit class="delete" onclick="return confirm('Are you sure?');" value="Delete" /></span>
