Subversion Repositories SmartDukaan

Rev

Rev 6241 | Rev 6532 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 6241 Rev 6530
Line 1... Line 1...
1
package in.shop2020.catalog.dashboard.client;
1
package in.shop2020.catalog.dashboard.client;
2
 
2
 
3
import in.shop2020.catalog.dashboard.shared.Item;
3
import in.shop2020.catalog.dashboard.shared.Item;
4
import in.shop2020.catalog.dashboard.shared.ItemInventory;
4
import in.shop2020.catalog.dashboard.shared.ItemInventory;
-
 
5
import in.shop2020.catalog.dashboard.shared.ItemWarehouse;
5
import in.shop2020.catalog.dashboard.shared.SourcePricings;
6
import in.shop2020.catalog.dashboard.shared.SourcePricings;
6
import in.shop2020.catalog.dashboard.shared.Utils;
7
import in.shop2020.catalog.dashboard.shared.Utils;
7
import in.shop2020.catalog.dashboard.shared.VendorItemMapping;
8
import in.shop2020.catalog.dashboard.shared.VendorItemMapping;
8
import in.shop2020.catalog.dashboard.shared.VendorPricings;
9
import in.shop2020.catalog.dashboard.shared.VendorPricings;
9
import in.shop2020.catalog.dashboard.shared.VoucherItemMapping;
10
import in.shop2020.catalog.dashboard.shared.VoucherItemMapping;
Line 70... Line 71...
70
                      TABLE_INDEX_WAREHOUSE_INVA = 2,
71
                      TABLE_INDEX_WAREHOUSE_INVA = 2,
71
                      TABLE_INDEX_WAREHOUSE_INVR = 3,
72
                      TABLE_INDEX_WAREHOUSE_INVR = 3,
72
                      TABLE_INDEX_WAREHOUSE_GET_BUTTON = 4,
73
                      TABLE_INDEX_WAREHOUSE_GET_BUTTON = 4,
73
                      TABLE_INDEX_WAREHOUSE_UPDATE_BUTTON = 5;
74
                      TABLE_INDEX_WAREHOUSE_UPDATE_BUTTON = 5;
74
    
75
    
-
 
76
    private final int TABLE_INDEX_WAREHOUSE_NAME = 0,
-
 
77
    				  TABLE_INDEX_WAREHOUSE_ADD_DEL_BUTTON = 1;    
-
 
78
    
75
    private final int TABLE_INDEX_SIMILAR_ITEMS_CATALOG_ITEM_ID = 0,
79
    private final int TABLE_INDEX_SIMILAR_ITEMS_CATALOG_ITEM_ID = 0,
76
                      TABLE_INDEX_SIMILAR_ITEMS_PRODUCT_GROUP = 1,
80
                      TABLE_INDEX_SIMILAR_ITEMS_PRODUCT_GROUP = 1,
77
                      TABLE_INDEX_SIMILAR_ITEMS_BRAND = 2,
81
                      TABLE_INDEX_SIMILAR_ITEMS_BRAND = 2,
78
                      TABLE_INDEX_SIMILAR_ITEMS_MODEL_NUMBER = 3,
82
                      TABLE_INDEX_SIMILAR_ITEMS_MODEL_NUMBER = 3,
79
                      TABLE_INDEX_SIMILAR_ITEMS_MODEL_NAME = 4,
83
                      TABLE_INDEX_SIMILAR_ITEMS_MODEL_NAME = 4,
Line 136... Line 140...
136
    @UiField DateBox startDate, expectedArrivalDate, comingSoonStartDate;
140
    @UiField DateBox startDate, expectedArrivalDate, comingSoonStartDate;
137
    @UiField FlexTable headerSimilarItems, tableSimilarItems;
141
    @UiField FlexTable headerSimilarItems, tableSimilarItems;
138
    @UiField ListBox preferredVendor;
142
    @UiField ListBox preferredVendor;
139
    @UiField Button comingSoonButton;
143
    @UiField Button comingSoonButton;
140
    @UiField FlexTable headerVouchers, tableVouchers;
144
    @UiField FlexTable headerVouchers, tableVouchers;
-
 
145
    @UiField FlexTable headerIgnoredWarehouse,tableIgnoredWarehouse;
141
 
146
 
142
    public ItemDetails(Item item){
147
    public ItemDetails(Item item){
143
        this();
148
        this();
144
        setItemDetails(item);
149
        setItemDetails(item);
145
    }
150
    }
Line 150... Line 155...
150
        initVendorKeysHeader();
155
        initVendorKeysHeader();
151
        initVendorPricingHeader();
156
        initVendorPricingHeader();
152
        initSourcePricingHeader();
157
        initSourcePricingHeader();
153
        initSimilarItemList();
158
        initSimilarItemList();
154
        initVoucherHeader();
159
        initVoucherHeader();
-
 
160
        initIgnoredWarehouseHeader();
155
        preferredVendor.addItem("null");
161
        preferredVendor.addItem("null");
156
        getConfigdataforPriceCompare();
162
        getConfigdataforPriceCompare();
157
    }
163
    }
158
 
164
 
159
    public void getConfigdataforPriceCompare(){
165
    public void getConfigdataforPriceCompare(){
Line 256... Line 262...
256
        updateVendorKeysTable(item.getVendorKeysMap());
262
        updateVendorKeysTable(item.getVendorKeysMap());
257
        updateVendorPricingTable(item.getVendorPricesMap());
263
        updateVendorPricingTable(item.getVendorPricesMap());
258
        updateSourcePricingTable(item.getSourcePricesMap());
264
        updateSourcePricingTable(item.getSourcePricesMap());
259
        updateSimilarItemsTable(item.getSimilarItems());
265
        updateSimilarItemsTable(item.getSimilarItems());
260
        updateVoucherTable(item.getVouchersMap());
266
        updateVoucherTable(item.getVouchersMap());
-
 
267
        updateTableIgnoredWarehouse();
261
    }
268
    }
262
 
269
 
263
    /**
270
    /**
264
     * initialise item availability table header.
271
     * initialise item availability table header.
265
     */
272
     */
Line 565... Line 572...
565
				});
572
				});
566
            	addSimilarItemDialog.show();
573
            	addSimilarItemDialog.show();
567
            }
574
            }
568
        });
575
        });
569
    }
576
    }
-
 
577
    
-
 
578
    private void initIgnoredWarehouseHeader(){
-
 
579
    	headerIgnoredWarehouse.getColumnFormatter().setWidth(TABLE_INDEX_WAREHOUSE_NAME, "100px");
-
 
580
    	headerIgnoredWarehouse.getColumnFormatter().setWidth(TABLE_INDEX_WAREHOUSE_ADD_DEL_BUTTON, BUTTON_WIDTH);
-
 
581
    	headerIgnoredWarehouse.setText(0, TABLE_INDEX_WAREHOUSE_NAME, "Warehouse Desc");
-
 
582
    	Button addButton = new Button("Add");
-
 
583
    	headerIgnoredWarehouse.setWidget(0,TABLE_INDEX_WAREHOUSE_ADD_DEL_BUTTON,addButton);
-
 
584
        addButton.addClickHandler(new ClickHandler() {
-
 
585
            @Override
-
 
586
            public void onClick(ClickEvent event) {
-
 
587
            	DeactivateWarehouseDialog deactivateWarehouseDialog = new DeactivateWarehouseDialog(new ArrayList<Long>(item.getVendorPricesMap().keySet()));
-
 
588
            	deactivateWarehouseDialog.updateButton.setText("Add");
-
 
589
        	    deactivateWarehouseDialog.setDeactivateWarehouseListener(new DeactivateWarehouseDialog.DeactivateWarehouseListener(){
-
 
590
					@Override
-
 
591
					public boolean onUpdate(final long warehouseId) {
-
 
592
						Window.alert("On update called.");
-
 
593
					       if(Utils.getignoredInventoryUpdateItemsIdsWarehouseIds().contains(new ItemWarehouse(item.getId(),warehouseId))) {
-
 
594
	                            Window.alert("Warehouse already deactivated");
-
 
595
	                            return false;
-
 
596
	                        }
-
 
597
					       Window.alert("After contains.");
-
 
598
	                       catalogService.addtoIgnoredInventoryUpdateItemsIdsWarehouseIds(item.getId(),warehouseId,new AsyncCallback<Boolean>() {
-
 
599
		                        @Override
-
 
600
		                        public void onSuccess(Boolean result) {
-
 
601
		                        	if(result) {
-
 
602
		                        		Utils.getignoredInventoryUpdateItemsIdsWarehouseIds().add(new ItemWarehouse(item.getId(),warehouseId));
-
 
603
		                                Window.alert("Warehouse deactivated successfully");
-
 
604
		                            }
-
 
605
		                            else {
-
 
606
		                                GWT.log("Error Deactivating warehouse");
-
 
607
		                                Window.alert("Error Deactivating warehouse");
-
 
608
		                            }
-
 
609
		                        }
-
 
610
		                        @Override
-
 
611
		                        public void onFailure(Throwable caught) {
-
 
612
		                            caught.printStackTrace();
-
 
613
		                            Window.alert("Error Deactivating warehouse");
-
 
614
		                        }
-
 
615
		                    });
-
 
616
	                        return true;
-
 
617
	                    }
-
 
618
					});
-
 
619
            	deactivateWarehouseDialog.show();
-
 
620
            }
-
 
621
        });
-
 
622
    }
-
 
623
    
570
 
624
 
571
    private void initVoucherHeader(){
625
    private void initVoucherHeader(){
572
    	headerVouchers.getColumnFormatter().setWidth(TABLE_INDEX_VOUCHERS_TYPE, ITEM_KEY_WIDTH);
626
    	headerVouchers.getColumnFormatter().setWidth(TABLE_INDEX_VOUCHERS_TYPE, ITEM_KEY_WIDTH);
573
    	headerVouchers.getColumnFormatter().setWidth(TABLE_INDEX_VOUCHERS_AMOUNT, VENDOR_DESC_WIDTH);
627
    	headerVouchers.getColumnFormatter().setWidth(TABLE_INDEX_VOUCHERS_AMOUNT, VENDOR_DESC_WIDTH);
574
    	headerVouchers.getColumnFormatter().setWidth(TABLE_INDEX_VOUCHERS_ADD_EDIT_BUTTON, BUTTON_WIDTH);
628
    	headerVouchers.getColumnFormatter().setWidth(TABLE_INDEX_VOUCHERS_ADD_EDIT_BUTTON, BUTTON_WIDTH);
Line 625... Line 679...
625
 
679
 
626
    /**
680
    /**
627
     * Clear and populate item availability table.
681
     * Clear and populate item availability table.
628
     * @param availabilityMap
682
     * @param availabilityMap
629
     */
683
     */
-
 
684
    
630
    private void updateAvailabilityTable(Map<Long, ItemInventory> itemInventoryMap){
685
    private void updateAvailabilityTable(Map<Long, ItemInventory> itemInventoryMap){
631
        availabilityTable.removeAllRows();
686
        availabilityTable.removeAllRows();
632
        if(itemInventoryMap == null || itemInventoryMap.isEmpty()) {
687
        if(itemInventoryMap == null || itemInventoryMap.isEmpty()) {
633
            return;
688
            return;
634
        }
689
        }
Line 935... Line 990...
935
                        }
990
                        }
936
                    });
991
                    });
937
                }
992
                }
938
            });
993
            });
939
            i++;
994
            i++;
-
 
995
        }
-
 
996
    }
-
 
997
    private void updateTableIgnoredWarehouse(){
-
 
998
    	tableIgnoredWarehouse.removeAllRows();
-
 
999
    	List<ItemWarehouse> itemWarehouses = Utils.getignoredInventoryUpdateItemsIdsWarehouseIds();
-
 
1000
    	Map<Long,String> ignoredWarehouses = null;
-
 
1001
    	for(ItemWarehouse itemWarehouse:itemWarehouses){
-
 
1002
    		if(itemWarehouse.getItemId()==item.getId()){
-
 
1003
    			ignoredWarehouses.put(itemWarehouse.getWarehouseId(),Utils.getAllWarehouses().get(itemWarehouse.getWarehouseId()));	
-
 
1004
    		}
-
 
1005
    		
-
 
1006
    	}		
-
 
1007
    	tableIgnoredWarehouse.getColumnFormatter().setWidth(TABLE_INDEX_WAREHOUSE_NAME, "100px");
-
 
1008
        tableIgnoredWarehouse.getColumnFormatter().setWidth(TABLE_INDEX_WAREHOUSE_ADD_DEL_BUTTON, BUTTON_WIDTH);
-
 
1009
        
-
 
1010
        int i=0;
-
 
1011
        for(final Map.Entry<Long,String> entry : ignoredWarehouses.entrySet()){
-
 
1012
        	tableIgnoredWarehouse.setText(i,TABLE_INDEX_WAREHOUSE_NAME,entry.getValue());
-
 
1013
        	Button deleteButton = new Button("Delete");
-
 
1014
            tableVouchers.setWidget(i, TABLE_INDEX_WAREHOUSE_ADD_DEL_BUTTON, deleteButton);
-
 
1015
            deleteButton.addClickHandler(new ClickHandler() {
-
 
1016
                @Override
-
 
1017
                public void onClick(ClickEvent event) {
-
 
1018
                    Cell cell = tableVouchers.getCellForEvent(event);
-
 
1019
                    final int row = cell.getRowIndex();
-
 
1020
                    catalogService.deleteFromIgnoredInventoryUpdateItemsIdsWarehouseIds(item.getCatalogItemId(),entry.getKey(), new AsyncCallback<Boolean>() {
-
 
1021
                        @Override
-
 
1022
                        public void onSuccess(Boolean result) {
-
 
1023
                            if(result) {
-
 
1024
                                GWT.log("Warehouse will now be in sync");
-
 
1025
                                tableVouchers.removeRow(row);
-
 
1026
                                Window.alert("Warehouse deleted from list ");
-
 
1027
                                Utils.getignoredInventoryUpdateItemsIdsWarehouseIds().remove(new ItemWarehouse(item.getCatalogItemId(),entry.getKey()));
-
 
1028
                                }
-
 
1029
                            else {
-
 
1030
                                GWT.log("Error deleting Warehouse");
-
 
1031
                                Window.alert("Error deleting Warehouse");
-
 
1032
                            }
-
 
1033
                        }
-
 
1034
                        @Override
-
 
1035
                        public void onFailure(Throwable caught) {
-
 
1036
                            caught.printStackTrace();
-
 
1037
                            Window.alert("Error deleting Warehouse");
-
 
1038
                        }
-
 
1039
                    });
-
 
1040
                }
-
 
1041
            });
-
 
1042
            i++;
940
        }
1043
        }
941
    }
1044
    }
942
 
1045
 
943
    /**
1046
    /**
944
     * called on the click event of update item button in ItemActions
1047
     * called on the click event of update item button in ItemActions