<div class="flex-1"></div>
</div>
-<div *ngIf="scko.auth.token() && scko.patronSummary" class="row mt-5">
+<div *ngIf="scko.auth.token() && scko.patronSummary" class="row mr-0 mt-5">
<div class="col-lg-9">
<div class="ml-2 scko-page">
<router-outlet></router-outlet>
logoutDialog: ConfirmDialogComponent;
alertDialog: AlertDialogComponent;
focusBarcode: EventEmitter<void> = new EventEmitter<void>();
+ patronLoaded: EventEmitter<void> = new EventEmitter<void>();
constructor(
private router: Router,
.then(patron => this.patronSummary = new PatronSummary(patron))
.then(_ => this.patrons.getVitalStats(this.patronSummary.patron))
.then(stats => this.patronSummary.stats = stats)
- .then(_ => this.resetPatronTimeout());
+ .then(_ => this.resetPatronTimeout())
+ .then(_ => this.patronLoaded.emit());
}
resetPatronTimeout() {
<div class="pl-2 mt-3">
<span class="mr-2" i18n>Receipt: </span>
- <div class="form-check form-check-inline">
+
+ <div *ngIf="showEmailOption" class="form-check form-check-inline">
<input class="form-check-input" name="receipt-type" type="radio"
[(ngModel)]="receiptType" id="receipt-email" value="email">
<label class="form-check-label" for="receipt-email" i18n>Email</label>
export class SckoSummaryComponent implements OnInit {
+ showEmailOption = false;
receiptType = 'email';
constructor(
ngOnInit() {
+ this.scko.patronLoaded.subscribe(() => {
+ if (this.canEmail()) {
+ this.showEmailOption = true;
+ this.receiptType = 'email';
+ } else {
+ this.showEmailOption = false;
+ this.receiptType = 'print';
+ }
+ });
+
+ }
+
+ canEmail(): boolean {
+ if (!this.scko.patronSummary) { return false; }
+
+ const patron = this.scko.patronSummary.patron;
+
+ const setting = patron.settings().filter(
+ s => s.name() === 'circ.send_email_checkout_receipts')[0];
+
+ return (
+ Boolean(patron.email())
+ && patron.email().match(/.*@.*/) !== null
+ && setting
+ && setting.value() === "true" // JSON
+ );
}
}