import { Injectable } from '@angular/core';
import { HttpClient, HttpHeaders } from '@angular/common/http';
import { environment } from 'src/environments/environment';
import { Observable } from 'rxjs';
import { Ccjoburlmaster,BidNumberMaster } from './collectionprocess';
import { LotMaster} from 'src/app/jobconfiguration/jobmaster/jobmaster';
let header = new HttpHeaders();
header = header.set('Content-Type', 'application/json; charset=utf-8');

@Injectable({
    providedIn: 'root'
  })
export class CollectionprocessService {
    baseUrl: string = environment.serviceUrl;
    constructor(private httpClient: HttpClient) { }

    GetJobByUserId(userid,projecdefid): Observable<any> {
        return this.httpClient.get<any>(this.baseUrl + 'api/JobConfigurationApi/GetCCJobByUserId/'+ userid+'/'+ projecdefid,{ observe: 'response' });
    }
    GetLotByJobId(jobid): Observable<any> {
        return this.httpClient.get<any>(this.baseUrl + 'api/LotApi/GetLotByJobId/'+jobid, { observe: 'response' });
    }
    PostCCLotMaster(ccjoburlmaster: Ccjoburlmaster): Observable<any> {
        return this.httpClient.post(this.baseUrl + 'api/LotApi/AddCCLotMaster',
        ccjoburlmaster, { headers: header, observe: 'response' });
    }
    PostCCJob(userid,projecdefid): Observable<any> {
      return this.httpClient.post<any>(this.baseUrl + 'api/JobConfigurationApi/PostCCJobMaster/'+ userid+'/'+ projecdefid,{ observe: 'response' });
  } 
    getJobDetails(data: any[]): Observable<any> {
        return this.httpClient.post<any>(this.baseUrl + 'api/WorkAreaApi/getJobDetails',
          data, { headers: header, observe: 'response' });
      }
/*       getalllotDetails(jobid: number): Observable<any> {
          return this.httpClient.get<any>(this.baseUrl + 'api/WorkAreaApi/getalllotDetails/' + jobid, { observe: 'response' });
      } */
      getalllotDetails(data: any): Observable<any> {
        return this.httpClient.post<any>(this.baseUrl + 'api/WorkAreaApi/getalllotDetails',data,
        {headers: header, observe: 'response' });
    }
      getLotDetailsComments(data: any[]): Observable<any> {
        return this.httpClient.post<any>(this.baseUrl + 'api/WorkAreaApi/getLotDetailsComments',
          data, { headers: header, observe: 'response' });
      }
      PostUpdateLotTransaction(data: FormData): Observable<any> {
        const headers = new HttpHeaders()
        return this.httpClient.post<any>(this.baseUrl + 'api/WorkAreaApi/CC_PostUpdatelot_transaction',
          data, { headers: headers, observe: 'response' });
      }
      getJobNo(data: any): Observable<any> {
        return this.httpClient.post<any>(this.baseUrl + 'api/DashboardApi/getJobNo',
            data, { headers: header, observe: 'response' });
    }
    PostCCLotMasterandtrans(cclotdetails: Ccjoburlmaster): Observable<any> {
        return this.httpClient.post(this.baseUrl + 'api/LotApi/AddCCLotMasterandtrans',
        cclotdetails, { headers: header, observe: 'response' });
    }
    getjoblotexcel(data: any): Observable<any> {
         return this.httpClient.post<any>(this.baseUrl + 'api/DashboardApi/getjoblotexcel',
        data, { headers: header, observe: 'response' });
    }
    addjoblotexcel(data: any): Observable<any> {
        return this.httpClient.post<any>(this.baseUrl + 'api/DashboardApi/Addjoblotinfo',
       data, { headers: header, observe: 'response' });
   }
   updatejoblotexcel(data: any): Observable<any> {
      return this.httpClient.post<any>(this.baseUrl + 'api/DashboardApi/Update',
      data, { headers: header, observe: 'response' });
    }
   /*  Putlotmetafields(lotmasters: LotMaster): Observable<any> {
        return this.httpClient.post(this.baseUrl + 'api/LotApi/Putlotmetafields',
        lotmasters, { headers: header, observe: 'response' });
    } */
    Putlotmetafields(lotmasters:any): Observable<any> {
      return this.httpClient.post(this.baseUrl + 'api/LotApi/Putlotmetafields',
      lotmasters, { headers: header, observe: 'response' });
  }
    getBylotId(data: any): Observable<any> {
        return this.httpClient.post<any>(this.baseUrl + 'api/LotApi/GetBylotId',
        data, { headers: header,observe: 'response' });
      }
      getCategory(): Observable<any> {
        debugger;
        return this.httpClient.get<any>(this.baseUrl + 'api/CategoryApi/GetActiveCategory', { observe: 'response' });
    }
    movemessage(data: FormData): Observable<any> {
        const headers = new HttpHeaders()
        return this.httpClient.post<any>(this.baseUrl + 'api/EmailReaderApi/movemessage',
        data, { headers: headers, observe: 'response' });
      }
      GetMailDetailsByID(data: FormData): Observable<any> {
        const headers = new HttpHeaders()
        return this.httpClient.post<any>(this.baseUrl + 'api/EmailReaderApi/GetMailDetailsByID',
        data, { headers: headers, observe: 'response' });
      } 
      getBylotProjectId(data: any): Observable<any> {
        return this.httpClient.post<any>(this.baseUrl + 'api/LotApi/GetBylotProjectId',
            data, { observe: 'response' });
    }
    Getdatabyname(data: any): Observable<any> {
      let header = new HttpHeaders();
      header = header.set('Content-Type', 'application/json; charset=utf-8');
      return this.httpClient.post<any>(this.baseUrl + 'api/WorkAreaApi/Bidnobyname',
        data, { headers: header, observe: 'response' });
    }
  
    Getbidlist(): Observable<any> {
      return this.httpClient.get<any>(this.baseUrl + 'api/WorkAreaApi/Getbidlist',{ observe: 'response' });
  }
  
  InsertBidnumber(bidnumber: BidNumberMaster): Observable<any> {
    return this.httpClient.post(this.baseUrl + 'api/LotApi/InsertBidnumber',
    bidnumber, { headers: header, observe: 'response' });
  }
  workarea_checkin(data:any){
    return this.httpClient.post<any>(this.baseUrl + 'api/WorkAreaApi/workareaCheckin',
        data, { headers: header,observe: 'response' });
  }
  GetLotDeatils(prdefid: number, wfdefid: number, jobid: number, userid: number): Observable<any> {
    return this.httpClient.get<any>(this.baseUrl + 'api/DashboardApi/getlot_userlst/' + prdefid.toString() + '/' + wfdefid.toString()
                                    + '/' + jobid.toString() + '/' + userid.toString());
  }
  VendorAllocation(data: FormData): Observable<any> {
    debugger;
    const headers = new HttpHeaders()
    return this.httpClient.post<any>(this.baseUrl + 'api/DashboardApi/venodorallocation',
      data, { headers: headers, observe: 'response' });
  }

  validatecompletebutton(jobid): Observable<any> {
    debugger;
    const headers = new HttpHeaders()
  return this.httpClient.get<any>(this.baseUrl + 'api/DashboardApi/validatevendorcomplelte/'+jobid, { headers: headers, observe: 'response' });
}

  getcurstagecheckoutony(tranid,userid): Observable<any> {
    return this.httpClient.post<any>(this.baseUrl + 'api/DashboardApi/getcurstagecheckoutony/'+ tranid+'/'+ userid,{ observe: 'response' });
   }
}