prescription
This commit is contained in:
@@ -34,6 +34,7 @@ class PrescriptionController extends Controller
|
||||
'tx_prescription_orders.sAddress as kirim_ke',
|
||||
'tx_prescription_orders.sDeliveryPrice as ongkir',
|
||||
'tx_prescription_orders.sDeliveryMethod as delivery',
|
||||
'tx_prescription_orders.sPaymentStatus',
|
||||
'tx_prescription_orders.nIDApotek',
|
||||
)
|
||||
->whereNotNull('nIDUser');
|
||||
|
||||
@@ -5,6 +5,7 @@ namespace Modules\Internal\Transformers;
|
||||
use App\Helpers\Helper;
|
||||
use Illuminate\Http\Resources\Json\JsonResource;
|
||||
use Carbon\Carbon;
|
||||
use GuzzleHttp\Client;
|
||||
|
||||
class ReportPrescriptionResource extends JsonResource
|
||||
{
|
||||
@@ -17,7 +18,34 @@ class ReportPrescriptionResource extends JsonResource
|
||||
public function toArray($request)
|
||||
{
|
||||
$patientName = $this->user ? $this->user->sFirstName .' '. $this->user->sLastName : '-';
|
||||
$client = new Client();
|
||||
$statusUrl = env('K24_URL') . "/partners/lms/v1/order/trackingOrder?order_id=" . $this->sKodeResep;
|
||||
try {
|
||||
$response = $client->request('GET', $statusUrl, [
|
||||
'headers' => [
|
||||
'Accept' => 'application/json',
|
||||
// Tambahkan token kalau perlu:
|
||||
// 'Authorization' => 'Bearer your_token_here',
|
||||
],
|
||||
'timeout' => 30,
|
||||
]);
|
||||
|
||||
$body = $response->getBody();
|
||||
$data = json_decode($body, true);
|
||||
|
||||
$statusString = '';
|
||||
|
||||
if (isset($data['data']) && is_array($data['data'])) {
|
||||
$statusString = collect($data['data'])->map(function ($item) {
|
||||
return "{$item['updated_time']} - {$item['status']}";
|
||||
});
|
||||
} else {
|
||||
$statusString = [];
|
||||
}
|
||||
|
||||
} catch (\Exception $e) {
|
||||
$statusString = '-';
|
||||
}
|
||||
$data = [
|
||||
'id' => $this->nID,
|
||||
'patient_name' => $patientName,
|
||||
@@ -28,6 +56,8 @@ class ReportPrescriptionResource extends JsonResource
|
||||
'items' => $this->items ? $this->items : [],
|
||||
'status_prescription' => $this->status_prescription,
|
||||
'price_delivery' => $this->ongkir,
|
||||
'payment_status' => $this->sPaymentStatus,
|
||||
'status_resep' => $statusString,
|
||||
'apotek_name' => $this->nIDApotek ? Helper::getOrganization($this->nIDApotek) : '-',
|
||||
];
|
||||
|
||||
|
||||
@@ -339,6 +339,18 @@ export default function List() {
|
||||
<TableCell align="left">{row.doctor_name ?? '-'}</TableCell>
|
||||
<TableCell align="left">{row.apotek_name ?? '-'}</TableCell>
|
||||
<TableCell align="left">{row.price_delivery ?? '-'}</TableCell>
|
||||
<TableCell align="left">{row.payment_status ?? '-'}</TableCell>
|
||||
<TableCell align="left">
|
||||
{Array.isArray(row.status_resep) && row.status_resep.length > 0 ? (
|
||||
<ul style={{ paddingLeft: '1rem', margin: 0 }}>
|
||||
{row.status_resep.map((item, idx) => (
|
||||
<li key={idx}>{item}</li>
|
||||
))}
|
||||
</ul>
|
||||
) : (
|
||||
'-'
|
||||
)}
|
||||
</TableCell>
|
||||
<TableCell align="left">{row.status_prescription ?? '-'}</TableCell>
|
||||
{/* <TableCell align="center">
|
||||
<ButtonGroup variant="text" aria-label="text button group">
|
||||
@@ -551,12 +563,15 @@ export default function List() {
|
||||
<TableCell style={headStyle} align="left">
|
||||
Harga Ongkos Kirim
|
||||
</TableCell>
|
||||
<TableCell style={headStyle} align="left">
|
||||
Status
|
||||
<TableCell style={headStyle} align="center">
|
||||
Status Pembayaran
|
||||
</TableCell>
|
||||
<TableCell style={{ ...headStyle, width: '300px' }} align="left">
|
||||
Status Resep
|
||||
</TableCell>
|
||||
<TableCell style={headStyle} align="center">
|
||||
Status Pengiriman
|
||||
</TableCell>
|
||||
{/* <TableCell style={headStyle} align="center">
|
||||
Aksi
|
||||
</TableCell> */}
|
||||
</TableRow>
|
||||
</TableBody>
|
||||
{dataTableIsLoading ? (
|
||||
|
||||
Reference in New Issue
Block a user