PageRenderTime 46ms CodeModel.GetById 8ms app.highlight 32ms RepoModel.GetById 1ms app.codeStats 0ms

/webccr/src/com/emis/caesarui/webccr/webccr.java

https://bitbucket.org/sanliou/synccr
Java | 800 lines | 559 code | 125 blank | 116 comment | 19 complexity | 0fdeb69bd10710737787f2207a87e982 MD5 | raw file
  1package com.emis.caesarui.webccr;
  2
  3
  4import com.emis.caesar.emisComponents;
  5import com.emis.caesar.emisUI;
  6import com.emis.caesar.emisUILoader;
  7import com.emis.caesar.senao.unit.TCcr;
  8import com.emis.caesar.senao.util.CcrUtil;
  9import com.emis.caesar.senao.util.UU2Util;
 10import com.emis.caesarui.webccr.button.TDynBtnFactory;
 11import com.emis.caesarui.webccr.core.PromotionInfoList;
 12import com.emis.caesarui.webccr.core.PromotionMgr;
 13import com.emis.caesarui.webccr.listener.TCcrKeyPressHandler;
 14import com.emis.caesarui.webccr.printer.emisPrinter;
 15import com.emis.caesarui.webccr.printer.emisPrinterFactory;
 16import com.emis.caesarui.webccr.ui.table.TSalePayTable;
 17import com.emis.caesarui.webccr.ui.table.TSalesTable;
 18import com.emis.db.emisProp;
 19import com.emis.servlet.jQueryServlet;
 20import com.emis.user.emisAuthFactory;
 21import com.emis.util.emisUtil;
 22import com.vaadin.annotations.Theme;
 23import com.vaadin.annotations.VaadinServletConfiguration;
 24import com.vaadin.event.FieldEvents;
 25import com.vaadin.event.LayoutEvents;
 26import com.vaadin.server.VaadinRequest;
 27import com.vaadin.server.VaadinService;
 28import com.vaadin.server.WrappedSession;
 29import com.vaadin.shared.communication.PushMode;
 30import com.vaadin.ui.*;
 31import com.vaadin.ui.Window.CloseEvent;
 32import com.vaadin.ui.Window.CloseListener;
 33import de.steinwedel.messagebox.ButtonOption;
 34import de.steinwedel.messagebox.MessageBox;
 35import elemental.json.JsonArray;
 36
 37import javax.servlet.annotation.WebServlet;
 38import java.util.HashMap;
 39
 40@SuppressWarnings("serial")
 41@Theme("caesar")
 42public class webccr extends emisUI {
 43
 44  @WebServlet(value = {"/webccr/*"}, asyncSupported = true)
 45  @VaadinServletConfiguration(productionMode = true, ui = webccr.class)
 46
 47  //public static class Servlet extends VaadinServlet {
 48  public static class Servlet extends jQueryServlet {
 49  }
 50
 51  // here we define some architecture flag
 52  public static final boolean bDevelopMode = true;
 53  public static final boolean bUseJavaScriptButton = true;
 54
 55  // if it is cloud db mode , you have to use localThreadFilter
 56  public static final boolean bCouldDBMode = true;
 57
 58  /*
 59   * 交易結束後,因為要多按一個 key, 或 5 秒後自動 reset 的機制,這邊需要一個 control flag
 60   */
 61  boolean m_bNewTransactionState = false;
 62
 63  private Label FlSysDate_;//交易日期
 64  private Label FlSysTime_;//時間
 65  private Label FlStoreNo_;//門市
 66  private Label FlIdNo_;//機號
 67  private Label FlInvNo_;//發票號碼
 68  private Label FlSlNo_;//交易序號
 69  private Label FlSaler;//售貨員
 70  private Label FlUID;// 統一編號
 71  private Label FlOwner;// 買受人
 72  private Label FlCsNo;// 經銷商
 73  private Label FlCarryDonate;// 電子發票歸戶
 74  private Label FlInvCount;//發票剩餘張數
 75  private Label FlCcrState;//CCR交易狀態
 76  private Label FlLMSState;//LMS連線狀態
 77  private Label FlTotalAmt;//銷售金額
 78  private Label FlTotalOrderAmt;//客訂金額
 79  private Label FlTotalPayAmt;//應付金額
 80  private Label FlChangeAmt;//未付款(+)/找零(-)
 81  private TextField textField; //畫面輸入框
 82  private Label showMsg; //訊息框
 83
 84  private GridLayout gridBtnTop_;
 85  private GridLayout gridBtnButton_;
 86
 87  private HashMap<Integer, GridLayout> hashMapTop_;
 88  private HashMap<Integer, GridLayout> hashMapButton_;
 89  private HashMap<String, HashMap<String, String>> hashMapAllButtonInfo_ = null;
 90
 91  private Table FTSaleTable;
 92  private Table FTSalePayTable;
 93
 94  VerticalLayout SLDateLayout;
 95  Label SLDateTitleLabel;
 96
 97  boolean m_keyClearState = false;
 98
 99  confirmDlg m_delAllDlg = null;
100  confirmDlg m_MessageDlg = null;
101  confirmDlg m_ExitDlg = null;
102
103  timeInfoThread bthread;
104//  backgroundTask bTask;
105
106  // some properties
107  String m_InvKey;
108  String m_3EINV_AP;
109  String m_3EINV_ACCOUNT;
110  String m_3EINV_PASSWD;
111  String m_PRINTER;
112  String m_PRINTTYPE;
113  String m_PRINTPORT;
114  String m_PRINTPORTCFG;
115
116  emisPrinter m_Printer;
117  private TCcr FoCCR_;
118  public emisComponents componentWebCcr_ = null;
119  
120  //會員
121  Label FlMEM_NAME = null;//會員姓名 
122  Label FlMEM_POINT = null; //會員點數
123  Label FlMEM_S_CARE = null; //S-Care
124  Label FlMEM_DOUBLE_AUTH = null; //神腦會員
125  Label FlMEM_JOINSTORE = null; //綁定門市
126  Label FlMEM_EMAIL = null; //email
127  Label FlMEM_ADDRESS = null; //居住區域
128  Label FlMEM_SEX = null; //性別
129  Label FlMEM_BIRTHDAY = null; //生日
130  Label FlMEN_NUMBER = null; //會員手機號碼
131
132  private TextArea ANNOUNCEMENT; // 公告訊息
133
134  @Override
135  protected void init(VaadinRequest request) {
136
137    if (!super.init(request, true)) {
138      return;
139    }
140    try {
141      FoCCR_ = (TCcr) emisAuthFactory.getCcr(emisUtil.getServletContext(), VaadinService.getCurrentRequest().getWrappedSession());
142    } catch (Exception e) {
143
144    }
145
146    this.getPushConfiguration().setPushMode(PushMode.DISABLED);
147//    System.out.println("TEST="+this.getPushConfiguration().getPushMode().isEnabled());
148
149    getPage().setTitle(FoCCR_.getWEB_TITLE() + FoCCR_.getPage());
150    FoCCR_.setPage(FoCCR_.getPage() + 1);
151
152
153    emisComponents pointDisc = null;
154    emisComponents buidCust = null;
155    emisComponents birthDiscDlg = null;
156    emisComponents clearCustDlg = null;
157    emisComponents delAllDlg = null;
158    emisComponents messageDlg = null;
159    emisComponents exitDlg = null;
160
161
162    try {
163      componentWebCcr_ = emisUILoader.load(this, m_config, "webccr");
164//			pointDisc= emisUILoader.load( this ,  m_config , "point_discount");
165//			buidCust = emisUILoader.load( this ,  m_config , "build_cust");
166//			birthDiscDlg = emisUILoader.load( this ,  m_config , "confirmdlg");
167//			clearCustDlg = emisUILoader.load( this ,  m_config , "confirmdlg");
168      delAllDlg = emisUILoader.load(this, m_config, "confirmdlg");
169      messageDlg = emisUILoader.load(this, m_config, "confirmdlg");
170      exitDlg = emisUILoader.load(this, m_config, "confirmdlg");
171
172      m_delAllDlg = new confirmDlg("", "是否取消交易Y/N ?", delAllDlg, "600px", "420px");
173      m_MessageDlg = new confirmDlg("", "", messageDlg, "600px", "420px");
174      m_ExitDlg = new confirmDlg("", "确定离开WebCCR系统?", exitDlg, "600px", "420px");
175    } catch (Exception e) {
176      senaolog.error(webccr.class, e);
177      e.getStackTrace();
178      return;
179    }
180
181    textField = (TextField) componentWebCcr_.getComponent("inputText");
182    showMsg = (Label) componentWebCcr_.getComponent("showMsg");
183
184
185    textField.addFocusListener(new FieldEvents.FocusListener() {
186      @Override
187      public void focus(FieldEvents.FocusEvent event) {
188        CcrUtil.setMessage("textField on focus");
189      }
190    });
191
192    textField.addBlurListener(new FieldEvents.BlurListener() {
193      @Override
194      public void blur(FieldEvents.BlurEvent event) {
195        //只有MESSAGE BOX設定FOCUS時才會設定為唯獨,因為有BUG會莫名其妙的FOCUS
196        //被拖走,初步懷疑是MESSGEBOX關窗的時候又把FOCUS拉走了,因此在此特別
197        //判斷若是唯獨狀態,則將FOCUS再拉回來一次
198        CcrUtil.setMessage(" textField blur event, isReadOnly:"+textField.isReadOnly());
199        if (textField.isReadOnly()) {
200          textField.setReadOnly(false);
201          textField.focus();
202        }
203      }
204    });
205
206    //設定按下鍵馬上觸發TEXTCHANGE 按鍵前的值可透過textField.getValue()取得,
207    //按鍵後的值可透過event.getText()取得
208    textField.setTextChangeEventMode(AbstractTextField.TextChangeEventMode.EAGER);
209    textField.addTextChangeListener(new FieldEvents.TextChangeListener() {
210      @Override
211      public void textChange(FieldEvents.TextChangeEvent event) {
212        String _sLastWord = "";
213        int _iPos = textField.getCursorPosition();
214//        System.out.println("current DisplayReset="+FoCCR_.isMainDisplayReset()); //滑鼠游標從0開始算起,當打了一個字就變成1
215        //判斷主畫面輸入框是否需要清除
216//        System.out.println("current position=" + _iPos); //滑鼠游標從0開始算起,當打了一個字就變成1
217        if (_iPos > 0 && FoCCR_.isMainDisplayReset()) {
218          //檢查目前游標位置要小於等於目前長度
219//          System.out.println("current value=" +textField.getValue());
220//          System.out.println("event text=" +event.getText());
221//          System.out.println("current value length =" + textField.getValue().length());
222//          System.out.println("event value length =" + event.getText().length());
223//          System.out.println("lastword=" + _sLastWord);
224          FoCCR_.setMainDisplayReset(false);//此行不可以放於textField.setValue之後,否則又會觸發一次validator
225          //計算大小
226//          int _iCnt =  event.getText().length() -  textField.getValue().length();
227//          //如果只差一個字,代表從鍵盤輸入的(目前只能這樣判斷因為不能擷取所有的鍵盤輸入)
228//         //若剪貼簿跟原字串正好相差一個字,就會有BUG會被清掉...
229//          if ( _iCnt == 1) {
230//            if (_iPos <= event.getText().length())
231//              _sLastWord = event.getText().substring(_iPos - 1, _iPos); // 依據目前游標位置取得輸入的值
232//          } else if (_iCnt >1 ){ //如果相差字數大於1代表剪貼簿來的
233//            //取得相差的字數代表剪貼簿貼上的字數,再從游標位置減掉該自數到目前的游標位置
234//            if (_iPos <= event.getText().length())
235//             _sLastWord = event.getText().substring(_iPos - _iCnt, _iPos);
236//          }   //如果相差字數=0或小於0代表剪貼簿的字數完全貼上則不做任何處理
237//          textField.setValue(_sLastWord );
238        }
239      }
240    });
241
242    TCcrKeyPressHandler _keyPressHandler = new TCcrKeyPressHandler();
243    _keyPressHandler.bindComponent(textField, "TextField");
244    this.addActionHandler(_keyPressHandler);
245
246    try {
247      TDynBtnFactory _oBtnFactory = new TDynBtnFactory(FoCCR_.getStore().getFLDxS_NO(), _keyPressHandler);
248      this.hashMapTop_ = _oBtnFactory.getHashMapTop_();
249      this.hashMapButton_ = _oBtnFactory.getHashMapButton_();
250      this.hashMapAllButtonInfo_ = _oBtnFactory.getHashMapAllButton_();
251
252      gridBtnTop_ = (GridLayout) componentWebCcr_.getComponent("gridBtnTop");
253      gridBtnButton_ = (GridLayout) componentWebCcr_.getComponent("gridBtnButton");
254
255      changeButton(0);
256      changeTopButton(0);
257    } catch (Exception e) {
258      MessageBox.createError()
259          .withCaption("錯誤")
260          .withMessage("設定有誤,請聯繫資訊人員")
261          .withWidth("400px")
262          .withCloseButton(() -> {
263            // 繼續往下執行
264            FoCCR_.UInotify.closeWebCcr();
265          }, ButtonOption.focus())
266          .open();
267      return;
268    }
269
270    // table
271    FTSaleTable = (TSalesTable) componentWebCcr_.getComponent("saleTable");
272    FTSalePayTable = (TSalePayTable) componentWebCcr_.getComponent("salePayTable");
273
274    VerticalLayout _oInfoGrid = (VerticalLayout) componentWebCcr_.getComponent("WEBCCR_LAYOUT");
275    _oInfoGrid.addLayoutClickListener(new LayoutEvents.LayoutClickListener() {
276      @Override
277      public void layoutClick(LayoutEvents.LayoutClickEvent event) {
278        CcrUtil.setMessage("LayoutEvents click");
279        textField.focus();
280      }
281    });
282
283    /**上方畫面資料顯示區**/
284    //交易日期
285    FlSysDate_ = (Label) componentWebCcr_.getComponent("SYSDATE");
286    FlSysDate_.setValue(FoCCR_.getSaleDate() + "/" + emisUtil.todayTime(":"));
287    //系統時間
288//    FlSysTime_ = (Label) componentWebCcr_.getComponent("SYSTIME");
289//    FlSysTime_.setValue(emisUtil.todayTime(":"));
290    //門市
291    FlStoreNo_ = (Label) componentWebCcr_.getComponent("STORENAME");
292//    FlStoreNo_.setValue(FoCCR_.getFoStore().getStoreNo()+" "+FoCCR_.getFoStore().getStoreName());
293    FlStoreNo_.setValue(FoCCR_.getStore().getFLDxS_NO());
294    //機號
295    FlIdNo_ = (Label) componentWebCcr_.getComponent("ID_NO");
296    FlIdNo_.setValue(FoCCR_.getCcrID());
297    //發票號碼
298    FlInvNo_ = (Label) componentWebCcr_.getComponent("INVNO");
299    FlInvNo_.setValue(FoCCR_.getCurrentInvoiceNo());
300    //交易序號
301    FlSlNo_ = (Label) componentWebCcr_.getComponent("SL_NO");
302    FlSlNo_.setValue("");
303    //售貨員
304    FlSaler = (Label) componentWebCcr_.getComponent("USER");
305    FlSaler.setValue("");
306    //統一編號
307    FlUID = (Label) componentWebCcr_.getComponent("UID");
308    FlUID.setValue("");
309    //買受人
310//    FlOwner = (Label) componentWebCcr_.getComponent("OWNER");
311//    FlOwner.setValue("");
312    //經銷商
313    FlCsNo = (Label) componentWebCcr_.getComponent("CS_NO");
314    FlCsNo.setValue("");
315    // 電子發票歸戶
316    FlCarryDonate = (Label) componentWebCcr_.getComponent("CARRY_DONATE");
317    FlCarryDonate.setValue("");
318    //發票剩餘張數
319    FlInvCount = (Label) componentWebCcr_.getComponent("INVCOUNT");
320    FlInvCount.setValue("");
321    //交易狀態
322    FlCcrState = (Label) componentWebCcr_.getComponent("CCRSTATE");
323    FlCcrState.setValue("");
324    //銷售金額
325    FlTotalAmt = (Label) componentWebCcr_.getComponent("TOTALAMT");
326    FlTotalAmt.setValue("");
327    //客訂金額
328    FlTotalOrderAmt = (Label) componentWebCcr_.getComponent("TOTALORDERAMT");
329    FlTotalOrderAmt.setValue("");
330    //應付金額
331    FlTotalPayAmt = (Label) componentWebCcr_.getComponent("TOTALPAYAMT");
332    FlTotalPayAmt.setValue("");
333    //未付款(+)/找零(-)
334    FlChangeAmt = (Label) componentWebCcr_.getComponent("CHANGEAMT");
335    FlChangeAmt.setValue("");
336    //LMS連線狀態
337    FlLMSState = (Label) componentWebCcr_.getComponent("LMSSTATE");
338    
339    //會員
340    FlMEM_NAME= (Label) componentWebCcr_.getComponent("MEM_NAME");//會員姓名 
341    FlMEM_POINT= (Label) componentWebCcr_.getComponent("MEM_POINT"); //會員點數
342//    FlMEM_S_CARE= (Label) componentWebCcr_.getComponent("MEM_S_CARE"); //S-Care
343    FlMEM_DOUBLE_AUTH= (Label) componentWebCcr_.getComponent("MEM_DOUBLE_AUTH"); //神腦會員
344    FlMEM_JOINSTORE= (Label) componentWebCcr_.getComponent("MEM_JOINSTORE"); //綁定門市
345    FlMEM_EMAIL= (Label) componentWebCcr_.getComponent("MEM_EMAIL"); //email
346    FlMEM_ADDRESS= (Label) componentWebCcr_.getComponent("MEM_ADDRESS"); //居住區域
347    FlMEM_SEX= (Label) componentWebCcr_.getComponent("MEM_SEX"); //性別
348    FlMEM_BIRTHDAY= (Label) componentWebCcr_.getComponent("MEM_BIRTHDAY"); //生日
349    FlMEN_NUMBER= (Label) componentWebCcr_.getComponent("MEN_NUMBER"); //會員手機號碼
350
351    //公告訊息
352    ANNOUNCEMENT = (TextArea) componentWebCcr_.getComponent("ANNOUNCEMENT");
353    ANNOUNCEMENT.setEnabled(false);
354
355    m_delAllDlg.addOnConfirmListener(new CCREventListener() {
356      public void onEvent(Object src) {
357        reset();
358      }
359    });
360    m_delAllDlg.addCloseListener(new CloseListener() {
361      public void windowClose(CloseEvent e) {
362        onSubWindowClose();
363      }
364    });
365
366    m_MessageDlg.addCloseListener(new CloseListener() {
367      public void windowClose(CloseEvent e) {
368        onSubWindowClose();
369      }
370    });
371
372
373    m_ExitDlg.addOnConfirmListener(new CCREventListener() {
374      public void onEvent(Object src) {
375        try {
376          emisAuthFactory.logout(m_application, m_session);
377          close();
378          emisUtil.setLocation("/esn/login");
379        } catch (Exception e) {
380          senaolog.error(webccr.class, e);
381        }
382      }
383    });
384
385    m_ExitDlg.addCloseListener(new CloseListener() {
386      public void windowClose(CloseEvent e) {
387        onSubWindowClose();
388      }
389    });
390
391    //JavaScript.getCurrent().execute("window.onbeforeunload = function (e) { var e = e || window.event; aboutToClose(); return '确定离开WebCCR系统?'; };");
392//    JavaScript.getCurrent().execute(
393//        "window.onbeforeunload = " +
394//            "function (e) {  return '確定離開WebCCR系统?'; };"
395//    );
396
397    bthread = new timeInfoThread(this);
398    bthread.start();
399
400//    bTask = new backgroundTask(this);
401//    bTask.start();
402
403
404    this.addDetachListener(new DetachListener() {
405
406      // clean the thread ?
407      public void detach(DetachEvent event) {
408        CcrUtil.setMessage("Detach called");
409
410        if (bthread != null) {
411          bthread.stopIt();
412        }
413//        if (bTask != null) {
414//          bTask.stopIt();
415//        }
416      }
417
418    });
419
420    //頁面關閉,關閉時間的Thread
421    JavaScript.getCurrent().addFunction("onClose", new JavaScriptFunction() {
422      public void call(JsonArray arguments) {
423        //System.out.println("Detach called");
424//        senaolog.info(webccr.class, "window onClose called");
425        CcrUtil.setMessage("window onClose called");
426//        if( bTask != null ) { bTask.stopIt(); }
427        if( bthread != null) { bthread.stopIt(); }
428      }
429    });
430    //
431    JavaScript.getCurrent().addFunction("CloseSession", new JavaScriptFunction() {
432      public void call(JsonArray arguments) {
433        try {
434          WrappedSession session = VaadinService.getCurrentRequest().getWrappedSession();
435          emisAuthFactory.logout(emisUtil.getServletContext(), session);
436        } catch (Exception e) {
437          e.printStackTrace();
438        }
439      }
440    });
441
442    JavaScript.getCurrent().execute("window.onbeforeunload = function (e) { e.returnValue = '確定離開WebCCR系统?'; return '確定離開WebCCR系统?'; };");
443//      JavaScript.getCurrent().execute("window.onunload = function (e) { onClose();  };");
444
445    //載入CCR周邊資訊
446//    emisUtil.getCcrDevice();
447    //
448    // 寫入ini
449    String path = "C:/emis/bin/";
450
451    JavaScript.getCurrent().execute(
452        " var util = new emisUtility(); " +
453        " var a = '" + FoCCR_.getCcrID() + "'; " +
454            " var d = '" + path +"CCR.ini';" +
455            " util.writeStringToUTF8File(d, a);");
456
457       //登錄下傳POSAP download/機台  至Local端 20190305 ADD BY DAFF-DWN
458       CcrUtil.Login_Download(FoCCR_.getCcrID());
459       senaolog.init(FoCCR_.getStore().getFLDxS_NO(), FoCCR_.getCcrID());
460
461//    ANNOUNCEMENT.addStyleName("SenaoMarquee");
462//    CcrUtil.realMsgRun("ANNOUNCEMENT");
463
464    //找出門市可用促銷單
465    FoCCR_.getPromoHashMap().clear();
466    FoCCR_.getDbData.getPromoMMStore();
467    FoCCR_.getDbData.getPromoFIStore();
468    FoCCR_.getDbData.getPromoSMStore();
469
470    textField.focus();
471    setContent(componentWebCcr_.getRootComponent());
472//    senaolog.info(login.class, "登入機號="+ FoCCR_.getCcrID());
473    CcrUtil.setMessage("登入機號="+ FoCCR_.getCcrID());
474    // 分頁付置問題
475    if (FoCCR_.getPage() > 1) {
476      MessageBox.createError()
477          .withCaption("錯誤")
478          .withMessage("Webccr頁面超過1頁或重新載入,請確認分頁數。")
479          .withWidth("400px")
480          .withCloseButton(() -> {
481            // 繼續往下執行
482            FoCCR_.UInotify.closeWebCcr();
483          }, ButtonOption.focus())
484          .open();
485    }
486    // 登入悠遊卡 連接熱感機才能登入
487    if (FoCCR_.isEINV()) {
488      UU2Util uu2 = new UU2Util();
489      uu2.signOnUUcard();
490      // 悠遊卡儲值料號取得語法(每個門市有機會不同)
491      String P_NO = FoCCR_.getDbData.getUU_PNO(FoCCR_.getStore().getFLDxS_NO());
492      if (!emisUtil.isEmpty(P_NO)) {
493        FoCCR_.setUU_PNO(P_NO);
494      }
495    }
496    // 福利金料號取得語法
497    String BENEFIT_PNO = FoCCR_.getDbData.getBENEFIT_PNO(FoCCR_.getStore().getFLDxS_NO());
498    if (!emisUtil.isEmpty(BENEFIT_PNO)) {
499      FoCCR_.setBENEFIT_PNO(BENEFIT_PNO);
500    }
501
502    //add by Ares 20181009 HAMIPOINT
503    // HAMIPOINT折抵料號取得語法
504    String HAMIPOINT_PNO = FoCCR_.getDbData.getHAMIPOINT_PNO(FoCCR_.getStore().getFLDxS_NO());
505    if (!emisUtil.isEmpty(HAMIPOINT_PNO)) {
506        FoCCR_.setHAMIPOINT_PNO(HAMIPOINT_PNO);
507    }
508  }
509public void changeButton(int page) {
510    gridBtnButton_.removeComponent(0, 0);
511    gridBtnButton_.addComponent((GridLayout) hashMapButton_.get(page), 0, 0);
512  }
513
514  public void changeTopButton(int page) {
515    gridBtnTop_.removeComponent(0, 0);
516    gridBtnTop_.addComponent((GridLayout) hashMapTop_.get(page), 0, 0);
517  }
518
519  protected void getCCRParameters() {
520    try {
521      HashMap m = emisProp.getProps(m_User, "INVKEY,3EINV_AP,3EINV_ACCOUNT,3EINV_PASSWD");
522
523      m_InvKey = (String) m.get("INVKEY");
524      m_3EINV_AP = (String) m.get("3EINV_AP");
525      m_3EINV_ACCOUNT = (String) m.get("3EINV_ACCOUNT");
526      m_3EINV_PASSWD = (String) m.get("3EINV_PASSWD");
527    } catch (Exception e) {
528      senaolog.error(webccr.class, e);
529    }
530    try {
531      HashMap m = emisProp.getCCRProps(m_User, "PRINTER,PRINTTYPE,PRINTPORT,PRINTPORTCFG");
532
533      m_PRINTER = (String) m.get(m_User.getID_NO() + ".PRINTER");
534      m_PRINTTYPE = (String) m.get(m_User.getID_NO() + ".PRINTTYPE");
535      m_PRINTPORT = (String) m.get(m_User.getID_NO() + ".PRINTPORT");
536      m_PRINTPORTCFG = (String) m.get(m_User.getID_NO() + ".PRINTPORTCFG");
537
538    } catch (Exception e) {
539      senaolog.error(webccr.class, e);
540    }
541    System.out.println("Printer:" + m_PRINTER + "," + m_PRINTTYPE + "," + m_PRINTPORT + "," + m_PRINTPORTCFG);
542    m_Printer = emisPrinterFactory.getPrinter(m_PRINTER);
543    m_Printer.setConfig(m_PRINTTYPE, m_PRINTPORT, m_PRINTPORTCFG);
544  }
545
546  public void reset() {
547    //SaleTransaction ccr = (SaleTransaction) src;
548    System.out.println("webccr.reset");
549    m_keyClearState = false;
550    SLDateLayout.removeStyleName("alert_labelLayoutStyle");
551    SLDateTitleLabel.removeStyleName("alert_labelstyle");
552    SLDateLayout.addStyleName("labelLayoutStyle");
553    SLDateTitleLabel.addStyleName("labelstyle");
554    SLDateTitleLabel.setValue("交易日期");
555  }
556
557  private void onSubWindowClose() {
558//		textField.focus();
559  }
560
561  // CLS , 清除
562  public void clear() {
563    setInput("");
564//		messageLabel.setValue("");
565    FlTotalAmt.setValue("");
566    FlTotalOrderAmt.setValue("");
567    FlTotalPayAmt.setValue("");
568    FlChangeAmt.setValue("");
569    m_keyClearState = false;
570  }
571
572  private void printhashMapAllButtonInfo() {
573    HashMap<String, String> mapBtn = null;
574    for (Object key1 : hashMapAllButtonInfo_.keySet()) {
575      mapBtn = hashMapAllButtonInfo_.get(key1);
576      System.out.println("--- " + key1 + " ---");
577      for (Object key2 : mapBtn.keySet()) {
578        System.out.println(key2 + " : " + mapBtn.get(key2));
579      }
580    }
581  }
582
583  CCREventListener m_OnTransactionEnd = null;
584
585  public void addTransactionEndListener(CCREventListener listener) {
586    m_OnTransactionEnd = listener;
587  }
588
589  // This is called by background thread
590  public void updateTimeInfo() {
591    if (FlSysDate_ != null) {
592      FlSysDate_.setValue(FoCCR_.getSaleDate() + "/" + emisUtil.todayTime(":"));
593//      this.push();
594    }
595  }
596
597
598  public synchronized boolean IsNewTransactionState() {
599    if (m_bNewTransactionState) {
600      m_bNewTransactionState = false;
601      return true;
602    }
603    return false;
604  }
605
606  /*
607   * 需求, 交易結束後 , 5 秒自動清除
608   */
609  public synchronized void clearbyBackground() {
610    if (IsNewTransactionState()) {
611      //System.out.println("clearbyBackground");
612      //m_CurrentSt.reset();
613      reset();
614      this.push();
615    }
616  }
617
618  public emisComponents getComponentWebCcr() {
619    return componentWebCcr_;
620  }
621
622  public String getInput() {
623    return this.textField.getValue();
624  }
625
626  public void setInput(String input) {
627    this.textField.setValue(input);
628  }
629
630  public TCcr getFoCCR() {
631    return FoCCR_;
632  }
633
634  public Table getFTSaleTable() {
635    return FTSaleTable;
636  }
637
638  public TextField getInputLabel() {
639    return textField;
640  }
641
642  public Label getFlSaler() {
643    return FlSaler;
644  }
645
646  public Label getFlUID() {
647    return FlUID;
648  }
649
650  public Label getFlOwner() {
651    return FlOwner;
652  }
653
654  public Label getFlCcrState() {
655    return FlCcrState;
656  }
657
658  public Label getFlLMSState() {
659    return FlLMSState;
660  }
661
662  public Table getFTSalePayTable() {
663    return FTSalePayTable;
664  }
665
666  public Label getFlSysDate() {
667    return FlSysDate_;
668  }
669
670  public Label getFlStoreNo() {
671    return FlStoreNo_;
672  }
673
674  public Label getFlIdNo() {
675    return FlIdNo_;
676  }
677
678  public Label getFlSlNo() {
679    return FlSlNo_;
680  }
681
682  public Label getFlInvNo() {
683    return FlInvNo_;
684  }
685
686  public Label getFlInvCount() {
687    return FlInvCount;
688  }
689
690  public Label getFlTotalAmt() {
691    return FlTotalAmt;
692  }
693
694  public Label getFlTotalOrderAmt() {
695    return FlTotalOrderAmt;
696  }
697
698  public Label getFlTotalPayAmt() {
699    return FlTotalPayAmt;
700  }
701
702  public Label getFlChangeAmt() {
703    return FlChangeAmt;
704  }
705
706  public GridLayout getGridBtnTop() {
707    return gridBtnTop_;
708  }
709
710  public GridLayout getGridBtnButton() {
711    return gridBtnButton_;
712  }
713
714  public HashMap getHashMapTop() {
715    return hashMapTop_;
716  }
717
718  public HashMap getHashMapButton() {
719    return hashMapButton_;
720  }
721
722  public HashMap<String, HashMap<String, String>> getHashMapAllButtonInfo_() {
723    return hashMapAllButtonInfo_;
724  }
725
726  // 取得某一個按鈕的資訊
727  public HashMap<String, String> getHashMapButtonInfo(String sFP_FUNC_CODE) {
728    return hashMapAllButtonInfo_.get(sFP_FUNC_CODE);
729  }
730
731  // 公司別先給空白
732  public PromotionInfoList getPmList() {
733    try {
734      return PromotionMgr.getInstance(emisUtil.getServletContext()).
735          getPromoteList(FoCCR_);
736    } catch (Exception e) {
737      senaolog.error(this.getClass(), e);
738      return null;
739    }
740  }
741
742  public webccrlog getlog() {
743    return senaolog;
744  }
745  public Label getFlMEM_NAME() {
746		return FlMEM_NAME;
747	}
748
749	public Label getFlMEM_POINT() {
750		return FlMEM_POINT;
751	}
752
753	public Label getFlMEM_S_CARE() {
754		return FlMEM_S_CARE;
755	}
756
757	public Label getFlMEM_DOUBLE_AUTH() {
758		return FlMEM_DOUBLE_AUTH;
759	}
760
761	public Label getFlMEM_JOINSTORE() {
762		return FlMEM_JOINSTORE;
763	}
764
765	public Label getFlMEM_EMAIL() {
766		return FlMEM_EMAIL;
767	}
768
769	public Label getFlMEM_ADDRESS() {
770		return FlMEM_ADDRESS;
771	}
772
773	public Label getFlMEM_SEX() {
774		return FlMEM_SEX;
775	}
776
777	public Label getFlMEM_BIRTHDAY() {
778		return FlMEM_BIRTHDAY;
779	}
780
781  public Label getShowMsg() {
782    return showMsg;
783  }
784
785  public void setShowMsg(String showMsg) {
786    this.showMsg.setValue(showMsg);
787  }
788
789  public Label getFlCsNo() {
790    return FlCsNo;
791  }
792
793  public Label getFlCarryDonate() {
794    return FlCarryDonate;
795  }
796
797  public Label getFlMEN_NUMBER() {
798    return FlMEN_NUMBER;
799  }
800}