package com.application.tak.takapplication;

import android.app.Activity;
import android.app.Fragment;
import android.content.Context;
import android.os.Bundle;
import android.support.design.widget.FloatingActionButton;
import android.support.design.widget.Snackbar;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.Toolbar;
import android.view.View;

import com.application.tak.takapplication.data_access.Config;
import com.application.tak.takapplication.data_model.Adress;
import com.application.tak.takapplication.data_model.User;
import com.application.tak.takapplication.services.LoginStatus;
//import com.application.tak.takapplication.services.LoginStatus;

public class actClientLoginRegulation extends AppCompatActivity {

    Activity act;
    Context _ctx;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.act_client_login_regulation);

        _ctx = this.getApplicationContext();
        act = this;
        FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.fab);
        fab.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {

                if(Config.LoggedInClient != null && Config.LoggedInClient.get_Adress() != null
                        && !Config.LoggedInClient.get_Username().isEmpty()&&
                        !Config.LoggedInClient.get_Password().isEmpty() &&
                        !Config.LoggedInClient.get_LName().isEmpty() &&
                        !Config.LoggedInClient.get_FName().isEmpty() &&
                        !Config.LoggedInClient.get_Adress().get_City().isEmpty() &&
                        !Config.LoggedInClient.get_Adress().get_PostCode().isEmpty() &&
                        !Config.LoggedInClient.get_PhoneNo().isEmpty() &&
                        !Config.LoggedInClient.get_Adress().get_Road().isEmpty())
                {
                    LoginStatus lgStatus = new LoginStatus(_ctx);
                    User u = Config.LoggedInClient;
                    u.set_IsActive(1);
                    u.set_RoleId(2);

                    Adress a = Config.LoggedInClient.get_Adress();

                    lgStatus.NewClient(u,a,act);


                }
            }
        });
    }
}

