import {Component, OnInit, TemplateRef, ViewChild} from '@angular/core';
import {ListComponent} from '../../../classes/base_components/list/list.component';
import {ICollection} from 'ngx-jsonapi';
import {User, UsersService} from '../../../classes/resorcess/users.service';
import {Dialog} from '../../../classes/base_components/dialog/dialog';
import {Http} from '@angular/http';
import {EditUsersComponent} from '../../user/users/edit-users/edit-users.component';
import {EditRequestsComponent} from './edit-requests/edit-requests.component';
import {RequestsService} from '../../../classes/resorcess/requests.service';

@Component({
  selector: 'app-requests',
  templateUrl: './requests.component.html',
  styleUrls: ['./requests.component.scss']
})
export class RequestsComponent extends ListComponent implements OnInit {
  @ViewChild('filter_id') public filter_id_ref: TemplateRef<any>;
  @ViewChild('filter_status') public filter_status_ref: TemplateRef<any>;
  @ViewChild('filter_gender') public filter_gender_ref: TemplateRef<any>;
  @ViewChild('filter_father_name') public filter_father_name_ref: TemplateRef<any>;
  @ViewChild('filter_mobile') public filter_mobile_ref: TemplateRef<any>;
  @ViewChild('filter_phone') public filter_phone_ref: TemplateRef<any>;
  @ViewChild('filter_name') public filter_name_ref: TemplateRef<any>;
  @ViewChild('filter_last_name') public filter_last_name_ref: TemplateRef<any>;
  @ViewChild('filter_student_code') public filter_student_code_ref: TemplateRef<any>;
  @ViewChild('filter_birth_date') public filter_birth_date_ref: TemplateRef<any>;
  @ViewChild('filter_address') public filter_address_ref: TemplateRef<any>;
  @ViewChild('filter_identify_id') public filter_identify_id_ref: TemplateRef<any>;
  @ViewChild('filter_birth_certificate_id') public filter_birth_certificate_id_ref: TemplateRef<any>;
  users: ICollection<User>;
  data: any;
  statusess ;


  constructor(public requestService: RequestsService,
              public dialog: Dialog,
              public http: Http,
  ) {
    super(requestService, dialog, EditRequestsComponent, http);
    this.listService.register();
    const basics = JSON.parse(localStorage.getItem('basics'));
    this.statusess = basics['statusess'] ;
  }

  ngOnInit() {
    this.columns = [
      {
        prop: 'name',
        name: 'نام',
        filter: this.filter_name_ref,
      },
      {
        prop: 'last_name',
        name: 'نام خانوادگی',
        filter: this.filter_last_name_ref,
      },

      {
        prop: 'student_code',
        name: 'شماره دانشجویی',
        filter: this.filter_student_code_ref,
      },

      {
        prop: 'birth_certificate_id',
        name: 'شماره شناسنامه',
        filter: this.filter_birth_certificate_id_ref,
      },
      {
        prop: 'identify_id',
        name: 'شماره ملی',
        filter: this.filter_identify_id_ref,
      },
      {
        prop: 'address',
        name: 'آدرس',
        filter: this.filter_address_ref,
      },
      {
        prop: 'birth_date',
        name: 'آدرس',
        filter: this.filter_birth_date_ref,
      },
      {
        prop: 'mobile',
        name: 'شماره همراه',
        filter: this.filter_mobile_ref,
      },
      {
        prop: 'phone',
        name: 'شماره ثابت ',
        filter: this.filter_phone_ref,
      },
      {
        prop: 'father_name',
        name: 'شماره ثابت ',
        filter: this.filter_father_name_ref,
      },
      {
        prop: 'gender',
        name: 'جنسیت',
        filter: this.filter_gender_ref,
      },
      {
        prop: 'status',
        name: 'وضعیت',
        filter: this.filter_status_ref,
      },
      {
        prop: 'id',
        name: 'شناسه',
        filter: this.filter_id_ref,
      },
    ];
    super.ngOnInit();
  }

}
