

<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
        <meta name="layout" content="main" />
        <title>Create InventoryItem</title>    
        <nav:resources override="true"/>     
    </head>
    <body>
        <div class="nav">
            <nav:renderSubItems group="nav"/>
        </div>
        <div class="body">
            <g:render template="/shared/messages" />
            <g:hasErrors bean="${inventoryItemInstance}">
            <div class="errors">
                <g:renderErrors bean="${inventoryItemInstance}" as="list" />
            </div>
            </g:hasErrors>
            <g:form action="save" method="post" >
                <div class="dialog">
                    <table>
                        <tbody>
                        
                            <tr class="prop">
                                <td valign="top" class="groupHeader">
                                    <label for="name">Inventory Item</label>
                                </td>
                                <td valign="top" class="value">
                                </td>
                            </tr>
                            
                            <tr class="prop">
                                <td valign="top" class="groupName">
                                    <label for="name">Name:</label>
                                </td>
                                <td valign="top" class="value ${hasErrors(bean:inventoryItemInstance,field:'name','errors')}">
                                    <input type="text" class="description" maxlength="50" id="name" name="name" value="${fieldValue(bean:inventoryItemInstance,field:'name')}"/>
                                    <g:helpBalloon class="helpballoon" code="inventory.item.name" />
                                </td>
                            </tr>
                            
                            <tr class="prop">
                                <td valign="top" class="groupName">
                                    <label for="description">Description:</label>
                                </td>
                                <td valign="top" class="value ${hasErrors(bean:inventoryItemInstance,field:'description','errors')}">
                                    <textarea rows="5" cols="40" name="description">${fieldValue(bean:inventoryItemInstance, field:'description')}</textarea>
                                    <g:helpBalloon class="helpballoon" code="inventory.item.description" />
                                </td>
                            </tr>
                        
                            <tr class="prop">
                                <td valign="top" class="groupName">
                                    <label for="comment">Comment:</label>
                                </td>
                                <td valign="top" class="value ${hasErrors(bean:inventoryItemInstance,field:'comment','errors')}">
                                    <textarea rows="5" cols="40" name="comment">${fieldValue(bean:inventoryItemInstance, field:'comment')}</textarea>
                                    <g:helpBalloon class="helpballoon" code="inventory.item.comment" />
                                </td>
                            </tr>
                        
                            <tr class="prop">
                                <td valign="top" class="groupName">
                                    <label for="unitOfMeasure">Unit Of Measure:</label>
                                </td>
                                <td valign="top">
                                    <g:select optionKey="id"
                                                        from="${UnitOfMeasure.findAllByIsActive(true)}"
                                                        name="unitOfMeasure.id"
                                                        value="${inventoryItemInstance?.unitOfMeasure?.id}" >
                                    </g:select>
                                    <g:helpBalloon class="helpballoon" code="inventory.item.unit.of.measure" />
                                </td>
                            </tr>
                        
                            <tr class="prop">
                                <td valign="top" class="groupName">
                                    <label for="inventoryLocation">Inventory Location:</label>
                                </td>
                                <td valign="top" class="value ${hasErrors(bean:inventoryItemInstance,field:'inventoryLocation','errors')}">
                                    <g:select optionKey="id"
                                                        from="${ InventoryLocation.findAllByIsActive(true).sort { p1, p2 -> p1.toString().compareToIgnoreCase(p2.toString()) } }"
                                                        name="inventoryLocation.id" value="${inventoryItemInstance?.inventoryLocation?.id}"
                                                        optionValue="${{it.name+ ' in ' + it.inventoryStore}}"
                                                        noSelection="['null':/${g.message(code:'default.please.select.text')}/]" >
                                    </g:select>
                                    <g:helpBalloon class="helpballoon" code="inventory.item.inventory.location" />

                                <p><g:link controller="inventoryLocationDetailed" action="create">+Add Location</g:link></p>
                                </td>
                            </tr>
                        
                            <tr class="prop">
                                <td valign="top" class="groupName">
                                    <label for="inventoryGroup">Inventory Group:</label>
                                </td>
                                <td valign="top" class="value ${hasErrors(bean:inventoryItemInstance,field:'inventoryGroup','errors')}">
                                    <g:select optionKey="id"
                                                        from="${InventoryGroup.findAllByIsActive(true).sort { p1, p2 -> p1.name.compareToIgnoreCase(p2.name) }}"
                                                        name="inventoryGroup.id"
                                                        value="${inventoryItemInstance?.inventoryGroup?.id}"
                                                        noSelection="['null':/${g.message(code:'default.please.select.text')}/]" >
                                    </g:select>
                                    <g:helpBalloon class="helpballoon" code="inventory.item.inventory.group" />
                                <p><g:link controller="inventoryGroupDetailed" action="create">+Add Group</g:link></p>
                                </td>
                            </tr> 
                        
                            <tr class="prop">
                                <td valign="top" class="groupName">
                                    <label for="inventoryType">Inventory Type:</label>
                                </td>
                                <td valign="top" class="value ${hasErrors(bean:inventoryItemInstance,field:'inventoryType','errors')}">
                                    <g:select optionKey="id"
                                                        from="${InventoryType.findAllByIsActive(true).sort { p1, p2 -> p1.name.compareToIgnoreCase(p2.name) }}"
                                                        name="inventoryType.id"
                                                        value="${inventoryItemInstance?.inventoryType?.id}"
                                                        noSelection="['null':/${g.message(code:'default.please.select.text')}/]" >
                                    </g:select>
                                    <g:helpBalloon class="helpballoon" code="inventory.item.inventory.type" />
                                </td>
                            </tr>
                            
                            <tr class="prop">
                                <td valign="top" class="groupHeader">
                                    <label for="name">Reorder Details</label>
                                </td>
                                <td valign="top" class="value">
                                </td>
                            </tr>
                        
                            <tr class="prop">
                                <td valign="top" class="groupName">
                                    <label for="enableReorderListing">Enable Reorder Listing:</label>
                                </td>
                                <td valign="top" class="value ${hasErrors(bean:inventoryItemInstance,field:'enableReorderListing','errors')}">
                                    <g:checkBox name="enableReorderListing" value="${inventoryItemInstance?.enableReorderListing}" ></g:checkBox>
                                    <g:helpBalloon class="helpballoon" code="inventory.item.enable.reorder.listing" />
                                </td>
                            </tr>
                        
                            <tr class="prop">
                                <td valign="top" class="groupName">
                                    <label for="reorderPoint">Reorder Point:</label>
                                </td>
                                <td valign="top">
                                    <input class="medium ${hasErrors(bean:inventoryItemInstance,field:'reorderPoint','errors')}"
                                                    type="text" id="reorderPoint" name="reorderPoint"
                                                    value="${fieldValue(bean:inventoryItemInstance,field:'reorderPoint')}" />
                                    <g:helpBalloon class="helpballoon" code="inventory.item.reorder.point" />
                                </td>
                            </tr>
                            
                            <tr class="prop">
                                <td valign="top" class="groupName">
                                    <label for="reorderQuantity">Reorder Quantity:</label>
                                </td>
                                <td valign="top">
                                    <input class="medium ${hasErrors(bean:inventoryItemInstance,field:'reorderQuantity','errors')}"
                                                type="text" id="reorderQuantity" name="reorderQuantity"
                                                value="${fieldValue(bean:inventoryItemInstance,field:'reorderQuantity')}" />
                                    <g:helpBalloon class="helpballoon" code="inventory.item.reorder.quantity" />
                                </td>
                            </tr>
                        
                            <tr class="prop">
                                <td valign="top" class="groupName">
                                    <label for="estimatedUnitPriceAmount">Estimated Unit Price:</label>
                                </td>
                                <td valign="top">
                                    <input  class="medium ${hasErrors(bean:inventoryItemInstance,field:'estimatedUnitPriceAmount','errors')}"
                                                    type="text" id="estimatedUnitPriceAmount" name="estimatedUnitPriceAmount"
                                                    value="${fieldValue(bean:inventoryItemInstance,field:'estimatedUnitPriceAmount')}" />
                                    <g:currencySelect name="estimatedUnitPriceCurrency"
                                                                        value="${inventoryItemInstance?.estimatedUnitPriceCurrency}"
                                                                        from="${grailsApplication.config.currencyList}">
                                    </g:currencySelect>
                                    <g:helpBalloon class="helpballoon" code="inventory.item.estimated.unit.price.amount" />
                                </td>
                            </tr>
                        
                            <tr class="prop">
                                <td valign="top" class="groupName">
                                    <label for="suppliersPartNumber">Suppliers Part Number:</label>
                                </td>
                                <td valign="top" class="value ${hasErrors(bean:inventoryItemInstance,field:'suppliersPartNumber','errors')}">
                                    <input type="text" id="suppliersPartNumber" maxlength="50" name="suppliersPartNumber" value="${fieldValue(bean:inventoryItemInstance,field:'suppliersPartNumber')}"/>
                                    <g:helpBalloon class="helpballoon" code="inventory.item.suppliers.part.number" />
                                </td>
                            </tr>
                        
                            <tr class="prop">
                                <td valign="top" class="groupName">
                                    <label for="preferredSupplier">Preferred Supplier:</label>
                                </td>
                                <td valign="top">
                                    <g:select optionKey="id"
                                                        from="${suppliers}"
                                                        name="preferredSupplier.id"
                                                        value="${inventoryItemInstance.preferredSupplier?.id}"
                                                        noSelection="['null':'--None--']">
                                    </g:select>
                                    <g:helpBalloon class="helpballoon" code="inventory.item.preferred.supplier" />
                                    <p><g:link controller="supplierDetailed" action="create">+Add Supplier</g:link></p>
                                </td>
                            </tr>

                            <tr class="prop">
                                <td valign="top" class="groupName">
                                    <label for="alternateSuppliers">Alternate Suppliers:</label>
                                </td>
                                <td valign="top" class="value ${hasErrors(bean:inventoryItemInstance,field:'alternateSuppliers','errors')}">
                                    <g:helpBalloon class="helpballoon" code="inventory.item.alternate.suppliers" />
                                    <custom:checkBoxList name="alternateSuppliers"
                                                                    from="${suppliers}"
                                                                    value="${inventoryItemInstance?.alternateSuppliers?.collect{it.id}}"
                                                                    optionKey="id"
                                                                    linkController="supplierDetailed"
                                                                    linkAction="show"/>
                                    <g:link controller="supplierDetailed" action="create">+Add Supplier</g:link>
                                </td>
                            </tr>
                            
                            <tr class="prop">
                                <td valign="top" class="groupHeader">
                                    <label for="name">Spare For</label>
                                </td>
                                <td valign="top" class="value">
                                </td>
                            </tr>
                            
                            <tr class="prop">
                                <td valign="top" class="groupName">
                                    <label for="spareFor">Assets:</label>
                                </td>
                                <td valign="top" class="value ${hasErrors(bean:inventoryItemInstance,field:'spareFor','errors')}">
                                    <g:helpBalloon class="helpballoon" code="inventory.item.spare.for" />
                                    <custom:checkBoxList name="spareFor"
                                                                    from="${Asset.findAllByIsActive(true).sort { p1, p2 -> p1.name.compareToIgnoreCase(p2.name) }}"
                                                                    value="${inventoryItemInstance?.spareFor?.collect{it.id}}"
                                                                    optionKey="id"
                                                                    sortBy="name"
                                                                    linkController="assetDetailed"
                                                                    linkAction="show"/>
                                    <g:link controller="assetDetailed" action="create">+Add Asset</g:link>
                                </td>
                            </tr>
                        
                        </tbody>
                    </table>
                </div>
                <div class="buttons">
                    <span class="button"><input class="save" type="submit" value="Create" /></span>
                </div>
            </g:form>
        </div>
    </body>
</html>
