Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import { Component } from '@angular/core';
- import { IonicPage, NavController, NavParams, ViewController, ModalController } from 'ionic-angular';
- import { Common } from '../../providers/common';
- import { AuthService } from '../../providers/auth-service';
- import moment from 'moment';
- @IonicPage()
- @Component({
- selector: 'page-schedule-tab-car-modal',
- templateUrl: 'schedule-tab-car-modal.html',
- })
- export class ScheduleTabCarModalPage {
- appointments: any = []
- response: any;
- dbData: any;
- minDate: any;
- maxDate: any;
- constructor(
- public navCtrl: NavController,
- public navParams: NavParams,
- public view: ViewController,
- public modalCtrl: ModalController,
- public authService: AuthService,
- public common: Common
- ) { }
- ionViewDidLoad() {
- this.add()
- }
- ngOnInit() {
- var now = new Date();
- now.setHours(9, 0, 0, 0);
- this.minDate = moment(now).add(1, 'days').toISOString(true);
- this.maxDate = moment(now).add(1, 'years').toISOString();
- }
- add() {
- this.appointments.push({
- 'user_id': localStorage.getItem("user_id"),
- 'address': '',
- 'myaddress': true,
- 'date': '',
- 'price_id': '',
- 'price': '',
- 'price2': '',
- 'address2': localStorage.getItem("user_address")
- });
- }
- remove(index) {
- this.appointments.splice(index, 1);
- }
- submit() {
- this.common.presentLoading("Loading...");
- this.authService.postData(this.appointments, "new_car").then(
- result => {
- this.response = result;
- this.dbData = this.response.data
- if (this.dbData.success === false) {
- this.common.presentToast(this.dbData.msg);
- this.common.closeLoading();
- return false;
- }
- this.common.presentToast("success");
- this.close_modal();
- this.common.closeLoading();
- },
- err => {
- this.common.presentToast('Connection failed');
- console.log(err);
- this.common.closeLoading();
- });
- }
- prices(idx) {
- this.common.presentLoading("Loading...");
- this.common.closeLoading();
- const modal = this.modalCtrl.create("ScheduleTabCarModalPricePage", {
- 'idx': idx
- });
- modal.present();
- modal.onDidDismiss((data) => {
- if (data) {
- this.appointments[data.idx].price_id = data.price_id;
- this.appointments[data.idx].type = data.type;
- this.appointments[data.idx].price = data.price;
- }
- });
- }
- close_modal() {
- this.view.dismiss();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement