Changeset 226
- Timestamp:
- Dec 9, 2009, 4:36:55 AM (15 years ago)
- Location:
- trunk/grails-app
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/grails-app/controllers/InventoryItemDetailedController.groovy
r225 r226 166 166 def useInventoryItem = { 167 167 168 params.inventoryMovementType = InventoryMovementType.get(1) // used.168 params.inventoryMovementType = InventoryMovementType.get(1) // Set type to "Used". 169 169 def result = inventoryMovementService.move(params) 170 170 -
trunk/grails-app/controllers/InventoryMovementDetailedController.groovy
r224 r226 27 27 /** 28 28 * List the inventory movements for an InventoryItem. 29 * @param params.i d The id of an existing inventory item.29 * @param params.inventoryItem.id The id of an existing inventory item. 30 30 */ 31 31 def listInventoryMovements = { 32 def inventoryItemInstance = InventoryItem.get(params.i d)32 def inventoryItemInstance = InventoryItem.get(params.inventoryItem.id) 33 33 34 34 if(!inventoryItemInstance) { … … 65 65 66 66 def create = { 67 if(!params.task?.id) {68 flash.message = "Please select a task, then the Inventory tab."69 redirect(controller:"taskDetailed", action:"search")70 }71 67 def inventoryMovementInstance = new InventoryMovement() 72 68 inventoryMovementInstance.properties = params 73 return ['inventoryMovementInstance':inventoryMovementInstance] 69 def inventoryMovementTypeList = InventoryMovementType.withCriteria { gt("id", 1L) } // Don't include "Used". 70 71 return ['inventoryMovementInstance': inventoryMovementInstance, 72 inventoryMovementTypeList: inventoryMovementTypeList] 74 73 } 75 74 75 /** 76 * Handles all inventory movements except those of type "Used". 77 * The "Used" type is handled directly by InventoryItemDetailedController and useInventoryItem. 78 */ 76 79 def save = { 77 80 def result = inventoryMovementService.move(params) … … 79 82 if(!result.error) { 80 83 flash.message = "Inventory Movement for ${result.inventoryMovementInstance.inventoryItem.name} created." 81 redirect(controller:"taskDetailed", action:"show", id: result.taskId) 84 if(result.taskId) { 85 redirect(controller:"taskDetailed", action:"show", id: result.taskId) 86 return 87 } 88 redirect(controller:"inventoryItemDetailed", action:"show", id: result.inventoryMovementInstance.inventoryItem.id) 82 89 } 83 90 else { 84 91 if(result.inventoryMovementInstance) { 85 render(view:'create',model:[inventoryMovementInstance:result.inventoryMovementInstance]) 92 def inventoryMovementTypeList = InventoryMovementType.withCriteria { gt("id", 1L) } // Don't include "Used". 93 render(view:'create', model:[inventoryMovementInstance: result.inventoryMovementInstance, 94 inventoryMovementTypeList: inventoryMovementTypeList]) 86 95 } 87 96 else { -
trunk/grails-app/services/InventoryItemService.groovy
r225 r226 19 19 def fail = { Object[] args -> 20 20 if(args.size() == 2) result.errors = [args[0], args[1]] 21 log.debug result.errors22 21 result.error = true 23 22 return result … … 41 40 return fail("inventoryItem", "inventoryItem.notFound") 42 41 43 log.debug "WTF are we doing here"44 45 42 def p = [:] 46 43 p.max = result.inventoryMovementListMax = 10 -
trunk/grails-app/services/InventoryMovementService.groovy
r225 r226 117 117 if(result.inventoryMovementInstance.validate()) { 118 118 def inventoryItem = InventoryItem.lock(result.inventoryMovementInstance.inventoryItem.id) 119 result.taskId = result.inventoryMovementInstance.task .id119 result.taskId = result.inventoryMovementInstance.task?.id 120 120 121 121 if(!inventoryItem) { -
trunk/grails-app/views/inventoryItemDetailed/show.gsp
r225 r226 292 292 <div class="buttons"> 293 293 <g:form controller="inventoryMovementDetailed"> 294 <g:hiddenField name="i d" value="${inventoryItemInstance?.id}" />294 <g:hiddenField name="inventoryItem.id" value="${inventoryItemInstance.id}" /> 295 295 <span class="button"><g:actionSubmit action="create" class="add" value="Create" /></span> 296 296 </g:form> … … 333 333 <div class="buttons"> 334 334 <g:form controller="inventoryMovementDetailed"> 335 <g:hiddenField name="i d" value="${inventoryItemInstance?.id}" />335 <g:hiddenField name="inventoryItem.id" value="${inventoryItemInstance.id}" /> 336 336 <g:if test="${inventoryMovementListTotal > inventoryMovementListMax}"> 337 337 Showing ${inventoryMovementListMax} of ${inventoryMovementListTotal} -
trunk/grails-app/views/inventoryMovementDetailed/create.gsp
r225 r226 21 21 </div> 22 22 </g:hasErrors> 23 23 24 <g:form action="save" method="post" > 25 <g:hiddenField name="inventoryItem.id" value="${inventoryMovementInstance?.inventoryItem?.id}" /> 24 26 <div class="dialog"> 25 27 <table> 26 28 <tbody> 27 29 28 30 <tr class="prop"> 29 31 <td valign="top" class="name"> … … 31 33 </td> 32 34 <td valign="top" class="value ${hasErrors(bean:inventoryMovementInstance,field:'inventoryItem','errors')}"> 33 <g:select optionKey="id" from="${InventoryItem.list()}" name="inventoryItem.id" value="${inventoryMovementInstance?.inventoryItem?.id}" ></g:select> 35 <g:link controller="inventoryItemDetailed" action="show" id="${inventoryMovementInstance?.inventoryItem?.id}" > 36 <g:fieldValue bean="${inventoryMovementInstance}" field="inventoryItem" /> 37 </g:link> 34 38 </td> 35 </tr> 36 39 </tr> 40 37 41 <tr class="prop"> 38 42 <td valign="top" class="name"> 39 43 <label for="quantity">Quantity:</label> 40 44 </td> 41 <td valign="top" class="value ${hasErrors(bean:inventoryMovementInstance,field:'quantity','errors')}"> 42 <input type="text" id="quantity" name="quantity" value="${fieldValue(bean:inventoryMovementInstance,field:'quantity')}"/> 45 <td valign="top"> 46 <input class="medium ${hasErrors(bean:inventoryMovementInstance,field:'quantity','errors')}" 47 type="text" id="quantity" name="quantity" 48 value="${fieldValue(bean:inventoryMovementInstance,field:'quantity')}"/> 49 ${inventoryMovementInstance?.inventoryItem?.unitOfMeasure.encodeAsHTML()} 43 50 </td> 44 51 </tr> … … 49 56 </td> 50 57 <td valign="top" class="value ${hasErrors(bean:inventoryMovementInstance,field:'inventoryMovementType','errors')}"> 51 <g:select optionKey="id" from="${ InventoryMovementType.list()}" name="inventoryMovementType.id" value="${inventoryMovementInstance?.inventoryMovementType?.id}" ></g:select>58 <g:select optionKey="id" from="${inventoryMovementTypeList}" name="inventoryMovementType.id" value="${inventoryMovementInstance?.inventoryMovementType?.id}" ></g:select> 52 59 </td> 53 60 </tr> 54 61 55 <g:if test="${inventoryMovementInstance .task}">62 <g:if test="${inventoryMovementInstance?.task}"> 56 63 <tr class="prop"> 57 64 <td valign="top" class="name"> 58 65 <label for="taskInstance">Linking with task:</label> 59 66 </td> 60 <td valign="top" name="inventoryMovementInstance.task"class="value">67 <td valign="top" class="value"> 61 68 <g:hiddenField name="task.id" value="${inventoryMovementInstance.task.id}" /> 62 69 <g:link controller="taskDetailed" action="show" id="${inventoryMovementInstance.task.id}" > 63 ${inventoryMovementInstance.task }70 ${inventoryMovementInstance.task.encodeAsHTML()} 64 71 </g:link> 65 72 </td> … … 70 77 </table> 71 78 </div> 79 72 80 <div class="buttons"> 73 81 <span class="button"><input class="save" type="submit" value="Create" /></span> 74 82 </div> 83 75 84 </g:form> 76 85 </div> 77 78 79 <!-- Start Search Pane -->80 <div class="overlayPane" id="searchPane" style="display:none;">81 <h2>Quick Search</h2>82 <g:form method="post" id="searchForm" name="searchForm" >83 <table>84 <tbody>85 86 <tr class="prop">87 <td valign="top" class="name">88 <label>My Tasks:</label>89 </td>90 <td valign="top" class="value">91 <g:link controller="taskDetailed"92 action="search"93 params="[quickSearch: 'searchMyTodays']">94 Today's95 </g:link>96 <br />97 <g:link controller="taskDetailed"98 action="search"99 params="[quickSearch: 'searchMyInTheLastWeek']">100 In the last week101 </g:link>102 </td>103 </tr>104 105 <tr class="prop">106 <td valign="top" class="name">107 <label>Tasks:</label>108 </td>109 <td valign="top" class="value">110 <g:link controller="taskDetailed"111 action="search"112 params="[quickSearch: 'searchTodays']">113 Today's114 </g:link>115 <br />116 <g:link controller="taskDetailed"117 action="search"118 params="[quickSearch: 'searchInTheLastWeek']">119 In the last week120 </g:link>121 </td>122 </tr>123 124 </tbody>125 </table>126 <div class="buttons">127 <span class="button">128 <input type="button" value="${g.message(code:'fp.tag.filterPane.button.cancel.text', default:'Cancel')}" onclick="return hideElement('searchPane');" />129 </span>130 <!-- <span class="button">131 <input type="button" value="${g.message(code:'fp.tag.filterPane.button.clear.text', default:'Clear')}" onclick="return clearFilterPane('searchForm');" />132 </span>133 <span class="button">134 <g:actionSubmit class="search" value="Search" />135 </span>-->136 </div>137 </g:form>138 </div> <!-- end search pane -->139 140 86 </body> 141 87 </html>
Note: See TracChangeset
for help on using the changeset viewer.