From 9acc580fb700eba72de68165906ed071749e7fe9 Mon Sep 17 00:00:00 2001 From: DevSoftTech Server Date: Thu, 22 Oct 2026 11:06:59 +0530 Subject: [PATCH] fix(medical): resolve dynamic container target for Edit Invoice and master edit navigation --- app/Controllers/Medical.php | 14 +- app/Views/medical/new_purchase_invoice.php | 3 +- app/Views/medical/purchase_invoice_edit.php | 31 +++-- .../medical/purchase_invoice_master_edit.php | 124 ++++++++++++------ .../medical/purchase_return_invoice_edit.php | 2 +- .../medical/purchase_return_supplier_list.php | 2 +- app/Views/medical/purchase_supp_list.php | 2 +- app/Views/welcome_message.php | 5 +- 8 files changed, 129 insertions(+), 54 deletions(-) diff --git a/app/Controllers/Medical.php b/app/Controllers/Medical.php index cc04de7..0aabc26 100644 --- a/app/Controllers/Medical.php +++ b/app/Controllers/Medical.php @@ -7697,9 +7697,15 @@ class Medical extends BaseController ->getResult(); } + $linkedGrn = null; + if ($this->db->tableExists('mst_grns')) { + $linkedGrn = $this->db->table('mst_grns')->where('purchase_id', $invId)->get()->getRowArray(); + } + return view('medical/purchase_invoice_edit', [ 'purchase_invoice' => [$invoice], 'med_gst_per' => $medGstPer, + 'linked_grn' => $linkedGrn, ]); } @@ -7739,10 +7745,16 @@ class Medical extends BaseController ->getResult(); } + $linkedGrn = null; + if ($this->db->tableExists('mst_grns')) { + $linkedGrn = $this->db->table('mst_grns')->where('purchase_id', $invId)->get()->getRowArray(); + } + return view('medical/purchase_invoice_master_edit', [ 'supplier_data' => $supplierData, 'inv_master_data' => [$invMasterRow], 'purchase_item' => $purchaseItems, + 'linked_grn' => $linkedGrn, 'can_update_purchase_status' => $this->canPharmacyPermission('pharmacy.purchase.status-update'), ]); } @@ -7840,7 +7852,7 @@ class Medical extends BaseController $update['inv_status'] = $invStatus; } if (in_array('inv_status_update_by', $fields, true)) { - $update['inv_status_update_by'] = $userInfo; + $update['inv_status_update_by'] = $userId; } if ($update !== []) { diff --git a/app/Views/medical/new_purchase_invoice.php b/app/Views/medical/new_purchase_invoice.php index f5b595f..5551aa7 100644 --- a/app/Views/medical/new_purchase_invoice.php +++ b/app/Views/medical/new_purchase_invoice.php @@ -51,7 +51,8 @@ return; } notify('success', 'Please Attention', 'Invoice Added : ID->' + data.insertid); - load_form_div('/' + data.insertid, 'searchresult', 'Purchase Invoice Edit'); + var t = document.getElementById('searchresult') ? 'searchresult' : 'medical-main'; + load_form_div('/' + data.insertid, t, 'Purchase Invoice Edit'); }, 'json').fail(function () { notify('error', 'Please Attention', 'Unable to create purchase invoice'); }); diff --git a/app/Views/medical/purchase_invoice_edit.php b/app/Views/medical/purchase_invoice_edit.php index 589e67d..62f6cba 100644 --- a/app/Views/medical/purchase_invoice_edit.php +++ b/app/Views/medical/purchase_invoice_edit.php @@ -6,14 +6,29 @@
-
Purchase Invoice Information
- - Supplier: name_supplier ?? '-') ?> | - ischallan ?? 0) === 1) ? 'Challan No.' : 'Invoice No.' ?>: Invoice_no ?? '')) ?> | - Invoice Date: str_date_of_invoice ?? '')) ?> - - - +
+
+
Purchase Invoice Information
+ + Supplier: name_supplier ?? '-') ?> | + ischallan ?? 0) === 1) ? 'Challan No.' : 'Invoice No.' ?>: Invoice_no ?? '')) ?> | + Invoice Date: str_date_of_invoice ?? '')) ?> + +
+
+ + + + + +
+
diff --git a/app/Views/medical/purchase_invoice_master_edit.php b/app/Views/medical/purchase_invoice_master_edit.php index f0d1f81..abeb9a5 100644 --- a/app/Views/medical/purchase_invoice_master_edit.php +++ b/app/Views/medical/purchase_invoice_master_edit.php @@ -7,10 +7,39 @@ if (! $inv) { $invStatus = (int) ($inv->inv_status ?? 0); $canUpdatePurchaseStatus = (bool) ($can_update_purchase_status ?? false); +$invDate = ''; +if (!empty($inv->date_of_invoice) && $inv->date_of_invoice !== '0000-00-00') { + $time = strtotime((string) $inv->date_of_invoice); + if ($time !== false && $time > 0) { + $invDate = date('d/m/Y', $time); + } +} ?>
-
Purchase Master Edit
+
+
+
Purchase Master Edit
+ + Invoice No: Invoice_no ?? '')) ?> | + Supplier: name_supplier ?? '-') ?> | + Status: Final and Checked' : 'Pending Entry' ?> + +
+
+ + + + + +
+
@@ -38,7 +67,7 @@ $canUpdatePurchaseStatus = (bool) ($can_update_purchase_status ?? false);
- +
@@ -46,22 +75,25 @@ $canUpdatePurchaseStatus = (bool) ($can_update_purchase_status ?? false);
-
name_supplier ?? '-') ?>
+
name_supplier ?? '-') ?>
-
Invoice_no ?? '')) ?>
+
Invoice_no ?? '')) ?>
-
date_of_invoice) ? esc(date('d/m/Y', strtotime((string) $inv->date_of_invoice))) : '' ?>
+
+
+
+ Locked (Final)
- + @@ -80,53 +112,63 @@ $canUpdatePurchaseStatus = (bool) ($can_update_purchase_status ?? false); + expiry_date ?? ''); + if (!empty($row->exp_date_str)) { + $expStr = (string) $row->exp_date_str; + } elseif (preg_match('/^\d{4}-\d{2}-\d{2}$/', $expStr)) { + $expStr = date('m/y', strtotime($expStr)); + } + ?> item_return ?? 0) === 1) ? 'style="color:red;"' : '' ?>> - - - - - - - - - - + + + + + + + + + + - - - - - - + + + + + +
# Item Name
Item_name ?? '') ?> batch_no ?? '') ?>expiry_date ?? '')) ?>mrp ?? 0)) ?>qty ?? 0)) ?>+qty_free ?? 0)) ?>purchase_price ?? 0)) ?>amount ?? 0)) ?>discount ?? 0)) ?>taxable_amount ?? 0)) ?>CGST_per ?? 0)) ?>SGST_per ?? 0)) ?>net_amount ?? 0)) ?>mrp ?? 0), 2) ?>qty ?? 0)) ?> + qty_free ?? 0)) ?>purchase_price ?? 0), 2) ?>amount ?? 0), 2) ?>discount ?? 0), 2) ?>taxable_amount ?? 0), 2) ?>CGST_per ?? 0)) ?>%SGST_per ?? 0)) ?>%net_amount ?? 0), 2) ?>
TotalTaxable_Amt ?? 0)) ?>CGST_Amt ?? 0)) ?>SGST_Amt ?? 0)) ?>T_Net_Amount ?? 0)) ?>
TotalTaxable_Amt ?? 0), 2) ?>CGST_Amt ?? 0), 2) ?>SGST_Amt ?? 0), 2) ?>T_Net_Amount ?? 0), 2) ?>
-
- -
- -
- + +
+ +
-
- -
-
- +
+
+ + +
- -
+
+ Status +
+
@@ -137,7 +179,8 @@ $canUpdatePurchaseStatus = (bool) ($can_update_purchase_status ?? false); function update_invoice_status() { var invoiceStatus = $('#cbo_invoice_status').val(); if (confirm('Are you sure to update Status?')) { - load_form_div('id ?? 0)) ?>/' + invoiceStatus, 'searchresult', 'Purchase Master Edit'); + var t = document.getElementById('searchresult') ? 'searchresult' : 'medical-main'; + load_form_div('id ?? 0)) ?>/' + invoiceStatus, t, 'Purchase Master Edit'); } } @@ -149,7 +192,8 @@ $(document).ready(function () { return; } notify('success', 'Update Success', data.show_text || 'Data Update'); - load_form_div('id ?? 0)) ?>', 'searchresult', 'Purchase Master Edit'); + var t = document.getElementById('searchresult') ? 'searchresult' : 'medical-main'; + load_form_div('id ?? 0)) ?>', t, 'Purchase Master Edit'); }, 'json'); }); }); diff --git a/app/Views/medical/purchase_return_invoice_edit.php b/app/Views/medical/purchase_return_invoice_edit.php index 3e2ed24..19a44ea 100644 --- a/app/Views/medical/purchase_return_invoice_edit.php +++ b/app/Views/medical/purchase_return_invoice_edit.php @@ -9,7 +9,7 @@ Invoice No.: Invoice_no ?? '')) ?> | Invoice Date: str_date_of_invoice ?? '')) ?> - + Print
diff --git a/app/Views/medical/purchase_return_supplier_list.php b/app/Views/medical/purchase_return_supplier_list.php index d725de8..3509d94 100644 --- a/app/Views/medical/purchase_return_supplier_list.php +++ b/app/Views/medical/purchase_return_supplier_list.php @@ -15,7 +15,7 @@ name_supplier ?? '')) ?> str_date_of_invoice ?? $row->date_of_invoice ?? '')) ?> - + Print diff --git a/app/Views/medical/purchase_supp_list.php b/app/Views/medical/purchase_supp_list.php index 10ff1ed..a096e46 100644 --- a/app/Views/medical/purchase_supp_list.php +++ b/app/Views/medical/purchase_supp_list.php @@ -17,7 +17,7 @@ str_date_of_invoice ?? $row->date_of_invoice ?? '')) ?> tamount ?? 0)) ?> - + tamount ?? 0) == 0.0): ?> diff --git a/app/Views/welcome_message.php b/app/Views/welcome_message.php index 086ad21..06268ad 100644 --- a/app/Views/welcome_message.php +++ b/app/Views/welcome_message.php @@ -482,10 +482,13 @@ }) .done(function(html) { var targetEl = document.getElementById(String(xdiv)); + if (!targetEl && (xdiv === 'searchresult' || xdiv === 'test_div')) { + targetEl = document.getElementById('medical-main') || document.getElementById('main'); + } if (targetEl) { targetEl.innerHTML = html; } - executeInjectedScripts(xdiv); + executeInjectedScripts(targetEl ? targetEl.id : xdiv); if (typeof window.showPageNotifications === 'function') { window.showPageNotifications(targetEl); }