import{a as M}from"./chunk-5OT2MLHH.js";import{a as D}from"./chunk-4IRXRL4C.js";import"./chunk-LAJI7RPC.js";import{a as N}from"./chunk-4MZCYQX4.js";import{b as _,c as P,d as w}from"./chunk-YOJ4KGSB.js";import"./chunk-I6FSQTEP.js";import"./chunk-CO3X7TQN.js";import{a as O}from"./chunk-VSFNMVXJ.js";import"./chunk-WQ6DP4JQ.js";import{Ob as A,a as q,ab as C,c as n,l as k,tb as E,wb as U}from"./chunk-YSQLW2JA.js";import"./chunk-NVJ2ZZFT.js";import{Dc as o,Fb as h,Hb as f,Mg as I,Ng as R,Te as S,af as b,bb as g,bh as x,cd as u,dd as v,g as F,gg as l,hd as d,hg as T,jg as y,ya as p}from"./chunk-SKPDQO4E.js";var G=`<div class="h-100">
  <side-navigation *ngIf="visibleComponent">
    <ng-template side-navigation-nav>
      <div class="row">
        <div class="col-12 mb-2">
          <label class="report-form-label">{{'SOCA.USAGE_TICKET' | translate}}</label>
          <armon-select-search query="ticket" [allowMulti]="true" [(ngModel)]="filter.regionTicketIds"
            (ngModelChange)="onFilterUpdated($event)">
          </armon-select-search>
        </div>
        <div class="col-12 mb-2" *ngIf="permissionSearchOrganizationUnit">
          <label class="report-form-label">{{'REPORT.ORGANIZATION_UNITS' | translate}}</label>
          <armon-select-search query="unit" [allowMulti]="true" [(ngModel)]="filter.organizationUnitIds"
            (ngModelChange)="onFilterUpdated($event)">
          </armon-select-search>
        </div>
        <div class="col-12 mb-2" *ngIf="permissionSearchUserGroup">
          <label class="report-form-label">{{'REPORT.USER_GROUPS' | translate : languageService.userTranslate}}</label>
          <armon-select-search query="group" [allowMulti]="true" [(ngModel)]="filter.userGroupIds"
            (ngModelChange)="onFilterUpdated($event)">
          </armon-select-search>
        </div>
        <div class="col-12 mb-2" *ngIf="permissionSearchIdentity">
          <label class="report-form-label">{{'IDENTITY.TITLE' | translate : languageService.userTranslate}}</label>
          <armon-select-search query="identity" [allowMulti]="true" [(ngModel)]="filter.userIds"
            (ngModelChange)="onFilterUpdated($event)">
          </armon-select-search>
        </div>
      </div>
      <div class="col-12 mt-3 d-flex justify-content-center">
        <button class="btn btn-success btn-sm" (click)="onGetExcelClicked($event)">{{'BUTTON.EXCEL' |
          translate}}</button>
      </div>
    </ng-template>
    <ng-template side-navigation-content>
      <div class="report-data-container">
        <div class="row report-filter-container">
          <div class="col-12">
            <div class="row">
              <div class="col-12">
                <armon-date-picker [options]="datePickerOptions" (selectionChanged)="onDateSelectionChanged($event)">
                </armon-date-picker>
              </div>
            </div>
          </div>
        </div>
        <div class="row pt-5" *ngIf="!usages || usages.length==0">
          <div class="col-12">
            <nz-empty [nzNotFoundContent]="contentTpl" [nzNotFoundImage]="'./assets/images/empty/empty_list.png'">
              <ng-template #contentTpl>
                <span>{{'COMMON.NO_DATA'|translate}}</span>
              </ng-template>
            </nz-empty>
          </div>
        </div>
        <div class="row report-data-table-container" id="report-data-table-container"
          *ngIf="usages && usages.length > 0">
          <div class="col-12">
            <p-table [value]="usages" dataKey="id" [responsive]="true" rowExpandMode="single">
              <ng-template pTemplate="header">
                <tr>
                  <th>{{'SOCA.BALANCE_FULLNAME' | translate}}</th>
                  <th>{{'SOCA.USAGE_DATE' | translate}}</th>
                  <th>{{'SOCA.USAGE_TICKET_NAME' | translate}}</th>
                </tr>
              </ng-template>
              <ng-template pTemplate="body" let-usage>
                <tr class="data-row">
                  <td>
                    <span>{{usage.user.fullname}}</span>
                  </td>
                  <td>
                    <div class="report-multi-data-cell">
                      <span class="main-text">{{usage.actionDateHourText}}<armon-local-date [dateUtc]="usage.date">
                        </armon-local-date></span>
                      <span class="sub-text">{{usage.actionDateText}}</span>
                    </div>
                  </td>
                  <td>
                    <span>
                      <cds-icon shape="tickets" size="sm" class="me-2"></cds-icon>{{usage.ticketName}}
                    </span>
                  </td>
                </tr>
              </ng-template>
            </p-table>
          </div>

          <div class="col-12 my-3">
            <armon-pagination [paginationResponse]="paginationResponse" [scrollDomId]="'report-data-table-container'"
              (pageChanged)="pageChanged($event)"></armon-pagination>
          </div>
        </div>
      </div>
    </ng-template>
  </side-navigation>
</div>`;var L=`.justify-content-center{-webkit-box-pack:center;-moz-box-pack:center;-webkit-flex-pack:center;-ms-flex-pack:center;-moz-justify-content:center;-webkit-justify-content:center;justify-content:center}.justify-content-flex-end{-webkit-box-pack:end;-moz-box-pack:end;-webkit-flex-pack:end;-ms-flex-pack:end;-moz-justify-content:flex-end;-webkit-justify-content:flex-end;justify-content:flex-end}.card-footer{padding:.28rem .7rem}.alert{font-size:.756rem}@media screen and (min-width: 992px){.modal-xxl{max-width:1640px}}@media screen and (min-width: 1200px){.modal-xxxl{max-width:1860px}}.modal-fs{max-width:none;position:absolute;margin:auto;inset:16px;height:100vh;display:flex}.btn-link{text-decoration:none}.btn-link:hover{text-decoration:underline}.invalid-feedback{margin-top:0!important;font-size:.672rem!important}
`;var j=F(q());var H=function(c,e,t,a){var r=arguments.length,i=r<3?e:a===null?a=Object.getOwnPropertyDescriptor(e,t):a,s;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")i=Reflect.decorate(c,e,t,a);else for(var m=c.length-1;m>=0;m--)(s=c[m])&&(i=(r<3?s(i):r>3?s(e,t,i):s(e,t))||i);return r>3&&i&&Object.defineProperty(e,t,i),i},z=class{router;route;authService;socialAreaService;languageService;translate;filter;usages;visibleComponent=!1;paginationResponse=new R;paginationRequest=new I;permissionSearchUserGroup;permissionSearchIdentity;permissionSearchOrganizationUnit;datePickerOptions=new T;constructor(e,t,a,r,i,s){this.router=e,this.route=t,this.authService=a,this.socialAreaService=r,this.languageService=i,this.translate=s}ngOnInit(){this.permissionSearchUserGroup=this.authService.checkPermission(d.USERGROUP.getRead()),this.permissionSearchIdentity=this.authService.checkPermission(d.IDENTITY.getReadBasic()),this.permissionSearchOrganizationUnit=this.authService.checkPermission(d.ORGANIZATIONUNIT.getReadBasic()),this.filter=C.getEmptyModel(),this.datePickerOptions.items=[{type:l.Today,selected:!0},{type:l.Yesterday},{type:l.SelectDay},{type:l.CustomWithTimer}];let e=y.getDateSelection(this.datePickerOptions.items[0]);this.setDateSelection(e),this.visibleComponent=!0}ngAfterViewInit(){this.route.queryParams.subscribe(e=>{let t=!1;e&&e[n.UserId]&&e[n.UserId]!=""&&this.permissionSearchIdentity&&(this.filter.userIds=[e[n.UserId]],t=!0),e&&e[n.TicketId]&&e[n.TicketId]!=""&&(this.filter.regionTicketIds=[e[n.TicketId]],t=!0),t||this.getList()})}ngOnDestroy(){}setDateSelection(e){this.filter.dateRange.startDateTime=e.startDate,this.filter.dateRange.endDateTime=e.endDate}getList(){this.socialAreaService.getUsageList(this.filter).subscribe(e=>{this.usages=e.items,this.paginationResponse=e.pagination})}refreshList(e=!0){e&&(this.filter.pagination.skip=0),this.getList()}onFilterUpdated(e){this.refreshList()}onGetExcelClicked(e){this.socialAreaService.getUsageListAsExcel(this.filter).subscribe(t=>{this.translate.get(["PAGES.SOCA_REPORT_USAGES"]).subscribe(a=>{j.default.saveAs(t,a["PAGES.SOCA_REPORT_USAGES"]+" "+o.fromJSDate(this.filter.dateRange.startDateTime).toLocaleString(o.DATE_HUGE)+" "+o.fromJSDate(this.filter.dateRange.endDateTime).toLocaleString(o.DATE_HUGE)+".xlsx")})})}pageChanged(e){this.filter.pagination.skip=e.skip,this.filter.pagination.take=e.take,this.refreshList(!1)}onDateSelectionChanged(e){this.setDateSelection(e),this.refreshList()}static ctorParameters=()=>[{type:f},{type:h},{type:A},{type:E},{type:b},{type:u}]};z=H([p({selector:"armon-soca-usage-report",template:G,standalone:!0,imports:[g,w,_,U,S,P,k,x,M,N,D,O,v],styles:[L]})],z);export{z as SocaUsageReportComponent};
