add print dialog, add preview button, add print dropdown button

This commit is contained in:
mahdahar 2025-12-16 16:44:25 +07:00
parent d3534e62a1
commit 3b9c3dec10
2 changed files with 75 additions and 6 deletions

View File

@ -0,0 +1,23 @@
<dialog class="modal" :open="isDialogPrintOpen">
<template x-if="printAccessnumber">
<div class="modal-box w-11/12 max-w-7xl h-[90vh] flex flex-col p-0 overflow-hidden bg-base-100">
<!-- Header -->
<div class="flex justify-between items-center p-3 bg-base-200 border-b border-base-300">
<h3 class="font-bold text-lg flex items-center gap-2">
<i class="fa fa-print text-primary"></i>
Print Preview
<span class="badge badge-neutral text-xs" x-text="printType ? printType.toUpperCase() : ''"></span>
<span class="badge badge-ghost text-xs" x-text="printAccessnumber"></span>
</h3>
<button class="btn btn-sm btn-circle btn-ghost" @click="closePrintDialog()">
<i class="fa fa-times"></i>
</button>
</div>
<!-- Content -->
<div class="flex-1 bg-base-300 relative p-1">
<iframe :src="getPrintUrl()" class="w-full h-full rounded shadow-sm bg-white"></iframe>
</div>
</div>
</template>
</dialog>

View File

@ -59,10 +59,10 @@
<span class="flex-1"></span>
<div class="form-control w-full md:w-auto">
<div class="relative">
<i class="fa fa-filter absolute left-3 top-2.5 text-base-content/30 text-xs"></i>
<input type="text" class="input input-sm input-bordered w-full md:w-64 pl-8" placeholder="Type to filter..." x-model="filterTable" />
</div>
<label class='input input-sm input-bordered'>
<i class="fa fa-filter"></i>
<input type="text" placeholder="Type to filter..." x-model="filterTable" />
</label>
</div>
</div>
</div>
@ -79,8 +79,9 @@
<th style='width:8%;'>Reff</th>
<th style='width:8%;'>Doctor</th>
<th style='width:15%;'>Tests</th>
<th style='width:5%;'>Result To</th>
<th style='width:5%;'>Validation</th>
<th style='width:3%;'>ResTo</th>
<th style='width:5%;'>Val</th>
<th style='width:5%;'>Result</th>
<th style='width:4%;'>Status</th>
</tr>
</thead>
@ -113,6 +114,24 @@
</template>
</div>
</td>
<td>
<template x-if="!req.VAL2USER">
<button class="btn btn-xs btn-outline btn-primary" @click="openPrintDialog(req.SP_ACCESSNUMBER, 'preview')">Preview</button>
</template>
<template x-if="req.VAL2USER">
<div class="dropdown dropdown-end">
<div tabindex="0" role="button" class="btn btn-xs btn-outline btn-primary">
Print <i class="fa fa-chevron-down text-[10px]"></i>
</div>
<ul tabindex="0" class="dropdown-content z-[50] menu p-2 shadow bg-base-100 rounded-box w-28 border border-base-200">
<li><a @click="openPrintDialog(req.SP_ACCESSNUMBER, 'preview')">Preview</a></li>
<li><a @click="openPrintDialog(req.SP_ACCESSNUMBER, 'ind')">IND</a></li>
<li><a @click="openPrintDialog(req.SP_ACCESSNUMBER, 'eng')">ENG</a></li>
<li><a @click="openPrintDialog(req.SP_ACCESSNUMBER, 'pdf')">PDF</a></li>
</ul>
</div>
</template>
</td>
<td><button x-text="req.STATS === 'Fin' ? 'Final' : req.STATS" class="btn btn-xs"
:class="statusColor[req.STATS]" @click="openSampleDialog(req.SP_ACCESSNUMBER)"></button></td>
</tr>
@ -127,6 +146,7 @@
<?php echo $this->include('v2/admin/dialog_sample'); ?>
<?php echo $this->include('v2/admin/dialog_val'); ?>
<?php echo $this->include('v2/admin/dialog_unval'); ?>
<?php echo $this->include('v2/admin/dialog_print'); ?>
</main>
<?= $this->endSection(); ?>
@ -371,6 +391,32 @@
this.isDialogUnvalOpen = false;
},
/*
print dialog
*/
isDialogPrintOpen : false,
printAccessnumber : null,
printType : null,
openPrintDialog (accessnumber, type) {
this.printAccessnumber = accessnumber;
this.printType = type;
this.isDialogPrintOpen = true;
},
closePrintDialog () {
this.isDialogPrintOpen = false;
},
getPrintUrl() {
// Base URL from existing modal_request.php reference
let base = 'http://glenlis/spooler_db/main_dev.php';
let url = `${base}?acc=${this.printAccessnumber}`;
// Append params based on type
if (this.printType === 'ind') url += '&lang=ID';
if (this.printType === 'eng') url += '&lang=EN';
if (this.printType === 'pdf') url += '&output=pdf';
return url;
},
}));
});