admin-pending.component.ts 6.02 KB
Newer Older
1
import { Component, OnInit } from '@angular/core';
2
import { NgbDate, NgbCalendar, NgbDateParserFormatter } from '@ng-bootstrap/ng-bootstrap';
3
import { NgbModal, ModalDismissReasons } from '@ng-bootstrap/ng-bootstrap';
4
import { Equirment } from 'src/app/models/equirment.model';
5
import { itemDetail } from 'src/app/models/itemDetail.model';
6 7 8 9
import { itemDetailService } from 'src/app/service/item-detail.service';
import { roomDetail } from 'src/app/models/roomDetail.model';
import { roomDetailService } from 'src/app/service/room-detail.service';
import { Room } from 'src/app/models/rooms.model';
10 11 12 13

@Component({
  selector: 'app-admin-pending',
  templateUrl: './admin-pending.component.html',
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40
  styleUrls: ['./admin-pending.component.scss'],
  styles: [`
  .form-group.hidden {
    width: 0;
    margin: 0;
    border: none;
    padding: 0;
  }
  .custom-day {
    text-align: center;
    padding: 0.185rem 0.25rem;
    display: inline-block;
    height: 2rem;
    width: 2rem;
  }
  .custom-day.focused {
    background-color: #e6e6e6;
  }
  .custom-day.range, .custom-day:hover {
    background-color: rgb(2, 117, 216);
    color: white;
  }
  .custom-day.faded {
    background-color: rgba(2, 117, 216, 0.5);
  }
`]

41
})
42

43 44 45 46
export class AdminPendingComponent implements OnInit {
  page = 1;
  pageSize = 10;

47 48
  closeResult = '';

49 50
  listitemDetail : itemDetail[] = [];
  listroomDetail : roomDetail[] = [];
51

52 53 54 55 56 57
  modelEquirment = new Equirment();
  modelRoom = new Room();
  modelitemDetail = new itemDetail();
  modelroomDetail = new roomDetail();

  collectionSize = this.listitemDetail.length;
58
  hoveredDate: NgbDate | null = null;
59

60 61 62
  fromDate: NgbDate | null;
  toDate: NgbDate | null;

63 64 65 66 67 68 69 70 71 72
  thStime: string;
  thEtime: string;
  thtimeChange (time:string,item:any){
    let timeSplit = time.split(":")
    item.hour = parseInt(timeSplit[0])
    item.minute = parseInt(timeSplit[1])
    console.log(this.modelroomDetail)
  }


73
  constructor(private calendar: NgbCalendar, public formatter: NgbDateParserFormatter, private modalService: NgbModal, private itemDetailService: itemDetailService, private roomDetailService: roomDetailService) {
74 75
    this.fromDate = calendar.getToday();
    this.toDate = calendar.getNext(calendar.getToday(), 'd', 10);
76
    this.refreshitemDetail();
77 78
  }

79
  refreshitemDetail() {
80
    this.listitemDetail = this.listitemDetail
81 82 83 84
      .map((country, i) => ({ id: i + 1, ...country }))
      .slice((this.page - 1) * this.pageSize, (this.page - 1) * this.pageSize + this.pageSize);
  }

85 86 87 88 89 90 91 92 93 94 95
  onDateSelection(date: NgbDate) {
    if (!this.fromDate && !this.toDate) {
      this.fromDate = date;
    } else if (this.fromDate && !this.toDate && date && date.after(this.fromDate)) {
      this.toDate = date;
    } else {
      this.toDate = null;
      this.fromDate = date;
    }
  }

96 97 98 99 100 101 102
  open(content) {
    this.modalService.open(content, { ariaLabelledBy: 'modal-basic-title' }).result.then((result) => {
      this.closeResult = `Closed with: ${result}`;
    }, (reason) => {
      this.closeResult = `Dismissed ${this.getDismissReason(reason)}`;
    });
  }
103 104 105 106 107 108
  date='10-12-2561'
  show(a:string){
    console.log(a)
  }
  sDate = ""
  eDate = ""
109 110
  openItemDetail(content : string ,item : itemDetail) {
    this.modelitemDetail = item ;
111 112 113 114 115 116
    this.thStime= this.modelitemDetail.sTime.hour + ':' + this.modelitemDetail.sTime.minute 
    this.thEtime= this.modelitemDetail.eTime.hour + ':' + this.modelitemDetail.eTime.minute
    let SDate = this.modelitemDetail.sDate.split('/')
    this.sDate = SDate[2]+"-"+SDate[1]+"-"+SDate[0]
    let EDate = this.modelitemDetail.eDate.split('/')
    this.eDate = EDate[2]+"-"+EDate[1]+"-"+EDate[0]
117 118 119 120 121 122 123
    this.modalService.open(content, { ariaLabelledBy: 'modal-basic-title' }).result.then((result) => {
      this.closeResult = `Closed with: ${result}`;
    }, (reason) => {
      this.closeResult = `Dismissed ${this.getDismissReason(reason)}`;
    });
  }

124 125 126 127 128 129 130 131 132 133 134 135 136
  rDate(item: string, item2: string){
    let Dates = item.split("-")
    let dates = Dates[2]+"/"+Dates[1]+"/"+Dates[0]
    
    if(item2=="sdate"){
      this.modelitemDetail.sDate = dates
    }
    if(item2=="edate"){
      this.modelitemDetail.eDate = dates
    }
    console.log(this.sDate)
  } 

137 138
  openRoomDetail(content : string ,item : roomDetail) {
    this.modelroomDetail = item ;
139 140 141 142 143 144
    this.thStime= this.modelroomDetail.sTime.hour + ':' + this.modelroomDetail.sTime.minute 
    this.thEtime= this.modelroomDetail.eTime.hour + ':' + this.modelroomDetail.eTime.minute 
    let SDate = this.modelroomDetail.sDate.split('/')
    this.sDate = SDate[2]+"-"+SDate[1]+"-"+SDate[0]
    let EDate = this.modelroomDetail.eDate.split('/')
    this.eDate = EDate[2]+"-"+EDate[1]+"-"+EDate[0]
145 146 147 148 149 150 151
    this.modalService.open(content, { ariaLabelledBy: 'modal-basic-title' }).result.then((result) => {
      this.closeResult = `Closed with: ${result}`;
    }, (reason) => {
      this.closeResult = `Dismissed ${this.getDismissReason(reason)}`;
    });
  }

152 153 154 155 156 157 158 159 160 161
  private getDismissReason(reason: any): string {
    if (reason === ModalDismissReasons.ESC) {
      return 'by pressing ESC';
    } else if (reason === ModalDismissReasons.BACKDROP_CLICK) {
      return 'by clicking on a backdrop';
    } else {
      return `with: ${reason}`;
    }
  }

162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178
  isHovered(date: NgbDate) {
    return this.fromDate && !this.toDate && this.hoveredDate && date.after(this.fromDate) && date.before(this.hoveredDate);
  }

  isInside(date: NgbDate) {
    return this.toDate && date.after(this.fromDate) && date.before(this.toDate);
  }

  isRange(date: NgbDate) {
    return date.equals(this.fromDate) || (this.toDate && date.equals(this.toDate)) || this.isInside(date) || this.isHovered(date);
  }

  validateInput(currentValue: NgbDate | null, input: string): NgbDate | null {
    const parsed = this.formatter.parse(input);
    return parsed && this.calendar.isValid(NgbDate.from(parsed)) ? NgbDate.from(parsed) : currentValue;
  }

179
  ngOnInit(): void {
180 181 182
    this.listitemDetail = this.itemDetailService.getListitemDetail();
    this.listroomDetail = this.roomDetailService.getListroomDetail();
    console.log(this.listitemDetail);
183 184
  }

185

186
}
187 188 189

export class NgbdDropdownBasic {
}