db = \Config\Database::connect(); } private function ensurePharmacyAccess() { $user = service('auth')->user(); $allowed = false; if ($user && method_exists($user, 'can')) { $allowed = $user->can('pharmacy.access') || $user->can('billing.access'); } if (! $allowed && $user && method_exists($user, 'inGroup')) { $allowed = $user->inGroup('superadmin', 'admin', 'developer'); } if ($allowed) { return null; } return $this->response ->setStatusCode(403) ->setBody('
| Item Name | Generic | Current Pak. | Current Unit Qty | ' . 'Total Sale Pak. | Total Sale Unit Qty | Lost Unit | Package/Re-Order Qty | ' . '
|---|---|---|---|---|---|---|---|
| ' . esc((string) ($row->item_name ?? '')) . ' | ' . '' . esc((string) ($row->genericname ?? '')) . ' | ' . '' . esc((string) ($row->C_Pak_Qty ?? '0')) . ' | ' . '' . esc(number_format((float) ($row->C_Unit_Stock_Qty ?? 0), 2, '.', '')) . ' | ' . '' . esc(number_format((float) ($row->C_Pak_Sale_Qty ?? 0), 2, '.', '')) . ' | ' . '' . esc(number_format((float) ($row->sale_unit ?? 0), 2, '.', '')) . ' | ' . '' . esc(number_format((float) ($row->total_lost_unit ?? 0), 2, '.', '')) . ' | ' . '' . esc((string) ($row->packing ?? '')) . '/' . esc((string) ($row->re_order_qty ?? '')) . ' | ' . '
| Item Name | Generic Name | MRP | Batch | Expiry | ' . 'Current Pak. | Current Unit Qty | Total Sale Pak. | Total Sale Unit Qty | ' . 'Package/Re-Order Qty | Purchase Unit Rate | GST | Stock Cost | ' . '
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| ' . esc((string) ($row->item_name ?? '')) . ' | ' . '' . esc((string) ($row->genericname ?? '')) . ' | ' . '' . esc(number_format((float) ($row->mrp ?? 0), 2, '.', '')) . ' | ' . '' . esc((string) ($row->batch_no ?? '')) . ' | ' . '' . esc((string) ($row->expiry_date ?? '')) . ' | ' . '' . esc(number_format((float) ($row->C_Pak_Qty ?? 0), 2, '.', '')) . ' | ' . '' . esc(number_format((float) ($row->C_Unit_Stock_Qty ?? 0), 2, '.', '')) . ' | ' . '' . esc(number_format((float) ($row->C_Pak_Sale_Qty ?? 0), 2, '.', '')) . ' | ' . '' . esc(number_format((float) ($row->sale_unit ?? 0), 2, '.', '')) . ' | ' . '' . esc((string) ($row->packing ?? '')) . ' | ' . '' . esc(number_format((float) ($row->purchase_unit_rate ?? 0), 2, '.', '')) . ' | ' . '' . esc(number_format((float) ($row->gst_per ?? 0), 2, '.', '')) . ' | ' . '' . esc(number_format($stockCost, 2, '.', '')) . ' | ' . '
| Total Stock Cost | ' . esc(number_format($totalStockValue, 2, '.', '')) . ' | |||||||||||
| Item Name | Generic Name | Pur Pak. | Pur Cost | ' . 'Current Pak. | Current Unit Qty | Total Sale Pak. | Total Sale Unit Qty | ' . 'Lost Unit | Package/Re-Order Qty | ' . '
|---|---|---|---|---|---|---|---|---|---|
| ' . esc((string) ($row->item_name ?? '')) . ' | ' . '' . esc((string) ($row->genericname ?? '')) . ' | ' . '' . esc(number_format((float) ($row->total_pak_qty ?? 0), 2, '.', '')) . ' | ' . '' . esc(number_format((float) ($row->purchase_cost ?? 0), 2, '.', '')) . ' | ' . '' . esc(number_format((float) ($row->current_pak_qty ?? 0), 2, '.', '')) . ' | ' . '' . esc(number_format((float) ($row->current_unit_qty ?? 0), 2, '.', '')) . ' | ' . '' . esc(number_format((float) ($row->total_sale_pak ?? 0), 2, '.', '')) . ' | ' . '' . esc(number_format((float) ($row->total_sale_unit ?? 0), 2, '.', '')) . ' | ' . '' . esc(number_format((float) ($row->total_lost_unit ?? 0), 2, '.', '')) . ' | ' . '' . esc((string) ($row->packing ?? '')) . '/' . esc((string) ($row->re_order_qty ?? '')) . ' | ' . '