var app = {
    // Application Constructor
    initialize: function() {
        document.addEventListener('deviceready', this.onDeviceReady.bind(this), false);
    },

    // deviceready Event Handler
    //
    // Bind any cordova events here. Common events are:
    // 'pause', 'resume', etc.
    onDeviceReady: function() {
        this.itemInit();
        this.eventInit();
        this.otherInit();
    },
    itemInit:function(){
        cordova.plugins.finPlugin.getReceitCancelCashInfo("", function(res){
            app.setReceitCancelCashInfo(res);
        }, function(error){
            alert(error);
        });
    },
    eventInit:function(){
       
    },
    otherInit:function(){

    },
    setReceitCancelCashInfo:function(res)
    {
        /*
        var dataObject = JSON.parse(res);
        dataObject['tradingCategory'];
        
        
        if(isIphone())
        {
          
            var data1 = "";
            var data2 = "";
            
            
           
            data1 = data1 + "<li>" + + "</li><li>" +
         dataObject['dateAndTime'] + "</li><li>" +
         dataObject['approvalNumber'] + "</li><li>" +
         dataObject['cardNumber'] + "</li><li>" +
         dataObject['totalAmount'] +"</li><li>" +
         dataObject['supplyAmount'] + "</li><li>"+
         dataObject['taxAmount'] + "</li>";
         
            data2 = data2 + "<li>" +
         dataObject['merchantName'] + "</li><li>" +
         dataObject['businessNumber'] + "</li><li>" +  +"</li><li>" +
         dataObject['phoneNumber']+ "</li>";
           
        }else{
            
        }
        
        $("#ReceiptCon1").html(data1);
        $("#ReceiptCon2").html(data2);
        */
        
        
        var receiptData = JSON.parse(res);
        if(null == receiptData) return;
        
        $("#title").html(receiptData['tradingCategory']);
        $("#li_kind").html(receiptData['tradingCategory']);
        $("#li_kind_sub").html(receiptData['information']);
        $("#li_time").html(receiptData['dateAndTime']);
        $("#li_approval").html(receiptData['approvalNumber']);
        $("#li_cardNumber").html(receiptData['cardNumber']);
        $("#li_total").html("- " + numberWithCommas(receiptData['totalAmount']) + '원');
        $("#li_supply").html("- " + numberWithCommas(receiptData['supplyAmount']) + '원');
        $("#li_tax").html("- " + numberWithCommas(receiptData['taxAmount']) + '원');
        
        $("#li_readerNumber").html(receiptData['terminalNumber'] );
        $("#li_bizName").html(receiptData['merchantName']);
        $("#li_bizOwner").html(receiptData['represent']);
        
        $("#li_bizNumber").html(receiptData['businessNumber']);
        $("#li_bizCallNumber").html(receiptData['phoneNumber']);
        $("#li_bizAddress").html(receiptData['merchantAddress']);
        
        if (receiptData['information'] == "발행안함") {
          $('#information').addClass('blind');
          $('#no_publish').addClass('blind');
          
        }
        
       

        $("#print_button").css("display","none");
        receiptNumber = receiptData['receiptNumber'];
        
        
    },sendMMS:function(){
       
        if(isIphone())
        {
            var data = {"TYPE":"CANCEL_CASH"};
            cordova.plugins.finPlugin.sendMMS(data,null, null);
        }else
        {
            cordova.plugins.finPlugin.sendMMS("",null, null);
        }
        
        
        
    },closeStack:function(){
        cordova.plugins.finPlugin.backButton("", null, null);
    },
    backbuttonAction:function()
    {
        if(isIphone())
        {
            if(!isPopupClose){
                cordova.plugins.finPlugin.backButton("", null, null);
            }
        }else
        {
            
        }
    },backReceipAction:function(){
        cordova.plugins.finPlugin.moveStack(RECEIPT.DATA, null,null);
    }

};

app.initialize();

