import { Component } from '@angular/core';
import { NavController,AlertController,MenuController,App,LoadingController } from 'ionic-angular';
import { LoginPage} from '../login/login';
import { AuthServiceProvider } from '../../providers/auth-service/auth-service';
import { feesDetails } from '../fees-details/feesDetails';

@Component({
  selector: 'page-contact',
  templateUrl: 'contact.html'
})
export class ContactPage {
  Fess: number;
  Document : number;
  Mark : number;
  Study : number;
  loadcourse : any;
 // fess: number;

 
  name: any;
  commonUrl: any;
  courseDetails: any;
  constructor(public navCtrl: NavController,
              public alertCtrl: AlertController,
              public Menu: MenuController,
              private authService:AuthServiceProvider,
              public app:App,
              public loadingCtrl : LoadingController) {
                //
                  this.courseLoading();
      //console.log(this.studentInformation);
      this.commonUrl = this.authService.commonUrl;
      //console.log("home "+this.commonUrl);
    this.name = localStorage.getItem("ID");
    let Requested = {requestedBy:this.name,requestedFrom:"2"}
            //console.log("req"+Requested);

           
    this.authService.studentGetInfo(Requested).subscribe(getStudent=>{
      
      if(getStudent.studentStatus == true){
       
        //localStorage.setItem('StudentDetails', getStudent.studentDetails); 
        this.courseDetails =  getStudent.courseDetails.courseStatus;
       
      //console.log(this.courseDetails);
           this.loadcourse.dismiss();
          
       }
     });

  
              }
  fees() {
    this.Fess = 1;
    this.Document = 0;
    this.Mark = 0;
    this.Study = 0;
    //this.navCtrl.push(LoginPage);
    }
    document() {
      this.Fess = 0;
      this.Document = 1;
      this.Mark = 0;
      this.Study = 0;
     
      }
      mark() {
        this.Fess = 0;
        this.Document = 0;
        this.Mark = 1;
        this.Study = 0;
        }
        study() {
          this.Fess = 0;
          this.Document = 0;
          this.Mark = 0;
          this.Study = 1;
          }
         courseLoading(){
           this.loadcourse = this.loadingCtrl.create({
              content : 'Please Wait...'

           });
           this.loadcourse.present(); 
         }
  logoutalert(){
    
    let alert = this.alertCtrl.create({
      title:'Successfully Logout',
      buttons:['Ok']
    });
  alert.present();
  this.logout();
  }  
  ionViewDidEnter(){
    this.Menu.enable(false);
  }
  ionViewWillLeave(){
    this.Menu.enable(true);
  }
  logout(){
    
    
    window.localStorage.removeItem('ID');
    window.localStorage.removeItem('userMobile');
    window.localStorage.removeItem('password');
    //window.localStorage.removeItem('password');
    window.localStorage.removeItem('feesID');
    this.app.getRootNav().setRoot(LoginPage);
    this.navCtrl.popToRoot(); 
    
  }

  getfeesdetails(courseID){
    //alert();
     this.navCtrl.push(feesDetails);
     // console.log(courseID);
      localStorage.setItem('CourseID',courseID);
      
  }
}
