- Timestamp:
- Nov 25, 2010, 8:47:00 AM (14 years ago)
- Location:
- trunk/grails-app
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/grails-app/controllers/InventoryItemDetailedController.groovy
r647 r719 344 344 associatedPropertyValues.inventoryLocationList = InventoryLocation.findAllByIsActive(true, [max:associatedPropertyMax, sort:'name']) 345 345 associatedPropertyValues.assetList = Asset.findAllByIsActive(true, [max:associatedPropertyMax, sort:'name']) 346 associatedPropertyValues.manufacturerList = Manufacturer.findAllByIsActive(true, [max:associatedPropertyMax, sort:'name'])347 346 associatedPropertyValues.supplierList = Supplier.findAllByIsActive(true, [max:associatedPropertyMax, sort:'name']) 348 347 … … 433 432 def possibleAlternateItems = inventoryItemService.getPossibleAlternateItems(result.inventoryItemInstance) 434 433 def suppliers = Supplier.findAllByIsActive(true).sort { p1, p2 -> p1.name.compareToIgnoreCase(p2.name) } 435 def manufacturers = Manufacturer.findAllByIsActive(true).sort { p1, p2 -> p1.name.compareToIgnoreCase(p2.name) }436 434 437 435 return [ inventoryItemInstance : result.inventoryItemInstance, 438 436 possibleAlternateItems: possibleAlternateItems, 439 suppliers: suppliers, 440 manufacturers: manufacturers] 437 suppliers: suppliers] 441 438 } 442 439 … … 462 459 def possibleAlternateItems = inventoryItemService.getPossibleAlternateItems(result.inventoryItemInstance) 463 460 def suppliers = Supplier.findAllByIsActive(true).sort { p1, p2 -> p1.name.compareToIgnoreCase(p2.name) } 464 def manufacturers = Manufacturer.findAllByIsActive(true).sort { p1, p2 -> p1.name.compareToIgnoreCase(p2.name) }465 461 render(view:'edit', model:[inventoryItemInstance: result.inventoryItemInstance.attach(), 466 462 possibleAlternateItems: possibleAlternateItems, 467 suppliers: suppliers, 468 manufacturers: manufacturers]) 463 suppliers: suppliers]) 469 464 } 470 465 … … 472 467 def result = inventoryItemService.create(params) 473 468 def suppliers = Supplier.findAllByIsActive(true).sort { p1, p2 -> p1.name.compareToIgnoreCase(p2.name) } 474 def manufacturers = Manufacturer.findAllByIsActive(true).sort { p1, p2 -> p1.name.compareToIgnoreCase(p2.name) }475 469 476 470 if(!result.error) 477 471 return [inventoryItemInstance: result.inventoryItemInstance, 478 suppliers: suppliers, 479 manufacturers: manufacturers] 472 suppliers: suppliers] 480 473 481 474 //flash.errorMessage = g.message(code: result.error.code, args: result.error.args) … … 493 486 494 487 def suppliers = Supplier.findAllByIsActive(true).sort { p1, p2 -> p1.name.compareToIgnoreCase(p2.name) } 495 def manufacturers = Manufacturer.findAllByIsActive(true).sort { p1, p2 -> p1.name.compareToIgnoreCase(p2.name) }496 488 497 489 //flash.errorMessage = g.message(code: result.error.code, args: result.error.args) 498 490 render(view:'create', model:[inventoryItemInstance: result.inventoryItemInstance, 499 suppliers: suppliers, 500 manufacturers: manufacturers]) 491 suppliers: suppliers]) 501 492 } 502 493 -
trunk/grails-app/domain/InventoryItem.groovy
r718 r719 6 6 Picture picture 7 7 Supplier preferredSupplier 8 Manufacturer preferredManufacturer9 8 String name 10 9 String description = "" 11 10 String comment = "" 12 String manufacturersPartNumber13 11 BigDecimal estimatedUnitPriceAmount 14 12 Currency estimatedUnitPriceCurrency … … 28 26 spareFor: Asset, 29 27 inventoryMovements: InventoryMovement, 30 alternateManufacturers: Manufacturer,31 28 alternateSuppliers: Supplier] 32 29 … … 49 46 inventoryGroup() 50 47 inventoryType() 51 manufacturersPartNumber(blank:true, nullable:true)52 48 suppliersPartNumber(blank:true, nullable:true) 53 49 preferredSupplier(nullable:true) 54 preferredManufacturer(nullable:true)55 50 } 56 51 -
trunk/grails-app/services/InventoryCsvService.groovy
r718 r719 52 52 def line = [] 53 53 def lineNumber = 0 54 def maxNumberOfColumns = 2 354 def maxNumberOfColumns = 20 55 55 def inventoryParams = [:] 56 56 def inventoryProperties = ["name", "description", "comment", "unitsInStock", "reorderPoint", "reorderQuantity", … … 59 59 "inventoryGroup", "inventoryType", 60 60 "suppliersPartNumber", "preferredSupplier", "alternateSuppliers", 61 "manufacturersPartNumber", "preferredManufacturer", "alternateManufacturers",62 61 "alternateItems", "spareFor"] 63 62 … … 69 68 def spareForInstance 70 69 def alternateItemInstance 71 def preferredManufacturerInstance72 def alternateManufacturerInstance73 def manufacturerTypeInstance74 def manufacturerTypeUnknown = ManufacturerType.get(1)75 70 def inventoryTypeInstance 76 71 def unitOfMeasureInstance … … 88 83 def tempSupplierType = '' 89 84 def tempSupplierItemAndType = [] 90 91 def tempPreferredManufacturerItemAndType = ''92 def tempPreferredManufacturerItem = ''93 def tempPreferredManufacturerType = ''94 95 def tempAlternateManufacturers = []96 def tempManufacturerItem = ''97 def tempManufacturerType = ''98 def tempManufacturerItemAndType = []99 85 100 86 def tempSpareFor = [] … … 238 224 return fail(code: "inventory.import.failure", args: [lineNumber, logFileLink]) 239 225 } 240 }241 242 // Preferred Manufacturer243 if(inventoryParams.preferredManufacturer) {244 tempPreferredManufacturerItemAndType = parseItemAndType(inventoryParams.preferredManufacturer)245 tempPreferredManufacturerItem = WordUtils.capitalize(tempPreferredManufacturerItemAndType[0])246 247 preferredManufacturerInstance = Manufacturer.findByName(tempPreferredManufacturerItem)248 if(!preferredManufacturerInstance) {249 250 // Manufacturer Type.251 if(tempPreferredManufacturerItemAndType.size == 2) {252 tempPreferredManufacturerType = WordUtils.capitalize(tempPreferredManufacturerItemAndType[1])253 manufacturerTypeInstance = ManufacturerType.findByName(tempPreferredManufacturerType)254 }255 else256 manufacturerTypeInstance = manufacturerTypeUnknown257 if(!manufacturerTypeInstance) {258 log.error "Failed to find preferred manufacturer type on line: " + lineNumber259 return fail(code: "inventory.import.failure", args: [lineNumber, logFileLink])260 }261 262 preferredManufacturerInstance = new Manufacturer(name: tempPreferredManufacturerItem,263 manufacturerType: manufacturerTypeInstance)264 if(!preferredManufacturerInstance.save()) {265 log.error "Failed to create preferred manufacturer on line: " + lineNumber266 return fail(code: "inventory.import.failure", args: [lineNumber, logFileLink])267 }268 }269 }270 else271 preferredManufacturerInstance = null272 273 // Alternate Manufacturers.274 tempAlternateManufacturers = parseInputList(inventoryParams.alternateManufacturers)275 inventoryParams.alternateManufacturers = []276 277 for(tempManufacturer in tempAlternateManufacturers) {278 tempManufacturerItemAndType = parseItemAndType(tempManufacturer)279 tempManufacturerItem = WordUtils.capitalizeFully(tempManufacturerItemAndType[0])280 281 alternateManufacturerInstance = Manufacturer.findByName(tempManufacturerItem)282 if(!alternateManufacturerInstance) {283 284 // ManufacturerType.285 if(tempManufacturerItemAndType.size == 2) {286 tempManufacturerType = WordUtils.capitalize(tempManufacturerItemAndType[1])287 manufacturerTypeInstance = ManufacturerType.findByName(tempManufacturerType)288 }289 else290 manufacturerTypeInstance = manufacturerTypeUnknown291 if(!manufacturerTypeInstance) {292 log.error "Failed to find manufacturer type on line: " + lineNumber293 return fail(code: "inventory.import.failure", args: [lineNumber, logFileLink])294 }295 296 alternateManufacturerInstance = new Manufacturer(name: tempManufacturerItem,297 manufacturerType: manufacturerTypeInstance)298 if(!alternateManufacturerInstance.save()) {299 log.error "Failed to create manufacturers on line: " + lineNumber300 return fail(code: "inventory.import.failure", args: [lineNumber, logFileLink])301 }302 }303 304 inventoryParams.alternateManufacturers.add(alternateManufacturerInstance)305 226 } 306 227 … … 417 338 inventoryParams.unitOfMeasure = unitOfMeasureInstance 418 339 inventoryParams.preferredSupplier = preferredSupplierInstance 419 inventoryParams.preferredManufacturer = preferredManufacturerInstance420 340 421 341 // Name. … … 485 405 writer.writeNext("Comment: Required columns are marked with a (*) in the header line.") 486 406 writer.writeNext("Comment: Lists of items in a column must be separated by a semicolon (;), not a comma.") 487 writer.writeNext("Comment: The at symbol (@) is reserved for indicating supplier and manufacturertypes.")407 writer.writeNext("Comment: The at symbol (@) is reserved for indicating supplier types.") 488 408 writer.writeNext("Comment: Identical and existing names will be considered as the same item.") 489 409 writer.writeNext("Comment: Lines containing 'comment' will be ignored.") … … 515 435 "123", "Multi Supplier@Local", 516 436 "Multi Distributors1@OEM; Multi Distributors2@Local", 517 "321", "Master Manufacturer@OEM",518 "Mega Manufacturer1@OEM;Mega Manufacturer2@Alternate",519 437 "2204E-2RS", "" 520 438 ] as String[]) … … 530 448 "456KL", "Multi Supplier", 531 449 "Multi Distributors1; Multi Distributors2", 532 "654OP", "Master Manufacturer",533 "Mega Manufacturer1;Mega Manufacturer2",534 450 "", "" 535 451 ] as String[]) … … 582 498 }.collect { it.name + "@" + it.supplierType }.join(';') ) 583 499 584 row.add(inventoryItem.manufacturersPartNumber)585 586 if(inventoryItem.preferredManufacturer)587 row.add( inventoryItem.preferredManufacturer.name + "@" + inventoryItem.preferredManufacturer.manufacturerType )588 else589 row.add('')590 591 row.add(inventoryItem.alternateManufacturers.sort { p1, p2 ->592 p1.name.compareToIgnoreCase(p2.name)593 }.collect { it.name + "@" + it.manufacturerType }.join(';'))594 595 row.add(inventoryItem.alternateItems.sort { p1, p2 ->596 p1.name.compareToIgnoreCase(p2.name)597 }.collect { it.name }.join(';') )598 599 500 row.add(inventoryItem.spareFor.sort { p1, p2 -> 600 501 p1.name.compareToIgnoreCase(p2.name) … … 813 714 "Estimated Unit Price", "Currency", "Enable Reorder", "Location*", "Store*", "Site*", "Group*", "Type*", 814 715 "Supplier's Part Number", "Preferred Supplier", "Alternate Suppliers", 815 " Manufacturer's Part Number", "Preferred Manufacturer", "Alternate Manufacturers", "Alternate Item", "Spare For"]716 "Alternate Item", "Spare For"] 816 717 } 817 718 -
trunk/grails-app/views/inventoryItemDetailed/create.gsp
r718 r719 169 169 </tr> 170 170 171 <tr class="prop">172 <td valign="top" class="name">173 <label for="manufacturersPartNumber">Manufacturers Part Number:</label>174 </td>175 <td valign="top" class="value ${hasErrors(bean:inventoryItemInstance,field:'manufacturersPartNumber','errors')}">176 <input type="text" id="manufacturersPartNumber" name="manufacturersPartNumber" value="${fieldValue(bean:inventoryItemInstance,field:'manufacturersPartNumber')}"/>177 </td>178 </tr>179 180 <tr class="prop">181 <td valign="top" class="name">182 <label for="preferredManufacturer">Preferred Manufacturer:</label>183 </td>184 <td valign="top">185 <g:select optionKey="id" from="${manufacturers}" name="preferredManufacturer.id" value="${inventoryItemInstance?.preferredManufacturer?.id}" noSelection="['null':'--None--']"></g:select>186 187 <p><g:link controller="manufacturerDetailed" action="create">+Add Manufacturer</g:link></p>188 </td>189 </tr>190 191 <tr class="prop">192 <td valign="top" class="name">193 <label for="manufacturers">Alternate Manufacturers:</label>194 </td>195 <td valign="top" class="value ${hasErrors(bean:inventoryItemInstance,field:'alternateManufacturers','errors')}">196 <g:select id="alternateManufacturers" name="alternateManufacturers"197 from="${manufacturers}"198 size="5" multiple="yes" optionKey="id"199 value="${inventoryItemInstance.alternateManufacturers?.id}" noSelection="['':'--None--']" />200 </td>201 </tr>202 203 171 </tbody> 204 172 </table> -
trunk/grails-app/views/inventoryItemDetailed/edit.gsp
r718 r719 207 207 <tr class="prop"> 208 208 <td valign="top" class="name"> 209 <label for="manufacturersPartNumber">Manufacturers Part Number:</label>210 </td>211 <td valign="top" class="value ${hasErrors(bean:inventoryItemInstance,field:'manufacturersPartNumber','errors')}">212 <input type="text" id="manufacturersPartNumber" name="manufacturersPartNumber" value="${fieldValue(bean:inventoryItemInstance,field:'manufacturersPartNumber')}"/>213 </td>214 </tr>215 216 <tr class="prop">217 <td valign="top" class="name">218 <label for="preferredManufacturer">Preferred Manufacturer:</label>219 </td>220 <td valign="top">221 <g:select optionKey="id" from="${manufacturers}" name="preferredManufacturer.id" value="${inventoryItemInstance.preferredManufacturer?.id}" noSelection="['null':'--None--']"></g:select>222 223 <p><g:link controller="manufacturerDetailed" action="create">+Add Manufacturer</g:link></p>224 </td>225 </tr>226 227 <tr class="prop">228 <td valign="top" class="name">229 <label for="manufacturers">Alternate Manufacturers:</label>230 </td>231 <td valign="top" class="value ${hasErrors(bean:inventoryItemInstance,field:'alternateManufacturers','errors')}">232 <g:select id="alternateManufacturers" name="alternateManufacturers"233 from="${manufacturers}"234 size="5" multiple="yes" optionKey="id"235 value="${inventoryItemInstance.alternateManufacturers?.id}" noSelection="['':'--None--']" />236 </td>237 </tr>238 239 <tr class="prop">240 <td valign="top" class="name">241 209 <label for="spareFor">Spare For:</label> 242 210 </td> -
trunk/grails-app/views/inventoryItemDetailed/search.gsp
r718 r719 242 242 excludeProperties="estimatedUnitPriceCurrency" 243 243 associatedProperties="inventoryLocation.name, 244 spareFor.name, 245 preferredManufacturer.name, 246 preferredSupplier.name" 244 spareFor.name" 247 245 filterPropertyValues="${['inventoryLocation.name':[values: associatedPropertyValues.inventoryLocationList], 248 246 'spareFor.name':[values: associatedPropertyValues.assetList], 249 'preferredManufacturer.name':[values: associatedPropertyValues.manufacturerList],250 247 'preferredSupplier.name':[values: associatedPropertyValues.supplierList] 251 248 ]}"/> -
trunk/grails-app/views/inventoryItemDetailed/show.gsp
r718 r719 299 299 </tr> 300 300 301 <tr class="prop">302 <td valign="top" class="name">Manufacturers Part Number:</td>303 <td valign="top" class="value">${fieldValue(bean:inventoryItemInstance, field:'manufacturersPartNumber')}</td>304 </tr>305 306 <tr class="prop">307 <td valign="top" class="name">Preferred Manufacturer:</td>308 309 <td valign="top" style="text-align:left;" class="value">310 <g:link controller="manufacturerDetailed" action="show" id="${inventoryItemInstance.preferredManufacturer?.id}">311 ${inventoryItemInstance.preferredManufacturer?.encodeAsHTML()}312 </g:link>313 </td>314 </tr>315 316 <tr class="prop">317 <td valign="top" class="name">Alternate Manufacturers:</td>318 319 <td valign="top" style="text-align:left;" class="value">320 <ul>321 <g:each var="m" in="${ inventoryItemInstance.alternateManufacturers.sort { p1, p2 -> p1.name.compareToIgnoreCase(p2.name) } }">322 <li><g:link controller="manufacturerDetailed" action="show" id="${m.id}">${m?.encodeAsHTML()}</g:link></li>323 </g:each>324 </ul>325 </td>326 </tr>327 328 329 301 </tbody> 330 302 </table>
Note: See TracChangeset
for help on using the changeset viewer.