@hitsoft/e-donusum 1.0.114 → 1.0.115

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (36) hide show
  1. package/esm2020/lib/auto-send-rules/auto-send-rule/auto-send-rule.module.mjs +1 -1
  2. package/esm2020/lib/components/hit-despatches/hit-despatch.component.mjs +36 -11
  3. package/esm2020/lib/components/hit-inbound-despatches/hit-inbound-despatch.component.mjs +50 -6
  4. package/esm2020/lib/components/hit-inbound-invoices/hit-inbound-invoice.component.mjs +36 -10
  5. package/esm2020/lib/components/hit-invoices/hit-invoice.component.mjs +37 -8
  6. package/esm2020/lib/hit-proxy/hit-despatches/hit-despatch.service.mjs +28 -5
  7. package/esm2020/lib/hit-proxy/hit-inbound-despatches/hit-inbound-despatch.service.mjs +3 -3
  8. package/esm2020/lib/hit-proxy/hit-inbound-invoices/hit-inbound-invoice.service.mjs +16 -2
  9. package/esm2020/lib/hit-proxy/hit-invoices/hit-invoice.service.mjs +44 -8
  10. package/esm2020/lib/hit-proxy/shared/hit-shared.service.mjs +94 -7
  11. package/esm2020/lib/proxy/auto-send-rule-doc-types/index.mjs +1 -1
  12. package/esm2020/lib/proxy/auto-send-rule-scenarios/index.mjs +1 -1
  13. package/esm2020/lib/proxy/auto-send-rules/index.mjs +1 -1
  14. package/esm2020/lib/proxy/document-serials/index.mjs +1 -1
  15. package/esm2020/lib/proxy/gib-partner-pks/index.mjs +1 -1
  16. package/esm2020/lib/proxy/note-rule-doc-types/index.mjs +1 -1
  17. package/esm2020/lib/proxy/note-rule-scenarios/index.mjs +1 -1
  18. package/esm2020/lib/proxy/note-rules/index.mjs +1 -1
  19. package/esm2020/lib/proxy/params-companies/index.mjs +1 -1
  20. package/esm2020/lib/proxy/params-generals/index.mjs +1 -1
  21. package/esm2020/lib/proxy/params-integrators/index.mjs +1 -1
  22. package/esm2020/lib/proxy/paramse-dispatches/index.mjs +1 -1
  23. package/esm2020/lib/proxy/paramse-invoices/index.mjs +1 -1
  24. package/esm2020/lib/proxy/xslt-formats/index.mjs +1 -1
  25. package/esm2020/lib/proxy/xslt-rule-doc-types/index.mjs +1 -1
  26. package/esm2020/lib/proxy/xslt-rule-scenarios/index.mjs +1 -1
  27. package/esm2020/lib/proxy/xslt-rules/index.mjs +1 -1
  28. package/fesm2015/hitsoft-e-donusum.mjs +335 -53
  29. package/fesm2015/hitsoft-e-donusum.mjs.map +1 -1
  30. package/fesm2020/hitsoft-e-donusum.mjs +333 -53
  31. package/fesm2020/hitsoft-e-donusum.mjs.map +1 -1
  32. package/lib/hit-proxy/hit-despatches/hit-despatch.service.d.ts +7 -2
  33. package/lib/hit-proxy/hit-inbound-invoices/hit-inbound-invoice.service.d.ts +4 -1
  34. package/lib/hit-proxy/hit-invoices/hit-invoice.service.d.ts +11 -2
  35. package/lib/hit-proxy/shared/hit-shared.service.d.ts +1 -1
  36. package/package.json +1 -1
@@ -17,15 +17,16 @@ import { PageModule } from '@abp/ng.components/page';
17
17
  import { DateAdapter } from '@abp/ng.theme.shared/extensions';
18
18
  import * as i4 from '@angular/forms';
19
19
  import { Validators } from '@angular/forms';
20
- import { finalize, tap, filter, switchMap } from 'rxjs/operators';
20
+ import { finalize, tap, filter, switchMap, map } from 'rxjs/operators';
21
21
  import * as i6 from '@swimlane/ngx-datatable';
22
22
  import * as i5 from '@angular/common';
23
23
  import * as AspNetData from 'devextreme-aspnet-data-nojquery';
24
24
  import * as i11 from 'devextreme-angular';
25
25
  import { DxDataGridModule, DxTextAreaModule, DxTextBoxModule, DxHtmlEditorModule, DxSelectBoxModule, DxLookupModule, DxTabPanelModule, DxCheckBoxModule, DxDateBoxModule, DxNumberBoxModule, DxTemplateModule, DxDropDownBoxModule, DxRadioGroupModule, DxPopupModule } from 'devextreme-angular';
26
26
  import * as i3$1 from 'devextreme-angular/ui/nested';
27
- import { finalize as finalize$1, tap as tap$1, filter as filter$1, switchMap as switchMap$1, firstValueFrom, BehaviorSubject, ReplaySubject } from 'rxjs';
27
+ import { finalize as finalize$1, tap as tap$1, filter as filter$1, switchMap as switchMap$1, firstValueFrom, BehaviorSubject, ReplaySubject, map as map$1 } from 'rxjs';
28
28
  import * as i13 from 'devextreme-angular/core';
29
+ import * as i3$2 from '@angular/common/http';
29
30
  import * as i1$2 from '@angular/platform-browser';
30
31
  import trMessages from 'devextreme/localization/messages/tr.json';
31
32
  import { loadMessages, locale } from 'devextreme/localization';
@@ -9154,9 +9155,12 @@ var InvoiceType;
9154
9155
  })(InvoiceType || (InvoiceType = {}));
9155
9156
 
9156
9157
  class HitInvoiceService {
9157
- constructor(restService, devexService) {
9158
+ constructor(restService, devexService, http, configState // ← ekle
9159
+ ) {
9158
9160
  this.restService = restService;
9159
9161
  this.devexService = devexService;
9162
+ this.http = http;
9163
+ this.configState = configState;
9160
9164
  this.apiName = 'eDonusum';
9161
9165
  this.LoadInvoices = this.devexService.createStore({
9162
9166
  key: "id",
@@ -9234,10 +9238,32 @@ class HitInvoiceService {
9234
9238
  url: '/api/e-donusum/invoices/get-invoice-response',
9235
9239
  params: { startDate: startDate, endDate: endDate, }
9236
9240
  }, { apiName: this.apiName });
9237
- this.getInvoiceView = (invoiceUUID) => this.restService.request({
9238
- method: 'GET',
9239
- url: `/api/e-donusum/invoices/get-invoice-view/${invoiceUUID}`,
9240
- }, { apiName: this.apiName });
9241
+ this.getInvoiceViewToken = (invoiceUUID) => {
9242
+ const httpClient = this.restService.http;
9243
+ // ABP'nin base URL'sini al
9244
+ const baseUrl = this.restService.configState?.getDeep('environment.apis.eDonusum.url')
9245
+ || this.restService.configState?.getDeep('environment.apis.default.url')
9246
+ || 'https://localhost:44359';
9247
+ return httpClient.get(`${baseUrl}/api/e-donusum/invoices/get-invoice-view/${invoiceUUID}`, {
9248
+ responseType: 'blob',
9249
+ observe: 'response',
9250
+ headers: {
9251
+ 'Authorization': `Bearer ${this.getToken()}`
9252
+ }
9253
+ }).pipe(map(response => {
9254
+ const cd = response.headers?.get('Content-Disposition');
9255
+ let filename = 'fatura.pdf';
9256
+ if (cd) {
9257
+ const match = cd.match(/filename[^;=\n]*=["']?([^"';\n]+)["']?/i);
9258
+ if (match)
9259
+ filename = match[1].trim();
9260
+ }
9261
+ return {
9262
+ blobUrl: URL.createObjectURL(response.body),
9263
+ filename: filename
9264
+ };
9265
+ }));
9266
+ };
9241
9267
  this.showAllFiles = (invoiceUUID) => this.restService.request({
9242
9268
  method: 'GET',
9243
9269
  url: `/api/e-donusum/invoices/show-all-files/${invoiceUUID}`,
@@ -9258,15 +9284,24 @@ class HitInvoiceService {
9258
9284
  params: { blobID: blobID }
9259
9285
  }, { apiName: this.apiName });
9260
9286
  }
9287
+ // invoice.service.ts - yeni method ekle
9288
+ getInvoiceViewUrl(invoiceUUID) {
9289
+ return `/api/e-donusum/invoices/get-invoice-view/${invoiceUUID}`;
9290
+ }
9291
+ getToken() {
9292
+ return localStorage.getItem('access_token')
9293
+ || sessionStorage.getItem('access_token')
9294
+ || '';
9295
+ }
9261
9296
  }
9262
- HitInvoiceService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.3.0", ngImport: i0, type: HitInvoiceService, deps: [{ token: i1.RestService }, { token: DevexpressRestService }], target: i0.ɵɵFactoryTarget.Injectable });
9297
+ HitInvoiceService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.3.0", ngImport: i0, type: HitInvoiceService, deps: [{ token: i1.RestService }, { token: DevexpressRestService }, { token: i3$2.HttpClient }, { token: i1.ConfigStateService }], target: i0.ɵɵFactoryTarget.Injectable });
9263
9298
  HitInvoiceService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "14.3.0", ngImport: i0, type: HitInvoiceService, providedIn: 'root' });
9264
9299
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.3.0", ngImport: i0, type: HitInvoiceService, decorators: [{
9265
9300
  type: Injectable,
9266
9301
  args: [{
9267
9302
  providedIn: 'root',
9268
9303
  }]
9269
- }], ctorParameters: function () { return [{ type: i1.RestService }, { type: DevexpressRestService }]; } });
9304
+ }], ctorParameters: function () { return [{ type: i1.RestService }, { type: DevexpressRestService }, { type: i3$2.HttpClient }, { type: i1.ConfigStateService }]; } });
9270
9305
 
9271
9306
  class HitFileDocumentTypeService {
9272
9307
  constructor(restService, devexService) {
@@ -9321,14 +9356,101 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.3.0", ngImpor
9321
9356
  class HitSharedService {
9322
9357
  constructor() {
9323
9358
  this.apiName = 'eDonusum';
9324
- this.previewFile = (base64) => {
9359
+ /*previewFile = (base64, filename: string = 'fatura.pdf') => {
9360
+ const cleanBase64 = base64.includes(',') ? base64.split(',')[1] : base64;
9361
+ const bytes = Uint8Array.from(atob(cleanBase64), c => c.charCodeAt(0));
9362
+
9363
+ // File objesi blob'a filename metadata'sı ekler
9364
+ const file = new File([bytes], filename, { type: 'application/pdf' });
9365
+ const url = URL.createObjectURL(file);
9366
+
9367
+ const newTab = window.open('', '_blank');
9368
+ newTab.history.pushState({}, filename, `/${filename}`);
9369
+ newTab.document.write(`
9370
+ <html>
9371
+ <head><title>${filename}</title></head>
9372
+ <body style="margin:0;overflow:hidden">
9373
+ <iframe
9374
+ src="${url}#toolbar=1"
9375
+ style="width:100%;height:100vh;border:none;"
9376
+ ></iframe>
9377
+ </body>
9378
+ </html>
9379
+ `);
9380
+
9381
+ setTimeout(() => URL.revokeObjectURL(url), 60_000);
9382
+ }*/
9383
+ this.previewFile = (base64, filename = 'fatura.pdf') => {
9325
9384
  const cleanBase64 = base64.includes(',') ? base64.split(',')[1] : base64;
9326
9385
  const bytes = Uint8Array.from(atob(cleanBase64), c => c.charCodeAt(0));
9327
- const blob = new Blob([bytes], { type: 'application/pdf' });
9328
- const url = URL.createObjectURL(blob);
9329
- // Yeni tab (preview)
9330
- window.open(url, '_blank', 'noopener');
9331
- // İstersen kısa süre sonra URL'i serbest bırak (preview açıldıktan sonra)
9386
+ const file = new File([bytes], filename, { type: 'application/pdf' });
9387
+ const url = URL.createObjectURL(file);
9388
+ const newTab = window.open('', '_blank');
9389
+ newTab.history.pushState({}, filename, `/${filename}`);
9390
+ newTab.document.write(`<!DOCTYPE html>
9391
+ <html>
9392
+ <head>
9393
+ <title>${filename}</title>
9394
+ <style>
9395
+ * { margin:0; padding:0; box-sizing:border-box; }
9396
+ body { background:#525659; font-family:sans-serif; }
9397
+ #toolbar {
9398
+ position:fixed; top:0; left:0; right:0; height:48px;
9399
+ background:#323639; display:flex; align-items:center;
9400
+ padding:0 16px; gap:16px; z-index:99;
9401
+ color:white; font-size:14px;
9402
+ }
9403
+ #pages { margin-top:56px; display:flex; flex-direction:column; align-items:center; padding:16px; gap:16px; }
9404
+ canvas { box-shadow:0 2px 8px #0006; background:white; }
9405
+ </style>
9406
+ </head>
9407
+ <body>
9408
+ <div id="toolbar">
9409
+ <span>${filename}</span>
9410
+ <span id="pageInfo"></span>
9411
+ <button onclick="changePage(-1)" style="background:#555;color:white;border:none;padding:4px 10px;cursor:pointer;border-radius:4px">◀</button>
9412
+ <button onclick="changePage(1)" style="background:#555;color:white;border:none;padding:4px 10px;cursor:pointer;border-radius:4px">▶</button>
9413
+ <a href="${url}" download="${filename}"
9414
+ style="margin-left:auto;background:#1976d2;color:white;padding:6px 14px;border-radius:4px;text-decoration:none">
9415
+ ⬇ İndir (${filename})
9416
+ </a>
9417
+ </div>
9418
+ <div id="pages"></div>
9419
+ <script src="https://cdnjs.cloudflare.com/ajax/libs/pdf.js/3.11.174/pdf.min.js"></script>
9420
+ <script>
9421
+ pdfjsLib.GlobalWorkerOptions.workerSrc = 'https://cdnjs.cloudflare.com/ajax/libs/pdf.js/3.11.174/pdf.worker.min.js';
9422
+ let currentPage = 1, totalPages = 0, pdfDoc = null;
9423
+
9424
+ pdfjsLib.getDocument('${url}').promise.then(pdf => {
9425
+ pdfDoc = pdf;
9426
+ totalPages = pdf.numPages;
9427
+ renderPage(currentPage);
9428
+ });
9429
+
9430
+ function renderPage(num) {
9431
+ pdfDoc.getPage(num).then(page => {
9432
+ const viewport = page.getViewport({ scale: 1.5 });
9433
+ const canvas = document.createElement('canvas');
9434
+ canvas.width = viewport.width;
9435
+ canvas.height = viewport.height;
9436
+ document.getElementById('pages').innerHTML = '';
9437
+ document.getElementById('pages').appendChild(canvas);
9438
+ page.render({ canvasContext: canvas.getContext('2d'), viewport });
9439
+ document.getElementById('pageInfo').textContent = num + ' / ' + totalPages;
9440
+ });
9441
+ }
9442
+
9443
+ function changePage(delta) {
9444
+ const next = currentPage + delta;
9445
+ if (next >= 1 && next <= totalPages) {
9446
+ currentPage = next;
9447
+ renderPage(currentPage);
9448
+ }
9449
+ }
9450
+ </script>
9451
+ </body>
9452
+ </html>
9453
+ `);
9332
9454
  setTimeout(() => URL.revokeObjectURL(url), 60000);
9333
9455
  };
9334
9456
  }
@@ -9555,13 +9677,42 @@ class HitInvoiceComponent {
9555
9677
  this.invoiceService.getInvoiceResponses(new Date().toISOString(), new Date().toISOString()).subscribe(() => this.dxInvoiceInstance.instance.refresh());
9556
9678
  }
9557
9679
  getInvoiceView(record) {
9558
- this.invoiceService.getInvoiceView(record.uuId).subscribe(item => {
9559
- const source = `data:${item.mimeType};base64,${item.content}`;
9560
- this.hitSharedService.previewFile(item.content);
9561
- /*const link = document.createElement('a');
9562
- link.href = source;
9563
- link.download = `${item.filename}`;
9564
- link.click();*/
9680
+ this.invoiceService.getInvoiceViewToken(record.uuId).subscribe(({ blobUrl, filename }) => {
9681
+ const newTab = window.open('', '_blank');
9682
+ newTab.document.write(`
9683
+ <html>
9684
+ <head>
9685
+ <title>${filename}</title>
9686
+ <style>
9687
+ * { margin: 0; padding: 0; box-sizing: border-box; }
9688
+ body { display: flex; flex-direction: column; height: 100vh; font-family: sans-serif; }
9689
+ .bar {
9690
+ background: #1976d2; color: white;
9691
+ padding: 6px 16px; display: flex;
9692
+ align-items: center; justify-content: space-between;
9693
+ flex-shrink: 0;
9694
+ }
9695
+ .bar span { font-size: 14px; }
9696
+ .bar a {
9697
+ color: white; text-decoration: none; font-size: 13px;
9698
+ background: rgba(255,255,255,0.2); padding: 4px 14px;
9699
+ border-radius: 4px; border: 1px solid rgba(255,255,255,0.4);
9700
+ }
9701
+ .bar a:hover { background: rgba(255,255,255,0.35); }
9702
+ iframe { flex: 1; border: none; width: 100%; }
9703
+ </style>
9704
+ </head>
9705
+ <body>
9706
+ <div class="bar">
9707
+ <span>📄 ${filename}</span>
9708
+ <a href="${blobUrl}" download="${filename}">⬇ İndir</a>
9709
+ </div>
9710
+ <iframe src="${blobUrl}"></iframe>
9711
+ </body>
9712
+ </html>
9713
+ `);
9714
+ newTab.document.close();
9715
+ setTimeout(() => URL.revokeObjectURL(blobUrl), 300000);
9565
9716
  });
9566
9717
  }
9567
9718
  showAllFiles(record) {
@@ -10189,7 +10340,20 @@ class HitInboundInvoiceService {
10189
10340
  method: 'GET',
10190
10341
  url: `/api/e-donusum/invoices/get-inbound-invoice-view/${invoiceGUID}`,
10191
10342
  params: { invoiceGUID: invoiceGUID }
10192
- }, { apiName: this.apiName });
10343
+ }, { apiName: this.apiName }).pipe(map$1(item => {
10344
+ // base64 string → blob
10345
+ const byteCharacters = atob(item.content);
10346
+ const byteNumbers = new Array(byteCharacters.length);
10347
+ for (let i = 0; i < byteCharacters.length; i++) {
10348
+ byteNumbers[i] = byteCharacters.charCodeAt(i);
10349
+ }
10350
+ const byteArray = new Uint8Array(byteNumbers);
10351
+ const blob = new Blob([byteArray], { type: 'application/pdf' });
10352
+ return {
10353
+ blobUrl: URL.createObjectURL(blob),
10354
+ filename: item.filename || 'fatura.pdf'
10355
+ };
10356
+ }));
10193
10357
  this.getBankAccountByCurrency = (actCurr) => this.restService.request({
10194
10358
  method: 'GET',
10195
10359
  url: '/api/e-donusum/invoices/get-bank-accounts',
@@ -10460,14 +10624,41 @@ class HitInboundInvoiceComponent {
10460
10624
  this.service.getInboundInvoice(new Date().toISOString(), new Date().toISOString()).subscribe(() => this.dxInboundInvoiceInstance.instance.refresh());
10461
10625
  }
10462
10626
  getInvoicePreview(record) {
10463
- debugger;
10464
- this.service.getInboundInvoiceView(record.uuId).subscribe(item => {
10465
- const source = `data:${item.mimeType};base64,${item.content}`;
10466
- this.hitSharedService.previewFile(item.content);
10467
- /*const link = document.createElement('a');
10468
- link.href = source;
10469
- link.download = `${item.filename}`;
10470
- link.click();*/
10627
+ this.service.getInboundInvoiceView(record.uuId).subscribe(({ blobUrl, filename }) => {
10628
+ const newTab = window.open('', '_blank');
10629
+ newTab.document.write(`
10630
+ <html>
10631
+ <head>
10632
+ <title>${filename}</title>
10633
+ <style>
10634
+ * { margin: 0; padding: 0; box-sizing: border-box; }
10635
+ body { display: flex; flex-direction: column; height: 100vh; font-family: sans-serif; }
10636
+ .bar {
10637
+ background: #1976d2; color: white;
10638
+ padding: 6px 16px; display: flex;
10639
+ align-items: center; justify-content: space-between;
10640
+ flex-shrink: 0;
10641
+ }
10642
+ .bar span { font-size: 14px; }
10643
+ .bar a {
10644
+ color: white; text-decoration: none; font-size: 13px;
10645
+ background: rgba(255,255,255,0.2); padding: 4px 14px;
10646
+ border-radius: 4px; border: 1px solid rgba(255,255,255,0.4);
10647
+ }
10648
+ iframe { flex: 1; border: none; width: 100%; }
10649
+ </style>
10650
+ </head>
10651
+ <body>
10652
+ <div class="bar">
10653
+ <span>📄 ${filename}</span>
10654
+ <a href="${blobUrl}" download="${filename}">⬇ İndir</a>
10655
+ </div>
10656
+ <iframe src="${blobUrl}"></iframe>
10657
+ </body>
10658
+ </html>
10659
+ `);
10660
+ newTab.document.close();
10661
+ setTimeout(() => URL.revokeObjectURL(blobUrl), 300000);
10471
10662
  });
10472
10663
  }
10473
10664
  openResponseModal(record) {
@@ -10815,7 +11006,6 @@ class HitInboundInvoiceComponent {
10815
11006
  this.isModalBusyForDocument = true;
10816
11007
  const dataSource = this.dxDocumentLines.instance.getDataSource();
10817
11008
  dataSource.store().load().then((gridLines) => {
10818
- console.log("GERÇEK DATA:", gridLines); // her zaman array
10819
11009
  if (gridLines.length == 0) {
10820
11010
  if (this.isDraft) {
10821
11011
  this.confirmation
@@ -11172,9 +11362,10 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.3.0", ngImpor
11172
11362
  }], ctorParameters: function () { return [{ type: i1$2.DomSanitizer }]; } });
11173
11363
 
11174
11364
  class HitDespatchService {
11175
- constructor(restService, devexService) {
11365
+ constructor(restService, devexService, http) {
11176
11366
  this.restService = restService;
11177
11367
  this.devexService = devexService;
11368
+ this.http = http;
11178
11369
  this.apiName = 'eDonusum';
11179
11370
  this.LoadDespatches = this.devexService.createStore({
11180
11371
  key: "id",
@@ -11215,7 +11406,27 @@ class HitDespatchService {
11215
11406
  this.getDespatchView = (despatchUUID) => this.restService.request({
11216
11407
  method: 'GET',
11217
11408
  url: `/api/e-donusum/despatches/get-despatch-view/${despatchUUID}`,
11218
- }, { apiName: this.apiName });
11409
+ }, { apiName: this.apiName }).pipe(map(item => {
11410
+ let blob;
11411
+ // base64 string mi yoksa byte array mi kontrol et
11412
+ if (typeof item.content === 'string') {
11413
+ // base64 string
11414
+ const byteCharacters = atob(item.content);
11415
+ const byteNumbers = new Array(byteCharacters.length);
11416
+ for (let i = 0; i < byteCharacters.length; i++) {
11417
+ byteNumbers[i] = byteCharacters.charCodeAt(i);
11418
+ }
11419
+ blob = new Blob([new Uint8Array(byteNumbers)], { type: 'application/pdf' });
11420
+ }
11421
+ else {
11422
+ // byte[] array
11423
+ blob = new Blob([new Uint8Array(item.content)], { type: 'application/pdf' });
11424
+ }
11425
+ return {
11426
+ blobUrl: URL.createObjectURL(blob),
11427
+ filename: item.filename || 'irsaliye.pdf'
11428
+ };
11429
+ }));
11219
11430
  this.downloadFileById = (blobID) => this.restService.request({
11220
11431
  method: 'GET',
11221
11432
  url: `/api/e-donusum/despatches/download-file-by-id/${blobID}`,
@@ -11263,14 +11474,14 @@ class HitDespatchService {
11263
11474
  }, { apiName: this.apiName });
11264
11475
  }
11265
11476
  }
11266
- HitDespatchService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.3.0", ngImport: i0, type: HitDespatchService, deps: [{ token: i1.RestService }, { token: DevexpressRestService }], target: i0.ɵɵFactoryTarget.Injectable });
11477
+ HitDespatchService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.3.0", ngImport: i0, type: HitDespatchService, deps: [{ token: i1.RestService }, { token: DevexpressRestService }, { token: i3$2.HttpClient }], target: i0.ɵɵFactoryTarget.Injectable });
11267
11478
  HitDespatchService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "14.3.0", ngImport: i0, type: HitDespatchService, providedIn: 'root' });
11268
11479
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.3.0", ngImport: i0, type: HitDespatchService, decorators: [{
11269
11480
  type: Injectable,
11270
11481
  args: [{
11271
11482
  providedIn: 'root',
11272
11483
  }]
11273
- }], ctorParameters: function () { return [{ type: i1.RestService }, { type: DevexpressRestService }]; } });
11484
+ }], ctorParameters: function () { return [{ type: i1.RestService }, { type: DevexpressRestService }, { type: i3$2.HttpClient }]; } });
11274
11485
 
11275
11486
  class HitDespatchComponent {
11276
11487
  constructor(list, service, fileDocumentTypeService, gibPartnerPkService, hitDocumentSerialService, confirmation, toasterService, hitSharedService) {
@@ -11452,16 +11663,41 @@ class HitDespatchComponent {
11452
11663
  return "";
11453
11664
  }
11454
11665
  getDespatchView(record) {
11455
- this.service.getDespatchView(record.uuId).subscribe(item => {
11456
- const source = `data:${item.mimeType};base64,${item.content}`;
11457
- // const newTab = window.open();
11458
- // newTab.document.title = record.id
11459
- // newTab.document.body.innerHTML = `<iframe src="${source}" width="100%" height="100%" style="border:none;"></iframe>`;
11460
- this.hitSharedService.previewFile(item.content);
11461
- /*const link = document.createElement('a');
11462
- link.href = source;
11463
- link.download = `${item.filename}`;
11464
- link.click();*/
11666
+ this.service.getDespatchView(record.uuId).subscribe(({ blobUrl, filename }) => {
11667
+ const newTab = window.open('', '_blank');
11668
+ newTab.document.write(`
11669
+ <html>
11670
+ <head>
11671
+ <title>${filename}</title>
11672
+ <style>
11673
+ * { margin: 0; padding: 0; box-sizing: border-box; }
11674
+ body { display: flex; flex-direction: column; height: 100vh; font-family: sans-serif; }
11675
+ .bar {
11676
+ background: #1976d2; color: white;
11677
+ padding: 6px 16px; display: flex;
11678
+ align-items: center; justify-content: space-between;
11679
+ flex-shrink: 0;
11680
+ }
11681
+ .bar span { font-size: 14px; }
11682
+ .bar a {
11683
+ color: white; text-decoration: none; font-size: 13px;
11684
+ background: rgba(255,255,255,0.2); padding: 4px 14px;
11685
+ border-radius: 4px; border: 1px solid rgba(255,255,255,0.4);
11686
+ }
11687
+ iframe { flex: 1; border: none; width: 100%; }
11688
+ </style>
11689
+ </head>
11690
+ <body>
11691
+ <div class="bar">
11692
+ <span>📄 ${filename}</span>
11693
+ <a href="${blobUrl}" download="${filename}">⬇ İndir</a>
11694
+ </div>
11695
+ <iframe src="${blobUrl}"></iframe>
11696
+ </body>
11697
+ </html>
11698
+ `);
11699
+ newTab.document.close();
11700
+ setTimeout(() => URL.revokeObjectURL(blobUrl), 300000);
11465
11701
  });
11466
11702
  }
11467
11703
  getDespatchResponses() {
@@ -11637,8 +11873,8 @@ class HitInboundDespatchService {
11637
11873
  }, { apiName: this.apiName });
11638
11874
  this.getDespatchPreviewInbound = (despatchGUID) => this.restService.request({
11639
11875
  method: 'GET',
11640
- url: `/api/e-donusum/despatches/get-html-preview-inbound/${despatchGUID}`,
11641
- params: { despatchGUID: despatchGUID }
11876
+ url: `/api/e-donusum/despatches/get-html-preview-inbound/${despatchGUID}`
11877
+ //params: { despatchGUID: despatchGUID}
11642
11878
  }, { apiName: this.apiName });
11643
11879
  }
11644
11880
  }
@@ -11767,12 +12003,56 @@ class HitInboundDespatchComponent {
11767
12003
  return "";
11768
12004
  }
11769
12005
  getInboundDespatchPreview(record) {
11770
- debugger;
11771
12006
  this.despatchService.getDespatchPreviewInbound(record.id).subscribe(despatch => {
11772
- const source = `data:text/html;base64,${despatch.previewHTML}`;
11773
- const newTab = window.open();
11774
- newTab.document.title = record.id;
11775
- newTab.document.body.innerHTML = `<iframe src="${source}" width="100%" height="100%" style="border:none;"></iframe>`;
12007
+ let htmlContent;
12008
+ if (typeof despatch.previewHTML === 'string') {
12009
+ htmlContent = atob(despatch.previewHTML);
12010
+ }
12011
+ else {
12012
+ htmlContent = new TextDecoder().decode(new Uint8Array(despatch.previewHTML));
12013
+ }
12014
+ const filename = `Irsaliye-${record.despatchId || record.id}`;
12015
+ const newTab = window.open('', '_blank');
12016
+ newTab.document.open();
12017
+ newTab.document.write(`
12018
+ <html>
12019
+ <head>
12020
+ <title>${filename}</title>
12021
+ <style>
12022
+ * { margin: 0; padding: 0; box-sizing: border-box; }
12023
+ body { display: flex; flex-direction: column; height: 100vh; font-family: sans-serif; }
12024
+ .bar {
12025
+ background: #1976d2; color: white;
12026
+ padding: 6px 16px; display: flex;
12027
+ align-items: center; justify-content: space-between;
12028
+ flex-shrink: 0;
12029
+ }
12030
+ .bar span { font-size: 14px; }
12031
+ .bar a {
12032
+ color: white; text-decoration: none; font-size: 13px;
12033
+ background: rgba(255,255,255,0.2); padding: 4px 14px;
12034
+ border-radius: 4px; border: 1px solid rgba(255,255,255,0.4);
12035
+ }
12036
+ iframe { flex: 1; border: none; width: 100%; }
12037
+ </style>
12038
+ </head>
12039
+ <body>
12040
+ <div class="bar">
12041
+ <span>📄 ${filename}</span>
12042
+ <a id="dlBtn" download="${filename}.html">⬇ İndir</a>
12043
+ </div>
12044
+ <iframe id="previewFrame"></iframe>
12045
+ <script>
12046
+ const html = ${JSON.stringify(htmlContent)};
12047
+ const blob = new Blob([html], { type: 'text/html' });
12048
+ const url = URL.createObjectURL(blob);
12049
+ document.getElementById('previewFrame').src = url;
12050
+ document.getElementById('dlBtn').href = url;
12051
+ </script>
12052
+ </body>
12053
+ </html>
12054
+ `);
12055
+ newTab.document.close();
11776
12056
  });
11777
12057
  }
11778
12058
  }