Park Rezervasyonu
Park Rezervasyonu Script
const getFc = (x) => this.recordService.formGroup.controls[x];
rxjs.combineLatest(
getFc('AGENCYID_AGENCYCODE').valueChanges.pipe(rxjs.startWith(getFc('AGENCYID_AGENCYCODE').value)),
getFc('ISAGENCY').valueChanges.pipe(rxjs.startWith(getFc('ISAGENCY').value)),
getFc('ISCOMPANY').valueChanges.pipe(rxjs.startWith(getFc('ISCOMPANY').value))
).subscribe(([v, agen, comp]) => {
const el = document.querySelector('.ang-field-AGENCYID_AGENCYCODE').querySelector('mat-label');
let text = '';
const wrapper = (x) => `<span style="color:red;">${x}</span>`;
let agency = angus.languageService.staticTranslator.translate('Agency');
let company = angus.languageService.staticTranslator.translate('Company');
let indi = angus.languageService.staticTranslator.translate('Individual');
text += agen ? wrapper(agency): agency;
text += ' / ';
text += comp ? wrapper(company): company;
text += ' / ';
text += v && (!agen && !comp) ? wrapper(indi): indi;
el.innerHTML = text;
});
/*
START
31.08.2019 Tolga
Gizli olan Check-In Butonunu duruma göre açma
*/
(() => {
// Buton, G0 grubu içerisinde, G0 tanımında da display: none; stili var.
// Grubu görünür hale getirince, buton da göz��kecek.
const __resRecordHideCheckInBtn = () => {
try {
document.querySelector('div.group.ang-group-G0').style.display = "none";
} catch(e) {}
};
const __resRecordShowCheckInBtn = () => {
try {
document.querySelector('div.group.ang-group-G0').style.display = "block";
} catch(e) {}
};
// Buton durumu kontrol fonksiyonu
const __resRecordCheckInButtonCheckState = () => {
// id yoksa, buton kapalı olacak
const id = this.recordService.formGroup.controls['ID'].value;
if (!id) {
__resRecordHideCheckInBtn();
return;
}
// resstateid 2 değilse (rezervasyon) buton kapalı olacak
const resstateid = this.recordService.formGroup.controls['RESSTATEID'].value;
if (resstateid !== 2) {
__resRecordHideCheckInBtn();
return;
}
// checkin ve progdate'in tarih kısımları farklı ise, buton kapalı olacak
const checkinDate = moment(this.recordService.formGroup.controls['CHECKIN'].value).startOf('day');
const progdate = moment(this.recordService.component.api.tenant.PROGDATE).startOf('day');
if (!checkinDate.isSame(progdate)) {
__resRecordHideCheckInBtn();
return;
}
// Program tarihindeki bir rezervasyonsa, buton açık olacak
console.warn('Activating Check-In Button (id, resstateid, checkinDate, progdate)', id, resstateid, checkinDate, progdate);
__resRecordShowCheckInBtn();
};
// Bunlardan herhangi biri değişirse, tekrar kontrol et butonun durumunu
this.recordService.formGroup.controls['ID'].valueChanges.subscribe(cid => {__resRecordCheckInButtonCheckState();});
this.recordService.formGroup.controls['RESSTATEID'].valueChanges.subscribe(state => {__resRecordCheckInButtonCheckState();});
this.recordService.formGroup.controls['CHECKIN'].valueChanges.subscribe(state => {__resRecordCheckInButtonCheckState();});
// buton durumunu kontrol et
__resRecordCheckInButtonCheckState();
})();
/*
31.08.2019 Tolga
END
*/
/*
START
13.09.2019 Mahmut
Gizli olan Check-Out Butonunu duruma göre açma
*/
(() => {
// Buton, G00 grubu içerisinde, G00 tanımında da display: none; stili var.
// Grubu görünür hale getirince, buton da gözükecek.
const __resRecordHideCheckOutBtn = () => {
try {
document.querySelector('div.group.ang-group-G00').style.display = "none";
} catch(e) {}
};
const __resRecordShowCheckOutBtn = () => {
try {
document.querySelector('div.group.ang-group-G00').style.display = "block";
} catch(e) {}
};
// Buton durumu kontrol fonksiyonu
const __resRecordCheckOutButtonCheckState = () => {
// id yoksa, buton kapalı olacak
const id = this.recordService.formGroup.controls['ID'].value;
if (!id) {
__resRecordHideCheckOutBtn();
return;
}
// resstateid 3 değilse (rezervasyon) buton kapalı olacak
const resstateid = this.recordService.formGroup.controls['RESSTATEID'].value;
if (resstateid !== 3) {
__resRecordHideCheckOutBtn();
return;
}
// checkin ve progdate'in tarih kısımları farklı ise, buton kapalı olacak
const checkoutDate = moment(this.recordService.formGroup.controls['CHECKOUT'].value).startOf('day');
const progdate = moment(this.recordService.component.api.tenant.PROGDATE).startOf('day');
if (!checkoutDate.isSame(progdate)) {
__resRecordHideCheckOutBtn();
return;
}
// Program tarihindeki bir rezervasyonsa, buton açık olacak
console.warn('Activating Check-Out Button (id, resstateid, checkoutDate, progdate)', id, resstateid, checkoutDate, progdate);
__resRecordShowCheckOutBtn();
};
// Bunlardan herhangi biri değişirse, tekrar kontrol et butonun durumunu
this.recordService.formGroup.controls['ID'].valueChanges.subscribe(cid => {__resRecordCheckOutButtonCheckState();});
this.recordService.formGroup.controls['RESSTATEID'].valueChanges.subscribe(state => {__resRecordCheckOutButtonCheckState();});
this.recordService.formGroup.controls['CHECKOUT'].valueChanges.subscribe(state => {__resRecordCheckOutButtonCheckState();});
// buton durumunu kontrol et
__resRecordCheckOutButtonCheckState();
})();
/*
13.09.2019 Mahmut
END
*/
let that = this;window.record = that;
console.log(that);
setTimeout(() => {
that.allFormControls.LOS.valueChanges.subscribe({
next(x) {
if (that.allFormControls.LOS._pendingChange)
that.allFormControls.CHECKOUT.setValue(moment(that.allFormControls.CHECKIN.value).add(x, "d").format("YYYY-MM-DD HH:mm:ss.SSS"));
},
error(err) {
console.log("LOS error :", err);
}
});
that.allFormControls.CHECKIN.valueChanges.subscribe({
next(x) {
if (! that.allFormControls.LOS._pendingChange)
that.allFormControls.LOS.setValue(Math.ceil(moment(that.allFormControls.CHECKOUT.value).diff(that.allFormControls.CHECKIN.value, "days", true)));
that.allFormControls.CHECKOUT.setValue(moment(x).add(1,'days'));
},
error(err) {
console.log("CHECKIN error :", err);
}
});
that.allFormControls.CHECKOUT.valueChanges.subscribe({
next(x) {
if (! that.allFormControls.LOS._pendingChange)
that.allFormControls.LOS.setValue(Math.ceil(moment(that.allFormControls.CHECKOUT.value).diff(that.allFormControls.CHECKIN.value, "days", true)));
},
error(err) {
console.log("CHECKOUT error :", err);
}
});
}, 1000);
let validateTC = function(v) {
if (v == "11111111111")
return true;
let tc = v.toString().split("").map(n => {return parseInt(n);});
let d10 = ((tc[0] + tc[2] + tc[4] + tc[6] + tc[8]) * 7 - (tc[1] + tc[3] + tc[5] + tc[7]) ) % 10;
return ((tc[9] == d10) && tc[10] == (tc[1] + tc[3] + tc[5] + tc[7] + tc[0] + tc[2] + tc[4] + tc[6] + tc[8] + d10) % 10);};
setTimeout(()=> {
let guestGrid = that.allGrids.parkguest.grid.agGrid;
guestGrid.cellEditingStopped.subscribe((d)=>{
console.log('edit stopped', d);
if(d.column.colId=="NATIONALIDNO"){
if(d.value !== '' && !validateTC(d.value)) {
angus.api.angusDialog.alert('('+ d.value + ') '+
that.languageService.dynamicTranslator.translate('is not valid! Please enter a valid ID number!'));
Object.values(guestGrid.api.rowModel.selectionController.selectedNodes).filter((r)=> {
return r !== undefined;
})[0].setDataValue('NATIONALIDNO','');
}
}
})
},2000);
//13/03/2020-Mehmet VoucherNo kontrol Başlangıç
let voucherBulCallBack = (voucherNo) => {
if(!voucherNo){
return;
}
let id = this.allFormControls['ID'].value;
this.recordService.component.api.select({
Object: 'HOTEL_RES',
Select: ['ID', 'VOUCHERNO'],
Where: [{
Column: 'VOUCHERNO',
Operator: '=',
Value: voucherNo
}, {
Column: 'RESSTATEID',
Operator: '<',
Value: 4
}, {
Column: 'ID',
Operator: '<>',
Value: id
}],
Paging: {
ItemsPerPage: 1,
Current: 1
}
}).then((response) => {
if (response.ResultSets[0].length > 0) {
let resID = response.ResultSets[0][0].ID;
if(+this.allFormControls['ID'].value === +resID){
return;
}
let msg = angus.languageService.dynamicTranslator.translate('Voucher No {{' + voucherNo + '}} Used before in Res ID : {{' + resID + '}}');
this.angusDialog.alert(msg);
}
});
}
this.allFormControls['VOUCHERNO'].valueChanges.pipe(rxjs.debounceTime(500), rxjs.distinctUntilChanged()).subscribe(voucherBulCallBack.bind(this));
//Voucherno Bitiş
//11.12.2020 MBASAL
const c1 = this.allFormControls['MANUELRATE'];
this.allFormControls.MANUELRATEENABLED.valueChanges.pipe(rxjs.startWith(this.allFormControls.MANUELRATEENABLED.value)).subscribe(v => {
if(!v){
c1.disable();
} else {
c1.enable();
}
});
Last updated