package com.tomas.ht_mast;

import android.content.Intent;
import android.os.Bundle;
import android.view.KeyEvent;
import android.view.View;
import android.widget.TextView;

import androidx.appcompat.app.AppCompatActivity;

import com.tomas.ht_mast.lib.ActionType;
import com.tomas.ht_mast.lib.KeyMapping;
import com.tomas.ht_mast.lib.Settings;

public class OutbountMenu_Activity extends AppCompatActivity implements View.OnClickListener {
    TextView txt_user, txt_device;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_outbount_menu);

        txt_user = (TextView) findViewById(R.id.txt_user);
        txt_user.setText("User : "+ Settings.getLoginUser().getName());

        txt_device = (TextView) findViewById(R.id.txt_device);
        txt_device.setText("Device : "+Settings.getDeviceNo());

    }

    @Override
    public void onClick(View view) {
        Intent intent;
        switch (view.getId()) {
            case R.id.imb_back:
                finish();
                break;
            case R.id.btn_work_outbound:
                  Settings.setActionType(String.valueOf(ActionType.Type.OUTBOUND_WORK));
                intent = new Intent(OutbountMenu_Activity.this, OutboundSchedule_Activity.class);
                startActivity(intent);
                break;

            case R.id.btn_pro_outbound:
                Settings.setActionType(String.valueOf(ActionType.Type.OUTBOUND_PRODUCTION));
                intent = new Intent(OutbountMenu_Activity.this, OutboundSchedule_Activity.class);
                startActivity(intent);
                break;

            case R.id.btn_outbound_manual:
                Settings.setActionType(String.valueOf(ActionType.Type.OUTBOUND_MANUAL));
//                intent = new Intent(OutbountMenu_Activity.this, OutboundManual_Activity.class);
                intent = new Intent(OutbountMenu_Activity.this, OutboutManualRecheck_Activity.class);
                startActivity(intent);
                break;
                }
        }

    @Override
    public boolean onKeyUp(int keyCode, KeyEvent event) {
        if (keyCode >= KeyMapping.P1.getId()
                && keyCode <= KeyMapping.P4.getId()) {
            switch (KeyMapping.fromId(keyCode)) {
                case P1:
                    finish();
                    break;
            }
        }

        return super.onKeyUp(keyCode, event);
    }
}