import{a as Z}from"./chunk-4INOPVVZ.js";import{a as Q}from"./chunk-CYRQZGFX.js";import{e as K}from"./chunk-RBSSJWML.js";import"./chunk-MFZ3EXVF.js";import"./chunk-R6MVWAVG.js";import"./chunk-SDHD5Z3H.js";import"./chunk-ZDEKLPKE.js";import"./chunk-VQU52MNH.js";import"./chunk-MXSLISEG.js";import"./chunk-JNXLVPIF.js";import"./chunk-PWALQELY.js";import"./chunk-3GSDFESG.js";import"./chunk-7QEXVS2A.js";import"./chunk-FSCI3FDB.js";import"./chunk-D4RZOGGF.js";import"./chunk-PMJFQIXL.js";import"./chunk-MNVOJIXC.js";import"./chunk-IMWNGRKR.js";import"./chunk-5WJM4RWS.js";import"./chunk-UZB7YFT6.js";import"./chunk-HXEFMD5A.js";import"./chunk-KCLQIV7M.js";import"./chunk-5KCUTXXV.js";import"./chunk-C7NDY7PV.js";import"./chunk-JUDWAYYT.js";import"./chunk-WFZJP5WR.js";import"./chunk-F6KLNSUK.js";import{b as $,c as X,d as j}from"./chunk-YOJ4KGSB.js";import"./chunk-I6FSQTEP.js";import"./chunk-CO3X7TQN.js";import{a as B}from"./chunk-VSFNMVXJ.js";import"./chunk-WQ6DP4JQ.js";import{J as q,Kb as Y,Ob as J,a as oe,c as s,d as S,h as w,i as g,j as M,l as N,m as F,o as G,s as U,v as z,wb as V,y as W}from"./chunk-YSQLW2JA.js";import{Ub as c,r as L,x as a}from"./chunk-NVJ2ZZFT.js";import{Dc as i,Fb as v,Ng as x,Pd as O,Qf as C,Te as b,Vc as T,ab as R,af as A,bb as y,cd as E,dd as I,eh as H,g as ae,gb as P,gg as n,hd as k,hg as _,ig as l,wa as h,ya as D}from"./chunk-SKPDQO4E.js";var ee=`<div class="h-100">
  <side-navigation #sideNavigation>
    <ng-template side-navigation-nav>
      <div *ngIf="filter">
        <div class="row">
          <div class="col-12">
            <label class="report-form-label">{{'REPORT.WORKPLANS' | translate}}</label>
            <armon-select-search query="workplan" [allowMulti]="true" [(ngModel)]="filter.userFilter.workPlanIds">
            </armon-select-search>
          </div>
          <div class="col-12">
            <label class="report-form-label">{{'REPORT.EMPLOYEES' | translate}}</label>
            <armon-select-search query="identity" [allowMulti]="true" [(ngModel)]="filter.userFilter.userIds">
            </armon-select-search>
          </div>
          <div class="col-12">
            <label class="report-form-label">{{'REPORT.ORGANIZATION_UNITS' | translate}}</label>
            <armon-select-search query="unit" [allowMulti]="true" [(ngModel)]="filter.userFilter.organizationUnitIds">
            </armon-select-search>
            <label class="report-checkbox-label" nz-checkbox
              *ngIf="filter.userFilter.organizationUnitIds && filter.userFilter.organizationUnitIds.length > 0"
              [(ngModel)]="filter.userFilter.applyOrganizationUnitFilterHierarchically">{{'REPORT.SHOW_HIERARCHICALLY'|
              translate}}</label>
          </div>
          <div class="col-12">
            <label class="report-form-label">{{'REPORT.USER_GROUPS' | translate :
              languageService.userTranslate}}</label>
            <armon-select-search query="group" [allowMulti]="true" [(ngModel)]="filter.userFilter.userGroupIds">
            </armon-select-search>
          </div>
          <div class="col-12">
            <label class="report-form-label">{{'REPORT.WORKING_STATUS' | translate}}</label>
            <nz-select class="w-100" [(ngModel)]="filter.userFilter.workStatusFilter" nzSize="small" nzMode="multiple"
              nzPlaceHolder="{{'COMMON.ALL'|translate}}">
              <nz-option *ngFor="let userWorkingStatus of userWorkingStatusList" [nzValue]="userWorkingStatus.type"
                [nzLabel]="userWorkingStatus.description |
                  translate"></nz-option>
            </nz-select>
          </div>
          <div class="col-12 mb-1 mt-2" *ngIf="filter">
            <label class="report-form-label">{{'REPORT.USER_STATUS' | translate}}</label>
            <armon-identity-status [(ngModel)]="filter.userFilter.userOrganizationStatus"></armon-identity-status>
          </div>
        </div>

        <!-- Buttons for filtering state -->
        <div class="centered filterButtons">


          <button nz-dropdown [nzDropdownMenu]="menuPrint" class="btn btn-success btn-sm me-2">
            {{'BUTTON.DOWNLOAD' | translate}}
            <cds-icon shape="angle" direction="down"></cds-icon>
          </button>
          <nz-dropdown-menu #menuPrint="nzDropdownMenu">
            <ul nz-menu>
              <li nz-menu-item (click)="onGetExcelClicked($event)">{{'BUTTON.EXCEL'|translate}}</li>
              <li nz-menu-item (click)="onGetPdfClicked($event)" *ngIf="!rangeSelected">{{'BUTTON.PDF'|translate}}</li>
            </ul>
          </nz-dropdown-menu>
          <button class="btn btn-primary btn-sm" (click)="onGetReportClicked($event)">{{'REPORT.GET_REPORT' |
            translate}}</button>
        </div>

      </div>
    </ng-template>
    <ng-template side-navigation-content>
      <div class="report-data-container">
        <div class="row report-filter-container">
          <div class="col-12" style="min-height:0;">
            <armon-report-template-panel *ngIf="dayView" [reportType]="reportDailyTemplateType"
              [templateId]="reportTemplateId" class="d-none d-md-block" [filter]="filter"
              (templateLoaded)="onTemplateLoaded($event)">
            </armon-report-template-panel>
            <armon-report-template-panel *ngIf="!dayView" [reportType]="reportRangeTemplateType"
              [templateId]="reportTemplateId" class="d-none d-md-block" [filter]="filter"
              (templateLoaded)="onTemplateLoaded($event)">
            </armon-report-template-panel>
            <div class="row">
              <div class="col-12">
                <armon-date-picker #datePicker [options]="datePickerOptions"
                  (selectionChanged)="onDateSelectionChanged($event)">
                </armon-date-picker>
              </div>
            </div>
          </div>
          <div class="col-12">
            <div class="row">
              <div class="col-12">
                <armon-sorting-picker #sortingPicker [data]="sortingPickerData"
                  (selectionChanged)="onSortingSelectionChanged($event)">
                </armon-sorting-picker>
              </div>
            </div>
          </div>
        </div>
        <div class="row report-data-table-container" id="report-data-table-container" *ngIf="dayView">
          <div class="col-12">
            <ng-container *ngFor="let record of records">
              <armon-report-pacs-daily-user [record]="record" [day]="selectedDay"></armon-report-pacs-daily-user>
            </ng-container>
          </div>
          <ng-template *ngTemplateOutlet="paginationTemplate"></ng-template>
        </div>
        <div class="row report-data-table-container" id="report-data-table-container" *ngIf="!dayView">
          <div class="col-12">
            <ng-container *ngFor="let rangeItem of rangeItems">
              <armon-report-entry-exit-user-range-summary [userCaptions]="rangeItem.userCaptions"
                [summary]="rangeItem.summary" [userId]="rangeItem.userId" [startDay]="filter.dateRange.startDateTime"
                [workStatusFilter]="filter.userFilter.workStatusFilter" [endDay]="filter.dateRange.endDateTime"
                [showDays]="true">
              </armon-report-entry-exit-user-range-summary>
            </ng-container>
          </div>
          <ng-template *ngTemplateOutlet="paginationTemplate"></ng-template>
        </div>
      </div>
    </ng-template>
  </side-navigation>
</div>

<ng-template #paginationTemplate>
  <div class="col-12 mb-3 mt-3">
    <armon-pagination [paginationResponse]="paginationResponse" [scrollDomId]="'report-data-table-container'"
      (pageChanged)="pageChanged($event)"></armon-pagination>
  </div>
</ng-template>`;var te="";var f=ae(oe());var le=function(u,e,t,r){var p=arguments.length,o=p<3?e:r===null?r=Object.getOwnPropertyDescriptor(e,t):r,d;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")o=Reflect.decorate(u,e,t,r);else for(var m=u.length-1;m>=0;m--)(d=u[m])&&(o=(p<3?d(o):p>3?d(e,t,o):d(e,t))||o);return p>3&&o&&Object.defineProperty(e,t,o),o},ie=class{interactionService;reportService;pacsService;sessionService;translate;languageService;route;authService;filter;records=[];rangeItems;reportDailyTemplateType=S.PACSDailyWorkingDetailsForEmployees;reportRangeTemplateType=S.PACSWorkignDetailsForEmployeesInDateRange;reportTemplateId;selectedDay;useAsHumanResources=!1;dayView=!0;rangeSelected=!0;paginationResponse=new x;datePickerOptions=new _;datePicker;userWorkingStatusList=Q;sortingPicker;sortingPickerData;getDaySortingPickerData=()=>({items:[{value:a.EmployeeName,label:"REPORT.SORTING_USERNAME",showDirection:!0,isAlpha:!0,directionDefault:g.ASC},{value:a.EmployeeUniqueId,label:"REPORT.SORTING_USER_UNIQUE_FIELD",showDirection:!0,labelTranslationData:{uniqueIdCaption:this.sessionService.currentOrganizationUniqueIdCaption?this.sessionService.currentOrganizationUniqueIdCaption:"-"}},{value:a.LateEntrance,label:"REPORT.SORTING_PACS_LATE_ACCESS",showDirection:!0},{value:a.EarylLeave,label:"REPORT.SORTING_PACS_EARLY_EXIT",showDirection:!0},{value:a.FirstEntrance,label:"REPORT.SORTING_PACS_ENTRANCE",showDirection:!0,directionDefault:g.ASC},{value:a.LastLeave,label:"REPORT.SORTING_PACS_EXIT",showDirection:!0,directionDefault:g.ASC},{value:a.ExtraWork,label:"REPORT.SORTING_EXTRAWORK",showDirection:!0},{value:a.MissingWork,label:"REPORT.SORTING_MISSEDWORK",showDirection:!0}]});_rangeSortingPickerData={items:[{value:a.LateEntrance,label:"REPORT.SORTING_PACS_LATE_ACCESS",showDirection:!0,selected:!0},{value:a.EarylLeave,label:"REPORT.SORTING_PACS_EARLY_EXIT",showDirection:!0},{value:a.EmployeeName,label:"REPORT.SORTING_USERNAME",showDirection:!0,isAlpha:!0,directionDefault:g.ASC}]};constructor(e,t,r,p,o,d,m,re){this.interactionService=e,this.reportService=t,this.pacsService=r,this.sessionService=p,this.translate=o,this.languageService=d,this.route=m,this.authService=re}ngOnInit(){this.useAsHumanResources=this.authService.checkPermission(k.PPERMISSION.getHRApprovement()),this.datePickerOptions.items=[{type:n.Today,selected:!0},{type:n.Yesterday},{type:n.SelectDay,max:i.local().endOf("day").toJSDate()},{type:n.CurrentMonth,hasDivider:!0},{type:n.PreviousMonth},{type:n.SelectMonth},{type:n.Custom,maxDays:31}],this.createFilter(!1),this.sortingPickerData=this.getDaySortingPickerData()}ngAfterViewInit(){this.route.queryParams.subscribe(e=>{e&&e[s.Day]&&e[s.Day]!=""?this.setDateSelection(this.datePicker.setPickerItemAndDate(2,i.fromISO(e[s.Day]).toJSDate())):(e&&e[s.ReportTemplateId]&&e[s.ReportTemplateId]!=""&&(this.reportTemplateId=e[s.ReportTemplateId],this.dayView=+e[s.ReportTemplateType]==S.PACSDailyWorkingDetailsForEmployees),this.setDefaultDateSelection()),e&&e[s.HasState]&&e[s.HasState]=="1"&&window.history.state&&window.history.state.idBasedUserFilter&&(this.filter.userFilter=window.history.state.idBasedUserFilter),this.setSortingSelection(this.sortingPickerData.items[0].value,T.ASC),this.reportTemplateId||this.fetchReportData()})}createFilter(e=!0){this.filter=c.getEmptyModel(),e&&this.setDefaultDateSelection()}setDefaultDateSelection(){this.dayView?this.setDateSelection(this.datePicker.setPickerItemAndDate(0)):this.setDateSelection(this.datePicker.setPickerItemAndDate(3))}lastDateSelection;setDateSelection(e){this.lastDateSelection=e,l.isRange(this.lastDateSelection.type)?(delete this.filter.date,this.filter.dateRange={startDateTime:i.fromJSDate(e.startDate).toFormat("yyyy-MM-dd"),endDateTime:i.fromJSDate(e.endDate).toFormat("yyyy-MM-dd")}):(delete this.filter.dateRange,this.filter.date=i.fromJSDate(e.startDate).toFormat("yyyy-MM-dd")),this.rangeSelected!=l.isRange(this.lastDateSelection.type)&&(l.isRange(this.lastDateSelection.type)?this.sortingPickerData=this._rangeSortingPickerData:this.sortingPickerData=this.getDaySortingPickerData(),this.sortingPickerData.items.findIndex(t=>t.value==this.filter.sortType)==-1&&(this.filter.sortType=L.LateAccess)),this.rangeSelected=l.isRange(this.lastDateSelection.type),this.selectedDay=this.filter.date}setSortingSelection(e,t){this.filter.sortType=e,this.filter.sortOrder=t}onGetReportClicked(e){this.filter.paginationRequest.skip=0,this.fetchReportData()}onGetExcelClicked(e){l.isRange(this.lastDateSelection.type)?this.reportService.exportPacsWorkingDetailRangeExcel(c.getRequestModel(this.filter)).subscribe(t=>{this.translate.get(["PAGES.REPORT_PACS_DAILY_DETAILED"]).subscribe(r=>{f.default.saveAs(t,r["PAGES.REPORT_PACS_DAILY_DETAILED"]+" "+i.fromJSDate(this.lastDateSelection.startDate).toLocaleString(i.DATE_HUGE)+"-"+i.fromJSDate(this.lastDateSelection.endDate).toLocaleString(i.DATE_HUGE)+".xlsx")})}):this.reportService.exportPacsWorkingDetailExcel(c.getRequestModel(this.filter)).subscribe(t=>{this.translate.get(["PAGES.REPORT_PACS_DAILY_DETAILED"]).subscribe(r=>{f.default.saveAs(t,r["PAGES.REPORT_PACS_DAILY_DETAILED"]+" "+i.fromJSDate(this.lastDateSelection.startDate).toLocaleString(i.DATE_HUGE)+".xlsx")})})}onGetPdfClicked(e){this.reportService.exportPacsWorkingDetailPdf(c.getRequestModel(this.filter)).subscribe(t=>{this.translate.get(["PAGES.REPORT_PACS_DAILY_DETAILED"]).subscribe(r=>{f.default.saveAs(t,r["PAGES.REPORT_PACS_DAILY_DETAILED"]+" "+i.fromJSDate(this.lastDateSelection.startDate).toLocaleString(i.DATE_HUGE)+".pdf")})})}fetchReportData(){l.isRange(this.lastDateSelection.type)?this.reportService.getPacsWorkingDetailRange(c.getRequestModel(this.filter)).subscribe(e=>{this.rangeItems=e.items,this.paginationResponse=e.pagination,this.dayView=!1}):this.reportService.getPacsWorkingDetail(c.getRequestModel(this.filter)).subscribe(e=>{this.records=e.items||[],this.paginationResponse=e.paginationResponse,this.dayView=!0})}pageChanged(e){this.filter.paginationRequest.skip=e.skip,this.filter.paginationRequest.take=e.take,this.fetchReportData()}onDateSelectionChanged(e){this.setDateSelection(e),this.filter.paginationRequest.skip=0,this.fetchReportData()}onSortingSelectionChanged(e){this.setSortingSelection(e.value,e.direction),this.fetchReportData()}onTemplateLoaded(e){e.filter&&(this.createFilter(),Object.assign(this.filter,e.filter),this.sortingPicker&&e.filter.sortOrder&&e.filter.sortType&&(this.filter.sortOrder=e.filter.sortOrder,this.filter.sortType=e.filter.sortType,this.sortingPicker.setSelection(e.filter.sortType,e.filter.sortOrder))),setTimeout(()=>{this.fetchReportData()},1e3)}static ctorParameters=()=>[{type:C},{type:q},{type:M},{type:O},{type:E},{type:A},{type:v},{type:J}];static propDecorators={datePicker:[{type:h,args:["datePicker"]}],sortingPicker:[{type:h,args:["sortingPicker"]}]}};ie=le([D({selector:"armon-report-pacs-daily",template:ee,standalone:!0,imports:[j,$,y,V,b,G,H,R,F,W,z,U,X,Y,N,w,K,P,Z,B,I],styles:[te]})],ie);export{ie as ReportPacsDailyComponent};
