dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #17992
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 7399: local/in CCEM work in progress
------------------------------------------------------------
revno: 7399
committer: Mithilesh Kumar Thakur<mithilesh.hisp@xxxxxxxxx>
branch nick: dhis2
timestamp: Tue 2012-06-26 14:08:56 +0530
message:
local/in CCEM work in progress
added:
local/in/dhis-web-coldchain/src/main/java/org/hisp/dhis/coldchain/catalog/action/CatalogSelectAction.java
local/in/dhis-web-coldchain/src/main/java/org/hisp/dhis/coldchain/catalog/action/GetCatalogListAction.java
local/in/dhis-web-coldchain/src/main/java/org/hisp/dhis/coldchain/catalog/action/GetCatalogTypeAttributeListAction.java
local/in/dhis-web-coldchain/src/main/webapp/dhis-web-coldchain/catalog_List.vm
local/in/dhis-web-coldchain/src/main/webapp/dhis-web-coldchain/responseCatalogTypeAttributes.vm
local/in/dhis-web-coldchain/src/main/webapp/dhis-web-coldchain/selectCatalog.vm
modified:
local/in/dhis-in-api/src/main/java/org/hisp/dhis/coldchain/catalog/CatalogService.java
local/in/dhis-in-api/src/main/java/org/hisp/dhis/coldchain/catalog/CatalogStore.java
local/in/dhis-in-services/dhis-in-service-coldchain/src/main/java/org/hisp/dhis/coldchain/catalog/DefaultCatalogService.java
local/in/dhis-in-services/dhis-in-service-coldchain/src/main/java/org/hisp/dhis/coldchain/catalog/hibernate/HibernateCatalogStore.java
local/in/dhis-in-services/dhis-in-service-coldchain/src/main/java/org/hisp/dhis/coldchain/inventory/hibernate/HibernateEquipmentInstanceStore.java
local/in/dhis-web-coldchain/src/main/resources/META-INF/dhis/beans.xml
local/in/dhis-web-coldchain/src/main/resources/org/hisp/dhis/coldchain/i18n_module.properties
local/in/dhis-web-coldchain/src/main/resources/struts.xml
local/in/dhis-web-coldchain/src/main/webapp/dhis-web-coldchain/addCatalogForm.vm
local/in/dhis-web-coldchain/src/main/webapp/dhis-web-coldchain/equipmentInstanceList.vm
local/in/dhis-web-coldchain/src/main/webapp/dhis-web-coldchain/javascript/catalog.js
local/in/dhis-web-coldchain/src/main/webapp/dhis-web-coldchain/showAddCatalogForm.vm
local/in/dhis-web-coldchain/src/main/webapp/dhis-web-coldchain/updateCatalogForm.vm
local/in/dhis-web-coldchain/src/main/webapp/dhis-web-coldchain/updateEquipmentForm.vm
local/in/dhis-web-coldchain/src/main/webapp/dhis-web-coldchain/uploadCatalogImageForm.vm
--
lp:dhis2
https://code.launchpad.net/~dhis2-devs-core/dhis2/trunk
Your team DHIS 2 developers is subscribed to branch lp:dhis2.
To unsubscribe from this branch go to https://code.launchpad.net/~dhis2-devs-core/dhis2/trunk/+edit-subscription
=== modified file 'local/in/dhis-in-api/src/main/java/org/hisp/dhis/coldchain/catalog/CatalogService.java'
--- local/in/dhis-in-api/src/main/java/org/hisp/dhis/coldchain/catalog/CatalogService.java 2012-05-09 07:02:15 +0000
+++ local/in/dhis-in-api/src/main/java/org/hisp/dhis/coldchain/catalog/CatalogService.java 2012-06-26 08:38:56 +0000
@@ -41,4 +41,11 @@
Collection<Catalog> getCatalogsBetweenByName( String name, int first, int max );
+ int getCountCatalog( CatalogType catalogType );
+
+ Collection<Catalog> getCatalogs( CatalogType catalogType, int min, int max );
+
+ int getCountCatalog( CatalogType catalogType, CatalogTypeAttribute catalogTypeAttribute, String searchText );
+
+ Collection<Catalog> getCatalogs( CatalogType catalogType, CatalogTypeAttribute catalogTypeAttribute, String searchText, int min, int max );
}
=== modified file 'local/in/dhis-in-api/src/main/java/org/hisp/dhis/coldchain/catalog/CatalogStore.java'
--- local/in/dhis-in-api/src/main/java/org/hisp/dhis/coldchain/catalog/CatalogStore.java 2012-05-09 07:02:15 +0000
+++ local/in/dhis-in-api/src/main/java/org/hisp/dhis/coldchain/catalog/CatalogStore.java 2012-06-26 08:38:56 +0000
@@ -22,4 +22,16 @@
Collection<Catalog> getAllCatalogs();
Collection<Catalog> getCatalogs( CatalogType catalogType );
+
+
+
+ int getCountCatalog( CatalogType catalogType );
+
+ Collection<Catalog> getCatalogs( CatalogType catalogType, int min, int max );
+
+ int getCountCatalog( CatalogType catalogType, CatalogTypeAttribute catalogTypeAttribute, String searchText );
+
+ Collection<Catalog> getCatalogs( CatalogType catalogType, CatalogTypeAttribute catalogTypeAttribute, String searchText, int min, int max );
+
+
}
=== modified file 'local/in/dhis-in-services/dhis-in-service-coldchain/src/main/java/org/hisp/dhis/coldchain/catalog/DefaultCatalogService.java'
--- local/in/dhis-in-services/dhis-in-service-coldchain/src/main/java/org/hisp/dhis/coldchain/catalog/DefaultCatalogService.java 2012-05-09 07:02:15 +0000
+++ local/in/dhis-in-services/dhis-in-service-coldchain/src/main/java/org/hisp/dhis/coldchain/catalog/DefaultCatalogService.java 2012-06-26 08:38:56 +0000
@@ -7,30 +7,35 @@
import java.util.Collection;
import java.util.List;
+import org.hisp.dhis.coldchain.inventory.EquipmentInstance;
+import org.hisp.dhis.coldchain.inventory.InventoryType;
+import org.hisp.dhis.coldchain.inventory.InventoryTypeAttribute;
import org.hisp.dhis.i18n.I18nService;
+import org.hisp.dhis.organisationunit.OrganisationUnit;
import org.springframework.transaction.annotation.Transactional;
@Transactional
-public class DefaultCatalogService implements CatalogService
+public class DefaultCatalogService
+ implements CatalogService
{
// -------------------------------------------------------------------------
// Dependencies
// -------------------------------------------------------------------------
private CatalogStore catalogStore;
-
+
public void setCatalogStore( CatalogStore catalogStore )
{
this.catalogStore = catalogStore;
}
-
+
private CatalogDataValueService catalogDataValueService;
-
+
public void setCatalogDataValueService( CatalogDataValueService catalogDataValueService )
{
this.catalogDataValueService = catalogDataValueService;
}
-
+
private I18nService i18nService;
public void setI18nService( I18nService service )
@@ -41,38 +46,35 @@
// -------------------------------------------------------------------------
// Catalog
// -------------------------------------------------------------------------
- /*
- public int addCatalog( Catalog catalog )
- {
- return catalogStore.addCatalog( catalog );
- }
+ /*
+ * public int addCatalog( Catalog catalog ) { return
+ * catalogStore.addCatalog( catalog ); }
+ *
+ * public void deleteCatalog( Catalog catalog ) {
+ * catalogStore.deleteCatalog( catalog ); }
+ *
+ * public void updateCatalog( Catalog catalog ) {
+ * catalogStore.updateCatalog( catalog ); }
+ */
- public void deleteCatalog( Catalog catalog )
- {
- catalogStore.deleteCatalog( catalog );
- }
-
- public void updateCatalog( Catalog catalog )
- {
- catalogStore.updateCatalog( catalog );
- }
- */
-
@Override
public int addCatalog( Catalog catalog )
{
return catalogStore.save( catalog );
}
+
@Override
public void deleteCatalog( Catalog catalog )
{
catalogStore.delete( catalog );
}
+
@Override
public void updateCatalog( Catalog catalog )
{
catalogStore.update( catalog );
}
+
@Override
public void deleteCatalogData( Catalog catalog )
{
@@ -83,21 +85,21 @@
{
return catalogStore.getAllCatalogs();
}
-
+
@Override
public Catalog getCatalog( int id )
{
return catalogStore.getCatalog( id );
}
-
+
@Override
public Catalog getCatalogByName( String name )
{
return catalogStore.getCatalogByName( name );
}
-
+
@Override
- public int createCatalog( Catalog catalog, List<CatalogDataValue> catalogDataValues )
+ public int createCatalog( Catalog catalog, List<CatalogDataValue> catalogDataValues )
{
int catalogId = addCatalog( catalog );
@@ -110,11 +112,12 @@
}
@Override
- public void updateCatalogAndDataValue( Catalog catalog, List<CatalogDataValue> valuesForSave, List<CatalogDataValue> valuesForUpdate, Collection<CatalogDataValue> valuesForDelete )
+ public void updateCatalogAndDataValue( Catalog catalog, List<CatalogDataValue> valuesForSave,
+ List<CatalogDataValue> valuesForUpdate, Collection<CatalogDataValue> valuesForDelete )
{
catalogStore.update( catalog );
- //catalogStore.updateCatalog( catalog );
-
+ // catalogStore.updateCatalog( catalog );
+
for ( CatalogDataValue catalogDataValueAdd : valuesForSave )
{
catalogDataValueService.addCatalogDataValue( catalogDataValueAdd );
@@ -124,48 +127,72 @@
{
catalogDataValueService.updateCatalogDataValue( catalogDataValueUpdate );
}
-
+
for ( CatalogDataValue catalogDataValueDelete : valuesForDelete )
{
catalogDataValueService.deleteCatalogDataValue( catalogDataValueDelete );
}
}
-
+
@Override
public void deleteCatalogAndDataValue( Catalog catalog )
{
- Collection<CatalogDataValue> valuesForDelete = catalogDataValueService.getAllCatalogDataValuesByCatalog( catalog ) ;
+ Collection<CatalogDataValue> valuesForDelete = catalogDataValueService
+ .getAllCatalogDataValuesByCatalog( catalog );
for ( CatalogDataValue catalogDataValueDelete : valuesForDelete )
{
catalogDataValueService.deleteCatalogDataValue( catalogDataValueDelete );
}
-
- //catalogStore.deleteCatalog( catalog );
+
+ // catalogStore.deleteCatalog( catalog );
}
-
+
public Collection<Catalog> getCatalogs( CatalogType catalogType )
{
return catalogStore.getCatalogs( catalogType );
}
-
- //Methods
+
+ // Methods
public int getCatalogCount()
{
return catalogStore.getCount();
}
-
+
public int getCatalogCountByName( String name )
{
return getCountByName( i18nService, catalogStore, name );
}
-
+
public Collection<Catalog> getCatalogsBetween( int first, int max )
{
return getObjectsBetween( i18nService, catalogStore, first, max );
}
-
+
public Collection<Catalog> getCatalogsBetweenByName( String name, int first, int max )
{
return getObjectsBetweenByName( i18nService, catalogStore, name, first, max );
- }
+ }
+
+ @Override
+ public int getCountCatalog( CatalogType catalogType )
+ {
+ return catalogStore.getCountCatalog( catalogType );
+ }
+
+ public Collection<Catalog> getCatalogs( CatalogType catalogType, int min, int max )
+ {
+ return catalogStore.getCatalogs( catalogType, min, max );
+ }
+
+ public int getCountCatalog( CatalogType catalogType, CatalogTypeAttribute catalogTypeAttribute, String searchText )
+ {
+ return catalogStore.getCountCatalog( catalogType, catalogTypeAttribute, searchText );
+ }
+
+ public Collection<Catalog> getCatalogs( CatalogType catalogType, CatalogTypeAttribute catalogTypeAttribute,
+ String searchText, int min, int max )
+ {
+ return catalogStore.getCatalogs( catalogType, catalogTypeAttribute, searchText, min, max );
+ }
+
}
=== modified file 'local/in/dhis-in-services/dhis-in-service-coldchain/src/main/java/org/hisp/dhis/coldchain/catalog/hibernate/HibernateCatalogStore.java'
--- local/in/dhis-in-services/dhis-in-service-coldchain/src/main/java/org/hisp/dhis/coldchain/catalog/hibernate/HibernateCatalogStore.java 2012-05-09 07:02:15 +0000
+++ local/in/dhis-in-services/dhis-in-service-coldchain/src/main/java/org/hisp/dhis/coldchain/catalog/hibernate/HibernateCatalogStore.java 2012-06-26 08:38:56 +0000
@@ -2,10 +2,13 @@
import java.util.Collection;
+import org.hibernate.Query;
+import org.hibernate.criterion.Projections;
import org.hibernate.criterion.Restrictions;
import org.hisp.dhis.coldchain.catalog.Catalog;
import org.hisp.dhis.coldchain.catalog.CatalogStore;
import org.hisp.dhis.coldchain.catalog.CatalogType;
+import org.hisp.dhis.coldchain.catalog.CatalogTypeAttribute;
import org.hisp.dhis.hibernate.HibernateGenericStore;
public class HibernateCatalogStore extends HibernateGenericStore<Catalog> implements CatalogStore
@@ -111,5 +114,52 @@
{
return getCriteria( Restrictions.eq( "catalogType", catalogType ) ).list();
}
-
+
+
+
+
+ public int getCountCatalog( CatalogType catalogType )
+ {
+ Number rs = (Number) getCriteria( Restrictions.eq( "catalogType", catalogType ) ).setProjection( Projections.rowCount() ).uniqueResult();
+
+ return rs != null ? rs.intValue() : 0;
+ }
+
+
+ @SuppressWarnings( "unchecked" )
+ public Collection<Catalog> getCatalogs( CatalogType catalogType, int min, int max )
+ {
+ return getCriteria( Restrictions.eq( "catalogType", catalogType ) ).setFirstResult( min ).setMaxResults( max ).list();
+ }
+
+
+ public int getCountCatalog( CatalogType catalogType, CatalogTypeAttribute catalogTypeAttribute, String searchText )
+ {
+ String hql = "SELECT COUNT( DISTINCT cat ) FROM Catalog AS cat " +
+ " WHERE cat IN ( SELECT catdata.catalog FROM CatalogDataValue catdata WHERE catdata.catalogTypeAttribute.id = "+ catalogTypeAttribute.getId()+" AND catdata.value LIKE '%" + searchText + "%' ) " +
+ " AND cat.catalogType.id = " + catalogType.getId();
+
+ System.out.println( hql );
+ Query query = getQuery( hql );
+
+ Number rs = (Number) query.uniqueResult();
+
+ return (rs != null) ? rs.intValue() : 0;
+ }
+
+ @SuppressWarnings( "unchecked" )
+ public Collection<Catalog> getCatalogs( CatalogType catalogType, CatalogTypeAttribute catalogTypeAttribute, String searchText, int min, int max )
+ {
+
+ //System.out.println("catalogTypeAttribute " + catalogTypeAttribute.getName() + "--- catalogType Name " + catalogType.getName() +"--- searchText is " + searchText );
+ String hql = "SELECT DISTINCT cat FROM Catalog AS cat " +
+ " WHERE cat IN ( SELECT catdata.catalog FROM CatalogDataValue catdata WHERE catdata.catalogTypeAttribute.id = "+ catalogTypeAttribute.getId()+" AND catdata.value LIKE '%" + searchText + "%' ) " +
+ " AND cat.catalogType.id = " + catalogType.getId();
+
+
+ Query query = getQuery( hql ).setFirstResult( min ).setMaxResults( max );
+
+ return query.list();
+ }
+
}
=== modified file 'local/in/dhis-in-services/dhis-in-service-coldchain/src/main/java/org/hisp/dhis/coldchain/inventory/hibernate/HibernateEquipmentInstanceStore.java'
--- local/in/dhis-in-services/dhis-in-service-coldchain/src/main/java/org/hisp/dhis/coldchain/inventory/hibernate/HibernateEquipmentInstanceStore.java 2012-05-02 09:18:42 +0000
+++ local/in/dhis-in-services/dhis-in-service-coldchain/src/main/java/org/hisp/dhis/coldchain/inventory/hibernate/HibernateEquipmentInstanceStore.java 2012-06-26 08:38:56 +0000
@@ -128,7 +128,7 @@
public int getCountEquipmentInstance( OrganisationUnit orgUnit, InventoryType inventoryType, InventoryTypeAttribute inventoryTypeAttribute, String searchText )
{
String hql = "SELECT COUNT( DISTINCT ei ) FROM EquipmentInstance AS ei " +
- " WHERE ei IN ( SELECT ed.equipmentInstance FROM EquipmentDetails AS ed WHERE ed.inventoryTypeAttribute.id = "+ inventoryTypeAttribute.getId()+" AND ed.value LIKE '%" + searchText + "%' ) " +
+ " WHERE ei IN ( SELECT ed.equipmentInstance FROM Equipment AS ed WHERE ed.inventoryTypeAttribute.id = "+ inventoryTypeAttribute.getId()+" AND ed.value LIKE '%" + searchText + "%' ) " +
" AND ei.organisationUnit.id = " + orgUnit.getId() +
" AND ei.inventoryType.id = " + inventoryType.getId();
@@ -144,7 +144,7 @@
public Collection<EquipmentInstance> getEquipmentInstances( OrganisationUnit orgUnit, InventoryType inventoryType, InventoryTypeAttribute inventoryTypeAttribute, String searchText, int min, int max )
{
String hql = "SELECT DISTINCT ei FROM EquipmentInstance AS ei " +
- " WHERE ei IN ( SELECT ed.equipmentInstance FROM EquipmentDetails AS ed WHERE ed.inventoryTypeAttribute.id = "+ inventoryTypeAttribute.getId()+" AND ed.value like '%" + searchText + "%' ) " +
+ " WHERE ei IN ( SELECT ed.equipmentInstance FROM Equipment AS ed WHERE ed.inventoryTypeAttribute.id = "+ inventoryTypeAttribute.getId()+" AND ed.value like '%" + searchText + "%' ) " +
" AND ei.organisationUnit.id = " + orgUnit.getId() +
" AND ei.inventoryType.id = " + inventoryType.getId();
=== added file 'local/in/dhis-web-coldchain/src/main/java/org/hisp/dhis/coldchain/catalog/action/CatalogSelectAction.java'
--- local/in/dhis-web-coldchain/src/main/java/org/hisp/dhis/coldchain/catalog/action/CatalogSelectAction.java 1970-01-01 00:00:00 +0000
+++ local/in/dhis-web-coldchain/src/main/java/org/hisp/dhis/coldchain/catalog/action/CatalogSelectAction.java 2012-06-26 08:38:56 +0000
@@ -0,0 +1,55 @@
+package org.hisp.dhis.coldchain.catalog.action;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.hisp.dhis.coldchain.catalog.CatalogType;
+import org.hisp.dhis.coldchain.catalog.CatalogTypeService;
+
+import com.opensymphony.xwork2.Action;
+
+/**
+ * @author Mithilesh Kumar Thakur
+ *
+ * @version CatalogSelectAction.java Jun 22, 2012 1:02:17 PM
+ */
+public class CatalogSelectAction implements Action
+{
+ // -------------------------------------------------------------------------
+ // Dependencies
+ // -------------------------------------------------------------------------
+
+ private CatalogTypeService catalogTypeService;
+
+ public void setCatalogTypeService( CatalogTypeService catalogTypeService )
+ {
+ this.catalogTypeService = catalogTypeService;
+ }
+
+
+ // -------------------------------------------------------------------------
+ // Input/output
+ // -------------------------------------------------------------------------
+
+ private List<CatalogType> catalogTypes;
+
+ public List<CatalogType> getCatalogTypes()
+ {
+ return catalogTypes;
+ }
+
+ // -------------------------------------------------------------------------
+ // Implementation Action
+ // -------------------------------------------------------------------------
+
+ public String execute()
+ throws Exception
+ {
+
+ catalogTypes = new ArrayList<CatalogType>( catalogTypeService.getAllCatalogTypes() );
+
+ return SUCCESS;
+ }
+
+}
+
=== added file 'local/in/dhis-web-coldchain/src/main/java/org/hisp/dhis/coldchain/catalog/action/GetCatalogListAction.java'
--- local/in/dhis-web-coldchain/src/main/java/org/hisp/dhis/coldchain/catalog/action/GetCatalogListAction.java 1970-01-01 00:00:00 +0000
+++ local/in/dhis-web-coldchain/src/main/java/org/hisp/dhis/coldchain/catalog/action/GetCatalogListAction.java 2012-06-26 08:38:56 +0000
@@ -0,0 +1,170 @@
+package org.hisp.dhis.coldchain.catalog.action;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.hisp.dhis.coldchain.catalog.Catalog;
+import org.hisp.dhis.coldchain.catalog.CatalogService;
+import org.hisp.dhis.coldchain.catalog.CatalogType;
+import org.hisp.dhis.coldchain.catalog.CatalogTypeAttribute;
+import org.hisp.dhis.coldchain.catalog.CatalogTypeAttributeService;
+import org.hisp.dhis.coldchain.catalog.CatalogTypeService;
+import org.hisp.dhis.paging.ActionPagingSupport;
+
+/**
+ * @author Mithilesh Kumar Thakur
+ *
+ * @version GetCatalogListAction.java Jun 22, 2012 3:30:36 PM
+ */
+public class GetCatalogListAction extends ActionPagingSupport<Catalog>
+{
+ // -------------------------------------------------------------------------
+ // Dependency
+ // -------------------------------------------------------------------------
+
+ private CatalogService catalogService;
+
+ public void setCatalogService( CatalogService catalogService )
+ {
+ this.catalogService = catalogService;
+ }
+
+ private CatalogTypeService catalogTypeService;
+
+ public void setCatalogTypeService( CatalogTypeService catalogTypeService )
+ {
+ this.catalogTypeService = catalogTypeService;
+ }
+
+ private CatalogTypeAttributeService catalogTypeAttributeService;
+
+ public void setCatalogTypeAttributeService( CatalogTypeAttributeService catalogTypeAttributeService )
+ {
+ this.catalogTypeAttributeService = catalogTypeAttributeService;
+ }
+ // -------------------------------------------------------------------------
+ // Input & Output
+ // -------------------------------------------------------------------------
+ /*
+ private int catalogTypeId;
+
+ public void setCatalogTypeId( int catalogTypeId )
+ {
+ this.catalogTypeId = catalogTypeId;
+ }
+ */
+
+ private String catalogTypeId;
+
+ public void setCatalogTypeId( String catalogTypeId )
+ {
+ this.catalogTypeId = catalogTypeId;
+ }
+
+ private Boolean listAll;
+
+ public void setListAll( Boolean listAll )
+ {
+ this.listAll = listAll;
+ }
+
+ private CatalogType catalogType;
+
+ public CatalogType getCatalogType()
+ {
+ return catalogType;
+ }
+
+ private Integer total;
+
+ public Integer getTotal()
+ {
+ return total;
+ }
+
+
+ private List<Catalog> catalogList;
+
+ public List<Catalog> getCatalogList()
+ {
+ return catalogList;
+ }
+ /*
+ private int catalogTypeAttributeId;
+
+ public void setCatalogTypeAttributeId( int catalogTypeAttributeId )
+ {
+ this.catalogTypeAttributeId = catalogTypeAttributeId;
+ }
+ */
+
+ private String catalogTypeAttributeId;
+
+ public void setCatalogTypeAttributeId( String catalogTypeAttributeId )
+ {
+ this.catalogTypeAttributeId = catalogTypeAttributeId;
+ }
+
+ private String searchText;
+
+ public String getSearchText()
+ {
+ return searchText;
+ }
+
+ public void setSearchText( String searchText )
+ {
+ this.searchText = searchText;
+ }
+
+ // -------------------------------------------------------------------------
+ // Action Implementation
+ // -------------------------------------------------------------------------
+ public String execute() throws Exception
+ {
+
+ catalogType = catalogTypeService.getCatalogType( Integer.parseInt( catalogTypeId ) );
+ //catalogType = catalogTypeService.getCatalogType( catalogTypeId );
+
+ if ( listAll != null && listAll )
+ {
+ listAllCatalog( catalogType );
+
+ return SUCCESS;
+ }
+
+ CatalogTypeAttribute catalogTypeAttribute = catalogTypeAttributeService.getCatalogTypeAttribute( Integer.parseInt( catalogTypeAttributeId ) );
+ //CatalogTypeAttribute catalogTypeAttribute = catalogTypeAttributeService.getCatalogTypeAttribute( catalogTypeAttributeId );
+ //System.out.println("catalogTypeAttribute " + catalogTypeAttribute.getName() + "--- catalogType Name " + catalogType.getName() +"--- searchText is " + searchText );
+
+
+ listCatalogByFilter( catalogType, catalogTypeAttribute, searchText);
+
+ return SUCCESS;
+ }
+
+
+ // supported Methods
+
+ private void listAllCatalog( CatalogType catalogType )
+ {
+ total = catalogService.getCountCatalog( catalogType );
+
+ this.paging = createPaging( total );
+
+ catalogList = new ArrayList<Catalog>( catalogService.getCatalogs( catalogType, paging.getStartPos(), paging.getPageSize() ));
+
+ }
+
+
+ private void listCatalogByFilter( CatalogType catalogType, CatalogTypeAttribute catalogTypeAttribute, String searchKey )
+ {
+ total = catalogService.getCountCatalog( catalogType, catalogTypeAttribute, searchText );
+
+ this.paging = createPaging( total );
+
+ catalogList = new ArrayList<Catalog>( catalogService.getCatalogs( catalogType, catalogTypeAttribute, searchText, paging.getStartPos(), paging.getPageSize() ));
+
+ }
+
+}
=== added file 'local/in/dhis-web-coldchain/src/main/java/org/hisp/dhis/coldchain/catalog/action/GetCatalogTypeAttributeListAction.java'
--- local/in/dhis-web-coldchain/src/main/java/org/hisp/dhis/coldchain/catalog/action/GetCatalogTypeAttributeListAction.java 1970-01-01 00:00:00 +0000
+++ local/in/dhis-web-coldchain/src/main/java/org/hisp/dhis/coldchain/catalog/action/GetCatalogTypeAttributeListAction.java 2012-06-26 08:38:56 +0000
@@ -0,0 +1,64 @@
+package org.hisp.dhis.coldchain.catalog.action;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.hisp.dhis.coldchain.catalog.CatalogType;
+import org.hisp.dhis.coldchain.catalog.CatalogTypeAttribute;
+import org.hisp.dhis.coldchain.catalog.CatalogTypeService;
+
+import com.opensymphony.xwork2.Action;
+
+/**
+ * @author Mithilesh Kumar Thakur
+ *
+ * @version GetCatalogTypeAttributeListAction.java Jun 22, 2012 2:10:54 PM
+ */
+public class GetCatalogTypeAttributeListAction implements Action
+{
+ // -------------------------------------------------------------------------
+ // Dependency
+ // -------------------------------------------------------------------------
+
+ private CatalogTypeService catalogTypeService;
+
+ public void setCatalogTypeService( CatalogTypeService catalogTypeService )
+ {
+ this.catalogTypeService = catalogTypeService;
+ }
+
+
+ // -------------------------------------------------------------------------
+ // Input & Output
+ // -------------------------------------------------------------------------
+
+ private List<CatalogTypeAttribute> catalogTypeAttributes = new ArrayList<CatalogTypeAttribute>();
+
+ public List<CatalogTypeAttribute> getCatalogTypeAttributes()
+ {
+ return catalogTypeAttributes;
+ }
+
+ private Integer id;
+
+ public void setId( Integer id )
+ {
+ this.id = id;
+ }
+
+
+
+ // -------------------------------------------------------------------------
+ // Action implementation
+ // -------------------------------------------------------------------------
+ public String execute() throws Exception
+ {
+ CatalogType catalogType = catalogTypeService.getCatalogType( id );
+
+ catalogTypeAttributes = catalogType.getCatalogTypeAttributes();
+
+ return SUCCESS;
+ }
+
+
+}
=== modified file 'local/in/dhis-web-coldchain/src/main/resources/META-INF/dhis/beans.xml'
--- local/in/dhis-web-coldchain/src/main/resources/META-INF/dhis/beans.xml 2012-06-18 09:15:09 +0000
+++ local/in/dhis-web-coldchain/src/main/resources/META-INF/dhis/beans.xml 2012-06-26 08:38:56 +0000
@@ -217,6 +217,34 @@
<!-- Catalog List -->
+
+ <bean id="org.hisp.dhis.coldchain.catalog.action.CatalogSelectAction"
+ class="org.hisp.dhis.coldchain.catalog.action.CatalogSelectAction"
+ scope="prototype">
+ <property name="catalogTypeService"
+ ref="org.hisp.dhis.coldchain.catalog.CatalogTypeService" />
+ </bean>
+
+ <bean id="org.hisp.dhis.coldchain.catalog.action.GetCatalogTypeAttributeListAction"
+ class="org.hisp.dhis.coldchain.catalog.action.GetCatalogTypeAttributeListAction"
+ scope="prototype">
+ <property name="catalogTypeService"
+ ref="org.hisp.dhis.coldchain.catalog.CatalogTypeService" />
+ </bean>
+
+
+ <bean id="org.hisp.dhis.coldchain.catalog.action.GetCatalogListAction"
+ class="org.hisp.dhis.coldchain.catalog.action.GetCatalogListAction"
+ scope="prototype">
+ <property name="catalogService"
+ ref="org.hisp.dhis.coldchain.catalog.CatalogService" />
+ <property name="catalogTypeService"
+ ref="org.hisp.dhis.coldchain.catalog.CatalogTypeService" />
+ <property name="catalogTypeAttributeService"
+ ref="org.hisp.dhis.coldchain.catalog.CatalogTypeAttributeService" />
+ </bean>
+
+<!--
<bean id="org.hisp.dhis.coldchain.catalog.action.CatalogListAction"
class="org.hisp.dhis.coldchain.catalog.action.CatalogListAction"
scope="prototype">
@@ -226,8 +254,11 @@
ref="org.hisp.dhis.coldchain.catalog.CatalogTypeService" />
<property name="userSettingService"
ref="org.hisp.dhis.user.UserSettingService" />
- </bean>
-
+ </bean>
+
+-->
+
+
<!-- Add Catalog Form -->
<bean id="org.hisp.dhis.coldchain.catalog.action.AddCatalogFormAction"
class="org.hisp.dhis.coldchain.catalog.action.AddCatalogFormAction"
=== modified file 'local/in/dhis-web-coldchain/src/main/resources/org/hisp/dhis/coldchain/i18n_module.properties'
--- local/in/dhis-web-coldchain/src/main/resources/org/hisp/dhis/coldchain/i18n_module.properties 2012-06-14 05:58:42 +0000
+++ local/in/dhis-web-coldchain/src/main/resources/org/hisp/dhis/coldchain/i18n_module.properties 2012-06-26 08:38:56 +0000
@@ -47,6 +47,9 @@
catalog__details = Details of catalog
attributes = Attributes
select_catalogType = Select catalogype
+list_all_catalogs = List all catalogs
+search_catalog_by_attributes = Search catalog by attributes
+
inventorytype_attribute_management = Inventorytype attribute management
=== modified file 'local/in/dhis-web-coldchain/src/main/resources/struts.xml'
--- local/in/dhis-web-coldchain/src/main/resources/struts.xml 2012-06-14 05:58:42 +0000
+++ local/in/dhis-web-coldchain/src/main/resources/struts.xml 2012-06-26 08:38:56 +0000
@@ -189,13 +189,35 @@
<!-- Catalog List -->
+
+ <action name="catalog" class="org.hisp.dhis.coldchain.catalog.action.CatalogSelectAction">
+ <result name="success" type="velocity">/main.vm</result>
+ <param name="page">/dhis-web-coldchain/selectCatalog.vm</param>
+ <param name="menu">/dhis-web-coldchain/menu.vm</param>
+ <param name="javascripts">javascript/catalog.js</param>
+ </action>
+
+ <action name="getCatalogTypeAttribute" class="org.hisp.dhis.coldchain.catalog.action.GetCatalogTypeAttributeListAction">
+ <result name="success" type="velocity-xml">/dhis-web-coldchain/responseCatalogTypeAttributes.vm</result>
+ <param name="onExceptionReturn">plainTextError</param>
+ </action>
+
+ <action name="getCatalogList" class="org.hisp.dhis.coldchain.catalog.action.GetCatalogListAction">
+ <result name="success" type="velocity">/content.vm</result>
+ <param name="page">/dhis-web-coldchain/catalog_List.vm</param>
+ <param name="requiredAuthorities">F_CATALOG_MANAGEMENT</param>
+ </action>
+
+
+
+ <!--
<action name="catalog" class="org.hisp.dhis.coldchain.catalog.action.CatalogListAction">
<result name="success" type="velocity">/main.vm</result>
<param name="page">/dhis-web-coldchain/catalogList.vm</param>
<param name="menu">/dhis-web-coldchain/menu.vm</param>
<param name="javascripts">javascript/catalog.js</param>
</action>
-
+ -->
<!-- Add Catalog Form -->
<action name="addCatalogForm" class="org.hisp.dhis.coldchain.catalog.action.AddCatalogFormAction">
<result name="success" type="velocity">/main.vm</result>
@@ -217,13 +239,14 @@
<!-- Add -->
<action name="addCatalog" class="org.hisp.dhis.coldchain.catalog.action.AddCatalogAction">
- <result name="success" type="redirect">catalog.action</result>
+ <!--<result name="success" type="redirect">catalog.action</result>-->
+ <result name="success" type="velocity-json">/dhis-web-commons/ajax/jsonResponseSuccess.vm</result>
<param name="requiredAuthorities">F_CATALOG_ADD</param>
</action>
<!-- Update Form -->
<action name="showUpdateCatalogForm" class="org.hisp.dhis.coldchain.catalog.action.UpdateCatalogFormAction">
- <result name="success" type="velocity">/main.vm</result>
+ <result name="success" type="velocity">/content.vm</result>
<param name="page">/dhis-web-coldchain/updateCatalogForm.vm</param>
<param name="stylesheets">css/style.css</param>
<param name="requiredAuthorities">F_CATALOG_UPDATE</param>
@@ -231,7 +254,8 @@
<!-- Update -->
<action name="updateCatalog" class="org.hisp.dhis.coldchain.catalog.action.UpdateCatalogAction">
- <result name="success" type="redirect">catalog.action</result>
+ <!--<result name="success" type="redirect">catalog.action</result>-->
+ <result name="success" type="velocity-json">/dhis-web-commons/ajax/jsonResponseSuccess.vm</result>
<param name="requiredAuthorities">F_CATALOG_UPDATE</param>
</action>
@@ -534,7 +558,8 @@
<!-- Upload Image Form -->
<action name="showUploadImageForm" class="org.hisp.dhis.coldchain.catalog.action.ShowUploadCatalogImageFormAction">
- <result name="success" type="velocity">/main.vm</result>
+ <!--<result name="success" type="velocity">/main.vm</result>-->
+ <result name="success" type="velocity">/content.vm</result>
<param name="page">/dhis-web-coldchain/uploadCatalogImageForm.vm</param>
<param name="stylesheets">css/style.css</param>
<param name="requiredAuthorities">F_CATALOG_UPDATE</param>
=== modified file 'local/in/dhis-web-coldchain/src/main/webapp/dhis-web-coldchain/addCatalogForm.vm'
--- local/in/dhis-web-coldchain/src/main/webapp/dhis-web-coldchain/addCatalogForm.vm 2012-06-14 05:58:42 +0000
+++ local/in/dhis-web-coldchain/src/main/webapp/dhis-web-coldchain/addCatalogForm.vm 2012-06-26 08:38:56 +0000
@@ -35,7 +35,8 @@
#parse( "/dhis-web-commons/loader/loader.vm" )
<p>
<input type="submit" class="button" value="$i18n.getString( 'add' )"/>
- <input type="button" value="$i18n.getString( 'cancel' )" onclick="window.location.href='catalog.action'" />
+ <!--<input type="button" value="$i18n.getString( 'cancel' )" onclick="window.location.href='catalog.action'" />-->
+ <input type="button" value="$i18n.getString( 'cancel' )" onclick="loadCatalogsByFilter();" />
</p>
</form>
=== added file 'local/in/dhis-web-coldchain/src/main/webapp/dhis-web-coldchain/catalog_List.vm'
--- local/in/dhis-web-coldchain/src/main/webapp/dhis-web-coldchain/catalog_List.vm 1970-01-01 00:00:00 +0000
+++ local/in/dhis-web-coldchain/src/main/webapp/dhis-web-coldchain/catalog_List.vm 2012-06-26 08:38:56 +0000
@@ -0,0 +1,87 @@
+<table>
+ <tr>
+ <td class='text-column' >$i18n.getString( "search_result_matching_the_search_criteria" ):</td>
+ <td> </td>
+ <td> </td>
+ <td>
+ #if($!listAll)
+ $i18n.getString( "list_all_catalogs" )
+ #else
+ $i18n.getString( "search_catalog_by_attributes" )
+ #end
+ </td>
+ </tr>
+
+ <tr>
+ <td class='text-column' >$i18n.getString( "total_result" )</td>
+ <td> </td>
+ <td> </td>
+ <td>$!total</td>
+ </tr>
+</table>
+
+#if( $catalogList.size() > 0 )
+<table class="mainPageTable">
+ <tr>
+ <td>
+ <table class="listTable" id="catalogList" width='100%'>
+ <col width="30"/>
+ <col/>
+ <col/>
+ <col width="120"/>
+ <thead>
+ <tr>
+ <th>#</th>
+ <th>$i18n.getString( "name" )</th>
+ <th>$i18n.getString( "description" )</th>
+ <th style="text-align:center" class="{sorter: false}">$i18n.getString( "operations" )</th>
+ </tr>
+ </thead>
+
+ <tbody id="list">
+ #set( $mark = false )
+ #foreach( $catalog in $catalogList )
+ <tr id="tr${catalog.id}" #alternate($mark) >
+
+ <td>
+ #set( $nr = ( ( $paging.getCurrentPage() - 1 ) * $paging.pageSize ) + $velocityCount )
+ $nr
+ </td>
+ <td>$!catalog.name</td>
+ <td>$!catalog.description</td>
+ <td>
+ <a href="javascript:showUploadCatalogImageForm( '$catalog.id' )"" title="$i18n.getString( 'upload_image' )"><img src="images/upload.png" alt="$i18n.getString( 'upload_image' )"></a>
+ <a href="javascript:showUpdateCatalogForm( '$catalog.id' )" title='$i18n.getString( "edit_equipment" )'><img src="../images/edit.png" alt='$i18n.getString( "edit_equipment" )'></a>
+ <a href="javascript:removeCatalog( '$catalog.id', '$encoder.jsEncode( $catalog.name )' )" title="$i18n.getString( 'remove' )"><img src="../images/delete.png" alt="$i18n.getString( 'remove' )" ></a>
+ <a href="javascript:showCatalogDetails( $catalog.id )" title="$i18n.getString( 'show_details' )"><img src="../images/information.png" alt="$i18n.getString( 'show_details' )"></a>
+ </td>
+
+ </tr>
+ #set( $mark = !$mark)
+ #end
+ </tbody>
+
+ </table>
+ </td>
+ </tr>
+ <tr>
+ <td colspan="6">
+ <p></p>
+ <div class="paging-container">
+ #parse( "/dhis-web-commons/paging/paging.vm" )
+ </div>
+ </td>
+ <td></td>
+ </tr>
+</table>
+
+<div id="detailsCatalogInfo"></div>
+
+#end
+<script type="text/javascript">
+ jQuery(document).ready(function(){
+ tableSorter( 'catalogList' );
+ });
+ var i18n_confirm_delete = '$encoder.jsEscape( $i18n.getString( "confirm_delete_catalog" ) , "'" )';
+ var i18n_catalog_details = '$encoder.jsEscape( $i18n.getString( "catalog__details" ) , "'" )';
+</script>
=== modified file 'local/in/dhis-web-coldchain/src/main/webapp/dhis-web-coldchain/equipmentInstanceList.vm'
--- local/in/dhis-web-coldchain/src/main/webapp/dhis-web-coldchain/equipmentInstanceList.vm 2012-06-18 09:15:09 +0000
+++ local/in/dhis-web-coldchain/src/main/webapp/dhis-web-coldchain/equipmentInstanceList.vm 2012-06-26 08:38:56 +0000
@@ -23,7 +23,7 @@
#if( $equipmentInstanceList.size() > 0 )
<table class="mainPageTable">
<tr>
- <td>
+ <td>
<table class="listTable" id="equipmentList" width='100%'>
<col width="30"/>
#set($equipmetnInstanceName = "" )
=== modified file 'local/in/dhis-web-coldchain/src/main/webapp/dhis-web-coldchain/javascript/catalog.js'
--- local/in/dhis-web-coldchain/src/main/webapp/dhis-web-coldchain/javascript/catalog.js 2012-06-21 12:52:08 +0000
+++ local/in/dhis-web-coldchain/src/main/webapp/dhis-web-coldchain/javascript/catalog.js 2012-06-26 08:38:56 +0000
@@ -1,4 +1,5 @@
+/*
jQuery(document).ready( function(){
validation( 'catalogForm', function(form){
form.submit();
@@ -10,7 +11,7 @@
checkValueIsExist( "name", "validateCatalog.action");
});
-
+*/
//-----------------------------------------------------------------------------
//View catalog type change
//-----------------------------------------------------------------------------
@@ -265,3 +266,300 @@
});
*/
+
+
+
+
+// for search ----
+
+
+
+
+// ----------------------------------------------------------------
+// On CatalogTypeChange - Loading CatalogType Attributes
+// ----------------------------------------------------------------
+function getCatalogTypeChange( catalogTypeId )
+{
+ if( catalogTypeId == "0" )
+ return;
+
+ showById('selectDiv');
+ disable('listAllCatalogBtn');
+
+ hideById('searchCatalogDiv');
+ hideById('listCatalogDiv');
+ hideById('addEditCatalogFormDiv');
+ hideById('resultSearchDiv');
+ hideById('editEquipmentStatusDiv');
+
+ jQuery('#loaderDiv').show();
+
+ $.post("getCatalogTypeAttribute.action",
+ {
+ id:catalogTypeId
+ },
+ function(data)
+ {
+ showById('searchCatalogDiv');
+ enable('listAllCatalogBtn');
+ jQuery('#loaderDiv').hide();
+ populateCatalogTypeAttributes( data );
+ },'xml');
+}
+
+function populateCatalogTypeAttributes( data )
+{
+ var searchingAttributeId = document.getElementById("searchingAttributeId");
+ clearList( searchingAttributeId );
+
+ var catalogTypeAttribs = data.getElementsByTagName("catalog-type-attribute");
+ for ( var i = 0; i < catalogTypeAttribs.length; i++ )
+ {
+ var id = catalogTypeAttribs[ i ].getElementsByTagName("id")[0].firstChild.nodeValue;
+ var name = catalogTypeAttribs[ i ].getElementsByTagName("name")[0].firstChild.nodeValue;
+
+ var option = document.createElement("option");
+ option.value = id;
+ option.text = name;
+ option.title = name;
+ searchingAttributeId.add(option, null);
+ }
+}
+
+
+//----------------------------------------------------------------
+//On LoadAllCatalogs
+//----------------------------------------------------------------
+
+function loadAllCatalogs()
+{
+ var catalogType = document.getElementById('catalogType');
+ var catalogTypeId = catalogType.options[ catalogType.selectedIndex ].value;
+
+ if( catalogTypeId == 0 )
+ {
+ showWarningMessage( i18n_select_please_select_catalog_type );
+ return;
+ }
+
+ hideById('addEditCatalogFormDiv');
+ hideById('resultSearchDiv');
+ hideById('uploadCatalogImageDiv');
+
+ showById('selectDiv');
+ showById('searchCatalogDiv');
+
+ jQuery('#loaderDiv').show();
+ contentDiv = 'listCatalogDiv';
+
+ jQuery('#listCatalogDiv').load('getCatalogList.action',{
+ listAll:true,
+ catalogTypeId:catalogTypeId
+ },
+ function(){
+ statusSearching = 0;
+ showById('listCatalogDiv');
+ jQuery('#loaderDiv').hide();
+ });
+ hideLoader();
+}
+
+
+//----------------------------------------------------------------
+//Load Equipments On Filter by catalogType Attribute
+//----------------------------------------------------------------
+function loadCatalogsByFilter( )
+{
+ var catalogType = document.getElementById('catalogType');
+ var catalogTypeId = catalogType.options[ catalogType.selectedIndex ].value;
+ var searchText = document.getElementById('searchText').value;
+
+ if( catalogTypeId == 0 )
+ {
+ showWarningMessage( i18n_select_please_select_catalog_type );
+ return;
+ }
+
+ var catalogTypeAttribute = document.getElementById('searchingAttributeId');
+ var catalogTypeAttributeId = catalogTypeAttribute.options[ catalogTypeAttribute.selectedIndex ].value;
+
+ hideById('addEditCatalogFormDiv');
+ hideById('resultSearchDiv');
+ hideById('uploadCatalogImageDiv');
+ showById('selectDiv');
+ showById('searchCatalogDiv');
+
+ jQuery('#loaderDiv').show();
+ contentDiv = 'listCatalogDiv';
+
+ jQuery('#listCatalogDiv').load('getCatalogList.action',{
+ catalogTypeId:catalogTypeId,
+ catalogTypeAttributeId:catalogTypeAttributeId,
+ searchText:searchText
+ },
+ function(){
+ statusSearching = 0;
+ showById('listCatalogDiv');
+ jQuery('#loaderDiv').hide();
+ });
+ hideLoader();
+}
+
+
+
+//----------------------------------------------------------------
+//Add Catalog
+//----------------------------------------------------------------
+
+function showAddCatalogForm()
+{
+ var catalogType = document.getElementById('catalogType');
+ var catalogTypeId = catalogType.options[ catalogType.selectedIndex ].value;
+
+ if( catalogTypeId == 0 )
+ {
+ showWarningMessage( i18n_select_please_select_catalog_type );
+ return;
+ }
+
+ hideById('listCatalogDiv');
+ hideById('selectDiv');
+ hideById('searchCatalogDiv');
+ hideById('uploadCatalogImageDiv');
+
+ jQuery('#loaderDiv').show();
+ jQuery('#addEditCatalogFormDiv').load('showAddCataLogForm.action',{
+ catalogTypeId:catalogTypeId
+ },
+ function()
+ {
+ showById('addEditCatalogFormDiv');
+ jQuery('#loaderDiv').hide();
+ });
+}
+
+function addCatalog()
+{
+ $.ajax({
+ type: "POST",
+ url: 'addCatalog.action',
+ data: getParamsForDiv('addCatalogFormDiv'),
+ success: function(json) {
+ var type = json.response;
+ jQuery('#resultSearchDiv').dialog('close');
+ loadAllCatalogs();
+ }
+ });
+ return false;
+}
+
+//----------------------------------------------------------------
+//Update Catalog
+//----------------------------------------------------------------
+
+function showUpdateCatalogForm( catalogId )
+{
+ hideById('listCatalogDiv');
+ hideById('selectDiv');
+ hideById('searchCatalogDiv');
+ hideById('uploadCatalogImageDiv');
+
+ setInnerHTML('addEditCatalogFormDiv', '');
+
+ jQuery('#loaderDiv').show();
+ jQuery('#addEditCatalogFormDiv').load('showUpdateCatalogForm.action',
+ {
+ id:catalogId
+ }, function()
+ {
+ showById('addEditCatalogFormDiv');
+ jQuery('#searchCatalogDiv').dialog('close');
+ jQuery('#loaderDiv').hide();
+ });
+
+ jQuery('#resultSearchDiv').dialog('close');
+}
+
+function updateCatalog()
+{
+ $.ajax({
+ type: "POST",
+ url: 'updateCatalog.action',
+ data: getParamsForDiv('addEditCatalogFormDiv'),
+ success: function( json ) {
+ loadAllCatalogs();
+ }
+ });
+}
+
+
+function showUploadCatalogImageForm( catalogId )
+{
+ hideById('listCatalogDiv');
+ hideById('selectDiv');
+ hideById('searchCatalogDiv');
+ hideById('addEditCatalogFormDiv');
+
+ setInnerHTML('uploadCatalogImageDiv', '');
+
+ jQuery('#loaderDiv').show();
+ jQuery('#uploadCatalogImageDiv').load('showUploadImageForm.action',
+ {
+ id:catalogId
+ }, function()
+ {
+ showById('uploadCatalogImageDiv');
+ jQuery('#searchCatalogDiv').dialog('close');
+ jQuery('#loaderDiv').hide();
+ });
+
+ jQuery('#resultSearchDiv').dialog('close');
+}
+
+function uploadCatalogImage()
+{
+ $.ajax({
+ type: "POST",
+ url: 'uploadCatalogImage.action',
+ data: getParamsForDiv('uploadCatalogImageDiv'),
+ success: function( json ) {
+ loadAllCatalogs();
+ }
+ });
+}
+
+
+
+//----------------------------------------------------------------
+//Get Params form Div
+//----------------------------------------------------------------
+
+function getParamsForDiv( catalogDiv )
+{
+ var params = '';
+
+ jQuery("#" + catalogDiv + " :input").each(function()
+ {
+ var elementId = $(this).attr('id');
+
+ if( $(this).attr('type') == 'checkbox' )
+ {
+ var checked = jQuery(this).attr('checked') ? true : false;
+ params += elementId + "=" + checked + "&";
+ }
+ else if( $(this).attr('type') != 'button' )
+ {
+ var value = "";
+ if( jQuery(this).val() != '' )
+ {
+ value = htmlEncode(jQuery(this).val());
+ }
+ params += elementId + "="+ value + "&";
+ }
+
+ });
+
+ //alert( params );
+
+ return params;
+}
=== added file 'local/in/dhis-web-coldchain/src/main/webapp/dhis-web-coldchain/responseCatalogTypeAttributes.vm'
--- local/in/dhis-web-coldchain/src/main/webapp/dhis-web-coldchain/responseCatalogTypeAttributes.vm 1970-01-01 00:00:00 +0000
+++ local/in/dhis-web-coldchain/src/main/webapp/dhis-web-coldchain/responseCatalogTypeAttributes.vm 2012-06-26 08:38:56 +0000
@@ -0,0 +1,10 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<catalog-type-attributes>
+ #foreach( $catalogTypeAttribute in $catalogTypeAttributes )
+ <catalog-type-attribute>
+ <id>$catalogTypeAttribute.id</id>
+ <name>$catalogTypeAttribute.name</name>
+ </catalog-type-attribute>
+ #end
+</catalog-type-attributes>
\ No newline at end of file
=== added file 'local/in/dhis-web-coldchain/src/main/webapp/dhis-web-coldchain/selectCatalog.vm'
--- local/in/dhis-web-coldchain/src/main/webapp/dhis-web-coldchain/selectCatalog.vm 1970-01-01 00:00:00 +0000
+++ local/in/dhis-web-coldchain/src/main/webapp/dhis-web-coldchain/selectCatalog.vm 2012-06-26 08:38:56 +0000
@@ -0,0 +1,61 @@
+<div id='selectDiv'>
+
+ <h3>$i18n.getString( "catalog_management" ) #openHelp( "catalog" )</h3>
+
+ <table>
+ <tr>
+ <td><label>$i18n.getString( "catalogType" )</label></td>
+ <td style="padding-right:5px">
+ <select id="catalogType" style="min-width:16em" onchange="getCatalogTypeChange( this.value )">
+ <option value="0">$i18n.getString( "please_select_catalog_type" )</option>
+ #foreach( $catalogType in $catalogTypes )
+ <option value="$catalogType.id">$catalogType.name</option>
+ #end
+ </select>
+ </td>
+ <td style="padding-right:5px"><input type="button" id='listAllCatalogBtn' value="$i18n.getString( 'list_all_catalogs' )" onclick='loadAllCatalogs();'></td>
+ <td><span id='warnmessage' style='color:red'></span></td>
+ </tr>
+ </table>
+
+</div>
+<div id='searchCatalogDiv' style='display:none'>
+ <table id='advancedSearchTB'>
+ <tbody>
+ <tr id='advSearchBox0'>
+ <td id='searchingAttributeIdTD'>
+ <select id="searchingAttributeId" name="searchingAttributeId" style="width:20.2em" #if( $catalogTypeAttributes.size() == 0 ) disabled="disabled" #end >
+ </select>
+ <em title="$i18n.getString( "required" )" class="required">*</em></label>
+ </td>
+ <td>
+ <input type="text" id="searchText" name="searchText" maxlength="30" style="width:20em" value="$!searchText">
+
+ </td>
+ <td></td>
+ <td><input type="button" value='$i18n.getString( "search" )' style="width:8.2em" onclick='loadCatalogsByFilter();'></td>
+ <td> </td>
+ <td><input type="button" value='$i18n.getString( "add_new" )' style="width:8.2em" onclick="showAddCatalogForm();"></td>
+ </tr>
+ </tbody>
+ </table>
+</div>
+
+
+
+<div id='listCatalogDiv'></div> <!-- List All/Filtered Catalogs -->
+<div id='addEditCatalogFormDiv'></div> <!-- Add Catalog Form -->
+<div id='uploadCatalogImageDiv'></div> <!-- Upload catalog Image -->
+<div id='resultSearchDiv'></div> <!-- List searching Equipment -->
+
+
+#parse( "/dhis-web-commons/loader/loader.vm" )
+
+
+
+<script>
+ var i18n_equipment_status_history = '$encoder.jsEscape( $i18n.getString( "equipment_status_history" ) , "'")';
+ var i18n_equipment_details = '$encoder.jsEscape( $i18n.getString( "equipment_details" ) , "'")';
+ var i18n_select_please_select_catalog_type = '$encoder.jsEscape( $i18n.getString( "please_select_catalog_type" ) , "'")';
+</script>
+
=== modified file 'local/in/dhis-web-coldchain/src/main/webapp/dhis-web-coldchain/showAddCatalogForm.vm'
--- local/in/dhis-web-coldchain/src/main/webapp/dhis-web-coldchain/showAddCatalogForm.vm 2012-05-30 10:46:26 +0000
+++ local/in/dhis-web-coldchain/src/main/webapp/dhis-web-coldchain/showAddCatalogForm.vm 2012-06-26 08:38:56 +0000
@@ -1,3 +1,4 @@
+<script type="text/javascript" src="javascript/catalog.js"></script>
## Macro for generating the jQuery validation rules
#macro( validate $type $require )
#if( $type == "NUMBER" )
@@ -6,18 +7,52 @@
{validate:{required:true}}
#end
#end
+
+<script>
+
+ jQuery(document).ready( function(){
+
+ currentDiv = 'catalogForm';
+ isSubmit = true;
+
+ jQuery("#catalogForm").validate({
+ meta:"validate"
+ ,errorElement:"span"
+ ,submitHandler: function(form)
+ {
+ if( isSubmit )
+ {
+ addCatalog();
+ }
+ }
+ });
+ });
+
+</script>
+
<script type="text/javascript">
checkValueIsExist( "name", "validateCatalog.action");
</script>
+<h3>$i18n.getString( "add_new_catalog" )</h3>
+
+<form id="catalogForm" name="catalogForm" method="post" >
+<input type="hidden" id="catalogType" name="catalogType" value="$catalogType.id" />
+
+ <table>
+ <tr>
+ <td>$i18n.getString( "catalogType" ) : </th>
+ <td>$catalogType.name</th>
+ </tr>
+ </table>
<!-- ATTRIBUTES -->
<table>
-<td>
-<td>
-
+ <tr><th colspan="2" class="heading-column">$i18n.getString( "catalogType_details" )</th></tr>
+<tr>
+<td>
<table>
<tr><td> </td></tr>
#if ( $catalogTypeAttributes.size() > 0)
- <tr><th colspan="2" class="heading-column">$i18n.getString( "catalogType_details" )</th></tr>
+
<tr>
<td><label>$i18n.getString( "name" ) <em title="$i18n.getString( 'required' )" class="required">*</em></label></td>
<td><input type="text" id="name" name="name" class="{validate:{required:true, rangelength:[4,160]}}"/></td>
@@ -27,7 +62,7 @@
<td><label>$i18n.getString( "description" ) <em title="$i18n.getString( 'required' )" class="required">*</em></label></td>
<td><input type="text" id="description" name="description" class="{validate:{required:true, minlength:4}}"/></td>
</tr>
-##if ( $catalogTypeAttributes.size() > 0)
+
<!--<tr><th colspan="2" class="heading-column">$i18n.getString( "catalogType_attribute" )</th></tr>-->
#foreach($attribute in $catalogTypeAttributes )
<tr>
@@ -66,4 +101,14 @@
<img src="showCatalogTypeImage.action?id=$catalogType.id" style="width:200px;height:200px;">
</td>
</tr>
-</table>
\ No newline at end of file
+</table>
+ <p>
+ <input type="submit" class="button" value="$i18n.getString( 'add' )"/>
+ <input type="button" class="button" value="$i18n.getString( 'back' )" onclick="loadAllCatalogs();"/>
+ </p>
+</form>
+<script>
+ var i18n_error_connect_to_server = '$encoder.jsEscape( $i18n.getString( "error_connect_to_server" ) , "'" )';
+ var i18n_add_equipment_successfully = '$encoder.jsEscape( $i18n.getString( "add_equipment_successfully" ) , "'" )';
+
+</script>
\ No newline at end of file
=== modified file 'local/in/dhis-web-coldchain/src/main/webapp/dhis-web-coldchain/updateCatalogForm.vm'
--- local/in/dhis-web-coldchain/src/main/webapp/dhis-web-coldchain/updateCatalogForm.vm 2012-06-18 09:15:09 +0000
+++ local/in/dhis-web-coldchain/src/main/webapp/dhis-web-coldchain/updateCatalogForm.vm 2012-06-26 08:38:56 +0000
@@ -1,3 +1,4 @@
+<script type="text/javascript" src="javascript/catalog.js"></script>
#macro( validate $type $require )
#if( $type == "NUMBER" )
{validate:{ number:true #if($require), required:true #end }}
@@ -7,11 +8,33 @@
{validate:{required:true}}
#end
#end
-<script type="text/javascript" src="javascript/updateCatalogForm.js"></script>
-
+<script>
+
+ jQuery(document).ready( function(){
+
+ currentDiv = 'updateCatalogForm';
+ isSubmit = true;
+
+ jQuery("#updateCatalogForm").validate({
+ meta:"validate"
+ ,errorElement:"span"
+ ,submitHandler: function(form)
+ {
+ if( isSubmit )
+ {
+ updateCatalog();
+ }
+ }
+ });
+ });
+
+</script>
+<script type="text/javascript">
+ checkValueIsExist( "name", "validateCatalog.action", {id:getFieldValue('id')});
+</script>
<h3>$i18n.getString( "edit_catalog" )</h3>
<p>
-<form id="updateCatalogForm" name="updateCatalogForm" action="updateCatalog.action" method="post" >
+<form id="updateCatalogForm" name="updateCatalogForm" method="post" >
<div>
<input type="hidden" id="id" name="id" value="$catalog.id">
<input type="hidden" id="catalogID" name="catalogID" value="$catalog.id">
@@ -32,7 +55,7 @@
<td class='text-column'><label for="description">$i18n.getString( "description" )<em title="$i18n.getString( 'required' )" class="required">*</em></label></td>
<td class="input-column" ><input type="text" id="description" name="description" value="$!catalog.description" class="{validate:{required:true, minlength:4}}"></td>
</tr>
--->
+
<tr>
<td class='text-column'><label>$i18n.getString( "catalogType" ) <em title="$i18n.getString( 'required' )" class="required">*</em></label></td>
<td class="input-column" >
@@ -44,6 +67,11 @@
</select>
</td>
</tr>
+-->
+ <tr>
+ <td>$i18n.getString( "catalogType" ) : </td>
+ <td>$catalog.catalogType.name</td>
+ </tr>
<!-- ATTRIBUTES -->
<tr><td> </td><td> </td></tr>
<tr><th colspan="2" class="heading-column">$i18n.getString( "catalogType_details" )</th></tr>
@@ -101,8 +129,13 @@
</table>
<p>
<input type="submit" class='button' value="$i18n.getString( 'update' )" >
- <input type="button" value="$i18n.getString( 'cancel' )" onclick="window.location.href='catalog.action'" />
+ <!--<input type="button" value="$i18n.getString( 'cancel' )" onclick="window.location.href='catalog.action'" />-->
+ <input type="button" class="button" value="$i18n.getString( 'back' )" onclick="loadAllCatalogs();"/>
</p>
</form>
-<!-- <img src="pulpit.jpg" alt="Pulpit rock" width="304" height="228" /> -->
\ No newline at end of file
+<!-- <img src="pulpit.jpg" alt="Pulpit rock" width="304" height="228" /> -->
+<script>
+ var i18n_error_connect_to_server = '$encoder.jsEscape( $i18n.getString( "error_connect_to_server" ) , "'" )';
+ var i18n_add_equipment_successfully = '$encoder.jsEscape( $i18n.getString( "updated_equipment_successfully" ) , "'" )';
+</script>
\ No newline at end of file
=== modified file 'local/in/dhis-web-coldchain/src/main/webapp/dhis-web-coldchain/updateEquipmentForm.vm'
--- local/in/dhis-web-coldchain/src/main/webapp/dhis-web-coldchain/updateEquipmentForm.vm 2012-06-18 09:15:09 +0000
+++ local/in/dhis-web-coldchain/src/main/webapp/dhis-web-coldchain/updateEquipmentForm.vm 2012-06-26 08:38:56 +0000
@@ -8,7 +8,6 @@
#end
#end
-
<script>
jQuery(document).ready( function(){
=== modified file 'local/in/dhis-web-coldchain/src/main/webapp/dhis-web-coldchain/uploadCatalogImageForm.vm'
--- local/in/dhis-web-coldchain/src/main/webapp/dhis-web-coldchain/uploadCatalogImageForm.vm 2012-06-21 12:52:08 +0000
+++ local/in/dhis-web-coldchain/src/main/webapp/dhis-web-coldchain/uploadCatalogImageForm.vm 2012-06-26 08:38:56 +0000
@@ -1,9 +1,29 @@
-
-<script type="text/javascript" src="javascript/uploadCatalogImageForm.js"></script>
-
+<script type="text/javascript" src="javascript/catalog.js"></script>
+<!--<script type="text/javascript" src="javascript/uploadCatalogImageForm.js"></script>-->
+<script>
+
+ jQuery(document).ready( function(){
+
+ currentDiv = 'uploadCatalogImageForm';
+ isSubmit = true;
+
+ jQuery("#uploadCatalogImageForm").validate({
+ meta:"validate"
+ ,errorElement:"span"
+ ,submitHandler: function(form)
+ {
+ if( isSubmit )
+ {
+ uploadCatalogImage();
+ }
+ }
+ });
+ });
+
+</script>
<h3>$i18n.getString( "upload_catalog_image" )</h3>
-
-<form id="uploadCatalogImageForm" name="uploadCatalogImageForm" action="uploadCatalogImage.action" method="post" enctype="multipart/form-data">
+<!--<form id="uploadCatalogImageForm" name="uploadCatalogImageForm" action="uploadCatalogImage.action" method="post" enctype="multipart/form-data">-->
+<form id="uploadCatalogImageForm" name="uploadCatalogImageForm" method="post" enctype="multipart/form-data">
<div>
<input type="hidden" id="id" name="id" value="$catalog.id" />
@@ -45,7 +65,8 @@
<td> </td>
<td>
<input type="submit" class='button' value="$i18n.getString( 'upload_image' )" >
- <input type="button" value="$i18n.getString( 'cancel' )" onclick="window.location.href='catalog.action'" />
+ <!--<input type="button" value="$i18n.getString( 'cancel' )" onclick="window.location.href='catalog.action'" />-->
+ <input type="button" class="button" value="$i18n.getString( 'cancel' )" onclick="loadAllCatalogs();"/>
</td>
</tr>
</table>