package com.dev.swms.client.ui.page;

import com.google.gwt.user.client.ui.HorizontalPanel;
import com.google.gwt.user.client.ui.TextBox;
import com.gwtext.client.widgets.form.Label;
import com.dev.swms.client.ui.data.Page_PA_DataAccessor;
import com.dev.energy.client.message.IMessagePage;
import com.dev.energy.client.ui.panel.AbstractSupportPanel;
import com.dev.energy.client.utils.LocaleUtils;

public class Sub_PickTicketInfo_Panel extends AbstractSupportPanel {

	protected final static String DEFAULT_NAME = "pickTicketInfo_Panel";
		
	transient HorizontalPanel subPanel;
	transient TextBox pickTicketCodeTextBox;
	transient TextBox ordersQuantityTextBox;
	transient TextBox preAllocateQuantityTextBox;
	transient TextBox allocateQuantityTextBox;
	transient TextBox pickItemQuantityTextBox;
	
	transient Label pickTicketCodeLabel;
	transient Label ordersQuantityLabel;
	transient Label preAllocateQuantityLabel;
	transient Label allocateQuantityLabel;	
	transient Label pickItemQuantityLabel;
	private String flag;
		
	
	
	public Sub_PickTicketInfo_Panel(IMessagePage page) {
		super(page, DEFAULT_NAME);
		this.drawWidget();
	}
	

	
	protected void drawWidget(){


		flag = curPADataAccessor().getFlag();
		subPanel = new HorizontalPanel();
		subPanel.setWidth("100%");
		
		pickTicketCodeLabel = new Label(LocaleUtils.getText("waveDoc.code"));
//		pickTicketCodeLabel.setWidth("80px");
		pickTicketCodeTextBox = new TextBox();
//		pickTicketCodeTextBox.setWidth("80px");
		pickTicketCodeTextBox.setEnabled(false);
		
		ordersQuantityLabel = new Label(LocaleUtils.getText("pickTicket.orderQuantity"));
//		ordersQuantityLabel.setWidth("80px");
		ordersQuantityTextBox = new TextBox();
//		ordersQuantityTextBox.setWidth("80px");
		ordersQuantityTextBox.setEnabled(false);
		
		preAllocateQuantityLabel = new Label(LocaleUtils.getText("pickTicket.preAllocatedQuantity"));
//		preAllocateQuantityLabel.setWidth("80px");
		preAllocateQuantityTextBox = new TextBox();
//		preAllocateQuantityTextBox.setWidth("80px");
		preAllocateQuantityTextBox.setEnabled(false);
		

		allocateQuantityLabel = new Label(LocaleUtils.getText("pickTicket.allocatedQuantity"));
//		allocateQuantityLabel.setWidth("80px");
		allocateQuantityTextBox = new TextBox();
//		allocateQuantityTextBox.setWidth("80px");
		allocateQuantityTextBox.setEnabled(false);
		
		pickItemQuantityLabel = new Label(LocaleUtils.getText("pickTicket.pickedQuantity"));
//		pickItemQuantityLabel.setWidth("80px");
		pickItemQuantityTextBox = new TextBox();
//		pickItemQuantityTextBox.setWidth("80px");
		pickItemQuantityTextBox.setEnabled(false);
		

		
		if(flag != "waveDocPage"){
			pickTicketCodeLabel.setText(LocaleUtils.getText("pickTicket.code"));
//			preAllocateQuantityLabel.setVisible(false);
//			preAllocateQuantityTextBox.setVisible(false);
			pickTicketCodeLabel.setWidth("80px");
			pickTicketCodeTextBox.setWidth("160px");
			ordersQuantityLabel.setWidth("80px");
			ordersQuantityTextBox.setWidth("90px");
			preAllocateQuantityLabel.setWidth("100px");
			preAllocateQuantityTextBox.setWidth("90px");
			allocateQuantityLabel.setWidth("80px");
			allocateQuantityTextBox.setWidth("80px");
			pickItemQuantityLabel.setWidth("80px");
			pickItemQuantityTextBox.setWidth("80px");
			
			
			subPanel.add(pickTicketCodeLabel);
			subPanel.add(pickTicketCodeTextBox);
			subPanel.add(ordersQuantityLabel);
			subPanel.add(ordersQuantityTextBox);
			subPanel.add(preAllocateQuantityLabel);
			subPanel.add(preAllocateQuantityTextBox);
			subPanel.add(allocateQuantityLabel);
			subPanel.add(allocateQuantityTextBox);
			subPanel.add(pickItemQuantityLabel);
			subPanel.add(pickItemQuantityTextBox);
			
		}else{
		
			subPanel.add(pickTicketCodeLabel);
			subPanel.add(pickTicketCodeTextBox);
			subPanel.add(ordersQuantityLabel);
			subPanel.add(ordersQuantityTextBox);
//			subPanel.add(preAllocateQuantityLabel);
//			subPanel.add(preAllocateQuantityTextBox);
			subPanel.add(allocateQuantityLabel);
			subPanel.add(allocateQuantityTextBox);
			subPanel.add(pickItemQuantityLabel);
			subPanel.add(pickItemQuantityTextBox);
		}
		this.setSize("950px", "25px");
		this.setBodyBorder(false);
		this.add(subPanel);	
	}

	public Page_PA_DataAccessor curPADataAccessor() {
		return (Page_PA_DataAccessor)super.getData();
	}

	
	public void doDispath(String message){
		super.doDispath(message);
		if(Page_PA_DataAccessor.INIT_PICK_TICKETS_INFO.equals(message) || Page_PA_DataAccessor.INIT_WAVE_DOC_INFO.equals(message)){

				pickTicketCodeTextBox.setText(String.valueOf(this.curPADataAccessor().currentPickTicket().getCode()));
				ordersQuantityTextBox.setText(String.valueOf((int)this.curPADataAccessor().currentPickTicket().getOrderQuantity()));
				preAllocateQuantityTextBox.setText(String.valueOf((int)this.curPADataAccessor().currentPickTicket().getPreAllocatedQuantity()));
				allocateQuantityTextBox.setText(String.valueOf((int)this.curPADataAccessor().currentPickTicket().getAllocatedQuantity()));
				pickItemQuantityTextBox.setText(String.valueOf((int)this.curPADataAccessor().currentPickTicket().getPickedQuantity()));			
		}
	}

}
