- Timestamp:
- Nov 19, 2009, 9:16:21 PM (15 years ago)
- Location:
- trunk/grails-app
- Files:
-
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/grails-app/controllers/EntryDetailedController.groovy
r186 r191 96 96 def entryInstance = new Entry() 97 97 entryInstance.task = taskInstance 98 entryInstance.entryType = EntryType.get(params.entryType.id) 98 99 return ['entryInstance':entryInstance] 99 100 } -
trunk/grails-app/controllers/InventoryMovementDetailedController.groovy
r177 r191 34 34 else { 35 35 if(result.inventoryMovementInstance) { 36 render(view:'show',model:[inventoryMovementInstance:result.inventoryMovementInstance]) 36 // For some reason we have to call refresh() here to get a hibernate session 37 // and avoid a lazy initialisation error. 38 render(view:'show',model:[inventoryMovementInstance:result.inventoryMovementInstance.refresh()]) 37 39 } 38 40 else { 39 41 flash.message = "Could not delete inventory movement." 40 redirect(controller:"taskDetailed", action:"search" , id:result.taskId)42 redirect(controller:"taskDetailed", action:"search") 41 43 } 42 44 } -
trunk/grails-app/i18n/messages.properties
r186 r191 26 26 27 27 task.modifications.failedToSave=Could not complete operation, as task modification record failed to save. 28 task.operationNotPermittedOnCompleteTask=This operation is not permitted on a complete task. 28 29 29 30 task.assignedPersons=Assigned Persons … … 55 56 entry.task.failedToSave=Could not complete operation, task failed to save. 56 57 entry.task.failedToSaveTaskModification=Could not complete operation, task modification failed to save. 57 entry.task.taskIsComplete=This operation is not permitted on a complete task.58 58 59 59 default.doesnt.match.message=Property [{0}] of class [{1}] with value [{2}] does not match the required pattern [{3}] -
trunk/grails-app/services/InventoryMovementService.groovy
r177 r191 6 6 InventoryMovement.withTransaction { status -> 7 7 def result = [:] 8 definventoryMovementInstance = InventoryMovement.lock(params.id)9 if( inventoryMovementInstance) {10 def inventoryItem = InventoryItem.lock( inventoryMovementInstance.inventoryItem.id)11 result.taskId = inventoryMovementInstance.task.id8 result.inventoryMovementInstance = InventoryMovement.lock(params.id) 9 if(result.inventoryMovementInstance) { 10 def inventoryItem = InventoryItem.lock(result.inventoryMovementInstance.inventoryItem.id) 11 result.taskId = result.inventoryMovementInstance.task.id 12 12 13 13 if(!inventoryItem) { 14 14 status.setRollbackOnly() 15 inventoryMovementInstance.errors.rejectValue('inventoryItem', "inventoryMovement.inventoryItem.notFound") 16 result.inventoryMovementInstance = inventoryMovementInstance 15 result.inventoryMovementInstance.errors.rejectValue('inventoryItem', "inventoryMovement.inventoryItem.notFound") 17 16 result.error = true 18 17 return result 19 18 } 20 19 20 if(result.inventoryMovementInstance.task.taskStatus.id == 3) { 21 status.setRollbackOnly() 22 result.inventoryMovementInstance.errors.rejectValue('task', "task.operationNotPermittedOnCompleteTask") 23 result.error = true 24 return result 25 } 26 21 27 // Reverse the movement of inventory. 22 if(! inventoryMovementInstance.inventoryMovementType.incrementsInventory) {23 inventoryItem.unitsInStock += inventoryMovementInstance.quantity28 if(!result.inventoryMovementInstance.inventoryMovementType.incrementsInventory) { 29 inventoryItem.unitsInStock += result.inventoryMovementInstance.quantity 24 30 } 25 31 else { 26 if(inventoryItem.unitsInStock >= inventoryMovementInstance.quantity) {27 inventoryItem.unitsInStock -= inventoryMovementInstance.quantity32 if(inventoryItem.unitsInStock >= result.inventoryMovementInstance.quantity) { 33 inventoryItem.unitsInStock -= result.inventoryMovementInstance.quantity 28 34 } 29 35 else { 30 36 status.setRollbackOnly() 31 inventoryMovementInstance.errors.rejectValue('quantity', "inventoryMovement.quantity.insufficientItemsInStock") 32 result.inventoryMovementInstance = inventoryMovementInstance 37 result.inventoryMovementInstance.errors.rejectValue('quantity', "inventoryMovement.quantity.insufficientItemsInStock") 33 38 result.error = true 34 39 return result … … 37 42 38 43 if(inventoryItem.save() ) { 39 inventoryMovementInstance.delete() 44 // All went well if we get to this point. 45 result.inventoryMovementInstance.delete() 40 46 return result 41 47 } … … 58 64 InventoryMovement.withTransaction { status -> 59 65 def result = [:] 60 definventoryMovementInstance = new InventoryMovement(params)66 result.inventoryMovementInstance = new InventoryMovement(params) 61 67 62 if( inventoryMovementInstance.validate()) {63 def inventoryItem = InventoryItem.lock( inventoryMovementInstance.inventoryItem.id)64 result.taskId = inventoryMovementInstance.task.id68 if(result.inventoryMovementInstance.validate()) { 69 def inventoryItem = InventoryItem.lock(result.inventoryMovementInstance.inventoryItem.id) 70 result.taskId = result.inventoryMovementInstance.task.id 65 71 66 72 if(!inventoryItem) { 67 status.setRollbackOnly() 68 inventoryMovementInstance.errors.rejectValue('inventoryItem', "inventoryMovement.inventoryItem.notFound") 69 result.inventoryMovementInstance = inventoryMovementInstance 70 result.error = true 71 return result 73 status.setRollbackOnly() 74 result.inventoryMovementInstance.errors.rejectValue('inventoryItem', "inventoryMovement.inventoryItem.notFound") 75 result.error = true 76 return result 77 } 78 79 if(result.inventoryMovementInstance.task.taskStatus.id == 3) { 80 status.setRollbackOnly() 81 result.inventoryMovementInstance.errors.rejectValue('task', "task.operationNotPermittedOnCompleteTask") 82 result.error = true 83 return result 72 84 } 73 85 74 86 // Perform the movement of inventory. 75 if( inventoryMovementInstance.inventoryMovementType.incrementsInventory) {76 inventoryItem.unitsInStock += inventoryMovementInstance.quantity87 if(result.inventoryMovementInstance.inventoryMovementType.incrementsInventory) { 88 inventoryItem.unitsInStock += result.inventoryMovementInstance.quantity 77 89 } 78 90 else { 79 if(inventoryItem.unitsInStock >= inventoryMovementInstance.quantity) {80 inventoryItem.unitsInStock -= inventoryMovementInstance.quantity91 if(inventoryItem.unitsInStock >= result.inventoryMovementInstance.quantity) { 92 inventoryItem.unitsInStock -= result.inventoryMovementInstance.quantity 81 93 } 82 94 else { 83 95 status.setRollbackOnly() 84 inventoryMovementInstance.errors.rejectValue('quantity', "inventoryMovement.quantity.insufficientItemsInStock") 85 result.inventoryMovementInstance = inventoryMovementInstance 96 result.inventoryMovementInstance.errors.rejectValue('quantity', "inventoryMovement.quantity.insufficientItemsInStock") 86 97 result.error = true 87 98 return result … … 89 100 } 90 101 91 if(inventoryItem.save() && inventoryMovementInstance.save()) {92 result.inventoryMovementInstance = inventoryMovementInstance102 if(inventoryItem.save() && result.inventoryMovementInstance.save()) { 103 // All went well if we get to this point. 93 104 return result 94 105 } 95 106 else { 96 107 status.setRollbackOnly() 97 result.inventoryMovementInstance = inventoryMovementInstance98 108 result.error = true 99 109 return result … … 102 112 } 103 113 else { 104 result.inventoryMovementInstance = inventoryMovementInstance105 114 result.error = true 106 115 return result -
trunk/grails-app/services/TaskService.groovy
r186 r191 55 55 if(taskInstance.taskStatus.id == 3) { 56 56 status.setRollbackOnly() 57 result.entryInstance.errors.rejectValue('task', " entry.task.taskIsComplete")57 result.entryInstance.errors.rejectValue('task', "task.operationNotPermittedOnCompleteTask") 58 58 result.error = true 59 59 return result -
trunk/grails-app/views/entryDetailed/create.gsp
r186 r191 24 24 <g:form action="save" method="post" > 25 25 <g:hiddenField name="task.id" value="${entryInstance.task.id}" /> 26 <g:hiddenField name="entryType.id" value="${entryInstance.entryType.id}" /> 26 27 <div class="dialog"> 27 28 <table> … … 33 34 </td> 34 35 <td valign="top" class="name"> 35 ${entryInstance?.task} 36 <g:link controller="taskDetailed" action="show" id="${entryInstance.task.id}" > 37 ${entryInstance?.task} 38 </g:link> 36 39 </td> 37 </tr> 40 </tr> 38 41 39 42 <tr class="prop"> 40 43 <td valign="top" class="name"> 41 <label for="comment"> Comment:</label>44 <label for="comment">${entryInstance?.entryType}:</label> 42 45 </td> 43 46 <td valign="top" class="value ${hasErrors(bean:entryInstance,field:'comment','errors')}"> … … 71 74 </td> 72 75 </tr> 73 74 <tr class="prop">75 <td valign="top" class="name">76 <label for="entryType">Entry Type:</label>77 </td>78 <td valign="top" class="value ${hasErrors(bean:entryInstance,field:'entryType','errors')}">79 <g:select optionKey="id" from="${EntryType.list()}" name="entryType.id" value="${entryInstance?.entryType?.id}" ></g:select>80 </td>81 </tr>82 76 83 77 </tbody> -
trunk/grails-app/views/inventoryMovementDetailed/create.gsp
r177 r191 59 59 </td> 60 60 <td valign="top" name="inventoryMovementInstance.task" class="value"> 61 <input type="hidden" id="task.id" name="task.id" value="${inventoryMovementInstance.task.id}" /> 62 ${inventoryMovementInstance.task} 61 <g:hiddenField name="task.id" value="${inventoryMovementInstance.task.id}" /> 62 <g:link controller="taskDetailed" action="show" id="${inventoryMovementInstance.task.id}" > 63 ${inventoryMovementInstance.task} 64 </g:link> 63 65 </td> 64 66 </tr> -
trunk/grails-app/views/taskDetailed/show.gsp
r184 r191 231 231 </div> 232 232 233 <div class="list">234 <h1>Faults</h1>235 <table>236 <thead>237 <tr>238 <th>Comment</th>239 <th>Date Done</th>240 <th>Duration</th>241 <th>Entered By</th>242 <th></th>243 </tr>244 </thead>245 <tbody>246 <g:each in="${entryFaultList}" status="i" var="entry">247 <tr class="${(i % 2) == 0 ? 'clickableOdd' : 'clickableEven'}" onclick='window.location = "${request.getContextPath()}/entryDetailed/edit/${entry.id}"'/>248 249 <td style="width:65%">${entry.comment}</td>250 <td><g:formatDate date="${entry.dateDone}" format="EEE, dd-MMM-yyyy"/></td>251 <td>${entry.durationHour}:${entry.durationMinute}</td>252 <td>${entry.enteredBy}</td>253 254 <td>255 <g:link controller="entryDetailed" action="edit" id="${entry.id}">256 <img src="${resource(dir:'images/skin',file:'database_edit.png')}" alt="Edit" />257 </g:link>258 </td>259 260 </tr>261 </g:each>262 </tbody>263 </table>264 </div>265 266 <div class="list">267 <h1>Work Done</h1>268 <table>269 <thead>270 <tr>271 <th>Comment</th>272 <th>Date Done</th>273 <th>Duration</th>274 <th>Entered By</th>275 <th></th>276 </tr>277 </thead>278 <tbody>279 <g:each in="${entryWorkDoneList}" status="i" var="entry">280 <tr class="${(i % 2) == 0 ? 'clickableOdd' : 'clickableEven'}" onclick='window.location = "${request.getContextPath()}/entryDetailed/edit/${entry.id}"'/>281 282 <td width="65%">${entry.comment}</td>283 <td><g:formatDate date="${entry.dateDone}" format="EEE, dd-MMM-yyyy"/></td>284 <td>${entry.durationHour}:${entry.durationMinute}</td>285 <td>${entry.enteredBy}</td>286 287 <td>288 <g:link controller="entryDetailed" action="edit" id="${entry.id}">289 <img src="${resource(dir:'images/skin',file:'database_edit.png')}" alt="Edit" />290 </g:link>291 </td>292 293 </tr>294 </g:each>295 </tbody>296 </table>297 </div>298 299 233 <br /> 234 235 <g:if test="${entryFaultList.isEmpty()}"> 236 <h1>No Faults</h1> 237 <br /> 238 </g:if> 239 <g:else> 240 <div class="list"> 241 <h1>Faults</h1> 242 <table> 243 <thead> 244 <tr> 245 <th>Comment</th> 246 <th>Date Done</th> 247 <th>Duration</th> 248 <th>Entered By</th> 249 <th></th> 250 </tr> 251 </thead> 252 <tbody> 253 <g:each in="${entryFaultList}" status="i" var="entry"> 254 <tr class="${(i % 2) == 0 ? 'clickableOdd' : 'clickableEven'}" onclick='window.location = "${request.getContextPath()}/entryDetailed/edit/${entry.id}"'/> 255 256 <td style="width:65%">${entry.comment}</td> 257 <td><g:formatDate date="${entry.dateDone}" format="EEE, dd-MMM-yyyy"/></td> 258 <td>${entry.durationHour}:${entry.durationMinute}</td> 259 <td>${entry.enteredBy}</td> 260 261 <td> 262 <g:link controller="entryDetailed" action="edit" id="${entry.id}"> 263 <img src="${resource(dir:'images/skin',file:'database_edit.png')}" alt="Edit" /> 264 </g:link> 265 </td> 266 267 </tr> 268 </g:each> 269 </tbody> 270 </table> 271 </div> 272 </g:else> 300 273 301 274 <div class="buttons"> 302 275 <g:form controller="entryDetailed"> 303 <input type="hidden" name="taskInstance.id" value="${taskInstance?.id}" /> 276 <g:hiddenField name="taskInstance.id" value="${taskInstance?.id}" /> 277 <g:hiddenField name="entryType.id" value="1" /> 304 278 <span class="button"> 305 <g:actionSubmit value="Add Entry" action="create" class="add"/> 279 <g:actionSubmit value="Add Fault" action="create" class="add"/> 280 </span> 281 </g:form> 282 </div> 283 284 <br /> 285 286 <g:if test="${entryWorkDoneList.isEmpty()}"> 287 <h1>No Work Done</h1> 288 <br /> 289 </g:if> 290 <g:else> 291 <div class="list"> 292 <h1>Work Done</h1> 293 <table> 294 <thead> 295 <tr> 296 <th>Comment</th> 297 <th>Date Done</th> 298 <th>Duration</th> 299 <th>Entered By</th> 300 <th></th> 301 </tr> 302 </thead> 303 <tbody> 304 <g:each in="${entryWorkDoneList}" status="i" var="entry"> 305 <tr class="${(i % 2) == 0 ? 'clickableOdd' : 'clickableEven'}" onclick='window.location = "${request.getContextPath()}/entryDetailed/edit/${entry.id}"'/> 306 307 <td width="65%">${entry.comment}</td> 308 <td><g:formatDate date="${entry.dateDone}" format="EEE, dd-MMM-yyyy"/></td> 309 <td>${entry.durationHour}:${entry.durationMinute}</td> 310 <td>${entry.enteredBy}</td> 311 312 <td> 313 <g:link controller="entryDetailed" action="edit" id="${entry.id}"> 314 <img src="${resource(dir:'images/skin',file:'database_edit.png')}" alt="Edit" /> 315 </g:link> 316 </td> 317 318 </tr> 319 </g:each> 320 </tbody> 321 </table> 322 </div> 323 </g:else> 324 325 <div class="buttons"> 326 <g:form controller="entryDetailed"> 327 <g:hiddenField name="taskInstance.id" value="${taskInstance?.id}" /> 328 <g:hiddenField name="entryType.id" value="2" /> 329 <span class="button"> 330 <g:actionSubmit value="Add Work Done" action="create" class="add"/> 306 331 </span> 307 332 </g:form>
Note: See TracChangeset
for help on using the changeset viewer.