From d94797a4334b8d53291f019bcf573e1377dcc407 Mon Sep 17 00:00:00 2001 From: DevSoftTech Server Date: Tue, 17 Mar 2026 04:05:02 +0530 Subject: [PATCH] Implement finance phase 2 pharmacy workflow and admin hospital/pharmacy profile settings --- DICOM_AI_IMPLEMENTATION.md | 238 + app/Config/AuthGroups.php | 27 + app/Config/Routes.php | 74 + app/Controllers/Diagnosis.php | 65 +- app/Controllers/DoctorDocument.php | 1079 +++ app/Controllers/Finance.php | 2083 +++++ app/Controllers/Medical.php | 528 +- app/Controllers/Opd_prescription.php | 229 +- app/Controllers/Report.php | 247 +- app/Controllers/Setting/HospitalProfile.php | 311 + app/Controllers/Setting/Template.php | 124 +- ...03-10-000011_CreateFinancePhase1Tables.php | 284 + ...0-000012_AddFinanceInvoiceMatchColumns.php | 106 + ...6-03-10-000013_CreateFinanceCashTables.php | 177 + ...000014_CreateFinanceDoctorPayoutTables.php | 189 + ...15_CreateFinanceDepositAndPolicyTables.php | 152 + ...5-000020_AddDiagnosisTemplateMarginsCm.php | 8 +- ...3-15-000021_CreateDoctorDocumentTables.php | 220 + ...2_AddDefaultPrintTypeToDocFormatMaster.php | 49 + ...00023_AddPrintMarginsToDocFormatMaster.php | 103 + ...024_CreateDoctorDocumentPrintTemplates.php | 122 + ...-17-000025_AddFinancePoDocumentColumns.php | 71 + ...7-000026_CreateFinancePoDocumentsTable.php | 65 + ...000027_CreateFinancePharmacyBillsTable.php | 109 + app/Models/FinanceBankDepositModel.php | 27 + app/Models/FinanceCashTransactionModel.php | 32 + app/Models/FinanceDoctorAgreementModel.php | 27 + app/Models/FinanceDoctorPayoutModel.php | 34 + app/Models/FinanceGrnModel.php | 24 + app/Models/FinancePharmacyBillModel.php | 23 + app/Models/FinancePoDocumentModel.php | 22 + app/Models/FinancePolicySettingModel.php | 21 + app/Models/FinancePurchaseOrderModel.php | 28 + app/Models/FinanceScrollSubmissionModel.php | 26 + app/Models/FinanceVendorInvoiceModel.php | 32 + app/Models/FinanceVendorModel.php | 28 + .../Admin/UserManagement/permissions.php | 9 + app/Views/Setting/Admin/hospital_profile.php | 280 + app/Views/Setting/Admin/index.php | 6 + .../Template/diagnosis_print_settings.php | 8 +- .../Template/document_print_settings.php | 201 + app/Views/Setting/Template/index.php | 33 +- app/Views/billing/opd_medicince_workspace.php | 87 +- .../diagnosis/lab_final_report_editor.php | 84 +- .../diagnosis/lab_invoice_main_test_list.php | 34 +- app/Views/diagnosis/lab_report_file_list.php | 95 +- app/Views/diagnosis/pathology_detail.php | 67 +- app/Views/diagnosis/print_single_report.php | 83 +- app/Views/doctor_document/doc_input_list.php | 100 + .../doctor_document/doc_letterhead_print.php | 60 + app/Views/doctor_document/doc_list.php | 55 + app/Views/doctor_document/doc_master_edit.php | 165 + app/Views/doctor_document/doc_pre_data.php | 85 + .../doctor_document/patient_doc_edit.php | 175 + .../doctor_document/patient_doc_master.php | 132 + app/Views/doctor_document/workspace.php | 70 + app/Views/finance/bank_deposits.php | 78 + app/Views/finance/cashbook.php | 149 + app/Views/finance/compliance_report.php | 82 + app/Views/finance/doctor_payout.php | 142 + app/Views/finance/index.php | 123 + .../finance/partials/bank_deposits_table.php | 39 + .../partials/cash_transactions_table.php | 44 + .../partials/doctor_agreements_table.php | 39 + .../finance/partials/doctor_payouts_table.php | 57 + app/Views/finance/partials/grn_table.php | 36 + app/Views/finance/partials/invoice_table.php | 50 + .../finance/partials/pharmacy_bills_table.php | 94 + app/Views/finance/partials/po_table.php | 59 + app/Views/finance/partials/scroll_table.php | 39 + app/Views/finance/partials/vendors_table.php | 39 + app/Views/finance/phase2.php | 275 + app/Views/finance/print/grn_vendor_copy.php | 119 + app/Views/finance/sections/grn_entry.php | 78 + app/Views/finance/sections/pharmacy_bills.php | 210 + app/Views/finance/sections/purchase_order.php | 241 + app/Views/finance/sections/vendor_invoice.php | 97 + app/Views/finance/sections/vendor_master.php | 67 + app/Views/medical/invoice_print.php | 16 +- app/Views/medical/invoice_print_pdf.php | 49 +- .../medical/new_purchase_return_invoice.php | 47 + app/Views/medical/purchase_invoice_edit.php | 2 +- app/Views/medical/purchase_return.php | 27 + .../medical/purchase_return_invoice_edit.php | 136 + .../medical/purchase_return_invoice_item.php | 57 + .../purchase_return_invoice_item_print.php | 123 + .../purchase_return_old_invoice_list.php | 57 + .../purchase_return_product_search.php | 88 + .../medical/purchase_return_supplier_list.php | 39 + app/Views/partials/sidebar.php | 300 +- app/Views/report/document_list.php | 85 + app/Views/report/document_list_table.php | 57 + app/Views/report/index.php | 10 +- app/Views/report/nabh_audit_report.php | 1 + app/Views/report/nabh_audit_report_table.php | 10 + app/Views/welcome_message.php | 3 +- old_code_ci3/controllers/Auth_ihc - Copy.php | 714 ++ old_code_ci3/controllers/Auth_ihc.php | 853 ++ old_code_ci3/controllers/Doc_Admin.php | 4 + old_code_ci3/controllers/Document_Patient.php | 606 +- old_code_ci3/controllers/IPD_Nursing.php | 4 +- old_code_ci3/controllers/Invoice.php | 8 +- old_code_ci3/controllers/InvoiceShow.php | 2 +- old_code_ci3/controllers/Ipd.php | 20 +- old_code_ci3/controllers/IpdNew.php | 71 +- old_code_ci3/controllers/Ipd_Report.php | 1 + old_code_ci3/controllers/Ipd_discharge.php | 2 +- old_code_ci3/controllers/Ipd_discharge1.php | 2569 +++++++ old_code_ci3/controllers/Lab_Admin.php | 44 +- old_code_ci3/controllers/Lab_Report.php | 629 +- old_code_ci3/controllers/Medical.php | 6842 +++++++++-------- old_code_ci3/controllers/Medical1.php | 4820 ++++++++++++ old_code_ci3/controllers/Medical_05102022.php | 5252 +++++++++++++ old_code_ci3/controllers/Medical_1.php | 3046 ++++++++ old_code_ci3/controllers/Medical_130621.php | 4747 ++++++++++++ old_code_ci3/controllers/Medical_Print.php | 3 +- old_code_ci3/controllers/Medical_Report.php | 120 +- .../controllers/Medical_Report_09032022.php | 2261 ++++++ .../controllers/Medical_backpanel.php | 6 +- old_code_ci3/controllers/OcasePathLap.php | 6 +- old_code_ci3/controllers/Ocasemaster.php | 6 +- old_code_ci3/controllers/Opd.php | 2 +- old_code_ci3/controllers/Opd2.php | 4 +- old_code_ci3/controllers/Opd_prescription.php | 100 +- old_code_ci3/controllers/Opd_print_1.php | 302 + old_code_ci3/controllers/Opdcase.php | 6 +- .../controllers/OrganizationInvoice.php | 4 +- old_code_ci3/controllers/Orgcase.php | 24 +- old_code_ci3/controllers/Package.php | 2 +- old_code_ci3/controllers/PathLab.php | 4 +- old_code_ci3/controllers/PathLab1.php | 1335 ++++ old_code_ci3/controllers/PathLab_17042021.php | 1750 +++++ old_code_ci3/controllers/Patient.php | 1253 +-- old_code_ci3/controllers/Payment_Medical.php | 29 +- old_code_ci3/controllers/Report.php | 2 +- old_code_ci3/controllers/Report2.php | 19 +- old_code_ci3/controllers/Report4.php | 21 +- old_code_ci3/controllers/Report5.php | 155 +- old_code_ci3/controllers/ReportPanel2.php | 2 +- old_code_ci3/controllers/Report_bak.php | 1978 +++++ .../controllers/opd_print_parcha_2.php | 21 + old_code_ci3/models/Custtag_M.php | 46 + old_code_ci3/models/Medical_M.php | 1 - old_code_ci3/views/AdminMain.php | 4 +- old_code_ci3/views/IPD2/ipd_main_panel.php | 10 - .../views/IPD2/ipd_payment_receipt_print.php | 2 +- old_code_ci3/views/IPD2/print_ipd_form1.php | 4 +- .../SVH_discharge_template_html.php | 3 + .../IPD_Discharge/ipd_discharge_edit.php | 12 +- .../views/IPD_Format/ipd_sticker_print_2.php | 32 +- .../views/Invoice/caseinvoice_print_V.php | 15 +- .../views/Invoice_PathLab_final_V - Copy.php | 544 ++ old_code_ci3/views/June19.xlsx | Bin 0 -> 183984 bytes .../views/Lab_Panel/lab_date_show.php | 94 +- .../views/Lab_Panel/lab_invoice_main.php | 16 +- .../views/Lab_Panel/lab_invoice_xray.php | 4 - old_code_ci3/views/Lab_Panel/lab_main.php | 13 - .../views/Lab_Panel/pathlab_request_list.php | 15 +- .../Lab_Panel/patient_lab_report_svh.php | 66 +- .../Lab_Panel/patient_lab_xray_report.php | 102 + .../views/Medical/Med_Model_Payment.php | 2 +- .../views/Medical/Med_Payment_Receipt.php | 16 +- old_code_ci3/views/Medical/Med_back_Panel.php | 10 - .../views/Medical/Medical_Final_Invoice.php | 8 +- .../Medical/Medical_Invoice_Return_print.php | 16 +- .../views/Medical/Medical_Invoice_V.php | 31 +- .../views/Medical/Medical_invoice_list.php | 9 +- .../views/Medical/Medical_invoice_print.php | 16 +- .../views/Medical/Medical_invoice_print_1.php | 18 +- .../views/Medical/Medical_invoice_print_2.php | 16 +- .../Medical/Medical_invoice_print_all.php | 16 +- .../Medical_invoice_print_all_provisional.php | 16 +- .../Medical/Print/Medical_return_medicine.php | 2 +- .../Medical/Print/medical_bill_print_a5.php | 4 +- .../Print/medical_bill_print_a5_discount.php | 4 +- .../Print/medical_bill_print_a5_old.php | 4 +- .../Medical/Print/medical_bill_print_a6.php | 6 +- .../Print/medical_bill_print_format.php | 4 +- .../medical_bill_print_format_newpage.php | 2 +- .../medical_bill_print_format_single.php | 13 +- .../medical_bill_print_format_with_return.php | 2 +- .../Print/medical_cash_received_bill.php | 2 +- .../Purchase/purchase_invoice_edit.php | 2 +- .../Purchase/purchase_invoice_master_edit.php | 364 +- .../views/Medical/Report/Med_Report_5.php | 3 +- .../Report/Med_Report_daily_med_doc_sale.php | 19 - .../views/Medical/Report/Purchase_Invoice.php | 4 +- .../Stock/purchase_invoice_item_print.php | 28 +- .../purchase_return_invoice_item print.php | 125 + .../Stock/purchase_return_invoice_item.php | 8 +- .../purchase_return_invoice_item_print.php | 45 +- old_code_ci3/views/Medical1/Dashboard.php | 49 + .../views/Medical1/Draft_Med_Invoice.php | 131 + .../Medical1/Draft_Med_Return_Invoice.php | 132 + old_code_ci3/views/Medical1/Drug_Details.php | 110 + .../views/Medical1/Drug_Details_all.php | 46 + old_code_ci3/views/Medical1/Drug_Stock.php | 123 + .../views/Medical1/Drug_Stock_Add.php | 292 + .../views/Medical1/Invoice_OLD_Master.php | 200 + .../views/Medical1/Invoice_med_list.php | 117 + old_code_ci3/views/Medical1/Med_Item_List.php | 93 + .../views/Medical1/Med_Item_old_list.php | 46 + .../views/Medical1/Med_Model_Payment.php | 323 + old_code_ci3/views/Medical1/Med_Payment.php | 308 + .../views/Medical1/Med_Payment_Receipt.php | 112 + .../Medical1/Med_Return_Invoice_search.php | 67 + .../views/Medical1/Med_back_Panel.php | 123 + .../views/Medical1/Med_old_invoice_list.php | 67 + .../views/Medical1/Medical_Final_Invoice.php | 394 + .../views/Medical1/Medical_Invoice_Return.php | 212 + .../Medical1/Medical_Invoice_Return_V.php | 294 + .../Medical1/Medical_Invoice_Return_pre.php | 148 + .../Medical1/Medical_Invoice_Return_print.php | 148 + .../views/Medical1/Medical_Invoice_V.php | 549 ++ .../views/Medical1/Medical_invoice_list.php | 338 + .../views/Medical1/Medical_invoice_print.php | 180 + .../Medical1/Medical_invoice_print_1.php | 182 + .../Medical1/Medical_invoice_print_2.php | 178 + .../Medical1/Medical_invoice_print_all.php | 197 + .../Medical_invoice_print_all_provisional.php | 179 + .../views/Medical1/Medical_ipd_org_list.php | 57 + .../Medical1/Medical_org_invoicelist.php | 97 + .../views/Medical1/Medical_org_list.php | 49 + .../views/Medical1/Medical_stock_drug.php | 116 + .../views/Medical1/Patient_Search_Result.php | 49 + .../views/Medical1/Print/Medicine_List.php | 86 + .../Medical1/Print/medical_bill_print_a6.php | 190 + .../Print/medical_bill_print_format.php | 191 + .../medical_bill_print_format_newpage.php | 145 + .../medical_bill_print_format_single.php | 184 + .../views/Medical1/Purchase/company_Edit.php | 76 + .../views/Medical1/Purchase/company_list.php | 60 + .../Medical1/Purchase/company_list_sub.php | 27 + .../Medical1/Purchase/drug_master_list.php | 30 + .../Medical1/Purchase/indent_req_list.php | 30 + .../Purchase/indent_req_list_search.php | 57 + .../Medical1/Purchase/indent_request_edit.php | 203 + .../Purchase/indent_request_item_list.php | 43 + .../Medical1/Purchase/indent_request_view.php | 60 + .../Medical1/Purchase/ledger_add_entry.php | 85 + .../views/Medical1/Purchase/ledger_data.php | 63 + .../Medical1/Purchase/ledger_edit_entry.php | 87 + .../Medical1/Purchase/new_indent_request.php | 56 + .../Purchase/new_purchase_invoice.php | 69 + .../views/Medical1/Purchase/product_edit.php | 313 + .../views/Medical1/Purchase/product_new.php | 247 + .../Purchase/product_search_result.php | 48 + .../Purchase/purchase_Invoice_Edit.php | 489 ++ .../Purchase/purchase_invoice_item.php | 72 + .../Purchase/purchase_invoice_master_edit.php | 226 + .../Medical1/Purchase/purchase_item_old.php | 31 + .../Medical1/Purchase/purchase_supp_list.php | 66 + .../views/Medical1/Purchase/supplier_Edit.php | 111 + .../Medical1/Purchase/supplier_account.php | 58 + .../Purchase/supplier_account_detail.php | 90 + .../views/Medical1/Purchase/supplier_list.php | 30 + .../Medical1/Purchase/supplier_master.php | 60 + .../Medical1/Purchase/supplier_master_sub.php | 30 + .../views/Medical1/Purchase_Invoice_Edit.php | 386 + .../Medical1/Report/IPD_Discharge_Report.php | 79 + .../Medical1/Report/Med_Payment_Recevie.php | 105 + .../views/Medical1/Report/Med_Report_1.php | 80 + .../views/Medical1/Report/Med_Report_2.php | 77 + .../Medical1/Report/Med_Report_2_Pending.php | 86 + .../Report/Med_Report_2_Pending_paid.php | 51 + .../views/Medical1/Report/Med_Report_3.php | 79 + .../views/Medical1/Report/Med_Report_4.php | 80 + .../views/Medical1/Report/Med_Report_5.php | 80 + .../Medical1/Report/Med_Report_IPD_Credit.php | 91 + .../Report/Med_Report_company_med_sale.php | 119 + .../Report/Med_Report_daily_med_sale.php | 79 + .../Medical1/Report/Purchase_Invoice.php | 94 + .../Medical1/Report/Report_Med_patient.php | 88 + .../Report/Report_Med_patient_result.php | 67 + .../Report/Report_org_invoice_list.php | 96 + .../views/Medical1/Search_Patient.php | 22 + .../Stock/Stock_search_qty_result.php | 96 + .../Medical1/Stock/Stock_search_result.php | 120 + .../Stock/indent_accept_items_list.php | 86 + .../Medical1/Stock/indent_counter_edit.php | 213 + .../Stock/indent_counter_item_list.php | 36 + .../Medical1/Stock/indent_counter_list.php | 41 + .../Stock/indent_counter_search_result.php | 58 + .../views/Medical1/Stock/indent_issue.php | 0 .../Medical1/Stock/indent_issue_item_view.php | 38 + .../Medical1/Stock/indent_issue_items.php | 78 + .../Stock/indent_req_view_with_store.php | 65 + .../views/Medical1/Stock/indent_request.php | 30 + .../Stock/indent_request_search_result.php | 56 + .../Medical1/Stock/indent_stock_list.php | 61 + .../Medical1/Stock/main_store_dashboard.php | 58 + .../views/Medical1/Stock/stock_search.php | 58 + old_code_ci3/views/Medical1/Stock_Update.php | 211 + .../Medical1/Store/Stock_Item_history.php | 54 + .../Store/Stock_Item_history_removed.php | 54 + .../Medical1/Store/Stock_search_result.php | 189 + .../Medical1/Store/stock_store_statement.php | 154 + .../Store/stock_store_statement_data.php | 199 + .../Medical1/Store/store_stock_search.php | 64 + .../views/Medical1/Store_Dashboard.php | 45 + old_code_ci3/views/Medical1/Supplier_Edit.php | 111 + .../views/Medical1/Supplier_master.php | 60 + .../views/Medical1/Supplier_master_sub.php | 30 + .../views/Medical1/invoice_master_edit.php | 408 + .../views/Medical1/new_purchase_invoice.php | 70 + old_code_ci3/views/Medical1/payment_edit.php | 156 + .../views/Medical1/payment_search.php | 25 + .../views/Medical1/purchase_invoice_item.php | 62 + .../views/Medical1/purchase_supp_list.php | 47 + .../views/Medical1/sale_item_list_for_add.php | 30 + old_code_ci3/views/Medical1/supplier_list.php | 30 + old_code_ci3/views/Medical2/Dashboard.php | 44 + .../views/Medical2/Draft_Med_Invoice.php | 126 + old_code_ci3/views/Medical2/Drug_Details.php | 110 + .../views/Medical2/Drug_Details_all.php | 46 + old_code_ci3/views/Medical2/Drug_Stock.php | 123 + .../views/Medical2/Drug_Stock_Add.php | 273 + .../views/Medical2/Medical_Final_Invoice.php | 415 + .../views/Medical2/Medical_Invoice_V.php | 443 ++ .../views/Medical2/Medical_invoice_list.php | 235 + .../views/Medical2/Medical_invoice_print.php | 174 + .../Medical2/Medical_invoice_print_1.php | 176 + .../Medical2/Medical_invoice_print_2.php | 172 + .../Medical2/Medical_invoice_print_all.php | 187 + .../views/Medical2/Medical_ipd_org_list.php | 57 + .../Medical2/Medical_org_invoicelist.php | 101 + .../views/Medical2/Medical_org_list.php | 49 + .../views/Medical2/Medical_stock_drug.php | 118 + .../views/Medical2/Patient_Search_Result.php | 44 + .../views/Medical2/Report/Med_Report_1.php | 80 + .../views/Medical2/Report/Med_Report_2.php | 79 + .../views/Medical2/Report/Med_Report_3.php | 79 + .../views/Medical2/Search_Patient.php | 22 + old_code_ci3/views/Medical2/Stock_Update.php | 192 + .../views/Medical_13062021/Dashboard.php | 49 + .../Medical_13062021/Draft_Med_Invoice.php | 131 + .../Draft_Med_Return_Invoice.php | 132 + .../views/Medical_13062021/Drug_Details.php | 110 + .../Medical_13062021/Drug_Details_all.php | 46 + .../views/Medical_13062021/Drug_Stock.php | 123 + .../views/Medical_13062021/Drug_Stock_Add.php | 292 + .../Medical_13062021/Invoice_OLD_Master.php | 200 + .../Medical_13062021/Invoice_med_list.php | 117 + .../views/Medical_13062021/Med_Item_List.php | 86 + .../Medical_13062021/Med_Item_old_list.php | 46 + .../Medical_13062021/Med_Model_Payment.php | 323 + .../views/Medical_13062021/Med_Payment.php | 308 + .../Medical_13062021/Med_Payment_Receipt.php | 112 + .../Med_Return_Invoice_search.php | 67 + .../views/Medical_13062021/Med_back_Panel.php | 123 + .../Medical_13062021/Med_old_invoice_list.php | 67 + .../Medical_Final_Invoice.php | 394 + .../Medical_Invoice_Return.php | 212 + .../Medical_Invoice_Return_V.php | 294 + .../Medical_Invoice_Return_pre.php | 148 + .../Medical_Invoice_Return_print.php | 148 + .../Medical_13062021/Medical_Invoice_V.php | 654 ++ .../Medical_13062021/Medical_invoice_list.php | 338 + .../Medical_invoice_print.php | 180 + .../Medical_invoice_print_1.php | 182 + .../Medical_invoice_print_2.php | 178 + .../Medical_invoice_print_all.php | 197 + .../Medical_invoice_print_all_provisional.php | 179 + .../Medical_13062021/Medical_ipd_org_list.php | 57 + .../Medical_org_invoicelist.php | 97 + .../Medical_13062021/Medical_org_list.php | 49 + .../Medical_13062021/Medical_stock_drug.php | 116 + .../Patient_Search_Result.php | 49 + .../Medical_13062021/Print/Medicine_List.php | 86 + .../Print/medical_bill_print_a6.php | 190 + .../Print/medical_bill_print_format.php | 191 + .../medical_bill_print_format_newpage.php | 145 + .../medical_bill_print_format_single.php | 184 + .../Purchase/Company_Edit.php | 76 + .../Purchase/Purchase_Invoice_Edit.php | 488 ++ .../Purchase/Supplier_Edit.php | 111 + .../Purchase/Supplier_account.php | 58 + .../Purchase/Supplier_account_detail.php | 90 + .../Purchase/Supplier_master.php | 60 + .../Purchase/Supplier_master_sub.php | 30 + .../Purchase/company_list.php | 60 + .../Purchase/company_list_sub.php | 27 + .../Purchase/drug_master_list.php | 30 + .../Purchase/indent_req_list.php | 30 + .../Purchase/indent_req_list_search.php | 57 + .../Purchase/indent_request_edit.php | 203 + .../Purchase/indent_request_item_list.php | 43 + .../Purchase/indent_request_view.php | 60 + .../Purchase/ledger_add_entry.php | 85 + .../Medical_13062021/Purchase/ledger_data.php | 63 + .../Purchase/ledger_edit_entry.php | 87 + .../Purchase/new_indent_request.php | 56 + .../Purchase/new_purchase_invoice.php | 69 + .../Purchase/product_edit.php | 313 + .../Medical_13062021/Purchase/product_new.php | 247 + .../Purchase/product_search_result.php | 48 + .../Purchase/purchase_invoice_item.php | 72 + .../Purchase/purchase_invoice_master_edit.php | 226 + .../Purchase/purchase_item_old.php | 31 + .../Purchase/purchase_supp_list.php | 66 + .../Purchase/supplier_list.php | 30 + .../Purchase_Invoice_Edit.php | 386 + .../Report/IPD_Discharge_Report.php | 79 + .../Report/Med_Payment_Recevie.php | 105 + .../Medical_13062021/Report/Med_Report_1.php | 80 + .../Medical_13062021/Report/Med_Report_2.php | 68 + .../Report/Med_Report_2_Pending.php | 86 + .../Report/Med_Report_2_Pending_paid.php | 51 + .../Medical_13062021/Report/Med_Report_3.php | 79 + .../Medical_13062021/Report/Med_Report_4.php | 80 + .../Medical_13062021/Report/Med_Report_5.php | 80 + .../Report/Med_Report_IPD_Credit.php | 91 + .../Report/Med_Report_company_med_sale.php | 119 + .../Report/Med_Report_daily_med_sale.php | 79 + .../Report/Purchase_Invoice.php | 94 + .../Report/Report_Med_patient.php | 88 + .../Report/Report_Med_patient_result.php | 67 + .../Report/Report_org_invoice_list.php | 96 + .../views/Medical_13062021/Search_Patient.php | 22 + .../Stock/Stock_search_qty_result.php | 96 + .../Stock/Stock_search_result.php | 120 + .../Stock/indent_accept_items_list.php | 86 + .../Stock/indent_counter_edit.php | 213 + .../Stock/indent_counter_item_list.php | 36 + .../Stock/indent_counter_list.php | 41 + .../Stock/indent_counter_search_result.php | 58 + .../Medical_13062021/Stock/indent_issue.php | 0 .../Stock/indent_issue_item_view.php | 38 + .../Stock/indent_issue_items.php | 78 + .../Stock/indent_req_view_with_store.php | 65 + .../Medical_13062021/Stock/indent_request.php | 30 + .../Stock/indent_request_search_result.php | 56 + .../Stock/indent_stock_list.php | 61 + .../Stock/main_store_dashboard.php | 58 + .../Medical_13062021/Stock/stock_search.php | 58 + .../views/Medical_13062021/Stock_Update.php | 211 + .../Store/Stock_Item_history.php | 30 + .../Store/Stock_search_result.php | 135 + .../Store/stock_store_statement.php | 113 + .../Store/store_stock_search.php | 64 + .../Medical_13062021/Store_Dashboard.php | 45 + .../views/Medical_13062021/Supplier_Edit.php | 111 + .../Medical_13062021/Supplier_master.php | 60 + .../Medical_13062021/Supplier_master_sub.php | 30 + .../Medical_13062021/invoice_master_edit.php | 408 + .../Medical_13062021/new_purchase_invoice.php | 70 + .../views/Medical_13062021/payment_edit.php | 156 + .../views/Medical_13062021/payment_search.php | 25 + .../purchase_invoice_item.php | 62 + .../Medical_13062021/purchase_supp_list.php | 47 + .../sale_item_list_for_add.php | 30 + .../views/Medical_13062021/supplier_list.php | 30 + .../lab_final_report_show_xray.php | 52 +- .../PathLab_Report/ultrasound_report_edit.php | 21 +- .../ultrasound_template_list.php | 4 +- old_code_ci3/views/Patient_V.php | 17 +- old_code_ci3/views/Person_Edit_V.php | 17 +- old_code_ci3/views/Report/ReportMain.php | 10 - .../Purchase/purchase_invoice_edit.php | 2 +- .../views/auth_ihc - Copy/create_group.php | 43 + .../views/auth_ihc - Copy/create_user.php | 95 + .../views/auth_ihc - Copy/edit_group.php | 20 + .../views/auth_ihc - Copy/edit_user.php | 121 + old_code_ci3/views/auth_ihc - Copy/index.php | 45 + old_code_ci3/views/auth_ihc - Copy/login.php | 99 + old_code_ci3/views/auth_ihc/create_group.php | 43 + old_code_ci3/views/auth_ihc/create_user.php | 95 + old_code_ci3/views/auth_ihc/edit_group.php | 20 + old_code_ci3/views/auth_ihc/edit_user.php | 111 + old_code_ci3/views/auth_ihc/index.php | 48 + old_code_ci3/views/auth_ihc/login.php | 100 + .../views/auth_ihc/profile_update.php | 64 + old_code_ci3/views/authb/change_password.php | 25 + old_code_ci3/views/authb/create_group.php | 20 + old_code_ci3/views/authb/create_user.php | 95 + old_code_ci3/views/authb/deactivate_user.php | 18 + old_code_ci3/views/authb/edit_group.php | 20 + old_code_ci3/views/authb/edit_user.php | 66 + .../views/authb/email/activate.tpl.php | 6 + .../views/authb/email/forgot_password.tpl.php | 6 + .../views/authb/email/new_password.tpl.php | 7 + old_code_ci3/views/authb/forgot_password.php | 15 + old_code_ci3/views/authb/index.php | 44 + old_code_ci3/views/authb/login.php | 100 + old_code_ci3/views/authb/login2.php | 28 + old_code_ci3/views/authb/new edit_user_1.php | 66 + old_code_ci3/views/authb/reset_password.php | 22 + .../views/dashboard/opd_letter_head_print.php | 28 +- ...opd_letter_head_print_radiant_drpoonam.php | 29 +- .../opd_letter_head_print_radiant_drvk.php | 3 - .../views/dashboard/opd_print_parcha_2.php | 4 +- .../views/dashboard/opd_print_parcha_4.php | 2 +- ..._print_parcha_agarwal_hospital_ksp new.php | 96 + .../views/dashboard/opd_print_parcha_svh.php | 21 + .../dashboard/opd_queue_status_tab_0.php | 14 - .../rx_print_drJoshiclinic_letterhead.php | 12 +- .../rx_print_drjoshiclinic_plain_paper.php | 16 +- ...shiclinic_pre_print_letter_head_format.php | 15 +- ...int_drjoshiclinic_rx_blank_letter_head.php | 15 +- old_code_ci3/views/setting/setting_main.php | 14 +- .../2026/03/diag_20260312_140042_0c6cf323.jpg | Bin 0 -> 132057 bytes .../2026/03/diag_20260312_202601_cd87bc8c.jpg | Bin 0 -> 116802 bytes .../03/diag_20260312_205413_33c84306.jpeg | Bin 0 -> 63251 bytes .../2026/03/diag_20260312_210604_74f6fe53.png | Bin 0 -> 160339 bytes .../2026/03/diag_20260312_225913_2886e5fd.dcm | Bin 0 -> 526336 bytes .../10002_20260316200538_58606967.jpg | Bin 0 -> 618829 bytes .../10002_20260316202542_87f7cad6.jpg | Bin 0 -> 1721892 bytes .../10002_20260316202559_8b3c9145.jpg | Bin 0 -> 755965 bytes writable/cache/index.html | 11 - writable/debugbar/index.html | 11 - writable/tmp_check_ai_settings.php | 120 +- writable/tmp_check_mpdf.php | 12 + 512 files changed, 80813 insertions(+), 6102 deletions(-) create mode 100644 DICOM_AI_IMPLEMENTATION.md create mode 100644 app/Controllers/DoctorDocument.php create mode 100644 app/Controllers/Finance.php create mode 100644 app/Controllers/Setting/HospitalProfile.php create mode 100644 app/Database/Migrations/2026-03-10-000011_CreateFinancePhase1Tables.php create mode 100644 app/Database/Migrations/2026-03-10-000012_AddFinanceInvoiceMatchColumns.php create mode 100644 app/Database/Migrations/2026-03-10-000013_CreateFinanceCashTables.php create mode 100644 app/Database/Migrations/2026-03-10-000014_CreateFinanceDoctorPayoutTables.php create mode 100644 app/Database/Migrations/2026-03-10-000015_CreateFinanceDepositAndPolicyTables.php create mode 100644 app/Database/Migrations/2026-03-15-000021_CreateDoctorDocumentTables.php create mode 100644 app/Database/Migrations/2026-03-15-000022_AddDefaultPrintTypeToDocFormatMaster.php create mode 100644 app/Database/Migrations/2026-03-15-000023_AddPrintMarginsToDocFormatMaster.php create mode 100644 app/Database/Migrations/2026-03-15-000024_CreateDoctorDocumentPrintTemplates.php create mode 100644 app/Database/Migrations/2026-03-17-000025_AddFinancePoDocumentColumns.php create mode 100644 app/Database/Migrations/2026-03-17-000026_CreateFinancePoDocumentsTable.php create mode 100644 app/Database/Migrations/2026-03-17-000027_CreateFinancePharmacyBillsTable.php create mode 100644 app/Models/FinanceBankDepositModel.php create mode 100644 app/Models/FinanceCashTransactionModel.php create mode 100644 app/Models/FinanceDoctorAgreementModel.php create mode 100644 app/Models/FinanceDoctorPayoutModel.php create mode 100644 app/Models/FinanceGrnModel.php create mode 100644 app/Models/FinancePharmacyBillModel.php create mode 100644 app/Models/FinancePoDocumentModel.php create mode 100644 app/Models/FinancePolicySettingModel.php create mode 100644 app/Models/FinancePurchaseOrderModel.php create mode 100644 app/Models/FinanceScrollSubmissionModel.php create mode 100644 app/Models/FinanceVendorInvoiceModel.php create mode 100644 app/Models/FinanceVendorModel.php create mode 100644 app/Views/Setting/Admin/hospital_profile.php create mode 100644 app/Views/Setting/Template/document_print_settings.php create mode 100644 app/Views/doctor_document/doc_input_list.php create mode 100644 app/Views/doctor_document/doc_letterhead_print.php create mode 100644 app/Views/doctor_document/doc_list.php create mode 100644 app/Views/doctor_document/doc_master_edit.php create mode 100644 app/Views/doctor_document/doc_pre_data.php create mode 100644 app/Views/doctor_document/patient_doc_edit.php create mode 100644 app/Views/doctor_document/patient_doc_master.php create mode 100644 app/Views/doctor_document/workspace.php create mode 100644 app/Views/finance/bank_deposits.php create mode 100644 app/Views/finance/cashbook.php create mode 100644 app/Views/finance/compliance_report.php create mode 100644 app/Views/finance/doctor_payout.php create mode 100644 app/Views/finance/index.php create mode 100644 app/Views/finance/partials/bank_deposits_table.php create mode 100644 app/Views/finance/partials/cash_transactions_table.php create mode 100644 app/Views/finance/partials/doctor_agreements_table.php create mode 100644 app/Views/finance/partials/doctor_payouts_table.php create mode 100644 app/Views/finance/partials/grn_table.php create mode 100644 app/Views/finance/partials/invoice_table.php create mode 100644 app/Views/finance/partials/pharmacy_bills_table.php create mode 100644 app/Views/finance/partials/po_table.php create mode 100644 app/Views/finance/partials/scroll_table.php create mode 100644 app/Views/finance/partials/vendors_table.php create mode 100644 app/Views/finance/phase2.php create mode 100644 app/Views/finance/print/grn_vendor_copy.php create mode 100644 app/Views/finance/sections/grn_entry.php create mode 100644 app/Views/finance/sections/pharmacy_bills.php create mode 100644 app/Views/finance/sections/purchase_order.php create mode 100644 app/Views/finance/sections/vendor_invoice.php create mode 100644 app/Views/finance/sections/vendor_master.php create mode 100644 app/Views/medical/new_purchase_return_invoice.php create mode 100644 app/Views/medical/purchase_return.php create mode 100644 app/Views/medical/purchase_return_invoice_edit.php create mode 100644 app/Views/medical/purchase_return_invoice_item.php create mode 100644 app/Views/medical/purchase_return_invoice_item_print.php create mode 100644 app/Views/medical/purchase_return_old_invoice_list.php create mode 100644 app/Views/medical/purchase_return_product_search.php create mode 100644 app/Views/medical/purchase_return_supplier_list.php create mode 100644 app/Views/report/document_list.php create mode 100644 app/Views/report/document_list_table.php create mode 100644 old_code_ci3/controllers/Auth_ihc - Copy.php create mode 100644 old_code_ci3/controllers/Auth_ihc.php create mode 100644 old_code_ci3/controllers/Ipd_discharge1.php create mode 100644 old_code_ci3/controllers/Medical1.php create mode 100644 old_code_ci3/controllers/Medical_05102022.php create mode 100644 old_code_ci3/controllers/Medical_1.php create mode 100644 old_code_ci3/controllers/Medical_130621.php create mode 100644 old_code_ci3/controllers/Medical_Report_09032022.php create mode 100644 old_code_ci3/controllers/Opd_print_1.php create mode 100644 old_code_ci3/controllers/PathLab1.php create mode 100644 old_code_ci3/controllers/PathLab_17042021.php create mode 100644 old_code_ci3/controllers/Report_bak.php create mode 100644 old_code_ci3/controllers/opd_print_parcha_2.php create mode 100644 old_code_ci3/models/Custtag_M.php create mode 100644 old_code_ci3/views/Invoice_PathLab_final_V - Copy.php create mode 100644 old_code_ci3/views/June19.xlsx create mode 100644 old_code_ci3/views/Lab_Panel/patient_lab_xray_report.php create mode 100644 old_code_ci3/views/Medical/Stock/purchase_return_invoice_item print.php create mode 100644 old_code_ci3/views/Medical1/Dashboard.php create mode 100644 old_code_ci3/views/Medical1/Draft_Med_Invoice.php create mode 100644 old_code_ci3/views/Medical1/Draft_Med_Return_Invoice.php create mode 100644 old_code_ci3/views/Medical1/Drug_Details.php create mode 100644 old_code_ci3/views/Medical1/Drug_Details_all.php create mode 100644 old_code_ci3/views/Medical1/Drug_Stock.php create mode 100644 old_code_ci3/views/Medical1/Drug_Stock_Add.php create mode 100644 old_code_ci3/views/Medical1/Invoice_OLD_Master.php create mode 100644 old_code_ci3/views/Medical1/Invoice_med_list.php create mode 100644 old_code_ci3/views/Medical1/Med_Item_List.php create mode 100644 old_code_ci3/views/Medical1/Med_Item_old_list.php create mode 100644 old_code_ci3/views/Medical1/Med_Model_Payment.php create mode 100644 old_code_ci3/views/Medical1/Med_Payment.php create mode 100644 old_code_ci3/views/Medical1/Med_Payment_Receipt.php create mode 100644 old_code_ci3/views/Medical1/Med_Return_Invoice_search.php create mode 100644 old_code_ci3/views/Medical1/Med_back_Panel.php create mode 100644 old_code_ci3/views/Medical1/Med_old_invoice_list.php create mode 100644 old_code_ci3/views/Medical1/Medical_Final_Invoice.php create mode 100644 old_code_ci3/views/Medical1/Medical_Invoice_Return.php create mode 100644 old_code_ci3/views/Medical1/Medical_Invoice_Return_V.php create mode 100644 old_code_ci3/views/Medical1/Medical_Invoice_Return_pre.php create mode 100644 old_code_ci3/views/Medical1/Medical_Invoice_Return_print.php create mode 100644 old_code_ci3/views/Medical1/Medical_Invoice_V.php create mode 100644 old_code_ci3/views/Medical1/Medical_invoice_list.php create mode 100644 old_code_ci3/views/Medical1/Medical_invoice_print.php create mode 100644 old_code_ci3/views/Medical1/Medical_invoice_print_1.php create mode 100644 old_code_ci3/views/Medical1/Medical_invoice_print_2.php create mode 100644 old_code_ci3/views/Medical1/Medical_invoice_print_all.php create mode 100644 old_code_ci3/views/Medical1/Medical_invoice_print_all_provisional.php create mode 100644 old_code_ci3/views/Medical1/Medical_ipd_org_list.php create mode 100644 old_code_ci3/views/Medical1/Medical_org_invoicelist.php create mode 100644 old_code_ci3/views/Medical1/Medical_org_list.php create mode 100644 old_code_ci3/views/Medical1/Medical_stock_drug.php create mode 100644 old_code_ci3/views/Medical1/Patient_Search_Result.php create mode 100644 old_code_ci3/views/Medical1/Print/Medicine_List.php create mode 100644 old_code_ci3/views/Medical1/Print/medical_bill_print_a6.php create mode 100644 old_code_ci3/views/Medical1/Print/medical_bill_print_format.php create mode 100644 old_code_ci3/views/Medical1/Print/medical_bill_print_format_newpage.php create mode 100644 old_code_ci3/views/Medical1/Print/medical_bill_print_format_single.php create mode 100644 old_code_ci3/views/Medical1/Purchase/company_Edit.php create mode 100644 old_code_ci3/views/Medical1/Purchase/company_list.php create mode 100644 old_code_ci3/views/Medical1/Purchase/company_list_sub.php create mode 100644 old_code_ci3/views/Medical1/Purchase/drug_master_list.php create mode 100644 old_code_ci3/views/Medical1/Purchase/indent_req_list.php create mode 100644 old_code_ci3/views/Medical1/Purchase/indent_req_list_search.php create mode 100644 old_code_ci3/views/Medical1/Purchase/indent_request_edit.php create mode 100644 old_code_ci3/views/Medical1/Purchase/indent_request_item_list.php create mode 100644 old_code_ci3/views/Medical1/Purchase/indent_request_view.php create mode 100644 old_code_ci3/views/Medical1/Purchase/ledger_add_entry.php create mode 100644 old_code_ci3/views/Medical1/Purchase/ledger_data.php create mode 100644 old_code_ci3/views/Medical1/Purchase/ledger_edit_entry.php create mode 100644 old_code_ci3/views/Medical1/Purchase/new_indent_request.php create mode 100644 old_code_ci3/views/Medical1/Purchase/new_purchase_invoice.php create mode 100644 old_code_ci3/views/Medical1/Purchase/product_edit.php create mode 100644 old_code_ci3/views/Medical1/Purchase/product_new.php create mode 100644 old_code_ci3/views/Medical1/Purchase/product_search_result.php create mode 100644 old_code_ci3/views/Medical1/Purchase/purchase_Invoice_Edit.php create mode 100644 old_code_ci3/views/Medical1/Purchase/purchase_invoice_item.php create mode 100644 old_code_ci3/views/Medical1/Purchase/purchase_invoice_master_edit.php create mode 100644 old_code_ci3/views/Medical1/Purchase/purchase_item_old.php create mode 100644 old_code_ci3/views/Medical1/Purchase/purchase_supp_list.php create mode 100644 old_code_ci3/views/Medical1/Purchase/supplier_Edit.php create mode 100644 old_code_ci3/views/Medical1/Purchase/supplier_account.php create mode 100644 old_code_ci3/views/Medical1/Purchase/supplier_account_detail.php create mode 100644 old_code_ci3/views/Medical1/Purchase/supplier_list.php create mode 100644 old_code_ci3/views/Medical1/Purchase/supplier_master.php create mode 100644 old_code_ci3/views/Medical1/Purchase/supplier_master_sub.php create mode 100644 old_code_ci3/views/Medical1/Purchase_Invoice_Edit.php create mode 100644 old_code_ci3/views/Medical1/Report/IPD_Discharge_Report.php create mode 100644 old_code_ci3/views/Medical1/Report/Med_Payment_Recevie.php create mode 100644 old_code_ci3/views/Medical1/Report/Med_Report_1.php create mode 100644 old_code_ci3/views/Medical1/Report/Med_Report_2.php create mode 100644 old_code_ci3/views/Medical1/Report/Med_Report_2_Pending.php create mode 100644 old_code_ci3/views/Medical1/Report/Med_Report_2_Pending_paid.php create mode 100644 old_code_ci3/views/Medical1/Report/Med_Report_3.php create mode 100644 old_code_ci3/views/Medical1/Report/Med_Report_4.php create mode 100644 old_code_ci3/views/Medical1/Report/Med_Report_5.php create mode 100644 old_code_ci3/views/Medical1/Report/Med_Report_IPD_Credit.php create mode 100644 old_code_ci3/views/Medical1/Report/Med_Report_company_med_sale.php create mode 100644 old_code_ci3/views/Medical1/Report/Med_Report_daily_med_sale.php create mode 100644 old_code_ci3/views/Medical1/Report/Purchase_Invoice.php create mode 100644 old_code_ci3/views/Medical1/Report/Report_Med_patient.php create mode 100644 old_code_ci3/views/Medical1/Report/Report_Med_patient_result.php create mode 100644 old_code_ci3/views/Medical1/Report/Report_org_invoice_list.php create mode 100644 old_code_ci3/views/Medical1/Search_Patient.php create mode 100644 old_code_ci3/views/Medical1/Stock/Stock_search_qty_result.php create mode 100644 old_code_ci3/views/Medical1/Stock/Stock_search_result.php create mode 100644 old_code_ci3/views/Medical1/Stock/indent_accept_items_list.php create mode 100644 old_code_ci3/views/Medical1/Stock/indent_counter_edit.php create mode 100644 old_code_ci3/views/Medical1/Stock/indent_counter_item_list.php create mode 100644 old_code_ci3/views/Medical1/Stock/indent_counter_list.php create mode 100644 old_code_ci3/views/Medical1/Stock/indent_counter_search_result.php create mode 100644 old_code_ci3/views/Medical1/Stock/indent_issue.php create mode 100644 old_code_ci3/views/Medical1/Stock/indent_issue_item_view.php create mode 100644 old_code_ci3/views/Medical1/Stock/indent_issue_items.php create mode 100644 old_code_ci3/views/Medical1/Stock/indent_req_view_with_store.php create mode 100644 old_code_ci3/views/Medical1/Stock/indent_request.php create mode 100644 old_code_ci3/views/Medical1/Stock/indent_request_search_result.php create mode 100644 old_code_ci3/views/Medical1/Stock/indent_stock_list.php create mode 100644 old_code_ci3/views/Medical1/Stock/main_store_dashboard.php create mode 100644 old_code_ci3/views/Medical1/Stock/stock_search.php create mode 100644 old_code_ci3/views/Medical1/Stock_Update.php create mode 100644 old_code_ci3/views/Medical1/Store/Stock_Item_history.php create mode 100644 old_code_ci3/views/Medical1/Store/Stock_Item_history_removed.php create mode 100644 old_code_ci3/views/Medical1/Store/Stock_search_result.php create mode 100644 old_code_ci3/views/Medical1/Store/stock_store_statement.php create mode 100644 old_code_ci3/views/Medical1/Store/stock_store_statement_data.php create mode 100644 old_code_ci3/views/Medical1/Store/store_stock_search.php create mode 100644 old_code_ci3/views/Medical1/Store_Dashboard.php create mode 100644 old_code_ci3/views/Medical1/Supplier_Edit.php create mode 100644 old_code_ci3/views/Medical1/Supplier_master.php create mode 100644 old_code_ci3/views/Medical1/Supplier_master_sub.php create mode 100644 old_code_ci3/views/Medical1/invoice_master_edit.php create mode 100644 old_code_ci3/views/Medical1/new_purchase_invoice.php create mode 100644 old_code_ci3/views/Medical1/payment_edit.php create mode 100644 old_code_ci3/views/Medical1/payment_search.php create mode 100644 old_code_ci3/views/Medical1/purchase_invoice_item.php create mode 100644 old_code_ci3/views/Medical1/purchase_supp_list.php create mode 100644 old_code_ci3/views/Medical1/sale_item_list_for_add.php create mode 100644 old_code_ci3/views/Medical1/supplier_list.php create mode 100644 old_code_ci3/views/Medical2/Dashboard.php create mode 100644 old_code_ci3/views/Medical2/Draft_Med_Invoice.php create mode 100644 old_code_ci3/views/Medical2/Drug_Details.php create mode 100644 old_code_ci3/views/Medical2/Drug_Details_all.php create mode 100644 old_code_ci3/views/Medical2/Drug_Stock.php create mode 100644 old_code_ci3/views/Medical2/Drug_Stock_Add.php create mode 100644 old_code_ci3/views/Medical2/Medical_Final_Invoice.php create mode 100644 old_code_ci3/views/Medical2/Medical_Invoice_V.php create mode 100644 old_code_ci3/views/Medical2/Medical_invoice_list.php create mode 100644 old_code_ci3/views/Medical2/Medical_invoice_print.php create mode 100644 old_code_ci3/views/Medical2/Medical_invoice_print_1.php create mode 100644 old_code_ci3/views/Medical2/Medical_invoice_print_2.php create mode 100644 old_code_ci3/views/Medical2/Medical_invoice_print_all.php create mode 100644 old_code_ci3/views/Medical2/Medical_ipd_org_list.php create mode 100644 old_code_ci3/views/Medical2/Medical_org_invoicelist.php create mode 100644 old_code_ci3/views/Medical2/Medical_org_list.php create mode 100644 old_code_ci3/views/Medical2/Medical_stock_drug.php create mode 100644 old_code_ci3/views/Medical2/Patient_Search_Result.php create mode 100644 old_code_ci3/views/Medical2/Report/Med_Report_1.php create mode 100644 old_code_ci3/views/Medical2/Report/Med_Report_2.php create mode 100644 old_code_ci3/views/Medical2/Report/Med_Report_3.php create mode 100644 old_code_ci3/views/Medical2/Search_Patient.php create mode 100644 old_code_ci3/views/Medical2/Stock_Update.php create mode 100644 old_code_ci3/views/Medical_13062021/Dashboard.php create mode 100644 old_code_ci3/views/Medical_13062021/Draft_Med_Invoice.php create mode 100644 old_code_ci3/views/Medical_13062021/Draft_Med_Return_Invoice.php create mode 100644 old_code_ci3/views/Medical_13062021/Drug_Details.php create mode 100644 old_code_ci3/views/Medical_13062021/Drug_Details_all.php create mode 100644 old_code_ci3/views/Medical_13062021/Drug_Stock.php create mode 100644 old_code_ci3/views/Medical_13062021/Drug_Stock_Add.php create mode 100644 old_code_ci3/views/Medical_13062021/Invoice_OLD_Master.php create mode 100644 old_code_ci3/views/Medical_13062021/Invoice_med_list.php create mode 100644 old_code_ci3/views/Medical_13062021/Med_Item_List.php create mode 100644 old_code_ci3/views/Medical_13062021/Med_Item_old_list.php create mode 100644 old_code_ci3/views/Medical_13062021/Med_Model_Payment.php create mode 100644 old_code_ci3/views/Medical_13062021/Med_Payment.php create mode 100644 old_code_ci3/views/Medical_13062021/Med_Payment_Receipt.php create mode 100644 old_code_ci3/views/Medical_13062021/Med_Return_Invoice_search.php create mode 100644 old_code_ci3/views/Medical_13062021/Med_back_Panel.php create mode 100644 old_code_ci3/views/Medical_13062021/Med_old_invoice_list.php create mode 100644 old_code_ci3/views/Medical_13062021/Medical_Final_Invoice.php create mode 100644 old_code_ci3/views/Medical_13062021/Medical_Invoice_Return.php create mode 100644 old_code_ci3/views/Medical_13062021/Medical_Invoice_Return_V.php create mode 100644 old_code_ci3/views/Medical_13062021/Medical_Invoice_Return_pre.php create mode 100644 old_code_ci3/views/Medical_13062021/Medical_Invoice_Return_print.php create mode 100644 old_code_ci3/views/Medical_13062021/Medical_Invoice_V.php create mode 100644 old_code_ci3/views/Medical_13062021/Medical_invoice_list.php create mode 100644 old_code_ci3/views/Medical_13062021/Medical_invoice_print.php create mode 100644 old_code_ci3/views/Medical_13062021/Medical_invoice_print_1.php create mode 100644 old_code_ci3/views/Medical_13062021/Medical_invoice_print_2.php create mode 100644 old_code_ci3/views/Medical_13062021/Medical_invoice_print_all.php create mode 100644 old_code_ci3/views/Medical_13062021/Medical_invoice_print_all_provisional.php create mode 100644 old_code_ci3/views/Medical_13062021/Medical_ipd_org_list.php create mode 100644 old_code_ci3/views/Medical_13062021/Medical_org_invoicelist.php create mode 100644 old_code_ci3/views/Medical_13062021/Medical_org_list.php create mode 100644 old_code_ci3/views/Medical_13062021/Medical_stock_drug.php create mode 100644 old_code_ci3/views/Medical_13062021/Patient_Search_Result.php create mode 100644 old_code_ci3/views/Medical_13062021/Print/Medicine_List.php create mode 100644 old_code_ci3/views/Medical_13062021/Print/medical_bill_print_a6.php create mode 100644 old_code_ci3/views/Medical_13062021/Print/medical_bill_print_format.php create mode 100644 old_code_ci3/views/Medical_13062021/Print/medical_bill_print_format_newpage.php create mode 100644 old_code_ci3/views/Medical_13062021/Print/medical_bill_print_format_single.php create mode 100644 old_code_ci3/views/Medical_13062021/Purchase/Company_Edit.php create mode 100644 old_code_ci3/views/Medical_13062021/Purchase/Purchase_Invoice_Edit.php create mode 100644 old_code_ci3/views/Medical_13062021/Purchase/Supplier_Edit.php create mode 100644 old_code_ci3/views/Medical_13062021/Purchase/Supplier_account.php create mode 100644 old_code_ci3/views/Medical_13062021/Purchase/Supplier_account_detail.php create mode 100644 old_code_ci3/views/Medical_13062021/Purchase/Supplier_master.php create mode 100644 old_code_ci3/views/Medical_13062021/Purchase/Supplier_master_sub.php create mode 100644 old_code_ci3/views/Medical_13062021/Purchase/company_list.php create mode 100644 old_code_ci3/views/Medical_13062021/Purchase/company_list_sub.php create mode 100644 old_code_ci3/views/Medical_13062021/Purchase/drug_master_list.php create mode 100644 old_code_ci3/views/Medical_13062021/Purchase/indent_req_list.php create mode 100644 old_code_ci3/views/Medical_13062021/Purchase/indent_req_list_search.php create mode 100644 old_code_ci3/views/Medical_13062021/Purchase/indent_request_edit.php create mode 100644 old_code_ci3/views/Medical_13062021/Purchase/indent_request_item_list.php create mode 100644 old_code_ci3/views/Medical_13062021/Purchase/indent_request_view.php create mode 100644 old_code_ci3/views/Medical_13062021/Purchase/ledger_add_entry.php create mode 100644 old_code_ci3/views/Medical_13062021/Purchase/ledger_data.php create mode 100644 old_code_ci3/views/Medical_13062021/Purchase/ledger_edit_entry.php create mode 100644 old_code_ci3/views/Medical_13062021/Purchase/new_indent_request.php create mode 100644 old_code_ci3/views/Medical_13062021/Purchase/new_purchase_invoice.php create mode 100644 old_code_ci3/views/Medical_13062021/Purchase/product_edit.php create mode 100644 old_code_ci3/views/Medical_13062021/Purchase/product_new.php create mode 100644 old_code_ci3/views/Medical_13062021/Purchase/product_search_result.php create mode 100644 old_code_ci3/views/Medical_13062021/Purchase/purchase_invoice_item.php create mode 100644 old_code_ci3/views/Medical_13062021/Purchase/purchase_invoice_master_edit.php create mode 100644 old_code_ci3/views/Medical_13062021/Purchase/purchase_item_old.php create mode 100644 old_code_ci3/views/Medical_13062021/Purchase/purchase_supp_list.php create mode 100644 old_code_ci3/views/Medical_13062021/Purchase/supplier_list.php create mode 100644 old_code_ci3/views/Medical_13062021/Purchase_Invoice_Edit.php create mode 100644 old_code_ci3/views/Medical_13062021/Report/IPD_Discharge_Report.php create mode 100644 old_code_ci3/views/Medical_13062021/Report/Med_Payment_Recevie.php create mode 100644 old_code_ci3/views/Medical_13062021/Report/Med_Report_1.php create mode 100644 old_code_ci3/views/Medical_13062021/Report/Med_Report_2.php create mode 100644 old_code_ci3/views/Medical_13062021/Report/Med_Report_2_Pending.php create mode 100644 old_code_ci3/views/Medical_13062021/Report/Med_Report_2_Pending_paid.php create mode 100644 old_code_ci3/views/Medical_13062021/Report/Med_Report_3.php create mode 100644 old_code_ci3/views/Medical_13062021/Report/Med_Report_4.php create mode 100644 old_code_ci3/views/Medical_13062021/Report/Med_Report_5.php create mode 100644 old_code_ci3/views/Medical_13062021/Report/Med_Report_IPD_Credit.php create mode 100644 old_code_ci3/views/Medical_13062021/Report/Med_Report_company_med_sale.php create mode 100644 old_code_ci3/views/Medical_13062021/Report/Med_Report_daily_med_sale.php create mode 100644 old_code_ci3/views/Medical_13062021/Report/Purchase_Invoice.php create mode 100644 old_code_ci3/views/Medical_13062021/Report/Report_Med_patient.php create mode 100644 old_code_ci3/views/Medical_13062021/Report/Report_Med_patient_result.php create mode 100644 old_code_ci3/views/Medical_13062021/Report/Report_org_invoice_list.php create mode 100644 old_code_ci3/views/Medical_13062021/Search_Patient.php create mode 100644 old_code_ci3/views/Medical_13062021/Stock/Stock_search_qty_result.php create mode 100644 old_code_ci3/views/Medical_13062021/Stock/Stock_search_result.php create mode 100644 old_code_ci3/views/Medical_13062021/Stock/indent_accept_items_list.php create mode 100644 old_code_ci3/views/Medical_13062021/Stock/indent_counter_edit.php create mode 100644 old_code_ci3/views/Medical_13062021/Stock/indent_counter_item_list.php create mode 100644 old_code_ci3/views/Medical_13062021/Stock/indent_counter_list.php create mode 100644 old_code_ci3/views/Medical_13062021/Stock/indent_counter_search_result.php create mode 100644 old_code_ci3/views/Medical_13062021/Stock/indent_issue.php create mode 100644 old_code_ci3/views/Medical_13062021/Stock/indent_issue_item_view.php create mode 100644 old_code_ci3/views/Medical_13062021/Stock/indent_issue_items.php create mode 100644 old_code_ci3/views/Medical_13062021/Stock/indent_req_view_with_store.php create mode 100644 old_code_ci3/views/Medical_13062021/Stock/indent_request.php create mode 100644 old_code_ci3/views/Medical_13062021/Stock/indent_request_search_result.php create mode 100644 old_code_ci3/views/Medical_13062021/Stock/indent_stock_list.php create mode 100644 old_code_ci3/views/Medical_13062021/Stock/main_store_dashboard.php create mode 100644 old_code_ci3/views/Medical_13062021/Stock/stock_search.php create mode 100644 old_code_ci3/views/Medical_13062021/Stock_Update.php create mode 100644 old_code_ci3/views/Medical_13062021/Store/Stock_Item_history.php create mode 100644 old_code_ci3/views/Medical_13062021/Store/Stock_search_result.php create mode 100644 old_code_ci3/views/Medical_13062021/Store/stock_store_statement.php create mode 100644 old_code_ci3/views/Medical_13062021/Store/store_stock_search.php create mode 100644 old_code_ci3/views/Medical_13062021/Store_Dashboard.php create mode 100644 old_code_ci3/views/Medical_13062021/Supplier_Edit.php create mode 100644 old_code_ci3/views/Medical_13062021/Supplier_master.php create mode 100644 old_code_ci3/views/Medical_13062021/Supplier_master_sub.php create mode 100644 old_code_ci3/views/Medical_13062021/invoice_master_edit.php create mode 100644 old_code_ci3/views/Medical_13062021/new_purchase_invoice.php create mode 100644 old_code_ci3/views/Medical_13062021/payment_edit.php create mode 100644 old_code_ci3/views/Medical_13062021/payment_search.php create mode 100644 old_code_ci3/views/Medical_13062021/purchase_invoice_item.php create mode 100644 old_code_ci3/views/Medical_13062021/purchase_supp_list.php create mode 100644 old_code_ci3/views/Medical_13062021/sale_item_list_for_add.php create mode 100644 old_code_ci3/views/Medical_13062021/supplier_list.php create mode 100644 old_code_ci3/views/auth_ihc - Copy/create_group.php create mode 100644 old_code_ci3/views/auth_ihc - Copy/create_user.php create mode 100644 old_code_ci3/views/auth_ihc - Copy/edit_group.php create mode 100644 old_code_ci3/views/auth_ihc - Copy/edit_user.php create mode 100644 old_code_ci3/views/auth_ihc - Copy/index.php create mode 100644 old_code_ci3/views/auth_ihc - Copy/login.php create mode 100644 old_code_ci3/views/auth_ihc/create_group.php create mode 100644 old_code_ci3/views/auth_ihc/create_user.php create mode 100644 old_code_ci3/views/auth_ihc/edit_group.php create mode 100644 old_code_ci3/views/auth_ihc/edit_user.php create mode 100644 old_code_ci3/views/auth_ihc/index.php create mode 100644 old_code_ci3/views/auth_ihc/login.php create mode 100644 old_code_ci3/views/auth_ihc/profile_update.php create mode 100644 old_code_ci3/views/authb/change_password.php create mode 100644 old_code_ci3/views/authb/create_group.php create mode 100644 old_code_ci3/views/authb/create_user.php create mode 100644 old_code_ci3/views/authb/deactivate_user.php create mode 100644 old_code_ci3/views/authb/edit_group.php create mode 100644 old_code_ci3/views/authb/edit_user.php create mode 100644 old_code_ci3/views/authb/email/activate.tpl.php create mode 100644 old_code_ci3/views/authb/email/forgot_password.tpl.php create mode 100644 old_code_ci3/views/authb/email/new_password.tpl.php create mode 100644 old_code_ci3/views/authb/forgot_password.php create mode 100644 old_code_ci3/views/authb/index.php create mode 100644 old_code_ci3/views/authb/login.php create mode 100644 old_code_ci3/views/authb/login2.php create mode 100644 old_code_ci3/views/authb/new edit_user_1.php create mode 100644 old_code_ci3/views/authb/reset_password.php create mode 100644 old_code_ci3/views/dashboard/opd_print_parcha_agarwal_hospital_ksp new.php create mode 100644 old_code_ci3/views/dashboard/opd_print_parcha_svh.php create mode 100644 public/uploads/diagnosis/2026/03/diag_20260312_140042_0c6cf323.jpg create mode 100644 public/uploads/diagnosis/2026/03/diag_20260312_202601_cd87bc8c.jpg create mode 100644 public/uploads/diagnosis/2026/03/diag_20260312_205413_33c84306.jpeg create mode 100644 public/uploads/diagnosis/2026/03/diag_20260312_210604_74f6fe53.png create mode 100644 public/uploads/diagnosis/2026/03/diag_20260312_225913_2886e5fd.dcm create mode 100644 public/uploads/finance_po_docs/10002_20260316200538_58606967.jpg create mode 100644 public/uploads/finance_po_docs/10002_20260316202542_87f7cad6.jpg create mode 100644 public/uploads/finance_po_docs/10002_20260316202559_8b3c9145.jpg delete mode 100644 writable/cache/index.html delete mode 100644 writable/debugbar/index.html create mode 100644 writable/tmp_check_mpdf.php diff --git a/DICOM_AI_IMPLEMENTATION.md b/DICOM_AI_IMPLEMENTATION.md new file mode 100644 index 0000000..759d47d --- /dev/null +++ b/DICOM_AI_IMPLEMENTATION.md @@ -0,0 +1,238 @@ +# DICOM File AI Analysis Implementation + +## Overview +DICOM (.dcm) files can now be uploaded and automatically converted to standard image format for AI analysis in the imaging diagnosis workflow. The system supports CT, MRI, and other DICOM-based imaging modalities. + +## Architecture + +### 1. **Python FastAPI Service** (`d:\Workplace\AI_Module_HMS\main.py`) + +#### New Imports Added (Lines 19-26) +```python +# --- DICOM support imports --- +try: + import pydicom + from pydicom.pixel_data_handlers.pillow_handler import apply_modality_lut +except ImportError: + pydicom = None + +import numpy as np +from PIL import Image +import io +``` + +#### New Helper Function: `_convert_dicom_to_image_bytes()` (Line ~1250) +Converts DICOM pixel data to standard JPEG/PNG image format with automatic windowing: + +**Key Features:** +- **Window Level/Width Handling**: Uses DICOM's WindowCenter and WindowWidth attributes for proper visualization +- **Auto-Scaling**: If window attributes unavailable, auto-scales pixel values to 0-255 range +- **Grayscale → RGB Conversion**: Converts single-channel DICOM images to RGB to ensure compatibility +- **Quality Preservation**: Uses JPEG quality=95 to minimize loss during conversion + +**Input:** Raw DICOM file bytes +**Output:** Image bytes ready for Google Vision API +**Error Handling:** Returns None if conversion fails; service returns error to client + +#### Modified `/diagnosis` Endpoint (Line ~1475) + +**What Changed:** +1. **File Type Detection**: Now accepts both image and DICOM files + ```python + is_dicom = filename_lower.endswith(('.dcm', '.dicom')) or 'dicom' in content_type + is_image = file.content_type and file.content_type.startswith("image/") + ``` + +2. **DICOM-to-JPEG Conversion Pipeline**: + ```python + if is_dicom: + converted_content = _convert_dicom_to_image_bytes(content, output_format="JPEG") + if not converted_content: + raise HTTPException(status_code=400, detail="Failed to convert DICOM file...") + content = converted_content + file.content_type = "image/jpeg" + ``` + +3. **Seamless AI Analysis**: After conversion, DICOM is processed identically to other image formats + - Google Vision label detection + - OCR extraction + - Modality/technique detection + - Gemini analysis via AI prompt system + +**Error Conditions:** +- Unsupported file type: `"Please upload a valid image file (JPEG/PNG) or DICOM (.dcm)"` +- DICOM conversion failed: `"Failed to convert DICOM file. File may be corrupted."` + +### 2. **PHP HMS Controller** (`d:\Workplace\HMS_CI4_OLD\app\Controllers\Diagnosis.php`) + +**No Changes Required** +- Backend file validation already includes `.dcm` and `.dicom` extensions +- File upload and storage remain unchanged +- Controller passes file path to `/diagnosis` endpoint which handles conversion + +### 3. **UI File Picker** (`d:\Workplace\HMS_CI4_OLD\app\Views\diagnosis\pathology_detail.php`) + +**No Changes Required** +- File picker `accept` attribute already includes DICOM MIME types: + ```javascript + input.accept = 'image/*,application/pdf,.dcm,application/dicom,application/dicom+json'; + ``` + +### 4. **Upload Gallery** (`d:\Workplace\HMS_CI4_OLD\app\Views\diagnosis\imaging_upload_gallery.php`) + +**No Changes Required** +- Gallery already shows medical file icon for non-image types +- Displays "Open File" button for DICOM files + +## Data Flow + +### CT/MRI DICOM Upload → AI Analysis Flow + +``` +User uploads .dcm file + ↓ +PHP validates extension ([jpg, png, webp, pdf, dcm, dicom]) ✓ + ↓ +File stored: public/uploads/diagnosis/{YYYY}/{MM}/{filename}.dcm + ↓ +User clicks "Analyze with AI" + ↓ +PHP POST to /diagnosis endpoint with file path + ↓ +Python FastAPI receives DICOM bytes + ↓ +_convert_dicom_to_image_bytes() + - Reads DICOM with pydicom + - Extracts pixel array + - Applies window level/width normalization + - Converts to RGB JPEG + ↓ +Google Vision API analyzes converted JPEG + - Label detection (anatomical structures, findings) + - OCR extraction (any text overlays) + ↓ +Modality-specific Gemini prompt applied + - CT: Organ, vessel, bone evaluation + - MRI: Brain, spine, vessel evaluation + - etc. + ↓ +AI-generated radiology report returned + ↓ +PHP extracts narrative findings and renders in modal + ↓ +Doctor reviews and signs off +``` + +## Supported Modalities + +DICOM files can now be analyzed for: +- **CT Scans**: Brain, Spine, Abdomen, Thorax, Angiography +- **MRI Scans**: Brain, Spine, Abdomen, Pelvis, Cardiac +- **Ultrasound**: (if DICOM format available) +- **X-rays**: Converted and analyzed as images +- **Other**: DR, CR, PT, NM formats (if pixel data available) + +## Technical Details + +### DICOM Windowing Algorithm +DICOM images often use 12-bit or 16-bit pixel data with implicit window settings. The conversion function: + +1. **Check for explicit window attributes**: + - `WindowCenter` (DICOM tag 0028,1050) + - `WindowWidth` (DICOM tag 0028,1051) + - Ideal for chest X-rays, CTs with clinical preset windows + +2. **If window attributes exist**: + ``` + min_val = WindowCenter - (WindowWidth / 2) + max_val = WindowCenter + (WindowWidth / 2) + Clip pixel data to [min_val, max_val] + Scale to 0-255 range + ``` + +3. **Fallback: Auto-scale**: + ``` + scale = (pixel_array - min) / (max - min) × 255 + ``` + +### RGB Conversion +- Grayscale DICOM → PIL 'L' mode → RGB mode (for Google Vision compatibility) +- RGB DICOM → Direct passthrough +- Multi-frame DICOM → First frame used (future: frame selection UI) + +### Output Format +- **JPEG Quality**: 95 (high quality, minimal loss) +- **File Type**: JPEG for all conversions (universal browser compatibility) +- **Buffer Management**: BytesIO for in-memory conversion (no temporary files) + +## Error Handling & Fallbacks + +| Error | Root Cause | User Message | Recovery | +|-------|-----------|--------------|----------| +| Conversion fails | Corrupted DICOM, invalid pixel data | "Failed to convert DICOM file. File may be corrupted." | User uploads different file or original image | +| Unsupported file type | Wrong extension or MIME type | "Please upload a valid image file (JPEG/PNG) or DICOM (.dcm)" | User checks file type | +| AI analysis fails on DICOM | Image quality too poor after conversion | Generic fallback report | Local chest X-ray model used (if applicable) | +| pydicom not installed | Missing dependency | Warning in logs, fallback validation | System admin installs pydicom | + +## Testing Checklist + +- [ ] Upload CT abdomen DICOM → AI generates findings (liver, spleen, kidneys) +- [ ] Upload MRI brain DICOM → AI generates findings (ventricles, lesions, midline) +- [ ] Upload multi-frame DICOM → First frame analyzed correctly +- [ ] Corrupted DICOM file → Error message shown, no crash +- [ ] DICOM with non-standard window settings → Proper windowing applied +- [ ] DICOM with text overlay → OCR extracts text metadata +- [ ] Provider/model badges show correctly in results +- [ ] Fallback warning appears if AI service uses local model + +## Security Considerations + +1. **File Type Validation**: Extension + MIME type check before processing +2. **Sandboxed Conversion**: DICOM parsing in isolated try/except block +3. **Size Limits**: PHP file upload max (typically 100MB) prevents DoS +4. **Failure Isolation**: DICOM conversion errors don't crash main endpoint + +## Performance Metrics + +- **DICOM to JPEG conversion**: ~100-500ms (depends on image size/complexity) +- **Google Vision analysis**: ~1-3s (network dependent) +- **Full pipeline (upload → AI → modal display)**: ~5-10s +- **Memory usage**: ~50-200MB per DICOM (loaded into RAM during conversion) + +## Future Enhancements + +1. **Multi-frame Support**: UI to select which frame to analyze +2. **DICOM-to-Video**: Convert series to video for temporal review +3. **Anonymization**: Strip PHI tags before AI analysis +4. **Caching**: Store converted JPEG to avoid re-conversion +5. **Batch Processing**: Upload multiple DICOM files at once +6. **Regional Analysis**: AI focus on specific anatomical regions per user request + +## Dependencies + +- **Python**: pydicom (DICOM reading), PIL/Pillow (image conversion), NumPy (array operations) +- **PHP**: No new dependencies (uses existing file upload framework) +- **Database**: No schema changes required +- **Frontend**: No changes (existing file picker supports DICOM MIME types) + +## Deployment Notes + +1. **Ensure pydicom installed** on AI server: + ```bash + pip install pydicom pillow numpy + ``` + +2. **Restart FastAPI service** after code update: + ```bash + # May require process restart or docker rebuild + ``` + +3. **Test with sample DICOM file** before production deployment + +4. **Monitor logs** for conversion errors during initial deployment + +--- + +**Status**: ✅ Implementation Complete +**Date**: March 13, 2026 +**Last Updated**: AI service now accepts DICOM files for CT/MRI/imaging workflows diff --git a/app/Config/AuthGroups.php b/app/Config/AuthGroups.php index 3f9fb04..d71dddb 100644 --- a/app/Config/AuthGroups.php +++ b/app/Config/AuthGroups.php @@ -81,6 +81,7 @@ class AuthGroups extends ShieldAuthGroups 'beta.access' => 'Can access beta-level features', 'billing.access' => 'Can access billing module', 'opd.doctor-panel.access' => 'Can access OPD doctor work panel (doctor-only)', + 'billing.opd.edit' => 'Can edit OPD registrations', 'billing.opd.pay' => 'Can confirm OPD payments', 'billing.charges.view' => 'Can view charges invoices', @@ -94,6 +95,23 @@ class AuthGroups extends ShieldAuthGroups 'billing.ipd.invoice' => 'Can view IPD invoice list', 'billing.ipd.cash-balance' => 'Can view IPD cash balance report', 'billing.ipd.export' => 'Can export IPD cash balance report', + 'finance.access' => 'Can access finance module', + 'finance.vendor.manage' => 'Can manage finance vendors', + 'finance.po.manage' => 'Can manage purchase orders', + 'finance.grn.manage' => 'Can manage GRN entries', + 'finance.invoice.manage' => 'Can manage vendor invoices', + 'finance.cash.manage' => 'Can manage cash collection and disbursement', + 'finance.doctor_payout.manage' => 'Can manage doctor payout workflow', + 'finance.bank_deposit.manage' => 'Can manage bank deposit register', + 'finance.compliance.view' => 'Can view finance compliance report', + 'diagnosis.access' => 'Can access diagnosis module', + 'diagnosis.report.view' => 'Can view diagnosis reports', + 'doctor_work.access' => 'Can access doctor work module', + 'doctor_work.appointment.view' => 'Can view OPD appointment list', + 'doctor_work.rx_group.manage' => 'Can manage Rx group panel', + 'doctor_work.medicine.manage' => 'Can manage OPD medicine', + 'doctor_work.advice.manage' => 'Can manage OPD advice master', + 'doctor_work.template_workspace.access' => 'Can access clinical templates workspace', 'pharmacy.access' => 'Can access pharmacy module', 'pharmacy.purchase.status-update' => 'Can update pharmacy purchase invoice status', 'template.pathology' => 'Can access pathology templates', @@ -119,6 +137,9 @@ class AuthGroups extends ShieldAuthGroups 'users.*', 'beta.*', 'billing.*', + 'finance.*', + 'diagnosis.*', + 'doctor_work.*', 'pharmacy.*', 'template.*', ], @@ -129,6 +150,9 @@ class AuthGroups extends ShieldAuthGroups 'users.delete', 'beta.access', 'billing.*', + 'finance.*', + 'diagnosis.*', + 'doctor_work.*', 'pharmacy.*', 'template.*', ], @@ -139,6 +163,9 @@ class AuthGroups extends ShieldAuthGroups 'users.edit', 'beta.access', 'billing.*', + 'finance.*', + 'diagnosis.*', + 'doctor_work.*', 'pharmacy.*', 'template.*', ], diff --git a/app/Config/Routes.php b/app/Config/Routes.php index f81e97e..0db3d1b 100644 --- a/app/Config/Routes.php +++ b/app/Config/Routes.php @@ -17,6 +17,7 @@ $routes->get('Medical/CounterSaleForm', 'Medical::counter_sale_form'); $routes->post('Medical/CounterSaleCreate', 'Medical::counter_sale_create'); $routes->match(['get', 'post'], 'Medical/search', 'Medical::search'); $routes->get('Medical/get_drug', 'Medical::get_drug'); +$routes->get('Medical/get_batch/(:num)', 'Medical::get_batch/$1'); $routes->get('Medical/check_invoice/(:num)/(:num)/(:num)', 'Medical::check_invoice/$1/$2/$3'); $routes->get('Medical/Invoice_counter_new/(:num)/(:num)/(:num)', 'Medical::Invoice_counter_new/$1/$2/$3'); $routes->get('Medical/invoice_new/(:num)', 'Medical::invoice_new/$1'); @@ -107,6 +108,15 @@ $routes->post('Medical/challan_item_to_purchase/(:num)/(:num)', 'Medical::challa $routes->post('Medical/challan_item_return/(:num)', 'Medical::challan_item_return/$1'); $routes->get('Medical/get_drug_master', 'Medical::get_drug_master'); $routes->get('Medical/Purchase_return', 'Medical::purchase_return'); +$routes->get('Medical/PurchaseReturnNew', 'Medical::purchase_return_new'); +$routes->post('Medical/PurchaseReturnInvoice', 'Medical::purchase_return_invoice'); +$routes->post('Medical/CreatePurchaseReturn', 'Medical::create_purchase_return'); +$routes->get('Medical/PurchaseReturnInvoiceEdit/(:num)', 'Medical::purchase_return_invoice_edit/$1'); +$routes->get('Medical/PurchaseReturn_invoice_item_list/(:num)', 'Medical::purchase_return_invoice_item_list/$1'); +$routes->get('Medical/Purchase_Invoice_product/(:num)', 'Medical::purchase_invoice_product/$1'); +$routes->match(['get', 'post'], 'Medical/Purchase_Invoice_old/(:num)', 'Medical::purchase_invoice_old/$1'); +$routes->post('Medical/remove_item_invoice/(:num)', 'Medical::purchase_return_remove_item_invoice/$1'); +$routes->get('Medical/print_purchase_return/(:num)', 'Medical::print_purchase_return/$1'); $routes->get('Medical/store_stock', 'Medical::store_stock'); $routes->post('Medical/store_stock_result', 'Medical::store_stock_result'); $routes->get('Medical/stock_result_excel/(:segment)/(:segment)/(:segment)', 'Medical::stock_result_excel/$1/$2/$3'); @@ -118,6 +128,18 @@ $routes->get('Medical_backpanel/store_stock', 'Medical::store_stock'); $routes->get('Medical_backpanel/stock', 'Medical::store_stock'); $routes->get('Medical_backpanel/Stock', 'Medical::store_stock'); $routes->get('Medical_backpanel/Purchase_return', 'Medical::purchase_return'); +$routes->get('Medical_backpanel/PurchaseReturnNew', 'Medical::purchase_return_new'); +$routes->post('Medical_backpanel/PurchaseReturnInvoice', 'Medical::purchase_return_invoice'); +$routes->post('Medical_backpanel/CreatePurchaseReturn', 'Medical::create_purchase_return'); +$routes->get('Medical_backpanel/PurchaseReturnInvoiceEdit/(:num)', 'Medical::purchase_return_invoice_edit/$1'); +$routes->get('Medical_backpanel/PurchaseReturn_invoice_item_list/(:num)', 'Medical::purchase_return_invoice_item_list/$1'); +$routes->get('Medical_backpanel/Purchase_Invoice_product/(:num)', 'Medical::purchase_invoice_product/$1'); +$routes->match(['get', 'post'], 'Medical_backpanel/Purchase_Invoice_old/(:num)', 'Medical::purchase_invoice_old/$1'); +$routes->post('Medical_backpanel/add_remove_item', 'Medical::purchase_return_add_remove_item'); +$routes->post('Medical_backpanel/remove_item_invoice/(:num)', 'Medical::purchase_return_remove_item_invoice/$1'); +$routes->get('Medical_backpanel/get_drug', 'Medical::get_drug'); +$routes->get('Medical_backpanel/get_batch/(:num)', 'Medical::get_batch/$1'); +$routes->get('Medical_Print/print_purchase_return/(:num)', 'Medical::print_purchase_return/$1'); $routes->get('Medical_backpanel/Report_Med_patient', 'Medical::report_med_patient'); $routes->get('Medical_backpanel/drug_patient_distribute/(:segment)/(:segment)/(:segment)/(:segment)', 'Medical::drug_patient_distribute/$1/$2/$3/$4'); $routes->get('Medical_backpanel/Print_bill_on_uhid', 'Medical::print_bill_on_uhid'); @@ -226,9 +248,16 @@ $routes->get('Finance', 'Finance::index'); $routes->get('Finance/index', 'Finance::index'); $routes->get('finance', 'Finance::index'); $routes->get('finance/index', 'Finance::index'); +$routes->get('Finance/phase2', 'Finance::phase2'); +$routes->get('Finance/section/vendor_master', 'Finance::sectionVendorMaster'); +$routes->get('Finance/section/purchase_order', 'Finance::sectionPurchaseOrder'); +$routes->get('Finance/section/grn_entry', 'Finance::sectionGrnEntry'); +$routes->get('Finance/section/vendor_invoice', 'Finance::sectionVendorInvoice'); $routes->get('Finance/vendors_table', 'Finance::vendorsTable'); $routes->get('Finance/po_table', 'Finance::poTable'); +$routes->get('Finance/po_documents/(:num)', 'Finance::poDocuments/$1'); $routes->get('Finance/grn_table', 'Finance::grnTable'); +$routes->get('Finance/grn_print/(:num)', 'Finance::grnPrint/$1'); $routes->get('Finance/invoice_table', 'Finance::invoiceTable'); $routes->get('Finance/cashbook', 'Finance::cashbook'); $routes->get('Finance/cash_transactions_table', 'Finance::cashTransactionsTable'); @@ -241,6 +270,7 @@ $routes->get('Finance/bank_deposits_table', 'Finance::bankDepositsTable'); $routes->get('Finance/compliance_report', 'Finance::complianceReport'); $routes->post('Finance/vendor_create', 'Finance::vendorCreate'); $routes->post('Finance/po_create', 'Finance::poCreate'); +$routes->post('Finance/po_update', 'Finance::poUpdate'); $routes->post('Finance/grn_create', 'Finance::grnCreate'); $routes->post('Finance/invoice_create', 'Finance::invoiceCreate'); $routes->post('Finance/cash_transaction_create', 'Finance::cashTransactionCreate'); @@ -249,6 +279,10 @@ $routes->post('Finance/doctor_agreement_create', 'Finance::doctorAgreementCreate $routes->post('Finance/doctor_payout_create', 'Finance::doctorPayoutCreate'); $routes->post('Finance/doctor_payout_approve', 'Finance::doctorPayoutApprove'); $routes->post('Finance/bank_deposit_create', 'Finance::bankDepositCreate'); +$routes->get('Finance/section/pharmacy_bills', 'Finance::sectionPharmacyBills'); +$routes->get('Finance/pharmacy_bills_table', 'Finance::pharmacyBillsTable'); +$routes->post('Finance/pharmacy_bill_create', 'Finance::pharmacyBillCreate'); +$routes->post('Finance/pharmacy_bill_settle', 'Finance::pharmacyBillSettle'); service('auth')->routes($routes); @@ -442,6 +476,30 @@ $routes->post('Opd_prescription/section_template_track_usage', 'Opd_prescription $routes->get('Opd_prescription/section_template_list', 'Opd_prescription::section_template_list'); $routes->get('Opd_prescription/section_past_data', 'Opd_prescription::section_past_data'); $routes->get('Opd_prescription/template_workspace', 'Opd_prescription::template_workspace', ['filter' => 'permission:doctor_work.template_workspace.access,doctor_work.access']); +$routes->get('doctor_work/document_workspace', 'DoctorDocument::workspace', ['filter' => 'permission:doctor_work.template_workspace.access,doctor_work.access']); + +// Legacy-compatible doctor document templates and issue flow. +$routes->get('Doc_Admin/doc_list', 'DoctorDocument::doc_list', ['filter' => 'permission:doctor_work.template_workspace.access,doctor_work.access']); +$routes->get('Doc_Admin/docedit_load', 'DoctorDocument::docedit_load', ['filter' => 'permission:doctor_work.template_workspace.access,doctor_work.access']); +$routes->get('Doc_Admin/docedit_load/(:num)', 'DoctorDocument::docedit_load/$1', ['filter' => 'permission:doctor_work.template_workspace.access,doctor_work.access']); +$routes->post('Doc_Admin/report_insert', 'DoctorDocument::report_insert', ['filter' => 'permission:doctor_work.template_workspace.access,doctor_work.access']); +$routes->post('Doc_Admin/report_update', 'DoctorDocument::report_update', ['filter' => 'permission:doctor_work.template_workspace.access,doctor_work.access']); +$routes->get('Doc_Admin/doc_input_list/(:num)', 'DoctorDocument::doc_input_list/$1', ['filter' => 'permission:doctor_work.template_workspace.access,doctor_work.access']); +$routes->get('Doc_Admin/input_parameter_load/(:num)/(:num)', 'DoctorDocument::input_parameter_load/$1/$2', ['filter' => 'permission:doctor_work.template_workspace.access,doctor_work.access']); +$routes->post('Doc_Admin/input_parameter_add', 'DoctorDocument::input_parameter_add', ['filter' => 'permission:doctor_work.template_workspace.access,doctor_work.access']); +$routes->post('Doc_Admin/input_parameter_edit', 'DoctorDocument::input_parameter_edit', ['filter' => 'permission:doctor_work.template_workspace.access,doctor_work.access']); + +$routes->get('Document_Patient/open_by_key', 'DoctorDocument::open_by_key', ['filter' => 'permission:doctor_work.template_workspace.access,doctor_work.access']); +$routes->get('Document_Patient/p_doc_record/(:num)', 'DoctorDocument::p_doc_record/$1', ['filter' => 'permission:doctor_work.template_workspace.access,doctor_work.access']); +$routes->post('Document_Patient/create_doc', 'DoctorDocument::create_doc', ['filter' => 'permission:doctor_work.template_workspace.access,doctor_work.access']); +$routes->get('Document_Patient/re_create_doc/(:num)', 'DoctorDocument::re_create_doc/$1', ['filter' => 'permission:doctor_work.template_workspace.access,doctor_work.access']); +$routes->get('Document_Patient/Pre_Data/(:num)', 'DoctorDocument::Pre_Data/$1', ['filter' => 'permission:doctor_work.template_workspace.access,doctor_work.access']); +$routes->post('Document_Patient/Entry_Update', 'DoctorDocument::Entry_Update', ['filter' => 'permission:doctor_work.template_workspace.access,doctor_work.access']); +$routes->post('Document_Patient/update_doc_field/(:num)', 'DoctorDocument::update_doc_field/$1', ['filter' => 'permission:doctor_work.template_workspace.access,doctor_work.access']); +$routes->get('Document_Patient/load_doc/(:num)', 'DoctorDocument::load_doc/$1', ['filter' => 'permission:doctor_work.template_workspace.access,doctor_work.access']); +$routes->post('Document_Patient/update_doc', 'DoctorDocument::update_doc', ['filter' => 'permission:doctor_work.template_workspace.access,doctor_work.access']); +$routes->get('Document_Patient/create_final/(:num)/(:num)', 'DoctorDocument::create_final/$1/$2', ['filter' => 'permission:doctor_work.template_workspace.access,doctor_work.access']); +$routes->get('Document_Patient/create_final/(:num)', 'DoctorDocument::create_final/$1', ['filter' => 'permission:doctor_work.template_workspace.access,doctor_work.access']); $routes->get('Opd_prescription/clinical_template_monitor', 'Opd_prescription::clinical_template_monitor'); $routes->get('Opd_prescription/clinical_template_usage_analytics', 'Opd_prescription::clinical_template_usage_analytics'); $routes->get('Opd_prescription/clinical_template_doctors', 'Opd_prescription::clinical_template_doctors'); @@ -553,6 +611,9 @@ $routes->post('Lab_Admin/test_item_search', 'Setting\Template::test_item_search' $routes->match(['get', 'post'], 'setting/template/discharge_templates', 'Setting\Template::discharge_templates'); $routes->get('setting/template/discharge_templates/delete/(:num)', 'Setting\Template::discharge_template_delete/$1'); +$routes->match(['get', 'post'], 'setting/template/diagnosis_print_settings', 'Setting\Template::diagnosis_print_settings'); +$routes->match(['get', 'post'], 'setting/template/diagnosis_print_settings/(:num)', 'Setting\Template::diagnosis_print_settings/$1'); +$routes->match(['get', 'post'], 'setting/template/document_print_settings', 'Setting\Template::document_print_settings'); $routes->get('Opdcase/addopd/(:num)', 'Opdcase::addopd/$1'); $routes->post('Opdcase/showfee', 'Opdcase::showfee'); @@ -574,6 +635,15 @@ $routes->get('Report/billing_operations_report', 'Report::billing_operations_rep $routes->get('Report/billing_operations_report_data/(:segment)/(:segment)', 'Report::billing_operations_report_data/$1/$2'); $routes->get('Report/billing_operations_report_data/(:segment)/(:segment)/(:num)', 'Report::billing_operations_report_data/$1/$2/$3'); +$routes->get('Report/document_list', 'Report::document_list'); +$routes->get('Report/document_list_data/(:segment)/(:num)', 'Report::document_list_data/$1/$2'); +$routes->get('Report/document_list_data/(:segment)/(:num)/(:num)', 'Report::document_list_data/$1/$2/$3'); + +// Legacy Report5 compatibility for Document Issue Report. +$routes->get('Report5/document_list', 'Report::document_list'); +$routes->get('Report5/document_list_data/(:segment)/(:num)', 'Report::document_list_data/$1/$2'); +$routes->get('Report5/document_list_data/(:segment)/(:num)/(:num)', 'Report::document_list_data/$1/$2/$3'); + $routes->get('Report/diagnosis_report', 'Report::diagnosis_report', ['filter' => 'permission:diagnosis.report.view,diagnosis.access']); $routes->get('Report/diagnosis_report_data/(:segment)', 'Report::diagnosis_report_data/$1'); $routes->get('Report/diagnosis_report_data/(:segment)/(:segment)', 'Report::diagnosis_report_data/$1/$2'); @@ -751,6 +821,10 @@ $routes->group('setting', static function($routes) { $routes->post('admin/ai-settings/save', 'Setting\\AiSettings::save'); $routes->post('admin/ai-settings/test', 'Setting\\AiSettings::test'); $routes->post('admin/ai-settings/usage', 'Setting\\AiSettings::usage'); + $routes->get('admin/hospital-profile', 'Setting\\HospitalProfile::index'); + $routes->post('admin/hospital-profile/save', 'Setting\\HospitalProfile::save'); + $routes->post('admin/hospital-profile/delete-logo', 'Setting\\HospitalProfile::deleteLogo'); + $routes->post('admin/hospital-profile/reset', 'Setting\\HospitalProfile::reset'); $routes->get('admin/doctor', 'Setting\\Doctor::index'); $routes->get('admin/doctor/new', 'Setting\\Doctor::create'); $routes->post('admin/doctor/new', 'Setting\\Doctor::store'); diff --git a/app/Controllers/Diagnosis.php b/app/Controllers/Diagnosis.php index 46027a0..3ad461b 100644 --- a/app/Controllers/Diagnosis.php +++ b/app/Controllers/Diagnosis.php @@ -1217,18 +1217,69 @@ class Diagnosis extends BaseController public function finalUpdate($labReqId) { $labReqId = (int) $labReqId; - $htmlData = (string) $this->request->getPost('HTMLData'); + // Accept both legacy and current POST keys for backward compatibility + $htmlData = (string) ($this->request->getPost('HTMLData') ?? $this->request->getPost('report_data') ?? ''); + $impression = (string) ($this->request->getPost('report_data_Impression') ?? $this->request->getPost('report_data_impression') ?? ''); + $editReason = trim((string) ($this->request->getPost('edit_reason') ?? '')); if ($labReqId <= 0) { return $this->response->setJSON(['status' => 'error', 'message' => 'Invalid request id']); } try { + $before = $this->db->table('lab_request') + ->select('id, status, report_edit_req_no, Report_Data, report_data_Impression') + ->where('id', $labReqId) + ->get(1) + ->getRowArray() ?? []; + + // NABH audit requirement: edit reason required for verified reports (status = 2) + if ((int) ($before['status'] ?? 0) === 2 && $editReason === '') { + return $this->response->setJSON([ + 'status' => 'error', + 'message' => 'Edit reason is required for verified report changes (NABH audit).', + ]); + } + $this->db->table('lab_request') ->where('id', $labReqId) - ->update(['Report_Data' => $htmlData]); + ->update([ + 'Report_Data' => $htmlData, + 'report_data_Impression' => $impression, + ]); - return $this->response->setJSON(['status' => 'success', 'message' => 'Report updated']); + // Track edit version for verified reports + $fields = $this->db->getFieldNames('lab_request'); + if (in_array('report_edit_req_no', $fields, true) && (int) ($before['status'] ?? 0) === 2) { + $nextEditNo = (int) ($before['report_edit_req_no'] ?? 0) + 1; + $this->db->table('lab_request') + ->where('id', $labReqId) + ->update(['report_edit_req_no' => $nextEditNo]); + } + + // NABH compliance: log all changes to verified reports + if ($this->db->tableExists('lab_log')) { + $user = service('auth')->user(); + $userId = (int) ($user->id ?? 0); + $userName = $user ? trim(($user->first_name ?? '') . ' ' . ($user->last_name ?? '')) : 'System'; + + $beforeHash = md5((string) ($before['Report_Data'] ?? '') . '|' . (string) ($before['report_data_Impression'] ?? '')); + $afterHash = md5($htmlData . '|' . $impression); + $reasonLog = $editReason !== '' ? $editReason : 'NA'; + + $this->db->table('lab_log')->insert([ + 'lab_repo_id' => $labReqId, + 'log_by_id' => $userId, + 'log_by' => $userName, + 'log_type_id' => 0, + 'log_type' => 'Report Edit', + 'log_Faults_id' => 0, + 'log_Faults' => 'Pathology', + 'comments' => 'Editor save [reason:' . substr($reasonLog, 0, 350) . '] [before:' . substr($beforeHash, 0, 8) . ' after:' . substr($afterHash, 0, 8) . ']', + ]); + } + + return $this->response->setJSON(['status' => 'success', 'message' => 'Saved']); } catch (\Throwable $e) { return $this->response->setJSON(['status' => 'error', 'message' => $e->getMessage()]); } @@ -1530,11 +1581,11 @@ class Diagnosis extends BaseController $defaults = array_merge($legacy, [ 'page_size' => 'A4', - 'page_margin_top_cm' => 1.2, + 'page_margin_top_cm' => 6.1, 'id' => 0, - 'page_margin_bottom_cm' => 1.2, - 'page_margin_left_cm' => 1.0, - 'page_margin_right_cm' => 1.0, + 'page_margin_bottom_cm' => 2.5, + 'page_margin_left_cm' => 0.7, + 'page_margin_right_cm' => 0.7, 'margin_header_cm' => 0.5, 'margin_footer_cm' => 1.5, 'page_background_image' => '', diff --git a/app/Controllers/DoctorDocument.php b/app/Controllers/DoctorDocument.php new file mode 100644 index 0000000..dfb2ba2 --- /dev/null +++ b/app/Controllers/DoctorDocument.php @@ -0,0 +1,1079 @@ +db = db_connect(); + helper(['form']); + } + + private function ensureAccess() + { + $user = auth()->user(); + if (! $user) { + return $this->response->setStatusCode(403)->setBody('Forbidden'); + } + + foreach ($this->doctorWorkspacePerms as $perm) { + if ($user->can($perm)) { + return null; + } + } + + return $this->response->setStatusCode(403)->setBody('Forbidden'); + } + + private function ensureDocumentTables(): bool + { + return $this->db->tableExists('doc_format_master') + && $this->db->tableExists('doc_format_sub') + && $this->db->tableExists('patient_doc') + && $this->db->tableExists('patient_doc_raw'); + } + + private function ensureDocumentPrintTemplateTable(): bool + { + if (! $this->db->tableExists('doc_print_templates')) { + return false; + } + + $columnSql = [ + 'print_on_type' => 'ALTER TABLE `doc_print_templates` ADD COLUMN `print_on_type` TINYINT(1) NOT NULL DEFAULT 1 AFTER `page_size`', + 'page_margin_top_cm' => 'ALTER TABLE `doc_print_templates` ADD COLUMN `page_margin_top_cm` DECIMAL(5,2) NOT NULL DEFAULT 6.10 AFTER `print_on_type`', + 'page_margin_bottom_cm' => 'ALTER TABLE `doc_print_templates` ADD COLUMN `page_margin_bottom_cm` DECIMAL(5,2) NOT NULL DEFAULT 2.50 AFTER `page_margin_top_cm`', + 'page_margin_left_cm' => 'ALTER TABLE `doc_print_templates` ADD COLUMN `page_margin_left_cm` DECIMAL(5,2) NOT NULL DEFAULT 0.70 AFTER `page_margin_bottom_cm`', + 'page_margin_right_cm' => 'ALTER TABLE `doc_print_templates` ADD COLUMN `page_margin_right_cm` DECIMAL(5,2) NOT NULL DEFAULT 0.70 AFTER `page_margin_left_cm`', + 'margin_header_cm' => 'ALTER TABLE `doc_print_templates` ADD COLUMN `margin_header_cm` DECIMAL(5,2) NOT NULL DEFAULT 0.50 AFTER `page_margin_right_cm`', + 'margin_footer_cm' => 'ALTER TABLE `doc_print_templates` ADD COLUMN `margin_footer_cm` DECIMAL(5,2) NOT NULL DEFAULT 1.50 AFTER `margin_header_cm`', + 'header_html' => 'ALTER TABLE `doc_print_templates` ADD COLUMN `header_html` LONGTEXT NULL AFTER `margin_footer_cm`', + 'footer_html' => 'ALTER TABLE `doc_print_templates` ADD COLUMN `footer_html` LONGTEXT NULL AFTER `header_html`', + ]; + + foreach ($columnSql as $column => $sql) { + if ($this->db->fieldExists($column, 'doc_print_templates')) { + continue; + } + try { + $this->db->query($sql); + } catch (\Throwable $e) { + log_message('error', 'Unable to add {column} column in doc_print_templates: {message}', [ + 'column' => $column, + 'message' => $e->getMessage(), + ]); + } + } + + return true; + } + + private function getDocumentPrintTemplates(): array + { + if (! $this->ensureDocumentPrintTemplateTable()) { + return []; + } + + return $this->db->table('doc_print_templates') + ->select('id, template_name, is_default, print_on_type') + ->where('status', 1) + ->orderBy('is_default', 'DESC') + ->orderBy('template_name', 'ASC') + ->get() + ->getResultArray(); + } + + private function ensurePrintTemplateColumns(): void + { + if (! $this->db->tableExists('doc_format_master')) { + return; + } + + $columnSql = [ + 'default_print_type' => 'ALTER TABLE `doc_format_master` ADD COLUMN `default_print_type` TINYINT(1) NOT NULL DEFAULT 0 AFTER `doc_raw_format`', + 'print_top_margin' => 'ALTER TABLE `doc_format_master` ADD COLUMN `print_top_margin` DECIMAL(5,2) NOT NULL DEFAULT 6.10 AFTER `default_print_type`', + 'print_bottom_margin' => 'ALTER TABLE `doc_format_master` ADD COLUMN `print_bottom_margin` DECIMAL(5,2) NOT NULL DEFAULT 2.50 AFTER `print_top_margin`', + 'print_left_margin' => 'ALTER TABLE `doc_format_master` ADD COLUMN `print_left_margin` DECIMAL(5,2) NOT NULL DEFAULT 0.70 AFTER `print_bottom_margin`', + 'print_right_margin' => 'ALTER TABLE `doc_format_master` ADD COLUMN `print_right_margin` DECIMAL(5,2) NOT NULL DEFAULT 0.70 AFTER `print_left_margin`', + 'print_header_margin' => 'ALTER TABLE `doc_format_master` ADD COLUMN `print_header_margin` DECIMAL(5,2) NOT NULL DEFAULT 0.50 AFTER `print_right_margin`', + 'print_footer_margin' => 'ALTER TABLE `doc_format_master` ADD COLUMN `print_footer_margin` DECIMAL(5,2) NOT NULL DEFAULT 1.50 AFTER `print_header_margin`', + ]; + + foreach ($columnSql as $column => $sql) { + if ($this->db->fieldExists($column, 'doc_format_master')) { + continue; + } + try { + $this->db->query($sql); + } catch (\Throwable $e) { + log_message('error', 'Unable to add {column} column: {message}', [ + 'column' => $column, + 'message' => $e->getMessage(), + ]); + } + } + } + + private function normalizeMarginValue($value, float $default): float + { + $number = (float) $value; + if ($number <= 0 || $number > 20) { + return $default; + } + + return round($number, 2); + } + + public function workspace() + { + if ($resp = $this->ensureAccess()) { + return $resp; + } + + return view('doctor_document/workspace'); + } + + public function open_by_key() + { + if ($resp = $this->ensureAccess()) { + return $resp; + } + + $rawKey = trim((string) $this->request->getGet('patient_key')); + if ($rawKey === '') { + return $this->response->setJSON([ + 'status' => 0, + 'message' => 'Enter patient id', + ]); + } + + $key = strtoupper(preg_replace('/\s+/', '', $rawKey)); + $digits = preg_replace('/\D+/', '', $key); + + $patient = null; + + // Priority 1: exact record by numeric patient_master.id + if (ctype_digit($key)) { + $patient = $this->db->table('patient_master') + ->select('id,p_code,old_uhid,p_fname') + ->where('id', (int) $key) + ->get(1) + ->getRowArray(); + } + + // Priority 2: exact record by UHID / old UHID + if (! is_array($patient)) { + $patient = $this->db->table('patient_master') + ->select('id,p_code,old_uhid,p_fname') + ->groupStart() + ->where('UPPER(TRIM(p_code))', $key) + ->orWhere('UPPER(TRIM(old_uhid))', $key) + ->groupEnd() + ->orderBy('id', 'DESC') + ->get(1) + ->getRowArray(); + } + + if (is_array($patient)) { + return $this->response->setJSON([ + 'status' => 1, + 'patient_id' => (int) ($patient['id'] ?? 0), + ]); + } + + // Priority 3: allow last digits search; open only when a single record is found. + if ($digits !== '') { + $builder = $this->db->table('patient_master') + ->select('id,p_code,old_uhid,p_fname') + ->groupStart() + ->like('p_code', $digits, 'before') + ->orLike('old_uhid', $digits, 'before') + ->groupEnd(); + + $matches = $builder + ->orderBy('id', 'DESC') + ->limit(6) + ->get() + ->getResultArray(); + + $count = count($matches); + if ($count === 1) { + return $this->response->setJSON([ + 'status' => 1, + 'patient_id' => (int) ($matches[0]['id'] ?? 0), + ]); + } + + if ($count > 1) { + return $this->response->setJSON([ + 'status' => 0, + 'message' => 'Multiple patients matched. Please enter complete UHID/Patient ID.', + ]); + } + } + + return $this->response->setJSON([ + 'status' => 0, + 'message' => 'Patient not found', + ]); + } + + public function doc_list() + { + if ($resp = $this->ensureAccess()) { + return $resp; + } + + if (! $this->ensureDocumentTables()) { + return $this->response->setStatusCode(500)->setBody('Document tables missing. Run migration: php spark migrate'); + } + + $this->ensurePrintTemplateColumns(); + + $rows = $this->db->table('doc_format_master') + ->where('active', 1) + ->orderBy('doc_name', 'ASC') + ->get() + ->getResultArray(); + + return view('doctor_document/doc_list', ['doc_master' => $rows]); + } + + public function docedit_load(int $docId = 0) + { + if ($resp = $this->ensureAccess()) { + return $resp; + } + + $this->ensurePrintTemplateColumns(); + + $master = []; + if ($docId > 0) { + $master = $this->db->table('doc_format_master')->where('df_id', $docId)->get(1)->getRowArray() ?? []; + } + + $items = []; + if ($docId > 0) { + $items = $this->db->table('doc_format_sub') + ->select('id as item_id,input_name,input_code,input_type,input_default_value,short_order') + ->where('doc_format_id', $docId) + ->where('active', 1) + ->orderBy('short_order', 'ASC') + ->get() + ->getResultArray(); + } + + return view('doctor_document/doc_master_edit', [ + 'doc_master' => $master, + 'doc_Item_List' => $items, + 'doc_id' => $docId, + ]); + } + + public function report_insert() + { + if ($resp = $this->ensureAccess()) { + return $resp; + } + + if (! $this->request->isAJAX()) { + return $this->response->setStatusCode(400)->setJSON(['insertid' => 0, 'showcontent' => 'Invalid request']); + } + + $name = trim((string) $this->request->getPost('input_docname')); + $desc = trim((string) $this->request->getPost('input_doc_desc')); + $html = (string) $this->request->getPost('HTMLData'); + $defaultPrintType = (int) $this->request->getPost('default_print_type'); + $printTopMargin = $this->normalizeMarginValue($this->request->getPost('print_top_margin'), 6.10); + $printBottomMargin = $this->normalizeMarginValue($this->request->getPost('print_bottom_margin'), 2.50); + $printLeftMargin = $this->normalizeMarginValue($this->request->getPost('print_left_margin'), 0.70); + $printRightMargin = $this->normalizeMarginValue($this->request->getPost('print_right_margin'), 0.70); + $printHeaderMargin = $this->normalizeMarginValue($this->request->getPost('print_header_margin'), 0.50); + $printFooterMargin = $this->normalizeMarginValue($this->request->getPost('print_footer_margin'), 1.50); + + if ($name === '') { + return $this->response->setJSON(['insertid' => 0, 'showcontent' => 'Document name is required']); + } + + $this->ensurePrintTemplateColumns(); + + $this->db->table('doc_format_master')->insert([ + 'doc_name' => $name, + 'doc_desc' => $desc, + 'doc_raw_format' => $html, + 'default_print_type' => ($defaultPrintType === 1 ? 1 : 0), + 'print_top_margin' => $printTopMargin, + 'print_bottom_margin' => $printBottomMargin, + 'print_left_margin' => $printLeftMargin, + 'print_right_margin' => $printRightMargin, + 'print_header_margin' => $printHeaderMargin, + 'print_footer_margin' => $printFooterMargin, + 'active' => 1, + 'created_at' => date('Y-m-d H:i:s'), + 'updated_at' => date('Y-m-d H:i:s'), + ]); + + return $this->response->setJSON([ + 'insertid' => (int) $this->db->insertID(), + 'showcontent' => 'Data saved successfully', + 'csrfName' => csrf_token(), + 'csrfHash' => csrf_hash(), + ]); + } + + public function report_update() + { + if ($resp = $this->ensureAccess()) { + return $resp; + } + + if (! $this->request->isAJAX()) { + return $this->response->setStatusCode(400)->setJSON(['update_record' => 0, 'showcontent' => 'Invalid request']); + } + + $id = (int) $this->request->getPost('df_id'); + $name = trim((string) $this->request->getPost('input_docname')); + $desc = trim((string) $this->request->getPost('input_doc_desc')); + $html = (string) $this->request->getPost('HTMLData'); + $defaultPrintType = (int) $this->request->getPost('default_print_type'); + $printTopMargin = $this->normalizeMarginValue($this->request->getPost('print_top_margin'), 6.10); + $printBottomMargin = $this->normalizeMarginValue($this->request->getPost('print_bottom_margin'), 2.50); + $printLeftMargin = $this->normalizeMarginValue($this->request->getPost('print_left_margin'), 0.70); + $printRightMargin = $this->normalizeMarginValue($this->request->getPost('print_right_margin'), 0.70); + $printHeaderMargin = $this->normalizeMarginValue($this->request->getPost('print_header_margin'), 0.50); + $printFooterMargin = $this->normalizeMarginValue($this->request->getPost('print_footer_margin'), 1.50); + + if ($id <= 0 || $name === '') { + return $this->response->setJSON(['update_record' => 0, 'showcontent' => 'Document id/name required']); + } + + $this->ensurePrintTemplateColumns(); + + $this->db->table('doc_format_master') + ->where('df_id', $id) + ->update([ + 'doc_name' => $name, + 'doc_desc' => $desc, + 'doc_raw_format' => $html, + 'default_print_type' => ($defaultPrintType === 1 ? 1 : 0), + 'print_top_margin' => $printTopMargin, + 'print_bottom_margin' => $printBottomMargin, + 'print_left_margin' => $printLeftMargin, + 'print_right_margin' => $printRightMargin, + 'print_header_margin' => $printHeaderMargin, + 'print_footer_margin' => $printFooterMargin, + 'updated_at' => date('Y-m-d H:i:s'), + ]); + + return $this->response->setJSON([ + 'update_record' => 1, + 'showcontent' => 'Data saved successfully', + 'csrfName' => csrf_token(), + 'csrfHash' => csrf_hash(), + ]); + } + + public function doc_input_list(int $docId) + { + if ($resp = $this->ensureAccess()) { + return $resp; + } + + $items = $this->db->table('doc_format_sub') + ->select('id as item_id,input_name,input_code,input_type,input_default_value,short_order') + ->where('doc_format_id', $docId) + ->where('active', 1) + ->orderBy('short_order', 'ASC') + ->get() + ->getResultArray(); + + return view('doctor_document/doc_input_list', [ + 'doc_Item_List' => $items, + 'doc_id' => $docId, + ]); + } + + public function input_parameter_load(int $itemId, int $docId) + { + if ($resp = $this->ensureAccess()) { + return $resp; + } + + $row = $this->db->table('doc_format_sub') + ->where('id', $itemId) + ->where('doc_format_id', $docId) + ->get(1) + ->getRowArray() ?? []; + + return $this->response->setJSON([ + 'update' => ! empty($row) ? 1 : 0, + 'row' => $row, + 'csrfName' => csrf_token(), + 'csrfHash' => csrf_hash(), + ]); + } + + public function input_parameter_add() + { + if ($resp = $this->ensureAccess()) { + return $resp; + } + + if (! $this->request->isAJAX()) { + return $this->response->setStatusCode(400)->setJSON(['insert_id' => 0, 'showcontent' => 'Invalid request']); + } + + $docId = (int) $this->request->getPost('doc_id'); + $inputName = trim((string) $this->request->getPost('input_input_name')); + $inputCode = trim((string) $this->request->getPost('input_input_code')); + $inputType = trim((string) $this->request->getPost('input_type')); + $defaultValue = (string) $this->request->getPost('input_default_value'); + + if ($docId <= 0 || $inputName === '' || $inputCode === '') { + return $this->response->setJSON(['insert_id' => 0, 'showcontent' => 'Required fields missing']); + } + + $exists = $this->db->table('doc_format_sub') + ->where('doc_format_id', $docId) + ->where('input_code', $inputCode) + ->where('active', 1) + ->countAllResults(); + + if ($exists > 0) { + return $this->response->setJSON(['insert_id' => 0, 'showcontent' => 'Input code already exists']); + } + + $maxOrderRow = $this->db->table('doc_format_sub')->selectMax('short_order')->where('doc_format_id', $docId)->get()->getRowArray(); + $nextOrder = (int) ($maxOrderRow['short_order'] ?? 0) + 1; + + $this->db->table('doc_format_sub')->insert([ + 'doc_format_id' => $docId, + 'input_name' => $inputName, + 'input_code' => $inputCode, + 'input_type' => $inputType !== '' ? $inputType : 'text', + 'input_default_value' => $defaultValue, + 'short_order' => max(1, $nextOrder), + 'active' => 1, + 'created_at' => date('Y-m-d H:i:s'), + 'updated_at' => date('Y-m-d H:i:s'), + ]); + + return $this->response->setJSON([ + 'insert_id' => (int) $this->db->insertID(), + 'showcontent' => 'Data saved successfully', + 'csrfName' => csrf_token(), + 'csrfHash' => csrf_hash(), + ]); + } + + public function input_parameter_edit() + { + if ($resp = $this->ensureAccess()) { + return $resp; + } + + if (! $this->request->isAJAX()) { + return $this->response->setStatusCode(400)->setJSON(['update_value' => 0, 'showcontent' => 'Invalid request']); + } + + $docId = (int) $this->request->getPost('doc_id'); + $subId = (int) $this->request->getPost('doc_sub_id'); + $inputName = trim((string) $this->request->getPost('input_input_name')); + $inputCode = trim((string) $this->request->getPost('input_input_code')); + $inputType = trim((string) $this->request->getPost('input_type')); + $defaultValue = (string) $this->request->getPost('input_default_value'); + + if ($docId <= 0 || $subId <= 0 || $inputName === '' || $inputCode === '') { + return $this->response->setJSON(['update_value' => 0, 'showcontent' => 'Required fields missing']); + } + + $exists = $this->db->table('doc_format_sub') + ->where('doc_format_id', $docId) + ->where('input_code', $inputCode) + ->where('id !=', $subId) + ->where('active', 1) + ->countAllResults(); + + if ($exists > 0) { + return $this->response->setJSON(['update_value' => 0, 'showcontent' => 'Input code already exists']); + } + + $this->db->table('doc_format_sub') + ->where('id', $subId) + ->where('doc_format_id', $docId) + ->update([ + 'input_name' => $inputName, + 'input_code' => $inputCode, + 'input_type' => $inputType !== '' ? $inputType : 'text', + 'input_default_value' => $defaultValue, + 'updated_at' => date('Y-m-d H:i:s'), + ]); + + return $this->response->setJSON([ + 'update_value' => 1, + 'showcontent' => 'Data saved successfully', + 'csrfName' => csrf_token(), + 'csrfHash' => csrf_hash(), + ]); + } + + public function p_doc_record(int $patientId) + { + if ($resp = $this->ensureAccess()) { + return $resp; + } + + $patient = $this->db->table('patient_master')->where('id', $patientId)->get(1)->getRowArray(); + if (! is_array($patient)) { + return $this->response->setStatusCode(404)->setBody('Patient not found'); + } + + $docFormats = $this->db->table('doc_format_master') + ->where('active', 1) + ->orderBy('doc_name', 'ASC') + ->get() + ->getResultArray(); + + $doctorList = $this->db->table('doctor_master') + ->select('id,p_fname') + ->where('active', 1) + ->orderBy('p_fname', 'ASC') + ->get() + ->getResultArray(); + + $patientDocs = $this->db->table('patient_doc pd') + ->select('pd.id,pd.date_issue,dm.doc_name') + ->join('doc_format_master dm', 'pd.doc_format_id=dm.df_id', 'left') + ->where('pd.p_id', $patientId) + ->orderBy('pd.date_issue', 'DESC') + ->orderBy('pd.id', 'DESC') + ->get() + ->getResultArray(); + + return view('doctor_document/patient_doc_master', [ + 'person_info' => $patient, + 'doc_format' => $docFormats, + 'doclist' => $doctorList, + 'patient_doc' => $patientDocs, + 'pno' => $patientId, + 'age_text' => $this->buildAgeText($patient), + ]); + } + + public function create_doc() + { + if ($resp = $this->ensureAccess()) { + return $resp; + } + + $patientId = (int) $this->request->getPost('patient_id'); + $docFormatId = (int) $this->request->getPost('document_format_id'); + $doctorId = (int) $this->request->getPost('doc_id'); + $issueDate = trim((string) $this->request->getPost('doc_issue_date')); + + $template = $this->db->table('doc_format_master')->where('df_id', $docFormatId)->get(1)->getRowArray(); + $patient = $this->db->table('patient_master')->where('id', $patientId)->get(1)->getRowArray(); + $doctor = $this->db->table('doctor_master')->where('id', $doctorId)->get(1)->getRowArray(); + + if (! is_array($template) || ! is_array($patient)) { + return $this->response->setBody('0'); + } + + $reportString = (string) ($template['doc_raw_format'] ?? ''); + $reportString = $this->applyDocumentTokens($reportString, $patient, $doctor, $issueDate); + + $issueMysql = $this->normalizeIssueDate($issueDate); + + $this->db->table('patient_doc')->insert([ + 'raw_data' => $reportString, + 'doc_format_id' => $docFormatId, + 'p_id' => $patientId, + 'dr_id' => $doctorId, + 'date_issue' => $issueMysql, + 'update_pre_value' => 0, + 'created_at' => date('Y-m-d H:i:s'), + 'updated_at' => date('Y-m-d H:i:s'), + ]); + $insertId = (int) $this->db->insertID(); + + $inputs = $this->db->table('doc_format_sub') + ->where('doc_format_id', $docFormatId) + ->where('active', 1) + ->orderBy('short_order', 'ASC') + ->get() + ->getResultArray(); + + foreach ($inputs as $row) { + $this->db->table('patient_doc_raw')->insert([ + 'p_id' => $patientId, + 'p_doc_id' => $insertId, + 'p_doc_sub_id' => (int) ($row['id'] ?? 0), + 'p_doc_raw_value' => (string) ($row['input_default_value'] ?? ''), + 'update_data' => 0, + 'created_at' => date('Y-m-d H:i:s'), + 'updated_at' => date('Y-m-d H:i:s'), + ]); + } + + return $this->response->setBody((string) $insertId); + } + + public function re_create_doc(int $docId) + { + if ($resp = $this->ensureAccess()) { + return $resp; + } + + $patientDoc = $this->db->table('patient_doc')->where('id', $docId)->get(1)->getRowArray(); + if (! is_array($patientDoc)) { + return $this->response->setStatusCode(404)->setBody('Document not found'); + } + + $template = $this->db->table('doc_format_master')->where('df_id', (int) ($patientDoc['doc_format_id'] ?? 0))->get(1)->getRowArray(); + $patient = $this->db->table('patient_master')->where('id', (int) ($patientDoc['p_id'] ?? 0))->get(1)->getRowArray(); + $doctor = $this->db->table('doctor_master')->where('id', (int) ($patientDoc['dr_id'] ?? 0))->get(1)->getRowArray(); + + if (! is_array($template) || ! is_array($patient)) { + if ($this->request->isAJAX()) { + return $this->load_doc($docId); + } + return redirect()->to(base_url('Document_Patient/load_doc/' . $docId)); + } + + $issueDate = ''; + if (! empty($patientDoc['date_issue'])) { + $issueDate = date('d/m/Y', strtotime((string) $patientDoc['date_issue'])); + } + + $reportString = $this->applyDocumentTokens((string) ($template['doc_raw_format'] ?? ''), $patient, $doctor, $issueDate); + + $this->db->table('patient_doc')->where('id', $docId)->update([ + 'raw_data' => $reportString, + 'update_pre_value' => 0, + 'updated_at' => date('Y-m-d H:i:s'), + ]); + + if ($this->request->isAJAX()) { + return $this->Pre_Data($docId); + } + + return redirect()->to(base_url('Document_Patient/Pre_Data/' . $docId)); + } + + public function Pre_Data(int $patientDocId) + { + if ($resp = $this->ensureAccess()) { + return $resp; + } + + $patientDoc = $this->db->table('patient_doc')->where('id', $patientDocId)->get(1)->getRowArray(); + if (! is_array($patientDoc)) { + return $this->response->setStatusCode(404)->setBody('Document not found'); + } + + $patient = $this->db->table('patient_master')->where('id', (int) ($patientDoc['p_id'] ?? 0))->get(1)->getRowArray(); + + $inputs = $this->db->table('patient_doc_raw r') + ->select('r.id,r.p_doc_raw_value,r.update_data,s.input_name,s.input_type') + ->join('doc_format_sub s', 'r.p_doc_sub_id=s.id', 'left') + ->where('r.p_doc_id', $patientDocId) + ->orderBy('s.short_order', 'ASC') + ->get() + ->getResultArray(); + + return view('doctor_document/doc_pre_data', [ + 'patient_doc' => $patientDoc, + 'person_info' => $patient, + 'doc_format_sub' => $inputs, + 'patient_doc_id' => $patientDocId, + ]); + } + + public function Entry_Update() + { + if ($resp = $this->ensureAccess()) { + return $resp; + } + + $testId = (int) $this->request->getPost('test_id'); + $testValue = (string) $this->request->getPost('test_value'); + + $this->db->table('patient_doc_raw')->where('id', $testId)->update([ + 'p_doc_raw_value' => $testValue, + 'update_data' => 1, + 'updated_at' => date('Y-m-d H:i:s'), + ]); + + return $this->response->setBody($testValue); + } + + public function update_doc_field(int $patientDocId) + { + if ($resp = $this->ensureAccess()) { + return $resp; + } + + $pending = $this->db->table('patient_doc_raw') + ->where('p_doc_id', $patientDocId) + ->where('update_data', 0) + ->countAllResults(); + + if ($pending > 0) { + return $this->response->setJSON([ + 'update' => 0, + 'error_text' => 'Some field pending', + 'csrfName' => csrf_token(), + 'csrfHash' => csrf_hash(), + ]); + } + + $patientDoc = $this->db->table('patient_doc')->where('id', $patientDocId)->get(1)->getRowArray(); + $report = (string) ($patientDoc['raw_data'] ?? ''); + + $values = $this->db->table('patient_doc_raw r') + ->select('r.p_doc_raw_value,s.input_code') + ->join('doc_format_sub s', 'r.p_doc_sub_id=s.id', 'left') + ->where('r.p_doc_id', $patientDocId) + ->get() + ->getResultArray(); + + foreach ($values as $row) { + $code = trim((string) ($row['input_code'] ?? '')); + if ($code === '') { + continue; + } + $val = nl2br((string) ($row['p_doc_raw_value'] ?? '')); + $report = str_replace('{' . $code . '}', $val, $report); + } + + $this->db->table('patient_doc')->where('id', $patientDocId)->update([ + 'raw_data' => $report, + 'update_pre_value' => 1, + 'updated_at' => date('Y-m-d H:i:s'), + ]); + + return $this->response->setJSON([ + 'update' => 1, + 'error_text' => 'Compile done', + 'csrfName' => csrf_token(), + 'csrfHash' => csrf_hash(), + ]); + } + + public function load_doc(int $patientDocId) + { + if ($resp = $this->ensureAccess()) { + return $resp; + } + + $patientDoc = $this->db->table('patient_doc')->where('id', $patientDocId)->get(1)->getRowArray(); + if (! is_array($patientDoc)) { + return $this->response->setStatusCode(404)->setBody('Document not found'); + } + + $patient = $this->db->table('patient_master')->where('id', (int) ($patientDoc['p_id'] ?? 0))->get(1)->getRowArray(); + $printTemplates = $this->getDocumentPrintTemplates(); + + $defaultTemplateId = 0; + foreach ($printTemplates as $templateRow) { + if ((int) ($templateRow['is_default'] ?? 0) === 1) { + $defaultTemplateId = (int) ($templateRow['id'] ?? 0); + break; + } + } + if ($defaultTemplateId <= 0 && ! empty($printTemplates)) { + $defaultTemplateId = (int) ($printTemplates[0]['id'] ?? 0); + } + + return view('doctor_document/patient_doc_edit', [ + 'patient_doc' => $patientDoc, + 'person_info' => $patient, + 'print_templates' => $printTemplates, + 'default_print_template_id' => $defaultTemplateId, + ]); + } + + public function update_doc() + { + if ($resp = $this->ensureAccess()) { + return $resp; + } + + $documentId = (int) $this->request->getPost('document_id'); + $htmlData = (string) $this->request->getPost('HTMLData'); + + $updated = $this->db->table('patient_doc')->where('id', $documentId)->update([ + 'raw_data' => $htmlData, + 'updated_at' => date('Y-m-d H:i:s'), + ]); + + return $this->response->setJSON([ + 'update_value' => $updated ? 1 : 0, + 'showcontent' => $updated ? 'Data saved successfully' : 'Unable to save', + 'csrfName' => csrf_token(), + 'csrfHash' => csrf_hash(), + ]); + } + + public function create_final(int $patientDocId, ?int $printOnType = null) + { + if ($resp = $this->ensureAccess()) { + return $resp; + } + + // Release session lock IMMEDIATELY so other requests from the same browser + // are not blocked while mPDF generates the PDF (which can take 5-30 seconds). + if (session_status() === PHP_SESSION_ACTIVE) { + session_write_close(); + } + + // mPDF is memory-heavy; ensure enough headroom and execution time. + $currentMemory = ini_get('memory_limit'); + if ((int) $currentMemory > 0 && (int) $currentMemory < 256) { + ini_set('memory_limit', '256M'); + } + set_time_limit(120); + + $this->ensurePrintTemplateColumns(); + $this->ensureDocumentPrintTemplateTable(); + + $requestedTemplateId = (int) ($this->request->getGet('ptid') ?? 0); + + $patientDoc = $this->db->table('patient_doc pd') + ->select('pd.*,dm.doc_name,dm.doc_desc,dm.default_print_type,dm.print_top_margin,dm.print_bottom_margin,dm.print_left_margin,dm.print_right_margin,dm.print_header_margin,dm.print_footer_margin,p.p_fname,p.p_relative,p.p_rname,p.p_code,p.gender,p.age,p.age_in_month,p.estimate_dob,p.dob,dr.p_fname as dr_name') + ->join('doc_format_master dm', 'pd.doc_format_id=dm.df_id', 'left') + ->join('patient_master p', 'pd.p_id=p.id', 'left') + ->join('doctor_master dr', 'pd.dr_id=dr.id', 'left') + ->where('pd.id', $patientDocId) + ->get(1) + ->getRowArray(); + + if (! is_array($patientDoc)) { + return $this->response->setStatusCode(404)->setBody('Document not found'); + } + + $selectedPrintTemplate = null; + if ($requestedTemplateId > 0 && $this->db->tableExists('doc_print_templates')) { + $selectedPrintTemplate = $this->db->table('doc_print_templates') + ->where('id', $requestedTemplateId) + ->where('status', 1) + ->get(1) + ->getRowArray(); + } + + if (! is_array($selectedPrintTemplate) && $this->db->tableExists('doc_print_templates')) { + $selectedPrintTemplate = $this->db->table('doc_print_templates') + ->where('status', 1) + ->where('is_default', 1) + ->orderBy('id', 'DESC') + ->get(1) + ->getRowArray(); + } + + $resolvedPrintType = $printOnType; + if ($resolvedPrintType === null) { + if (is_array($selectedPrintTemplate)) { + $resolvedPrintType = (int) ($selectedPrintTemplate['print_on_type'] ?? 1); + } else { + $resolvedPrintType = (int) ($patientDoc['default_print_type'] ?? 0); + } + } + $resolvedPrintType = ((int) $resolvedPrintType === 1) ? 1 : 0; + + if (is_array($selectedPrintTemplate)) { + $printTopMargin = $this->normalizeMarginValue($selectedPrintTemplate['page_margin_top_cm'] ?? null, 6.10); + $printBottomMargin = $this->normalizeMarginValue($selectedPrintTemplate['page_margin_bottom_cm'] ?? null, 2.50); + $printLeftMargin = $this->normalizeMarginValue($selectedPrintTemplate['page_margin_left_cm'] ?? null, 0.70); + $printRightMargin = $this->normalizeMarginValue($selectedPrintTemplate['page_margin_right_cm'] ?? null, 0.70); + $printHeaderMargin = $this->normalizeMarginValue($selectedPrintTemplate['margin_header_cm'] ?? null, 0.50); + $printFooterMargin = $this->normalizeMarginValue($selectedPrintTemplate['margin_footer_cm'] ?? null, 1.50); + $pageSize = trim((string) ($selectedPrintTemplate['page_size'] ?? 'A4')); + if ($pageSize === '') { + $pageSize = 'A4'; + } + } else { + $printTopMargin = $this->normalizeMarginValue($patientDoc['print_top_margin'] ?? null, 6.10); + $printBottomMargin = $this->normalizeMarginValue($patientDoc['print_bottom_margin'] ?? null, 2.50); + $printLeftMargin = $this->normalizeMarginValue($patientDoc['print_left_margin'] ?? null, 0.70); + $printRightMargin = $this->normalizeMarginValue($patientDoc['print_right_margin'] ?? null, 0.70); + $printHeaderMargin = $this->normalizeMarginValue($patientDoc['print_header_margin'] ?? null, 0.50); + $printFooterMargin = $this->normalizeMarginValue($patientDoc['print_footer_margin'] ?? null, 1.50); + $pageSize = 'A4'; + } + + $issueDate = ! empty($patientDoc['date_issue']) ? date('d-m-Y', strtotime((string) $patientDoc['date_issue'])) : date('d-m-Y'); + $printNo = 1; + if ($this->db->tableExists('file_upload_data')) { + $printNo = (int) $this->db->table('file_upload_data')->where('doc_id', $patientDocId)->countAllResults() + 1; + } + + $headerRef = 'Document Ref. No.' . date('Y') . '/' . $printNo . '/' . $patientDocId; + $content = '
' + . $headerRef . 'Date : ' . $issueDate . '
'; + $content .= (string) ($patientDoc['raw_data'] ?? ''); + + $data = [ + 'content' => $content, + 'print_on_type' => $resolvedPrintType, + 'bar_content' => $headerRef . '/' . $issueDate, + 'doctor_name' => (string) ($patientDoc['dr_name'] ?? ''), + 'report_title' => (string) ($patientDoc['doc_name'] ?? 'Patient Document'), + 'print_top_margin' => $printTopMargin, + 'print_bottom_margin' => $printBottomMargin, + 'print_left_margin' => $printLeftMargin, + 'print_right_margin' => $printRightMargin, + 'print_header_margin' => $printHeaderMargin, + 'print_footer_margin' => $printFooterMargin, + 'custom_header_html' => (string) ($selectedPrintTemplate['header_html'] ?? ''), + 'custom_footer_html' => (string) ($selectedPrintTemplate['footer_html'] ?? ''), + ]; + + $mpdfTempDir = WRITEPATH . 'cache' . DIRECTORY_SEPARATOR . 'mpdf'; + if (! is_dir($mpdfTempDir)) { + mkdir($mpdfTempDir, 0755, true); + } + + try { + $mpdf = new Mpdf([ + 'format' => $pageSize, + 'margin_top' => $printTopMargin * 10, + 'margin_bottom' => $printBottomMargin * 10, + 'margin_left' => $printLeftMargin * 10, + 'margin_right' => $printRightMargin * 10, + 'margin_header' => $printHeaderMargin * 10, + 'margin_footer' => $printFooterMargin * 10, + 'tempDir' => $mpdfTempDir, + 'autoScriptToLang' => false, + 'autoLanguageDetection' => false, + 'autoArabic' => false, + 'autoVietnamese' => false, + ]); + } catch (\Throwable $e) { + log_message('error', '[DoctorDocument::create_final] mPDF init failed: {msg}', ['msg' => $e->getMessage()]); + return $this->response + ->setStatusCode(500) + ->setHeader('Content-Type', 'text/plain') + ->setBody('PDF init failed: ' . $e->getMessage()); + } + + if ($resolvedPrintType === 1) { + $hospitalName = defined('H_Name') ? (string) constant('H_Name') : 'Hospital'; + $mpdf->SetWatermarkText($hospitalName, 0.1); + $mpdf->showWatermarkText = true; + } + + $html = view('doctor_document/doc_letterhead_print', $data); + + try { + $mpdf->WriteHTML($html, HTMLParserMode::DEFAULT_MODE); + } catch (\Throwable $e) { + log_message('error', '[DoctorDocument::create_final] mPDF WriteHTML failed: {msg}', ['msg' => $e->getMessage()]); + return $this->response + ->setStatusCode(500) + ->setHeader('Content-Type', 'text/plain') + ->setBody('PDF generation failed: ' . $e->getMessage()); + } + + $fileName = 'Document-' . $patientDocId . '-' . date('YmdHis') . '.pdf'; + + try { + $pdfBytes = $mpdf->Output($fileName, 'S'); + } catch (\Throwable $e) { + log_message('error', '[DoctorDocument::create_final] mPDF Output failed: {msg}', ['msg' => $e->getMessage()]); + return $this->response + ->setStatusCode(500) + ->setHeader('Content-Type', 'text/plain') + ->setBody('PDF output failed: ' . $e->getMessage()); + } + + return $this->response + ->setHeader('Content-Type', 'application/pdf') + ->setHeader('Content-Disposition', 'inline; filename="' . $fileName . '"') + ->setHeader('Cache-Control', 'no-store, no-cache, must-revalidate, max-age=0') + ->setHeader('Pragma', 'no-cache') + ->setHeader('Expires', '0') + ->setBody($pdfBytes); + } + + private function normalizeIssueDate(string $date): ?string + { + $date = trim($date); + if ($date === '') { + return date('Y-m-d'); + } + + $formats = ['d/m/Y', 'd-m-Y', 'Y-m-d']; + foreach ($formats as $fmt) { + $obj = \DateTime::createFromFormat($fmt, $date); + if ($obj instanceof \DateTime) { + return $obj->format('Y-m-d'); + } + } + + $ts = strtotime($date); + if ($ts === false) { + return date('Y-m-d'); + } + + return date('Y-m-d', $ts); + } + + private function buildAgeText(array $patient): string + { + if (function_exists('get_age_1')) { + return (string) get_age_1( + $patient['dob'] ?? null, + $patient['age'] ?? '', + $patient['age_in_month'] ?? '', + $patient['estimate_dob'] ?? '', + date('Y-m-d H:i:s') + ); + } + + return (string) ($patient['age'] ?? '-'); + } + + private function applyDocumentTokens(string $template, array $patient, ?array $doctor, string $issueDate): string + { + $gender = (int) ($patient['gender'] ?? 0); + $genderText = $gender === 1 ? 'Male' : ($gender === 2 ? 'Female' : 'Other'); + $heShe = $gender === 2 ? 'she' : 'he'; + $hisHer = $gender === 2 ? 'her' : 'his'; + + $address = trim(implode(', ', array_filter([ + (string) ($patient['add1'] ?? ''), + (string) ($patient['add2'] ?? ''), + (string) ($patient['city'] ?? ''), + (string) ($patient['state'] ?? ''), + ]))); + + $replace = [ + '{p_code}' => (string) ($patient['p_code'] ?? ''), + '{p_fname}' => (string) ($patient['p_fname'] ?? ''), + '{p_rname}' => (string) ($patient['p_rname'] ?? ''), + '{str_age}' => $this->buildAgeText($patient), + '{p_relative}' => (string) ($patient['p_relative'] ?? ''), + '{gender}' => $genderText, + '{p_title}' => (string) ($patient['title'] ?? ''), + '{p_address}' => $address, + '{p_he_she}' => $heShe, + '{p_his_her}' => $hisHer, + '{dr_name}' => (string) ($doctor['p_fname'] ?? ''), + '{dr_sign}' => nl2br((string) ($doctor['doc_sign'] ?? '')), + '{current_date}' => date('d-m-Y'), + '{issue_date}' => $issueDate !== '' ? str_replace('/', '-', $issueDate) : date('d-m-Y'), + ]; + + return strtr($template, $replace); + } +} diff --git a/app/Controllers/Finance.php b/app/Controllers/Finance.php new file mode 100644 index 0000000..9fc8ff1 --- /dev/null +++ b/app/Controllers/Finance.php @@ -0,0 +1,2083 @@ +vendorModel = new FinanceVendorModel(); + $this->poModel = new FinancePurchaseOrderModel(); + $this->poDocumentModel = new FinancePoDocumentModel(); + $this->grnModel = new FinanceGrnModel(); + $this->invoiceModel = new FinanceVendorInvoiceModel(); + $this->cashTxnModel = new FinanceCashTransactionModel(); + $this->bankDepositModel = new FinanceBankDepositModel(); + $this->policySettingModel = new FinancePolicySettingModel(); + $this->scrollModel = new FinanceScrollSubmissionModel(); + $this->doctorAgreementModel = new FinanceDoctorAgreementModel(); + $this->doctorPayoutModel = new FinanceDoctorPayoutModel(); + $this->pharmBillModel = new FinancePharmacyBillModel(); + } + + public function bankDeposits() + { + if (! $this->canFinance('finance.bank_deposit.manage')) { + return $this->response->setStatusCode(403)->setBody('Access denied'); + } + + return view('finance/bank_deposits', [ + 'deposits' => $this->fetchBankDeposits(), + 'scroll_options' => $this->scrollModel->orderBy('id', 'DESC')->findAll(100), + 'summary' => $this->buildDepositSummary(), + ]); + } + + public function bankDepositsTable() + { + if (! $this->canFinance('finance.bank_deposit.manage')) { + return $this->response->setStatusCode(403)->setBody('Access denied'); + } + + return view('finance/partials/bank_deposits_table', [ + 'deposits' => $this->fetchBankDeposits(), + ]); + } + + public function bankDepositCreate() + { + if (! $this->canFinance('finance.bank_deposit.manage')) { + return $this->response->setStatusCode(403)->setJSON(['status' => 0, 'message' => 'Access denied']); + } + + $depositDate = trim((string) ($this->request->getPost('deposit_date') ?? '')); + $department = trim((string) ($this->request->getPost('department') ?? '')); + $bankName = trim((string) ($this->request->getPost('bank_name') ?? '')); + $amount = (float) ($this->request->getPost('deposited_amount') ?? 0); + $relatedScrollId = (int) ($this->request->getPost('related_scroll_id') ?? 0) ?: null; + + if ($depositDate === '' || $department === '' || $bankName === '' || $amount <= 0) { + return $this->response->setStatusCode(422)->setJSON([ + 'status' => 0, + 'message' => 'Date, department, bank name and amount are required.', + ]); + } + + $status = 'pending'; + if ($relatedScrollId !== null) { + $scroll = $this->scrollModel->find($relatedScrollId); + if ($scroll) { + $variance = abs((float) ($scroll['submitted_amount'] ?? 0) - $amount); + $status = $variance <= 0.01 ? 'matched' : 'pending'; + } + } + + $this->bankDepositModel->insert([ + 'deposit_date' => $depositDate, + 'department' => $department, + 'bank_name' => $bankName, + 'slip_no' => trim((string) ($this->request->getPost('slip_no') ?? '')), + 'deposited_amount' => $amount, + 'related_scroll_id' => $relatedScrollId, + 'reconciliation_status' => $status, + 'remarks' => trim((string) ($this->request->getPost('remarks') ?? '')), + 'created_by' => $this->currentUserName(), + ]); + + return $this->response->setJSON([ + 'status' => 1, + 'message' => 'Bank deposit saved. Reconciliation status: ' . $status . '.', + ]); + } + + public function complianceReport() + { + if (! $this->canFinance('finance.compliance.view')) { + return $this->response->setStatusCode(403)->setBody('Access denied'); + } + + $from = $this->normalizeDateInput((string) ($this->request->getGet('from') ?? '')); + $to = $this->normalizeDateInput((string) ($this->request->getGet('to') ?? '')); + $export = (string) ($this->request->getGet('export') ?? '') === '1'; + + $invoiceQuery = $this->invoiceModel + ->select('finance_vendor_invoices.*, finance_vendors.vendor_name') + ->join('finance_vendors', 'finance_vendors.id = finance_vendor_invoices.vendor_id', 'left') + ->where('finance_vendor_invoices.is_compliance_hold', 1); + if ($from !== '') { + $invoiceQuery->where('finance_vendor_invoices.invoice_date >=', $from); + } + if ($to !== '') { + $invoiceQuery->where('finance_vendor_invoices.invoice_date <=', $to); + } + $invoiceExceptions = $invoiceQuery + ->orderBy('finance_vendor_invoices.id', 'DESC') + ->findAll($export ? 5000 : 20); + + $cashQuery = $this->cashTxnModel->where('is_compliance_hold', 1); + if ($from !== '') { + $cashQuery->where('txn_date >=', $from); + } + if ($to !== '') { + $cashQuery->where('txn_date <=', $to); + } + $cashAlerts = $cashQuery + ->orderBy('id', 'DESC') + ->findAll($export ? 5000 : 20); + + $pendingPayoutQuery = $this->doctorPayoutModel->where('status !=', 'paid'); + if ($from !== '') { + $pendingPayoutQuery->where('payout_date >=', $from); + } + if ($to !== '') { + $pendingPayoutQuery->where('payout_date <=', $to); + } + $pendingPayouts = $pendingPayoutQuery->countAllResults(); + + $invoiceHoldCountQuery = $this->invoiceModel->where('is_compliance_hold', 1); + if ($from !== '') { + $invoiceHoldCountQuery->where('invoice_date >=', $from); + } + if ($to !== '') { + $invoiceHoldCountQuery->where('invoice_date <=', $to); + } + + $cashHoldCountQuery = $this->cashTxnModel->where('is_compliance_hold', 1); + if ($from !== '') { + $cashHoldCountQuery->where('txn_date >=', $from); + } + if ($to !== '') { + $cashHoldCountQuery->where('txn_date <=', $to); + } + + $pendingDepositQuery = $this->bankDepositModel->where('reconciliation_status', 'pending'); + if ($from !== '') { + $pendingDepositQuery->where('deposit_date >=', $from); + } + if ($to !== '') { + $pendingDepositQuery->where('deposit_date <=', $to); + } + + $summary = [ + 'invoice_holds' => $invoiceHoldCountQuery->countAllResults(), + 'cash_holds' => $cashHoldCountQuery->countAllResults(), + 'pending_deposits' => $pendingDepositQuery->countAllResults(), + 'pending_payouts' => $pendingPayouts, + ]; + + if ($export) { + $lines = []; + $lines[] = $this->csvLine(['Finance Compliance Report']); + $lines[] = $this->csvLine(['From', $from !== '' ? $from : 'NA', 'To', $to !== '' ? $to : 'NA']); + $lines[] = ''; + $lines[] = $this->csvLine(['Summary']); + $lines[] = $this->csvLine(['Invoice Holds', (string) $summary['invoice_holds']]); + $lines[] = $this->csvLine(['Cash Holds', (string) $summary['cash_holds']]); + $lines[] = $this->csvLine(['Pending Deposits', (string) $summary['pending_deposits']]); + $lines[] = $this->csvLine(['Draft/Unpaid Payouts', (string) $summary['pending_payouts']]); + $lines[] = ''; + $lines[] = $this->csvLine(['Cash Compliance Alerts']); + $lines[] = $this->csvLine(['Date', 'Type', 'Department', 'Amount', 'Note']); + foreach ($cashAlerts as $row) { + $lines[] = $this->csvLine([ + (string) ($row['txn_date'] ?? ''), + (string) ($row['txn_type'] ?? ''), + (string) ($row['department'] ?? ''), + number_format((float) ($row['amount'] ?? 0), 2, '.', ''), + (string) ($row['compliance_note'] ?? ''), + ]); + } + $lines[] = ''; + $lines[] = $this->csvLine(['Invoice Match Exceptions']); + $lines[] = $this->csvLine(['Date', 'Invoice', 'Vendor', 'Status', 'Variance', 'Note']); + foreach ($invoiceExceptions as $row) { + $lines[] = $this->csvLine([ + (string) ($row['invoice_date'] ?? ''), + (string) ($row['invoice_no'] ?? ''), + (string) ($row['vendor_name'] ?? ''), + (string) ($row['match_status'] ?? ''), + number_format((float) ($row['variance_amount'] ?? 0), 2, '.', ''), + (string) ($row['match_note'] ?? ''), + ]); + } + + $filename = 'finance_compliance_' . date('Ymd_His') . '.csv'; + + return $this->response + ->setHeader('Content-Type', 'text/csv; charset=UTF-8') + ->setHeader('Content-Disposition', 'attachment; filename=' . $filename) + ->setBody(implode("\n", $lines)); + } + + return view('finance/compliance_report', [ + 'summary' => $summary, + 'from' => $from, + 'to' => $to, + 'invoice_exceptions' => $invoiceExceptions, + 'cash_alerts' => $cashAlerts, + ]); + } + + public function doctorPayout() + { + if (! $this->canFinance('finance.doctor_payout.manage')) { + return $this->response->setStatusCode(403)->setBody('Access denied'); + } + + return view('finance/doctor_payout', [ + 'agreements' => $this->fetchDoctorAgreements(), + 'payouts' => $this->fetchDoctorPayouts(), + 'doctor_options' => $this->doctorAgreementModel->where('status', 1)->orderBy('doctor_name', 'ASC')->findAll(), + 'summary' => $this->buildDoctorPayoutSummary(), + ]); + } + + public function doctorAgreementsTable() + { + if (! $this->canFinance('finance.doctor_payout.manage')) { + return $this->response->setStatusCode(403)->setBody('Access denied'); + } + + return view('finance/partials/doctor_agreements_table', [ + 'agreements' => $this->fetchDoctorAgreements(), + ]); + } + + public function doctorPayoutsTable() + { + if (! $this->canFinance('finance.doctor_payout.manage')) { + return $this->response->setStatusCode(403)->setBody('Access denied'); + } + + return view('finance/partials/doctor_payouts_table', [ + 'payouts' => $this->fetchDoctorPayouts(), + ]); + } + + public function doctorAgreementCreate() + { + if (! $this->canFinance('finance.doctor_payout.manage')) { + return $this->response->setStatusCode(403)->setJSON(['status' => 0, 'message' => 'Access denied']); + } + + $doctorCode = strtoupper(trim((string) ($this->request->getPost('doctor_code') ?? ''))); + $doctorName = trim((string) ($this->request->getPost('doctor_name') ?? '')); + + if ($doctorCode === '' || $doctorName === '') { + return $this->response->setStatusCode(422)->setJSON([ + 'status' => 0, + 'message' => 'Doctor code and name are required.', + ]); + } + + if ($this->doctorAgreementModel->where('doctor_code', $doctorCode)->countAllResults() > 0) { + return $this->response->setStatusCode(422)->setJSON([ + 'status' => 0, + 'message' => 'Doctor code already exists.', + ]); + } + + $this->doctorAgreementModel->insert([ + 'doctor_code' => $doctorCode, + 'doctor_name' => $doctorName, + 'specialization' => trim((string) ($this->request->getPost('specialization') ?? '')), + 'consultation_rate' => (float) ($this->request->getPost('consultation_rate') ?? 0), + 'surgery_rate' => (float) ($this->request->getPost('surgery_rate') ?? 0), + 'agreement_start_date' => trim((string) ($this->request->getPost('agreement_start_date') ?? '')) ?: null, + 'agreement_end_date' => trim((string) ($this->request->getPost('agreement_end_date') ?? '')) ?: null, + 'status' => 1, + 'created_by' => $this->currentUserName(), + ]); + + return $this->response->setJSON([ + 'status' => 1, + 'message' => 'Doctor agreement saved successfully.', + ]); + } + + public function doctorPayoutCreate() + { + if (! $this->canFinance('finance.doctor_payout.manage')) { + return $this->response->setStatusCode(403)->setJSON(['status' => 0, 'message' => 'Access denied']); + } + + $doctorId = (int) ($this->request->getPost('doctor_id') ?? 0); + $payoutDate = trim((string) ($this->request->getPost('payout_date') ?? '')); + $payoutType = trim((string) ($this->request->getPost('payout_type') ?? '')); + $units = max(1, (int) ($this->request->getPost('units') ?? 1)); + + if ($doctorId <= 0 || $payoutDate === '' || ! in_array($payoutType, ['consultation', 'surgery'], true)) { + return $this->response->setStatusCode(422)->setJSON([ + 'status' => 0, + 'message' => 'Doctor, payout date and payout type are required.', + ]); + } + + $agreement = $this->doctorAgreementModel->find($doctorId); + if (! $agreement) { + return $this->response->setStatusCode(422)->setJSON([ + 'status' => 0, + 'message' => 'Doctor agreement not found.', + ]); + } + + $rate = $payoutType === 'consultation' + ? (float) ($agreement['consultation_rate'] ?? 0) + : (float) ($agreement['surgery_rate'] ?? 0); + $calculatedAmount = round($rate * $units, 2); + + $this->doctorPayoutModel->insert([ + 'payout_date' => $payoutDate, + 'doctor_id' => $doctorId, + 'case_reference' => trim((string) ($this->request->getPost('case_reference') ?? '')), + 'payout_type' => $payoutType, + 'units' => $units, + 'rate' => $rate, + 'calculated_amount' => $calculatedAmount, + 'approved_amount' => $calculatedAmount, + 'status' => 'draft', + 'remarks' => trim((string) ($this->request->getPost('remarks') ?? '')), + 'hr_submitted_by' => $this->currentUserName(), + ]); + + return $this->response->setJSON([ + 'status' => 1, + 'message' => 'Payout draft created. Current status: draft.', + ]); + } + + public function doctorPayoutApprove() + { + if (! $this->canFinance('finance.doctor_payout.manage')) { + return $this->response->setStatusCode(403)->setJSON(['status' => 0, 'message' => 'Access denied']); + } + + $payoutId = (int) ($this->request->getPost('payout_id') ?? 0); + $level = trim((string) ($this->request->getPost('level') ?? '')); + + $row = $this->doctorPayoutModel->find($payoutId); + if (! $row) { + return $this->response->setStatusCode(404)->setJSON(['status' => 0, 'message' => 'Payout not found']); + } + + $status = (string) ($row['status'] ?? 'draft'); + $now = date('Y-m-d H:i:s'); + $user = $this->currentUserName(); + $update = []; + + if ($level === 'finance' && $status === 'draft') { + $update = [ + 'status' => 'finance_approved', + 'finance_approved_by' => $user, + 'finance_approved_at' => $now, + ]; + } elseif ($level === 'ceo' && $status === 'finance_approved') { + $update = [ + 'status' => 'ceo_approved', + 'ceo_approved_by' => $user, + 'ceo_approved_at' => $now, + ]; + } elseif ($level === 'paid' && $status === 'ceo_approved') { + $update = [ + 'status' => 'paid', + 'paid_at' => $now, + ]; + } else { + return $this->response->setStatusCode(422)->setJSON([ + 'status' => 0, + 'message' => 'Invalid approval transition from ' . $status . ' using level ' . $level . '.', + ]); + } + + $this->doctorPayoutModel->update($payoutId, $update); + + return $this->response->setJSON([ + 'status' => 1, + 'message' => 'Payout status updated to ' . $update['status'] . '.', + ]); + } + + public function cashbook() + { + if (! $this->canFinance('finance.cash.manage')) { + return $this->response->setStatusCode(403)->setBody('Access denied'); + } + + return view('finance/cashbook', [ + 'transactions' => $this->fetchCashTransactions(), + 'scrolls' => $this->fetchScrolls(), + 'summary' => $this->buildCashSummary(), + ]); + } + + public function cashTransactionsTable() + { + if (! $this->canFinance('finance.cash.manage')) { + return $this->response->setStatusCode(403)->setBody('Access denied'); + } + + return view('finance/partials/cash_transactions_table', [ + 'transactions' => $this->fetchCashTransactions(), + ]); + } + + public function scrollTable() + { + if (! $this->canFinance('finance.cash.manage')) { + return $this->response->setStatusCode(403)->setBody('Access denied'); + } + + return view('finance/partials/scroll_table', [ + 'scrolls' => $this->fetchScrolls(), + ]); + } + + public function cashTransactionCreate() + { + if (! $this->canFinance('finance.cash.manage')) { + return $this->response->setStatusCode(403)->setJSON(['status' => 0, 'message' => 'Access denied']); + } + + $txnDate = trim((string) ($this->request->getPost('txn_date') ?? '')); + $txnType = trim((string) ($this->request->getPost('txn_type') ?? '')); + $amount = (float) ($this->request->getPost('amount') ?? 0); + $mode = trim((string) ($this->request->getPost('mode') ?? '')); + + if ($txnDate === '' || ! in_array($txnType, ['receipt', 'disbursement'], true) || $amount <= 0 || $mode === '') { + return $this->response->setStatusCode(422)->setJSON([ + 'status' => 0, + 'message' => 'Date, type, amount and mode are required.', + ]); + } + + $flag269st = 0; + $flag40a3 = 0; + $complianceHold = 0; + $notes = []; + + if ($mode === 'cash' && $txnType === 'receipt' && $amount >= 200000) { + $flag269st = 1; + $complianceHold = 1; + $notes[] = 'Potential Sec 269ST threshold breach (>= 200000 cash receipt).'; + } + + if ($mode === 'cash' && $txnType === 'disbursement' && $amount > 10000) { + $flag40a3 = 1; + $complianceHold = 1; + $notes[] = 'Potential Sec 40A(3) breach (> 10000 cash disbursement).'; + } + + if ($mode === 'cash' && $txnType === 'disbursement') { + $pettyLimit = $this->getPolicyLimit('petty_cash_daily_limit', 50000); + $todayTotal = $this->cashTxnModel + ->select('COALESCE(SUM(amount),0) as total') + ->where('txn_date', $txnDate) + ->where('txn_type', 'disbursement') + ->where('mode', 'cash') + ->where('department', trim((string) ($this->request->getPost('department') ?? ''))) + ->first(); + + $projected = (float) ($todayTotal['total'] ?? 0) + $amount; + if ($projected > $pettyLimit) { + $complianceHold = 1; + $notes[] = 'Petty cash daily limit exceeded. Limit: ' . number_format($pettyLimit, 2) . ', projected: ' . number_format($projected, 2) . '.'; + } + } + + $this->cashTxnModel->insert([ + 'txn_date' => $txnDate, + 'txn_type' => $txnType, + 'flow_type' => trim((string) ($this->request->getPost('flow_type') ?? 'other')), + 'department' => trim((string) ($this->request->getPost('department') ?? '')), + 'reference_no' => trim((string) ($this->request->getPost('reference_no') ?? '')), + 'amount' => $amount, + 'mode' => $mode, + 'party_name' => trim((string) ($this->request->getPost('party_name') ?? '')), + 'narration' => trim((string) ($this->request->getPost('narration') ?? '')), + 'flag_269st' => $flag269st, + 'flag_40a3' => $flag40a3, + 'is_compliance_hold' => $complianceHold, + 'compliance_note' => empty($notes) ? 'Compliant entry' : implode(' ', $notes), + 'created_by' => $this->currentUserName(), + ]); + + $message = empty($notes) + ? 'Cash transaction saved.' + : 'Cash transaction saved with compliance alert: ' . implode(' ', $notes); + + return $this->response->setJSON([ + 'status' => 1, + 'message' => $message, + ]); + } + + public function scrollCreate() + { + if (! $this->canFinance('finance.cash.manage')) { + return $this->response->setStatusCode(403)->setJSON(['status' => 0, 'message' => 'Access denied']); + } + + $scrollDate = trim((string) ($this->request->getPost('scroll_date') ?? '')); + $department = trim((string) ($this->request->getPost('department') ?? '')); + $submittedAmount = (float) ($this->request->getPost('submitted_amount') ?? 0); + + if ($scrollDate === '' || $department === '' || $submittedAmount < 0) { + return $this->response->setStatusCode(422)->setJSON([ + 'status' => 0, + 'message' => 'Scroll date, department and submitted amount are required.', + ]); + } + + $row = $this->cashTxnModel + ->select('COALESCE(SUM(amount),0) AS total') + ->where('txn_date', $scrollDate) + ->where('txn_type', 'receipt') + ->where('department', $department) + ->first(); + + $totalReceipts = (float) ($row['total'] ?? 0); + $variance = round($submittedAmount - $totalReceipts, 2); + $status = abs($variance) <= 0.01 ? 'matched' : 'pending'; + + $this->scrollModel->insert([ + 'scroll_date' => $scrollDate, + 'department' => $department, + 'total_receipts' => $totalReceipts, + 'submitted_amount' => $submittedAmount, + 'variance_amount' => $variance, + 'reconciliation_status' => $status, + 'submitted_by' => trim((string) ($this->request->getPost('submitted_by') ?? $this->currentUserName())), + 'remarks' => trim((string) ($this->request->getPost('remarks') ?? '')), + ]); + + return $this->response->setJSON([ + 'status' => 1, + 'message' => 'Scroll submitted. Reconciliation status: ' . $status . '.', + ]); + } + + public function index() + { + if (! $this->canFinance('finance.access')) { + return $this->response->setStatusCode(403)->setBody('Access denied'); + } + + return view('finance/index', $this->buildDashboardData()); + } + + public function phase2() + { + if (! $this->canFinance('finance.access')) { + return $this->response->setStatusCode(403)->setBody('Access denied'); + } + + return view('finance/phase2', $this->buildPhase2Data()); + } + + public function sectionVendorMaster() + { + if (! $this->canFinance('finance.access')) { + return $this->response->setStatusCode(403)->setBody('Access denied'); + } + + return view('finance/sections/vendor_master', [ + 'vendors' => $this->fetchVendors(), + ]); + } + + public function sectionPurchaseOrder() + { + if (! $this->canFinance('finance.access')) { + return $this->response->setStatusCode(403)->setBody('Access denied'); + } + + return view('finance/sections/purchase_order', [ + 'purchase_orders' => $this->fetchPurchaseOrders(), + 'vendor_options' => $this->vendorModel->select('id, vendor_name, vendor_code')->orderBy('vendor_name', 'ASC')->findAll(), + ]); + } + + public function sectionGrnEntry() + { + if (! $this->canFinance('finance.access')) { + return $this->response->setStatusCode(403)->setBody('Access denied'); + } + + return view('finance/sections/grn_entry', [ + 'grns' => $this->fetchGrns(), + 'po_options' => $this->poModel->select('id, po_no')->orderBy('id', 'DESC')->findAll(), + ]); + } + + public function sectionVendorInvoice() + { + if (! $this->canFinance('finance.access')) { + return $this->response->setStatusCode(403)->setBody('Access denied'); + } + + return view('finance/sections/vendor_invoice', [ + 'vendor_invoices' => $this->fetchVendorInvoices(), + 'vendor_options' => $this->vendorModel->select('id, vendor_name, vendor_code')->orderBy('vendor_name', 'ASC')->findAll(), + 'po_options' => $this->poModel->select('id, po_no')->orderBy('id', 'DESC')->findAll(), + 'grn_options' => $this->grnModel->select('id, grn_no')->orderBy('id', 'DESC')->findAll(), + ]); + } + + public function vendorsTable() + { + if (! $this->canFinance('finance.access')) { + return $this->response->setStatusCode(403)->setBody('Access denied'); + } + + return view('finance/partials/vendors_table', [ + 'vendors' => $this->fetchVendors(), + ]); + } + + public function poTable() + { + if (! $this->canFinance('finance.access')) { + return $this->response->setStatusCode(403)->setBody('Access denied'); + } + + return view('finance/partials/po_table', [ + 'purchase_orders' => $this->fetchPurchaseOrders(), + ]); + } + + public function grnTable() + { + if (! $this->canFinance('finance.access')) { + return $this->response->setStatusCode(403)->setBody('Access denied'); + } + + return view('finance/partials/grn_table', [ + 'grns' => $this->fetchGrns(), + ]); + } + + public function invoiceTable() + { + if (! $this->canFinance('finance.access')) { + return $this->response->setStatusCode(403)->setBody('Access denied'); + } + + return view('finance/partials/invoice_table', [ + 'vendor_invoices' => $this->fetchVendorInvoices(), + ]); + } + + public function vendorCreate() + { + if (! $this->canFinance('finance.vendor.manage')) { + return $this->response->setStatusCode(403)->setJSON(['status' => 0, 'message' => 'Access denied']); + } + + $vendorCode = strtoupper(trim((string) ($this->request->getPost('vendor_code') ?? ''))); + $vendorName = trim((string) ($this->request->getPost('vendor_name') ?? '')); + + if ($vendorCode === '' || $vendorName === '') { + return $this->response->setStatusCode(422)->setJSON([ + 'status' => 0, + 'message' => 'Vendor code and vendor name are required.', + ]); + } + + if ($this->vendorModel->where('vendor_code', $vendorCode)->countAllResults() > 0) { + return $this->response->setStatusCode(422)->setJSON([ + 'status' => 0, + 'message' => 'Vendor code already exists.', + ]); + } + + $this->vendorModel->insert([ + 'vendor_code' => $vendorCode, + 'vendor_name' => $vendorName, + 'contact_person' => trim((string) ($this->request->getPost('contact_person') ?? '')), + 'phone' => trim((string) ($this->request->getPost('phone') ?? '')), + 'email' => trim((string) ($this->request->getPost('email') ?? '')), + 'gst_no' => trim((string) ($this->request->getPost('gst_no') ?? '')), + 'pan_no' => trim((string) ($this->request->getPost('pan_no') ?? '')), + 'address' => trim((string) ($this->request->getPost('address') ?? '')), + 'status' => (int) ($this->request->getPost('status') ?? 1) === 1 ? 1 : 0, + 'created_by' => $this->currentUserName(), + ]); + + return $this->response->setJSON([ + 'status' => 1, + 'message' => 'Vendor created successfully.', + ]); + } + + public function poCreate() + { + if (! $this->canFinance('finance.po.manage')) { + return $this->response->setStatusCode(403)->setJSON(['status' => 0, 'message' => 'Access denied']); + } + + $poNo = strtoupper(trim((string) ($this->request->getPost('po_no') ?? ''))); + $poDate = trim((string) ($this->request->getPost('po_date') ?? '')); + $vendorId = (int) ($this->request->getPost('vendor_id') ?? 0); + + if ($poNo === '' || $poDate === '' || $vendorId <= 0) { + return $this->response->setStatusCode(422)->setJSON([ + 'status' => 0, + 'message' => 'PO no, date and vendor are required.', + ]); + } + + if ($this->poModel->where('po_no', $poNo)->countAllResults() > 0) { + return $this->response->setStatusCode(422)->setJSON([ + 'status' => 0, + 'message' => 'PO number already exists.', + ]); + } + + $uploadResult = $this->handlePoDocumentUploads($poNo); + if (! $uploadResult['ok']) { + return $this->response->setStatusCode($uploadResult['code'])->setJSON([ + 'status' => 0, + 'message' => $uploadResult['message'], + ]); + } + $uploadedDocs = $uploadResult['documents']; + + $insertData = [ + 'po_no' => $poNo, + 'po_date' => $poDate, + 'vendor_id' => $vendorId, + 'department' => trim((string) ($this->request->getPost('department') ?? '')), + 'amount' => (float) ($this->request->getPost('amount') ?? 0), + 'approval_status' => trim((string) ($this->request->getPost('approval_status') ?? 'draft')), + 'remarks' => trim((string) ($this->request->getPost('remarks') ?? '')), + 'created_by' => $this->currentUserName(), + ]; + + $documentPath = ''; + $documentName = ''; + if (! empty($uploadedDocs)) { + $documentPath = (string) ($uploadedDocs[0]['file_path'] ?? ''); + $documentName = (string) ($uploadedDocs[0]['file_name'] ?? ''); + } + + if ($documentPath !== '' && $this->tableHasField('finance_purchase_orders', 'po_document_path')) { + $insertData['po_document_path'] = $documentPath; + } + if ($documentName !== '' && $this->tableHasField('finance_purchase_orders', 'po_document_name')) { + $insertData['po_document_name'] = $documentName; + } + + $this->poModel->insert($insertData); + $poId = (int) $this->poModel->getInsertID(); + + if ($poId > 0) { + $this->savePoDocuments($poId, $uploadedDocs); + } + + return $this->response->setJSON([ + 'status' => 1, + 'message' => $documentPath !== '' + ? 'Purchase order created successfully with document upload.' + : 'Purchase order created successfully.', + ]); + } + + public function poUpdate() + { + if (! $this->canFinance('finance.po.manage')) { + return $this->response->setStatusCode(403)->setJSON(['status' => 0, 'message' => 'Access denied']); + } + + $poId = (int) ($this->request->getPost('po_id') ?? 0); + $poNo = strtoupper(trim((string) ($this->request->getPost('po_no') ?? ''))); + $poDate = trim((string) ($this->request->getPost('po_date') ?? '')); + $vendorId = (int) ($this->request->getPost('vendor_id') ?? 0); + + if ($poId <= 0 || $poNo === '' || $poDate === '' || $vendorId <= 0) { + return $this->response->setStatusCode(422)->setJSON([ + 'status' => 0, + 'message' => 'PO id, no, date and vendor are required.', + ]); + } + + $existing = $this->poModel->find($poId); + if (! $existing) { + return $this->response->setStatusCode(404)->setJSON([ + 'status' => 0, + 'message' => 'Purchase order not found.', + ]); + } + + $duplicate = $this->poModel + ->where('po_no', $poNo) + ->where('id !=', $poId) + ->countAllResults(); + + if ($duplicate > 0) { + return $this->response->setStatusCode(422)->setJSON([ + 'status' => 0, + 'message' => 'PO number already exists.', + ]); + } + + $uploadResult = $this->handlePoDocumentUploads($poNo); + if (! $uploadResult['ok']) { + return $this->response->setStatusCode($uploadResult['code'])->setJSON([ + 'status' => 0, + 'message' => $uploadResult['message'], + ]); + } + + $removeDocIds = $this->request->getPost('remove_document_ids'); + if (is_array($removeDocIds) && ! empty($removeDocIds)) { + foreach ($removeDocIds as $docId) { + $this->removePoDocument($poId, (int) $docId); + } + } + + $uploadedDocs = $uploadResult['documents']; + if (! empty($uploadedDocs)) { + $this->savePoDocuments($poId, $uploadedDocs); + } + + $updateData = [ + 'po_no' => $poNo, + 'po_date' => $poDate, + 'vendor_id' => $vendorId, + 'department' => trim((string) ($this->request->getPost('department') ?? '')), + 'amount' => (float) ($this->request->getPost('amount') ?? 0), + 'approval_status' => trim((string) ($this->request->getPost('approval_status') ?? 'draft')), + 'remarks' => trim((string) ($this->request->getPost('remarks') ?? '')), + ]; + + $latestDoc = $this->fetchLatestPoDocument($poId); + if ($this->tableHasField('finance_purchase_orders', 'po_document_path')) { + $updateData['po_document_path'] = (string) ($latestDoc['file_path'] ?? ''); + } + if ($this->tableHasField('finance_purchase_orders', 'po_document_name')) { + $updateData['po_document_name'] = (string) ($latestDoc['file_name'] ?? ''); + } + + $this->poModel->update($poId, $updateData); + + return $this->response->setJSON([ + 'status' => 1, + 'message' => 'Purchase order updated successfully.', + ]); + } + + public function poDocuments($poId) + { + if (! $this->canFinance('finance.po.manage')) { + return $this->response->setStatusCode(403)->setJSON(['status' => 0, 'message' => 'Access denied']); + } + + $poId = (int) $poId; + if ($poId <= 0) { + return $this->response->setStatusCode(422)->setJSON(['status' => 0, 'message' => 'Invalid PO id']); + } + + $docs = $this->fetchPoDocuments($poId); + + return $this->response->setJSON([ + 'status' => 1, + 'documents' => $docs, + ]); + } + + private function handlePoDocumentUploads(string $poNo): array + { + $files = $this->request->getFileMultiple('po_documents'); + if (! is_array($files) || empty($files)) { + $single = $this->request->getFile('po_document'); + if ($single && $single->isValid() && ! $single->hasMoved()) { + $files = [$single]; + } + } + + if (! is_array($files) || empty($files)) { + return [ + 'ok' => true, + 'code' => 200, + 'message' => '', + 'documents' => [], + ]; + } + + $canSaveDocument = $this->tableHasField('finance_purchase_orders', 'po_document_path') + && $this->tableHasField('finance_purchase_orders', 'po_document_name'); + + if (! $canSaveDocument) { + return [ + 'ok' => false, + 'code' => 500, + 'message' => 'PO document columns are missing. Please run latest migrations and retry upload.', + 'documents' => [], + ]; + } + + $targetDir = rtrim(FCPATH, DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR . 'uploads' . DIRECTORY_SEPARATOR . 'finance_po_docs'; + if (! is_dir($targetDir)) { + @mkdir($targetDir, 0755, true); + } + + if (! is_dir($targetDir)) { + return [ + 'ok' => false, + 'code' => 500, + 'message' => 'Unable to create PO document upload directory.', + 'documents' => [], + ]; + } + + $allowedExt = ['pdf', 'jpg', 'jpeg', 'png']; + $maxBytes = 5 * 1024 * 1024; + $safePoNo = preg_replace('/[^A-Z0-9_-]/i', '_', $poNo); + $uploadedDocs = []; + + foreach ($files as $file) { + if (! $file || ! $file->isValid() || $file->hasMoved()) { + continue; + } + + $ext = strtolower((string) $file->getExtension()); + if (! in_array($ext, $allowedExt, true)) { + return [ + 'ok' => false, + 'code' => 422, + 'message' => 'Invalid PO document type. Allowed: PDF, JPG, JPEG, PNG.', + 'documents' => [], + ]; + } + + if ((int) $file->getSize() > $maxBytes) { + return [ + 'ok' => false, + 'code' => 422, + 'message' => 'Each PO document size must be 5 MB or less.', + 'documents' => [], + ]; + } + + $newName = $safePoNo . '_' . date('YmdHis') . '_' . bin2hex(random_bytes(4)) . '.' . $ext; + try { + $file->move($targetDir, $newName, true); + } catch (\Throwable $e) { + return [ + 'ok' => false, + 'code' => 500, + 'message' => 'Unable to upload PO document.', + 'documents' => [], + ]; + } + + $uploadedDocs[] = [ + 'file_name' => (string) $file->getClientName(), + 'file_path' => 'uploads/finance_po_docs/' . $newName, + ]; + } + + return [ + 'ok' => true, + 'code' => 200, + 'message' => '', + 'documents' => $uploadedDocs, + ]; + } + + private function savePoDocuments(int $poId, array $documents): void + { + if ($poId <= 0 || empty($documents) || ! $this->canUsePoDocumentTable()) { + return; + } + + $rows = []; + foreach ($documents as $doc) { + $path = trim((string) ($doc['file_path'] ?? '')); + $name = trim((string) ($doc['file_name'] ?? '')); + if ($path === '' || $name === '') { + continue; + } + + $rows[] = [ + 'po_id' => $poId, + 'file_name' => $name, + 'file_path' => $path, + 'uploaded_by' => $this->currentUserName(), + ]; + } + + if (! empty($rows)) { + $this->poDocumentModel->insertBatch($rows); + } + } + + private function removePoDocument(int $poId, int $docId): void + { + if ($poId <= 0 || $docId <= 0 || ! $this->canUsePoDocumentTable()) { + return; + } + + $doc = $this->poDocumentModel + ->where('id', $docId) + ->where('po_id', $poId) + ->first(); + + if (! $doc) { + return; + } + + $path = trim((string) ($doc['file_path'] ?? '')); + if ($path !== '') { + $fullPath = rtrim(FCPATH, DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR . str_replace(['/', '\\'], DIRECTORY_SEPARATOR, $path); + if (is_file($fullPath)) { + @unlink($fullPath); + } + } + + $this->poDocumentModel->delete((int) ($doc['id'] ?? 0)); + } + + private function fetchPoDocuments(int $poId): array + { + if ($poId <= 0) { + return []; + } + + $docs = []; + if ($this->canUsePoDocumentTable()) { + $rows = $this->poDocumentModel + ->where('po_id', $poId) + ->orderBy('id', 'DESC') + ->findAll(); + + foreach ($rows as $row) { + $path = trim((string) ($row['file_path'] ?? '')); + if ($path === '') { + continue; + } + $docs[] = [ + 'id' => (int) ($row['id'] ?? 0), + 'file_name' => (string) ($row['file_name'] ?? 'Document'), + 'file_path' => $path, + 'url' => base_url($path), + 'removable' => true, + ]; + } + } + + if (empty($docs)) { + $po = $this->poModel->find($poId); + $legacyPath = trim((string) ($po['po_document_path'] ?? '')); + if ($legacyPath !== '') { + $docs[] = [ + 'id' => 0, + 'file_name' => (string) ($po['po_document_name'] ?? 'Legacy document'), + 'file_path' => $legacyPath, + 'url' => base_url($legacyPath), + 'removable' => false, + ]; + } + } + + return $docs; + } + + private function fetchLatestPoDocument(int $poId): array + { + if ($poId <= 0) { + return []; + } + + if ($this->canUsePoDocumentTable()) { + $row = $this->poDocumentModel + ->where('po_id', $poId) + ->orderBy('id', 'DESC') + ->first(); + if (! empty($row)) { + return [ + 'file_name' => (string) ($row['file_name'] ?? ''), + 'file_path' => (string) ($row['file_path'] ?? ''), + ]; + } + } + + $po = $this->poModel->find($poId); + return [ + 'file_name' => (string) ($po['po_document_name'] ?? ''), + 'file_path' => (string) ($po['po_document_path'] ?? ''), + ]; + } + + private function canUsePoDocumentTable(): bool + { + if (! method_exists($this->db, 'tableExists') || ! $this->db->tableExists('finance_po_documents')) { + return false; + } + + return $this->tableHasField('finance_po_documents', 'po_id') + && $this->tableHasField('finance_po_documents', 'file_name') + && $this->tableHasField('finance_po_documents', 'file_path'); + } + + public function grnCreate() + { + if (! $this->canFinance('finance.grn.manage')) { + return $this->response->setStatusCode(403)->setJSON(['status' => 0, 'message' => 'Access denied']); + } + + $grnNo = strtoupper(trim((string) ($this->request->getPost('grn_no') ?? ''))); + $grnDate = trim((string) ($this->request->getPost('grn_date') ?? '')); + $poId = (int) ($this->request->getPost('po_id') ?? 0); + + if ($grnNo === '' || $grnDate === '' || $poId <= 0) { + return $this->response->setStatusCode(422)->setJSON([ + 'status' => 0, + 'message' => 'GRN no, date and PO are required.', + ]); + } + + if ($this->grnModel->where('grn_no', $grnNo)->countAllResults() > 0) { + return $this->response->setStatusCode(422)->setJSON([ + 'status' => 0, + 'message' => 'GRN number already exists.', + ]); + } + + $this->grnModel->insert([ + 'grn_no' => $grnNo, + 'grn_date' => $grnDate, + 'po_id' => $poId, + 'received_amount' => (float) ($this->request->getPost('received_amount') ?? 0), + 'received_by' => trim((string) ($this->request->getPost('received_by') ?? '')), + 'remarks' => trim((string) ($this->request->getPost('remarks') ?? '')), + ]); + + return $this->response->setJSON([ + 'status' => 1, + 'message' => 'GRN created successfully.', + ]); + } + + public function grnPrint($grnId) + { + if (! $this->canFinance('finance.grn.manage')) { + return $this->response->setStatusCode(403)->setBody('Access denied'); + } + + $grnId = (int) $grnId; + if ($grnId <= 0) { + return $this->response->setStatusCode(422)->setBody('Invalid GRN id'); + } + + $grn = $this->grnModel + ->select('finance_grns.*, finance_purchase_orders.po_no, finance_purchase_orders.po_date, finance_vendors.vendor_name, finance_vendors.vendor_code, finance_vendors.phone as vendor_phone, finance_vendors.address as vendor_address') + ->join('finance_purchase_orders', 'finance_purchase_orders.id = finance_grns.po_id', 'left') + ->join('finance_vendors', 'finance_vendors.id = finance_purchase_orders.vendor_id', 'left') + ->where('finance_grns.id', $grnId) + ->first(); + + if (! $grn) { + return $this->response->setStatusCode(404)->setBody('GRN not found'); + } + + return view('finance/print/grn_vendor_copy', [ + 'grn' => $grn, + 'printed_at' => date('Y-m-d H:i:s'), + ]); + } + + public function invoiceCreate() + { + if (! $this->canFinance('finance.invoice.manage')) { + return $this->response->setStatusCode(403)->setJSON(['status' => 0, 'message' => 'Access denied']); + } + + $invoiceNo = strtoupper(trim((string) ($this->request->getPost('invoice_no') ?? ''))); + $invoiceDate = trim((string) ($this->request->getPost('invoice_date') ?? '')); + $vendorId = (int) ($this->request->getPost('vendor_id') ?? 0); + + if ($invoiceNo === '' || $invoiceDate === '' || $vendorId <= 0) { + return $this->response->setStatusCode(422)->setJSON([ + 'status' => 0, + 'message' => 'Invoice no, date and vendor are required.', + ]); + } + + $invoiceAmount = (float) ($this->request->getPost('invoice_amount') ?? 0); + $poId = (int) ($this->request->getPost('po_id') ?? 0) ?: null; + $grnId = (int) ($this->request->getPost('grn_id') ?? 0) ?: null; + $match = $this->evaluateInvoiceMatch($vendorId, $poId, $grnId, $invoiceAmount); + + $this->invoiceModel->insert([ + 'invoice_no' => $invoiceNo, + 'invoice_date' => $invoiceDate, + 'vendor_id' => $vendorId, + 'po_id' => $poId, + 'grn_id' => $grnId, + 'invoice_amount' => $invoiceAmount, + 'payment_status' => trim((string) ($this->request->getPost('payment_status') ?? 'pending')), + 'match_status' => $match['match_status'], + 'variance_amount' => $match['variance_amount'], + 'match_note' => $match['match_note'], + 'is_compliance_hold' => $match['is_compliance_hold'], + 'match_checked_at' => date('Y-m-d H:i:s'), + 'remarks' => trim((string) ($this->request->getPost('remarks') ?? '')), + 'created_by' => $this->currentUserName(), + ]); + + return $this->response->setJSON([ + 'status' => 1, + 'message' => 'Vendor invoice created successfully. Match status: ' . $match['match_status'] . '.', + ]); + } + + // ── Finance Phase 2 – Pharmacy Bills (Payable / Cr. to Hospital) ───────────── + + public function sectionPharmacyBills() + { + if (! $this->canFinance('finance.access')) { + return $this->response->setStatusCode(403)->setBody('Access denied'); + } + + return view('finance/sections/pharmacy_bills', [ + 'pharmacy_bills' => $this->fetchPharmacyBills(), + ]); + } + + public function pharmacyBillsTable() + { + if (! $this->canFinance('finance.access')) { + return $this->response->setStatusCode(403)->setBody('Access denied'); + } + + return view('finance/partials/pharmacy_bills_table', [ + 'pharmacy_bills' => $this->fetchPharmacyBills(), + ]); + } + + public function pharmacyBillCreate() + { + if (! $this->canFinance('finance.invoice.manage')) { + return $this->response->setStatusCode(403)->setJSON(['status' => 0, 'message' => 'Access denied']); + } + + $billNo = strtoupper(trim((string) ($this->request->getPost('bill_no') ?? ''))); + $billDate = trim((string) ($this->request->getPost('bill_date') ?? '')); + $pharmName = trim((string) ($this->request->getPost('pharmacy_name') ?? '')); + + if ($billNo === '' || $billDate === '' || $pharmName === '') { + return $this->response->setStatusCode(422)->setJSON([ + 'status' => 0, + 'message' => 'Bill number, date and pharmacy name are required.', + ]); + } + + $billAmount = (float) ($this->request->getPost('bill_amount') ?? 0); + $taxAmount = (float) ($this->request->getPost('tax_amount') ?? 0); + $netAmount = (float) ($this->request->getPost('net_amount') ?? 0); + if ($netAmount <= 0) { + $netAmount = $billAmount + $taxAmount; + } + + $this->pharmBillModel->insert([ + 'bill_no' => $billNo, + 'bill_date' => $billDate, + 'pharmacy_name' => $pharmName, + 'description' => trim((string) ($this->request->getPost('description') ?? '')), + 'bill_amount' => $billAmount, + 'tax_amount' => $taxAmount, + 'net_amount' => $netAmount, + 'payment_status' => 'pending', + 'paid_amount' => 0.00, + 'remarks' => trim((string) ($this->request->getPost('remarks') ?? '')), + 'created_by' => $this->currentUserName(), + ]); + + return $this->response->setJSON([ + 'status' => 1, + 'message' => 'Pharmacy bill registered. Net payable: Rs. ' . number_format($netAmount, 2) . '.', + ]); + } + + public function pharmacyBillSettle() + { + if (! $this->canFinance('finance.invoice.manage')) { + return $this->response->setStatusCode(403)->setJSON(['status' => 0, 'message' => 'Access denied']); + } + + $billId = (int) ($this->request->getPost('bill_id') ?? 0); + $paidAmount = (float) ($this->request->getPost('paid_amount') ?? 0); + $paymentDate = trim((string) ($this->request->getPost('payment_date') ?? '')); + $paymentMode = trim((string) ($this->request->getPost('payment_mode') ?? '')); + $paymentRef = trim((string) ($this->request->getPost('payment_ref') ?? '')); + + if ($billId <= 0 || $paidAmount <= 0 || $paymentDate === '') { + return $this->response->setStatusCode(422)->setJSON([ + 'status' => 0, + 'message' => 'Bill, paid amount, and payment date are required.', + ]); + } + + $bill = $this->pharmBillModel->find($billId); + if (! $bill) { + return $this->response->setStatusCode(404)->setJSON(['status' => 0, 'message' => 'Bill not found.']); + } + + $netAmount = (float) ($bill['net_amount'] ?? 0); + $alreadyPaid = (float) ($bill['paid_amount'] ?? 0); + $totalPaid = $alreadyPaid + $paidAmount; + $paymentStatus = $totalPaid >= $netAmount ? 'paid' : ($totalPaid > 0 ? 'part_paid' : 'pending'); + + $this->pharmBillModel->update($billId, [ + 'paid_amount' => min($totalPaid, $netAmount), + 'payment_status' => $paymentStatus, + 'payment_date' => $paymentDate, + 'payment_mode' => $paymentMode, + 'payment_ref' => $paymentRef, + ]); + + return $this->response->setJSON([ + 'status' => 1, + 'message' => 'Payment recorded. Status: ' . $paymentStatus . '.', + ]); + } + + private function fetchPharmacyBills(): array + { + return $this->pharmBillModel + ->orderBy('bill_date', 'DESC') + ->orderBy('id', 'DESC') + ->findAll(200); + } + + // ── end Pharmacy Bills ──────────────────────────────────────────────────────── + + private function buildDashboardData(): array + { + $matchSummary = [ + 'matched' => 0, + 'minor_variance' => 0, + 'mismatch' => 0, + 'hold' => 0, + ]; + + $summaryRows = $this->invoiceModel + ->select('match_status, is_compliance_hold, COUNT(*) as total') + ->groupBy('match_status, is_compliance_hold') + ->findAll(); + + foreach ($summaryRows as $row) { + $status = (string) ($row['match_status'] ?? 'not_checked'); + $count = (int) ($row['total'] ?? 0); + + if ($status === 'matched') { + $matchSummary['matched'] += $count; + } + if ($status === 'minor_variance') { + $matchSummary['minor_variance'] += $count; + } + if ($status === 'mismatch' || $status === 'not_checked') { + $matchSummary['mismatch'] += $count; + } + if ((int) ($row['is_compliance_hold'] ?? 0) === 1) { + $matchSummary['hold'] += $count; + } + } + + return [ + 'vendors' => $this->fetchVendors(), + 'purchase_orders' => $this->fetchPurchaseOrders(), + 'grns' => $this->fetchGrns(), + 'vendor_invoices' => $this->fetchVendorInvoices(), + 'match_summary' => $matchSummary, + 'vendor_options' => $this->vendorModel->select('id, vendor_name, vendor_code')->orderBy('vendor_name', 'ASC')->findAll(), + 'po_options' => $this->poModel->select('id, po_no')->orderBy('id', 'DESC')->findAll(), + 'grn_options' => $this->grnModel->select('id, grn_no')->orderBy('id', 'DESC')->findAll(), + ]; + } + + private function buildPhase2Data(): array + { + $opdSummary = $this->buildOpdReceivableSummary(); + $ipdSummary = $this->buildIpdReceivableSummary(); + $pharmacySummary = $this->buildPharmacyReceivableSummary(); + $orgSummary = $this->buildOrganizationExposureSummary(); + $refundSummary = $this->buildRefundLifecycleSummary(); + + $receivableSummary = [ + 'total_billed' => $opdSummary['billed_total'] + $ipdSummary['billed_total'] + $pharmacySummary['billed_total'], + 'total_collected' => $opdSummary['collected_total'] + $ipdSummary['collected_total'] + $pharmacySummary['collected_total'], + 'total_outstanding' => $opdSummary['outstanding_total'] + $ipdSummary['outstanding_total'] + $pharmacySummary['outstanding_total'], + 'pending_invoice_count' => $opdSummary['pending_count'] + $ipdSummary['pending_count'] + $pharmacySummary['pending_count'], + 'streams' => [ + 'opd' => $opdSummary, + 'ipd' => $ipdSummary, + 'pharmacy' => $pharmacySummary, + ], + ]; + + // Pharmacy Bills payable summary (hospital owes to pharmacy entity) + $pharmBillSummary = ['total_bills' => 0, 'total_net' => 0.0, 'total_paid' => 0.0, 'total_pending' => 0.0, 'pending_count' => 0]; + if ($this->db->tableExists('finance_pharmacy_bills')) { + try { + $row = $this->db->table('finance_pharmacy_bills') + ->select('COUNT(*) as total_bills', false) + ->select('COALESCE(SUM(net_amount),0) as total_net', false) + ->select('COALESCE(SUM(paid_amount),0) as total_paid', false) + ->select('COALESCE(SUM(CASE WHEN payment_status != \'paid\' THEN net_amount - paid_amount ELSE 0 END),0) as total_pending', false) + ->select('COALESCE(SUM(CASE WHEN payment_status != \'paid\' THEN 1 ELSE 0 END),0) as pending_count', false) + ->get()->getRowArray(); + $pharmBillSummary = [ + 'total_bills' => (int) ($row['total_bills'] ?? 0), + 'total_net' => (float) ($row['total_net'] ?? 0), + 'total_paid' => (float) ($row['total_paid'] ?? 0), + 'total_pending' => (float) ($row['total_pending'] ?? 0), + 'pending_count' => (int) ($row['pending_count'] ?? 0), + ]; + } catch (\Throwable $e) { + // leave defaults + } + } + + return [ + 'phase_started_at' => '2026-03-17', + 'phase_plan' => [ + ['phase' => 1, 'name' => 'Procurement, cash controls, payouts, compliance', 'status' => 'live'], + ['phase' => 2, 'name' => 'AR, refund, pharmacy and org-credit consolidation', 'status' => 'started'], + ['phase' => 3, 'name' => 'Ledger hardening, audit trails, and statutory exports', 'status' => 'planned'], + ], + 'receivable_summary' => $receivableSummary, + 'organization_summary' => $orgSummary, + 'refund_summary' => $refundSummary, + 'pharm_bill_summary' => $pharmBillSummary, + 'bridge_metrics' => [ + 'charge_invoices_total' => $opdSummary['invoice_count'], + 'refund_requests_total' => $refundSummary['total_requests'], + 'medical_purchase_invoices_total' => $this->countTableRows('purchase_invoice'), + 'supplier_ledger_entries_total' => $this->countTableRows('med_supplier_ledger'), + 'organization_cases_total' => $orgSummary['case_count'], + ], + ]; + } + + private function buildOpdReceivableSummary(): array + { + $summary = $this->defaultReceivableSummary('OPD Billing'); + if (! method_exists($this->db, 'tableExists') || ! $this->db->tableExists('invoice_master')) { + return $summary; + } + + $netExpr = $this->resolveNetExpression('invoice_master', 'inv', ['correction_net_amount', 'net_amount']); + $outstandingExpr = $this->resolveOutstandingExpression('invoice_master', 'inv', ['payment_part_balance', 'payment_balance'], $netExpr, ['payment_part_received', 'payment_received']); + $collectedExpr = $this->resolveCollectedExpression('invoice_master', 'inv', ['payment_part_received', 'payment_received'], $netExpr, $outstandingExpr); + + if ($netExpr === null || $outstandingExpr === null || $collectedExpr === null) { + return $summary; + } + + try { + $builder = $this->db->table('invoice_master inv') + ->select('COUNT(*) as invoice_count', false) + ->select('COALESCE(SUM(' . $netExpr . '),0) as billed_total', false) + ->select('COALESCE(SUM(' . $collectedExpr . '),0) as collected_total', false) + ->select('COALESCE(SUM(' . $outstandingExpr . '),0) as outstanding_total', false) + ->select('COALESCE(SUM(CASE WHEN ' . $outstandingExpr . ' > 0 THEN 1 ELSE 0 END),0) as pending_count', false); + + if ($this->tableHasField('invoice_master', 'invoice_status')) { + $builder->where('inv.invoice_status', 1); + } + if ($this->tableHasField('invoice_master', 'ipd_id')) { + $builder->groupStart()->where('inv.ipd_id', 0)->orWhere('inv.ipd_id IS NULL', null, false)->groupEnd(); + } + + $row = (array) ($builder->get()->getRowArray() ?? []); + + $summary['invoice_count'] = (int) ($row['invoice_count'] ?? 0); + $summary['pending_count'] = (int) ($row['pending_count'] ?? 0); + $summary['billed_total'] = (float) ($row['billed_total'] ?? 0); + $summary['collected_total'] = (float) ($row['collected_total'] ?? 0); + $summary['outstanding_total'] = (float) ($row['outstanding_total'] ?? 0); + } catch (\Throwable $e) { + return $summary; + } + + return $summary; + } + + private function buildIpdReceivableSummary(): array + { + $summary = $this->defaultReceivableSummary('IPD Billing'); + if (! method_exists($this->db, 'tableExists') || ! $this->db->tableExists('ipd_master')) { + return $summary; + } + + $netExpr = $this->resolveNetExpression('ipd_master', 'ipd', ['net_amount']); + $outstandingExpr = $this->resolveOutstandingExpression('ipd_master', 'ipd', ['balance_amount'], $netExpr, ['total_paid_amount']); + + $collectedExpr = null; + if ($this->tableHasField('ipd_master', 'total_paid_amount') && $this->tableHasField('ipd_master', 'org_amount_recived')) { + $collectedExpr = 'GREATEST(IFNULL(ipd.total_paid_amount,0) + IFNULL(ipd.org_amount_recived,0),0)'; + } + if ($collectedExpr === null) { + $collectedExpr = $this->resolveCollectedExpression('ipd_master', 'ipd', ['total_paid_amount'], $netExpr, $outstandingExpr); + } + + if ($netExpr === null || $outstandingExpr === null || $collectedExpr === null) { + return $summary; + } + + try { + $builder = $this->db->table('ipd_master ipd') + ->select('COUNT(*) as invoice_count', false) + ->select('COALESCE(SUM(' . $netExpr . '),0) as billed_total', false) + ->select('COALESCE(SUM(' . $collectedExpr . '),0) as collected_total', false) + ->select('COALESCE(SUM(' . $outstandingExpr . '),0) as outstanding_total', false) + ->select('COALESCE(SUM(CASE WHEN ' . $outstandingExpr . ' > 0 THEN 1 ELSE 0 END),0) as pending_count', false); + + if ($this->tableHasField('ipd_master', 'net_amount')) { + $builder->where('ipd.net_amount >', 0); + } + + $row = (array) ($builder->get()->getRowArray() ?? []); + $summary['invoice_count'] = (int) ($row['invoice_count'] ?? 0); + $summary['pending_count'] = (int) ($row['pending_count'] ?? 0); + $summary['billed_total'] = (float) ($row['billed_total'] ?? 0); + $summary['collected_total'] = (float) ($row['collected_total'] ?? 0); + $summary['outstanding_total'] = (float) ($row['outstanding_total'] ?? 0); + } catch (\Throwable $e) { + return $summary; + } + + return $summary; + } + + private function buildPharmacyReceivableSummary(): array + { + $summary = $this->defaultReceivableSummary('Pharmacy Billing'); + if (! method_exists($this->db, 'tableExists') || ! $this->db->tableExists('invoice_med_master')) { + return $summary; + } + + $netExpr = $this->resolveNetExpression('invoice_med_master', 'med', ['net_amount']); + $outstandingExpr = $this->resolveOutstandingExpression('invoice_med_master', 'med', ['payment_balance'], $netExpr, ['payment_received']); + $collectedExpr = $this->resolveCollectedExpression('invoice_med_master', 'med', ['payment_received'], $netExpr, $outstandingExpr); + + if ($netExpr === null || $outstandingExpr === null || $collectedExpr === null) { + return $summary; + } + + try { + $builder = $this->db->table('invoice_med_master med') + ->select('COUNT(*) as invoice_count', false) + ->select('COALESCE(SUM(' . $netExpr . '),0) as billed_total', false) + ->select('COALESCE(SUM(' . $collectedExpr . '),0) as collected_total', false) + ->select('COALESCE(SUM(' . $outstandingExpr . '),0) as outstanding_total', false) + ->select('COALESCE(SUM(CASE WHEN ' . $outstandingExpr . ' > 0 THEN 1 ELSE 0 END),0) as pending_count', false); + + if ($this->tableHasField('invoice_med_master', 'invoice_status')) { + $builder->where('med.invoice_status', 1); + } + if ($this->tableHasField('invoice_med_master', 'sale_return')) { + $builder->where('med.sale_return', 0); + } + + $row = (array) ($builder->get()->getRowArray() ?? []); + $summary['invoice_count'] = (int) ($row['invoice_count'] ?? 0); + $summary['pending_count'] = (int) ($row['pending_count'] ?? 0); + $summary['billed_total'] = (float) ($row['billed_total'] ?? 0); + $summary['collected_total'] = (float) ($row['collected_total'] ?? 0); + $summary['outstanding_total'] = (float) ($row['outstanding_total'] ?? 0); + } catch (\Throwable $e) { + return $summary; + } + + return $summary; + } + + private function buildOrganizationExposureSummary(): array + { + $summary = [ + 'case_count' => $this->countTableRows('organization_case_master'), + 'invoice_outstanding' => 0.0, + 'ipd_outstanding' => 0.0, + 'total_outstanding' => 0.0, + ]; + + if (method_exists($this->db, 'tableExists') && $this->db->tableExists('invoice_master') && $this->tableHasField('invoice_master', 'insurance_case_id')) { + $outstandingExpr = $this->resolveOutstandingExpression('invoice_master', 'inv', ['payment_part_balance', 'payment_balance'], $this->resolveNetExpression('invoice_master', 'inv', ['correction_net_amount', 'net_amount']), ['payment_part_received', 'payment_received']); + if ($outstandingExpr !== null) { + try { + $row = $this->db->table('invoice_master inv') + ->select('COALESCE(SUM(' . $outstandingExpr . '),0) as total', false) + ->where('inv.insurance_case_id >', 0) + ->get() + ->getRowArray(); + $summary['invoice_outstanding'] = (float) ($row['total'] ?? 0); + } catch (\Throwable $e) { + $summary['invoice_outstanding'] = 0.0; + } + } + } + + if (method_exists($this->db, 'tableExists') && $this->db->tableExists('ipd_master') && $this->tableHasField('ipd_master', 'case_id') && $this->tableHasField('ipd_master', 'balance_amount')) { + try { + $row = $this->db->table('ipd_master ipd') + ->select('COALESCE(SUM(GREATEST(IFNULL(ipd.balance_amount,0),0)),0) as total', false) + ->where('ipd.case_id >', 0) + ->get() + ->getRowArray(); + $summary['ipd_outstanding'] = (float) ($row['total'] ?? 0); + } catch (\Throwable $e) { + $summary['ipd_outstanding'] = 0.0; + } + } + + $summary['total_outstanding'] = $summary['invoice_outstanding'] + $summary['ipd_outstanding']; + + return $summary; + } + + private function buildRefundLifecycleSummary(): array + { + $summary = [ + 'total_requests' => 0, + 'total_requested_amount' => 0.0, + 'pending_count' => 0, + 'pending_amount' => 0.0, + 'completed_count' => 0, + 'completed_amount' => 0.0, + 'cancelled_count' => 0, + 'cancelled_amount' => 0.0, + 'by_type' => [], + ]; + + if (! method_exists($this->db, 'tableExists') || ! $this->db->tableExists('refund_order')) { + return $summary; + } + + $hasType = $this->tableHasField('refund_order', 'refund_type'); + $hasProcess = $this->tableHasField('refund_order', 'refund_process'); + $hasAmount = $this->tableHasField('refund_order', 'refund_amount'); + + if (! $hasType || ! $hasProcess || ! $hasAmount) { + return $summary; + } + + try { + $row = (array) ($this->db->table('refund_order r') + ->select('COUNT(*) as total_requests', false) + ->select('COALESCE(SUM(IFNULL(r.refund_amount,0)),0) as total_requested_amount', false) + ->select('COALESCE(SUM(CASE WHEN IFNULL(r.refund_process,0)=0 THEN 1 ELSE 0 END),0) as pending_count', false) + ->select('COALESCE(SUM(CASE WHEN IFNULL(r.refund_process,0)=0 THEN IFNULL(r.refund_amount,0) ELSE 0 END),0) as pending_amount', false) + ->select('COALESCE(SUM(CASE WHEN IFNULL(r.refund_process,0)=2 THEN 1 ELSE 0 END),0) as cancelled_count', false) + ->select('COALESCE(SUM(CASE WHEN IFNULL(r.refund_process,0)=2 THEN IFNULL(r.refund_amount,0) ELSE 0 END),0) as cancelled_amount', false) + ->select('COALESCE(SUM(CASE WHEN IFNULL(r.refund_process,0)>0 AND IFNULL(r.refund_process,0)<>2 THEN 1 ELSE 0 END),0) as completed_count', false) + ->select('COALESCE(SUM(CASE WHEN IFNULL(r.refund_process,0)>0 AND IFNULL(r.refund_process,0)<>2 THEN IFNULL(r.refund_amount,0) ELSE 0 END),0) as completed_amount', false) + ->get() + ->getRowArray() ?? []); + + $summary['total_requests'] = (int) ($row['total_requests'] ?? 0); + $summary['total_requested_amount'] = (float) ($row['total_requested_amount'] ?? 0); + $summary['pending_count'] = (int) ($row['pending_count'] ?? 0); + $summary['pending_amount'] = (float) ($row['pending_amount'] ?? 0); + $summary['completed_count'] = (int) ($row['completed_count'] ?? 0); + $summary['completed_amount'] = (float) ($row['completed_amount'] ?? 0); + $summary['cancelled_count'] = (int) ($row['cancelled_count'] ?? 0); + $summary['cancelled_amount'] = (float) ($row['cancelled_amount'] ?? 0); + + $typeRows = $this->db->table('refund_order r') + ->select('IFNULL(r.refund_type,0) as refund_type', false) + ->select('COUNT(*) as total_requests', false) + ->select('COALESCE(SUM(IFNULL(r.refund_amount,0)),0) as total_amount', false) + ->select('COALESCE(SUM(CASE WHEN IFNULL(r.refund_process,0)=0 THEN 1 ELSE 0 END),0) as pending_count', false) + ->select('COALESCE(SUM(CASE WHEN IFNULL(r.refund_process,0)=0 THEN IFNULL(r.refund_amount,0) ELSE 0 END),0) as pending_amount', false) + ->select('COALESCE(SUM(CASE WHEN IFNULL(r.refund_process,0)>0 AND IFNULL(r.refund_process,0)<>2 THEN IFNULL(r.refund_amount,0) ELSE 0 END),0) as completed_amount', false) + ->groupBy('r.refund_type') + ->orderBy('r.refund_type', 'ASC') + ->get() + ->getResultArray(); + + foreach ($typeRows as $typeRow) { + $typeCode = (int) ($typeRow['refund_type'] ?? 0); + $summary['by_type'][] = [ + 'type_code' => $typeCode, + 'type_label' => match ($typeCode) { + 1 => 'OPD', + 2 => 'Charge', + 3 => 'IPD', + default => 'Other', + }, + 'total_requests' => (int) ($typeRow['total_requests'] ?? 0), + 'total_amount' => (float) ($typeRow['total_amount'] ?? 0), + 'pending_count' => (int) ($typeRow['pending_count'] ?? 0), + 'pending_amount' => (float) ($typeRow['pending_amount'] ?? 0), + 'completed_amount' => (float) ($typeRow['completed_amount'] ?? 0), + ]; + } + } catch (\Throwable $e) { + return $summary; + } + + return $summary; + } + + private function defaultReceivableSummary(string $label): array + { + return [ + 'label' => $label, + 'invoice_count' => 0, + 'pending_count' => 0, + 'billed_total' => 0.0, + 'collected_total' => 0.0, + 'outstanding_total' => 0.0, + ]; + } + + private function resolveNetExpression(string $table, string $alias, array $preferredColumns): ?string + { + $column = $this->firstExistingColumn($table, $preferredColumns); + return $column === null ? null : 'GREATEST(IFNULL(' . $alias . '.' . $column . ',0),0)'; + } + + private function resolveOutstandingExpression(string $table, string $alias, array $balanceCandidates, ?string $netExpr, array $paidCandidates): ?string + { + $balanceColumn = $this->firstExistingColumn($table, $balanceCandidates); + if ($balanceColumn !== null) { + return 'GREATEST(IFNULL(' . $alias . '.' . $balanceColumn . ',0),0)'; + } + + $paidColumn = $this->firstExistingColumn($table, $paidCandidates); + if ($netExpr !== null && $paidColumn !== null) { + return 'GREATEST((' . $netExpr . ') - GREATEST(IFNULL(' . $alias . '.' . $paidColumn . ',0),0),0)'; + } + + return $netExpr; + } + + private function resolveCollectedExpression(string $table, string $alias, array $paidCandidates, ?string $netExpr, ?string $outstandingExpr): ?string + { + $paidColumn = $this->firstExistingColumn($table, $paidCandidates); + if ($paidColumn !== null) { + return 'GREATEST(IFNULL(' . $alias . '.' . $paidColumn . ',0),0)'; + } + + if ($netExpr !== null && $outstandingExpr !== null) { + return 'GREATEST((' . $netExpr . ') - (' . $outstandingExpr . '),0)'; + } + + return null; + } + + private function firstExistingColumn(string $table, array $candidates): ?string + { + foreach ($candidates as $column) { + if ($this->tableHasField($table, $column)) { + return $column; + } + } + + return null; + } + + private function tableHasField(string $table, string $field): bool + { + return method_exists($this->db, 'fieldExists') && $this->db->fieldExists($field, $table); + } + + private function countTableRows(string $table): int + { + if (! method_exists($this->db, 'tableExists') || ! $this->db->tableExists($table)) { + return 0; + } + + try { + return (int) $this->db->table($table)->countAllResults(); + } catch (\Throwable $e) { + return 0; + } + } + + private function fetchVendors(): array + { + return $this->vendorModel->orderBy('id', 'DESC')->findAll(12); + } + + private function fetchPurchaseOrders(): array + { + $rows = $this->poModel + ->select('finance_purchase_orders.*, finance_vendors.vendor_name, finance_vendors.vendor_code') + ->join('finance_vendors', 'finance_vendors.id = finance_purchase_orders.vendor_id', 'left') + ->orderBy('finance_purchase_orders.id', 'DESC') + ->findAll(12); + + if (empty($rows)) { + return []; + } + + $poIds = array_map(static fn(array $r): int => (int) ($r['id'] ?? 0), $rows); + $docCountMap = []; + if ($this->canUsePoDocumentTable()) { + $countRows = $this->poDocumentModel + ->select('po_id, COUNT(*) as cnt') + ->whereIn('po_id', $poIds) + ->groupBy('po_id') + ->findAll(); + + foreach ($countRows as $countRow) { + $docCountMap[(int) ($countRow['po_id'] ?? 0)] = (int) ($countRow['cnt'] ?? 0); + } + } + + foreach ($rows as &$row) { + $id = (int) ($row['id'] ?? 0); + $row['document_count'] = (int) ($docCountMap[$id] ?? 0); + } + unset($row); + + return $rows; + } + + private function fetchGrns(): array + { + return $this->grnModel + ->select('finance_grns.*, finance_purchase_orders.po_no, finance_vendors.vendor_name, finance_vendors.vendor_code') + ->join('finance_purchase_orders', 'finance_purchase_orders.id = finance_grns.po_id', 'left') + ->join('finance_vendors', 'finance_vendors.id = finance_purchase_orders.vendor_id', 'left') + ->orderBy('finance_grns.id', 'DESC') + ->findAll(12); + } + + private function fetchVendorInvoices(): array + { + return $this->invoiceModel + ->select('finance_vendor_invoices.*, finance_vendors.vendor_name, finance_purchase_orders.po_no, finance_grns.grn_no') + ->join('finance_vendors', 'finance_vendors.id = finance_vendor_invoices.vendor_id', 'left') + ->join('finance_purchase_orders', 'finance_purchase_orders.id = finance_vendor_invoices.po_id', 'left') + ->join('finance_grns', 'finance_grns.id = finance_vendor_invoices.grn_id', 'left') + ->orderBy('finance_vendor_invoices.id', 'DESC') + ->findAll(12); + } + + private function currentUserName(): string + { + $user = function_exists('auth') ? auth()->user() : null; + + return trim((string) ($user->username ?? 'System')); + } + + private function fetchCashTransactions(): array + { + return $this->cashTxnModel->orderBy('id', 'DESC')->findAll(15); + } + + private function fetchScrolls(): array + { + return $this->scrollModel->orderBy('id', 'DESC')->findAll(15); + } + + private function buildCashSummary(): array + { + $today = date('Y-m-d'); + + $receiptRow = $this->cashTxnModel + ->select('COALESCE(SUM(amount),0) AS total') + ->where('txn_date', $today) + ->where('txn_type', 'receipt') + ->first(); + + $disbursementRow = $this->cashTxnModel + ->select('COALESCE(SUM(amount),0) AS total') + ->where('txn_date', $today) + ->where('txn_type', 'disbursement') + ->first(); + + return [ + 'today_receipts' => (float) ($receiptRow['total'] ?? 0), + 'today_disbursements' => (float) ($disbursementRow['total'] ?? 0), + 'hold_count' => $this->cashTxnModel->where('is_compliance_hold', 1)->countAllResults(), + 'pending_scroll' => $this->scrollModel->where('reconciliation_status', 'pending')->countAllResults(), + ]; + } + + private function fetchDoctorAgreements(): array + { + return $this->doctorAgreementModel->orderBy('id', 'DESC')->findAll(12); + } + + private function fetchDoctorPayouts(): array + { + return $this->doctorPayoutModel + ->select('finance_doctor_payouts.*, finance_doctor_agreements.doctor_name') + ->join('finance_doctor_agreements', 'finance_doctor_agreements.id = finance_doctor_payouts.doctor_id', 'left') + ->orderBy('finance_doctor_payouts.id', 'DESC') + ->findAll(20); + } + + private function buildDoctorPayoutSummary(): array + { + return [ + 'draft' => $this->doctorPayoutModel->where('status', 'draft')->countAllResults(), + 'finance_approved' => $this->doctorPayoutModel->where('status', 'finance_approved')->countAllResults(), + 'ceo_approved' => $this->doctorPayoutModel->where('status', 'ceo_approved')->countAllResults(), + 'paid' => $this->doctorPayoutModel->where('status', 'paid')->countAllResults(), + ]; + } + + private function fetchBankDeposits(): array + { + return $this->bankDepositModel->orderBy('id', 'DESC')->findAll(20); + } + + private function buildDepositSummary(): array + { + $today = date('Y-m-d'); + $todayRow = $this->bankDepositModel + ->select('COALESCE(SUM(deposited_amount),0) AS total') + ->where('deposit_date', $today) + ->first(); + + return [ + 'today_deposit' => (float) ($todayRow['total'] ?? 0), + 'pending_count' => $this->bankDepositModel->where('reconciliation_status', 'pending')->countAllResults(), + 'matched_count' => $this->bankDepositModel->where('reconciliation_status', 'matched')->countAllResults(), + ]; + } + + private function getPolicyLimit(string $key, float $default): float + { + $row = $this->policySettingModel->where('setting_key', $key)->first(); + if (! $row) { + return $default; + } + + $value = (float) ($row['setting_value'] ?? $default); + + return $value > 0 ? $value : $default; + } + + private function normalizeDateInput(string $date): string + { + $date = trim($date); + if ($date === '') { + return ''; + } + + return preg_match('/^\d{4}-\d{2}-\d{2}$/', $date) === 1 ? $date : ''; + } + + private function csvLine(array $cells): string + { + $escaped = array_map(static function ($value): string { + $text = str_replace('"', '""', (string) $value); + + return '"' . $text . '"'; + }, $cells); + + return implode(',', $escaped); + } + + private function canFinance(string $permission): bool + { + $user = function_exists('auth') ? auth()->user() : null; + if (! $user || ! method_exists($user, 'can')) { + return false; + } + + $inDefaultFinanceGroup = method_exists($user, 'inGroup') + ? $user->inGroup('superadmin', 'admin', 'developer') + : false; + + return $user->can($permission) || $user->can('finance.*') || $inDefaultFinanceGroup; + } + + private function evaluateInvoiceMatch(int $vendorId, ?int $poId, ?int $grnId, float $invoiceAmount): array + { + $poAmount = null; + $grnAmount = null; + $issues = []; + + if ($poId !== null) { + $po = $this->poModel->find($poId); + if (! $po) { + $issues[] = 'PO not found'; + } else { + $poAmount = (float) ($po['amount'] ?? 0); + if ((int) ($po['vendor_id'] ?? 0) !== $vendorId) { + $issues[] = 'Vendor mismatch against PO'; + } + } + } + + if ($grnId !== null) { + $grn = $this->grnModel->find($grnId); + if (! $grn) { + $issues[] = 'GRN not found'; + } else { + $grnAmount = (float) ($grn['received_amount'] ?? 0); + if ($poId !== null && (int) ($grn['po_id'] ?? 0) !== $poId) { + $issues[] = 'GRN does not belong to PO'; + } + } + } + + $referenceAmount = $grnAmount ?? $poAmount; + if ($referenceAmount === null) { + return [ + 'match_status' => 'not_checked', + 'variance_amount' => 0, + 'match_note' => 'PO/GRN missing for 3-way check', + 'is_compliance_hold' => 1, + ]; + } + + $variance = round($invoiceAmount - $referenceAmount, 2); + $absVariance = abs($variance); + $status = 'matched'; + $complianceHold = 0; + + if (! empty($issues)) { + $status = 'mismatch'; + $complianceHold = 1; + } elseif ($absVariance > 0.01 && $absVariance <= 100) { + $status = 'minor_variance'; + } elseif ($absVariance > 100) { + $status = 'mismatch'; + $complianceHold = 1; + $issues[] = 'Invoice variance exceeds tolerance'; + } + + return [ + 'match_status' => $status, + 'variance_amount' => $variance, + 'match_note' => empty($issues) ? 'Auto matched against reference amount' : implode('; ', $issues), + 'is_compliance_hold' => $complianceHold, + ]; + } +} diff --git a/app/Controllers/Medical.php b/app/Controllers/Medical.php index dedb2b4..fda8795 100644 --- a/app/Controllers/Medical.php +++ b/app/Controllers/Medical.php @@ -551,6 +551,55 @@ class Medical extends BaseController return $this->response->setJSON($result); } + public function get_batch($itemId) + { + if ($deny = $this->ensurePharmacyAccess()) { + return $deny; + } + + $itemId = (int) $itemId; + $term = trim((string) $this->request->getGet('term')); + + if ($itemId <= 0 || ! $this->db->tableExists('purchase_invoice_item')) { + return $this->response->setJSON([]); + } + + $itemFields = $this->db->getFieldNames('purchase_invoice_item') ?? []; + if (! in_array('batch_no', $itemFields, true) || ! in_array('item_code', $itemFields, true)) { + return $this->response->setJSON([]); + } + + $builder = $this->db->table('purchase_invoice_item') + ->select('batch_no') + ->where('item_code', $itemId) + ->where('batch_no !=', ''); + + if ($term !== '') { + $builder->like('batch_no', $term, 'after'); + } + + $rows = $builder + ->groupBy('batch_no') + ->orderBy('batch_no', 'ASC') + ->limit(100) + ->get() + ->getResultArray(); + + $result = []; + foreach ($rows as $row) { + $batch = (string) ($row['batch_no'] ?? ''); + if ($batch === '') { + continue; + } + $result[] = [ + 'label' => $batch, + 'value' => $batch, + ]; + } + + return $this->response->setJSON($result); + } + public function get_drug_master() { if ($deny = $this->ensurePharmacyAccess()) { @@ -5978,7 +6027,484 @@ class Medical extends BaseController return $deny; } - return view('medical/placeholder', ['title' => 'Purchase Return']); + return view('medical/purchase_return'); + } + + public function purchase_return_new() + { + if ($deny = $this->ensurePharmacyAccess()) { + return $deny; + } + + $supplierData = []; + if ($this->db->tableExists('med_supplier')) { + $supplierData = $this->db->table('med_supplier') + ->orderBy('name_supplier', 'ASC') + ->get() + ->getResult(); + } + + return view('medical/new_purchase_return_invoice', [ + 'supplier_data' => $supplierData, + ]); + } + + public function purchase_return_invoice() + { + if ($deny = $this->ensurePharmacyAccess()) { + return $deny; + } + + $rows = []; + if ($this->db->tableExists('purchase_return_invoice')) { + $searchRaw = (string) ($this->request->getPost('txtsearch') ?? $this->request->getGet('txtsearch')); + $search = preg_replace('/[^A-Za-z0-9_ \-]/', '', trim($searchRaw)); + $invNoCol = $this->purchaseReturnInvoiceNoColumn(); + + $builder = $this->db->table('purchase_return_invoice p') + ->select("p.id, p.{$invNoCol} AS p_r_invoice_no, p.date_of_invoice, DATE_FORMAT(p.date_of_invoice,'%d-%m-%Y') AS str_date_of_invoice, p.sid, IFNULL(s.name_supplier,'-') AS name_supplier, IFNULL(s.short_name,'-') AS short_name", false) + ->join('med_supplier s', 'p.sid=s.sid', 'left'); + + if ($search !== '') { + $builder->groupStart(); + $builder->like("p.{$invNoCol}", $search); + if (ctype_digit($search)) { + $builder->orWhere('p.id', (int) $search); + } + $builder->groupEnd(); + } + + $rows = $builder + ->orderBy('p.id', 'DESC') + ->limit(50) + ->get() + ->getResult(); + } + + return view('medical/purchase_return_supplier_list', [ + 'purchase_return_invoice' => $rows, + ]); + } + + public function create_purchase_return() + { + if ($deny = $this->ensurePharmacyAccess()) { + return $deny; + } + + if (! $this->request->isAJAX() || ! $this->db->tableExists('purchase_return_invoice')) { + return $this->response->setJSON([ + 'insertid' => 0, + 'show_text' => 'Invalid request', + ]); + } + + $sid = (int) ($this->request->getPost('input_supplier') ?? 0); + $invoiceDate = $this->normalizeUiDate((string) ($this->request->getPost('datepicker_invoice') ?? '')); + + $errors = []; + if ($sid <= 0) { + $errors[] = 'Supplier is required'; + } + if ($invoiceDate === '') { + $errors[] = 'Invoice date is invalid'; + } + + if ($errors !== []) { + return $this->response->setJSON([ + 'insertid' => 0, + 'show_text' => implode('
', array_map('esc', $errors)), + ]); + } + + $fields = $this->db->getFieldNames('purchase_return_invoice') ?? []; + $insert = []; + if (in_array('sid', $fields, true)) { + $insert['sid'] = $sid; + } + if (in_array('date_of_invoice', $fields, true)) { + $insert['date_of_invoice'] = $invoiceDate; + } + if (in_array('status', $fields, true)) { + $insert['status'] = 0; + } + + $this->db->table('purchase_return_invoice')->insert($insert); + $insertId = (int) $this->db->insertID(); + + if ($insertId > 0 && in_array('p_r_invoice_no', $fields, true)) { + $invoiceNo = 'PR' . date('ym') . str_pad((string) ($insertId % 1000), 3, '0', STR_PAD_LEFT); + $this->db->table('purchase_return_invoice') + ->where('id', $insertId) + ->update(['p_r_invoice_no' => $invoiceNo]); + } + + return $this->response->setJSON([ + 'insertid' => $insertId, + 'show_text' => $insertId > 0 ? 'Added Successfully' : 'Unable to create purchase return invoice', + ]); + } + + public function purchase_return_invoice_edit($invId) + { + if ($deny = $this->ensurePharmacyAccess()) { + return $deny; + } + + $invId = (int) $invId; + if ($invId <= 0 || ! $this->db->tableExists('purchase_return_invoice')) { + return '
Purchase return invoice not found.
'; + } + + $invNoCol = $this->purchaseReturnInvoiceNoColumn(); + $invoice = $this->db->table('purchase_return_invoice p') + ->select("p.id, p.{$invNoCol} AS Invoice_no, p.date_of_invoice, DATE_FORMAT(p.date_of_invoice,'%d/%m/%Y') AS str_date_of_invoice, p.sid, p.status AS inv_status, IFNULL(s.name_supplier,'-') AS name_supplier, IFNULL(s.short_name,'-') AS short_name, IFNULL(s.gst_no,'-') AS gst_no", false) + ->join('med_supplier s', 'p.sid=s.sid', 'left') + ->where('p.id', $invId) + ->get() + ->getRow(); + + if (! $invoice) { + return '
Purchase return invoice not found.
'; + } + + $items = $this->fetchPurchaseReturnItems($invId); + $content = view('medical/purchase_return_invoice_item', [ + 'purchase_return_invoice_item' => $items, + ]); + + return view('medical/purchase_return_invoice_edit', [ + 'purchase_return_invoice' => $invoice, + 'purchase_return_invoice_item' => $items, + 'content' => $content, + ]); + } + + public function purchase_return_invoice_item_list($invId) + { + if ($deny = $this->ensurePharmacyAccess()) { + return $deny; + } + + $invId = (int) $invId; + $items = $this->fetchPurchaseReturnItems($invId); + $invoice = null; + if ($invId > 0 && $this->db->tableExists('purchase_return_invoice')) { + $invoice = $this->db->table('purchase_return_invoice')->where('id', $invId)->get()->getRow(); + } + + return view('medical/purchase_return_invoice_item', [ + 'purchase_return_invoice_item' => $items, + 'purchase_return_invoice' => $invoice ? [$invoice] : [], + ]); + } + + public function purchase_invoice_product($suppId) + { + if ($deny = $this->ensurePharmacyAccess()) { + return $deny; + } + + return view('medical/purchase_return_product_search', [ + 'supp_id' => (int) $suppId, + ]); + } + + public function purchase_invoice_old($suppId) + { + if ($deny = $this->ensurePharmacyAccess()) { + return $deny; + } + + $suppId = (int) $suppId; + $searchRaw = (string) ($this->request->getPost('txtsearch') ?? $this->request->getGet('txtsearch')); + $search = preg_replace('/[^A-Za-z0-9_ \-]/', '', trim($searchRaw)); + + $rows = []; + if ( + $suppId > 0 + && $this->db->tableExists('purchase_invoice') + && $this->db->tableExists('purchase_invoice_item') + && $this->db->tableExists('med_supplier') + ) { + $itemFields = $this->db->getFieldNames('purchase_invoice_item') ?? []; + + $curQtyExpr = '(IFNULL(i.total_unit,0)-IFNULL(i.total_sale_unit,0)-IFNULL(i.total_lost_unit,0)-IFNULL(i.total_return_unit,0))'; + $builder = $this->db->table('purchase_invoice p') + ->select("p.id AS pur_id, p.Invoice_no, p.date_of_invoice, IF(i.expiry_datejoin('med_supplier s', 'p.sid=s.sid', 'inner') + ->join('purchase_invoice_item i', 'p.id=i.purchase_id', 'inner') + ->where('s.sid', $suppId) + ->where('p.date_of_invoice >= DATE_ADD(CURDATE(), INTERVAL -1 YEAR)', null, false) + ->where("{$curQtyExpr} > 0", null, false); + + if (in_array('remove_item', $itemFields, true)) { + $builder->where('i.remove_item', 0); + } + if (in_array('item_return', $itemFields, true)) { + $builder->where('i.item_return', 0); + } + + if ($search !== '') { + $builder->groupStart(); + $builder->like('p.Invoice_no', $search); + if (ctype_digit($search)) { + $builder->orWhere('p.id', (int) $search); + } + $builder->groupEnd(); + } + + $rows = $builder + ->orderBy('p.id', 'DESC') + ->get() + ->getResult(); + } + + return view('medical/purchase_return_old_invoice_list', [ + 'purchase_list' => $rows, + ]); + } + + public function purchase_return_add_remove_item() + { + if ($deny = $this->ensurePharmacyAccess()) { + return $deny; + } + + $invId = (int) ($this->request->getPost('inv_id') ?? 0); + $itemId = (int) ($this->request->getPost('itemid') ?? 0); + $rqty = (float) ($this->request->getPost('rqty') ?? 0); + $rbatchNo = trim((string) ($this->request->getPost('rbatch_no') ?? '')); + $rexpiryDt = trim((string) ($this->request->getPost('rexpiry_dt') ?? '')); + + $respond = function (int $update, string $msgText) use ($invId) { + return $this->response->setJSON([ + 'update' => $update, + 'msg_text' => $msgText, + 'content' => view('medical/purchase_return_invoice_item', [ + 'purchase_return_invoice_item' => $this->fetchPurchaseReturnItems($invId), + ]), + ]); + }; + + if ( + $invId <= 0 + || $itemId <= 0 + || $rqty <= 0 + || ! $this->db->tableExists('purchase_return_invoice') + || ! $this->db->tableExists('purchase_return_invoice_item') + || ! $this->db->tableExists('purchase_invoice_item') + ) { + return $respond(0, 'Invalid return input'); + } + + $invoice = $this->db->table('purchase_return_invoice')->where('id', $invId)->get()->getRow(); + if (! $invoice) { + return $respond(0, 'Purchase return invoice not found'); + } + + $sourceItem = $this->db->table('purchase_invoice_item')->where('id', $itemId)->get()->getRow(); + if (! $sourceItem) { + return $respond(0, 'No item found'); + } + + $totalUnit = (float) ($sourceItem->total_unit ?? 0); + $totalSaleUnit = (float) ($sourceItem->total_sale_unit ?? 0); + $totalReturnUnit = (float) ($sourceItem->total_return_unit ?? 0); + $totalLostUnit = (float) ($sourceItem->total_lost_unit ?? 0); + $curQty = $totalUnit - $totalSaleUnit - $totalReturnUnit - $totalLostUnit; + + if ($curQty <= 0) { + return $respond(0, 'Current Item Qty is 0'); + } + if ($rqty > $curQty) { + return $respond(0, 'Current Item Qty is ' . rtrim(rtrim((string) $curQty, '0'), '.')); + } + + $fields = $this->db->getFieldNames('purchase_return_invoice_item') ?? []; + $insert = []; + if (in_array('purchase_inv_id', $fields, true)) { + $insert['purchase_inv_id'] = $invId; + } + if (in_array('purchase_item_id', $fields, true)) { + $insert['purchase_item_id'] = $itemId; + } + if (in_array('item_code', $fields, true)) { + $insert['item_code'] = $sourceItem->item_code ?? 0; + } + if (in_array('Item_name', $fields, true)) { + $insert['Item_name'] = $sourceItem->Item_name ?? ($sourceItem->item_name ?? ''); + } + if (in_array('batch_no_r', $fields, true)) { + $insert['batch_no_r'] = $rbatchNo; + } + if (in_array('expiry_date_r', $fields, true)) { + $insert['expiry_date_r'] = $rexpiryDt !== '' ? $rexpiryDt : null; + } + if (in_array('qty', $fields, true)) { + $insert['qty'] = $rqty; + } + + $this->db->table('purchase_return_invoice_item')->insert($insert); + $newId = (int) $this->db->insertID(); + if ($newId <= 0) { + return $respond(0, 'Item not added'); + } + + $this->adjustPurchaseItemReturnUnit($itemId, $rqty); + return $respond(1, 'Item Added'); + } + + public function purchase_return_remove_item_invoice($itemId) + { + if ($deny = $this->ensurePharmacyAccess()) { + return $deny; + } + + $itemId = (int) $itemId; + if ($itemId <= 0 || ! $this->db->tableExists('purchase_return_invoice_item')) { + return $this->response->setJSON([ + 'update' => 0, + 'msg_text' => 'Invalid return item', + 'content' => '', + ]); + } + + $row = $this->db->table('purchase_return_invoice_item')->where('id', $itemId)->get()->getRow(); + if (! $row) { + return $this->response->setJSON([ + 'update' => 0, + 'msg_text' => 'No item found', + 'content' => '', + ]); + } + + $invId = (int) ($row->purchase_inv_id ?? 0); + $sourceItemId = (int) ($row->purchase_item_id ?? 0); + $qty = (float) ($row->qty ?? 0); + + $this->db->table('purchase_return_invoice_item')->where('id', $itemId)->delete(); + if ($sourceItemId > 0 && $qty > 0) { + $this->adjustPurchaseItemReturnUnit($sourceItemId, -1 * $qty); + } + + return $this->response->setJSON([ + 'update' => 1, + 'msg_text' => 'Item Removed', + 'content' => view('medical/purchase_return_invoice_item', [ + 'purchase_return_invoice_item' => $this->fetchPurchaseReturnItems($invId), + ]), + ]); + } + + public function print_purchase_return($invId) + { + if ($deny = $this->ensurePharmacyAccess()) { + return $deny; + } + + $invId = (int) $invId; + if ($invId <= 0 || ! $this->db->tableExists('purchase_return_invoice')) { + return $this->response->setStatusCode(404)->setBody('Purchase return invoice not found'); + } + + $invNoCol = $this->purchaseReturnInvoiceNoColumn(); + $invoice = $this->db->table('purchase_return_invoice p') + ->select("p.id, p.{$invNoCol} AS Invoice_no, p.date_of_invoice, DATE_FORMAT(p.date_of_invoice,'%d/%m/%Y') AS str_date_of_invoice, p.sid, p.status AS inv_status, IFNULL(s.name_supplier,'-') AS name_supplier, IFNULL(s.short_name,'-') AS short_name, IFNULL(s.gst_no,'-') AS gst_no", false) + ->join('med_supplier s', 'p.sid=s.sid', 'left') + ->where('p.id', $invId) + ->get() + ->getRow(); + + if (! $invoice) { + return $this->response->setStatusCode(404)->setBody('Purchase return invoice not found'); + } + + $items = $this->fetchPurchaseReturnItems($invId); + $content = view('medical/purchase_return_invoice_item_print', [ + 'purchase_return_invoice' => [$invoice], + 'purchase_return_invoice_item' => $items, + ]); + + $mpdf = new Mpdf([ + 'mode' => 'utf-8', + 'format' => 'A4', + 'tempDir' => WRITEPATH . 'cache/mpdf', + ]); + $mpdf->showWatermarkText = false; + $mpdf->WriteHTML($content); + + $filename = 'Return_Invoice-' . $invId . '-' . date('YmdHis') . '.pdf'; + return $this->response + ->setHeader('Content-Type', 'application/pdf') + ->setBody($mpdf->Output($filename, 'S')); + } + + private function purchaseReturnInvoiceNoColumn(): string + { + $fields = $this->db->getFieldNames('purchase_return_invoice') ?? []; + if (in_array('p_r_invoice_no', $fields, true)) { + return 'p_r_invoice_no'; + } + + return in_array('Invoice_no', $fields, true) ? 'Invoice_no' : 'id'; + } + + private function fetchPurchaseReturnItems(int $invId): array + { + if ( + $invId <= 0 + || ! $this->db->tableExists('purchase_return_invoice_item') + || ! $this->db->tableExists('purchase_invoice_item') + ) { + return []; + } + + $itemFields = $this->db->getFieldNames('purchase_invoice_item') ?? []; + $gstPerExpr = '0'; + if (in_array('CGST_per_old', $itemFields, true) && in_array('CGST_per', $itemFields, true)) { + $gstPerExpr = 'IF(p.CGST_per_old IS NULL, p.CGST_per, p.CGST_per_old) * 2'; + } elseif (in_array('CGST_per', $itemFields, true)) { + $gstPerExpr = 'p.CGST_per * 2'; + } + + return $this->db->table('purchase_return_invoice_item r') + ->select("p.*, r.purchase_inv_id, r.qty AS r_qty, ROUND(r.qty/IFNULL(NULLIF(p.packing,0),1),2) AS qty_pak, r.id AS r_id, IF(IFNULL(r.batch_no_r,'')='', p.batch_no, r.batch_no_r) AS batch_no_r_s, DATE_FORMAT(p.expiry_date,'%m/%y') AS exp_date_str, p.purchase_unit_rate*r.qty AS r_amount, p.purchase_unit_rate, {$gstPerExpr} AS gst_per", false) + ->join('purchase_invoice_item p', 'r.purchase_item_id=p.id', 'inner') + ->where('r.purchase_inv_id', $invId) + ->orderBy('r.id', 'ASC') + ->get() + ->getResult(); + } + + private function adjustPurchaseItemReturnUnit(int $purchaseItemId, float $qtyDelta): void + { + if ($purchaseItemId <= 0 || ! $this->db->tableExists('purchase_invoice_item')) { + return; + } + + $fields = $this->db->getFieldNames('purchase_invoice_item') ?? []; + if (! in_array('total_return_unit', $fields, true)) { + return; + } + + $row = $this->db->table('purchase_invoice_item') + ->select('id,total_return_unit') + ->where('id', $purchaseItemId) + ->get() + ->getRow(); + if (! $row) { + return; + } + + $nextQty = (float) ($row->total_return_unit ?? 0) + $qtyDelta; + if ($nextQty < 0) { + $nextQty = 0; + } + + $this->db->table('purchase_invoice_item') + ->where('id', $purchaseItemId) + ->update(['total_return_unit' => $nextQty]); } public function main_store_placeholder($slug = '') diff --git a/app/Controllers/Opd_prescription.php b/app/Controllers/Opd_prescription.php index b1f57d5..d69d451 100644 --- a/app/Controllers/Opd_prescription.php +++ b/app/Controllers/Opd_prescription.php @@ -2181,6 +2181,25 @@ class Opd_prescription extends BaseController return $this->response->setJSON(['update' => 0, 'error_text' => 'Medicine name is required']); } + $local = $this->lookupMedicineDetailsFromMaster($name, $formulation); + if (($local['genericname'] ?? '') !== '' || ($local['salt_name'] ?? '') !== '') { + return $this->response->setJSON([ + 'update' => 1, + 'provider' => 'local-master', + 'match_confidence' => (string) ($local['match_confidence'] ?? 'partial'), + 'matched_item_name' => (string) ($local['matched_item_name'] ?? ''), + 'details' => [ + 'genericname' => trim((string) ($local['genericname'] ?? '')), + 'salt_name' => trim((string) ($local['salt_name'] ?? '')), + 'dosage_restriction' => trim((string) ($local['dosage_restriction'] ?? '')), + 'caution_note' => trim((string) ($local['caution_note'] ?? '')), + ], + 'error_text' => 'Medicine details found from local master data', + 'csrfName' => csrf_token(), + 'csrfHash' => csrf_hash(), + ]); + } + $prompt = "You are a medicine data enrichment assistant for OPD master data in India.\n" . "For this medicine, provide structured details based on public medical references and standard labeling guidance.\n" . "Medicine Name: {$name}\n" @@ -2191,17 +2210,57 @@ class Opd_prescription extends BaseController $this->lastAiProvider = 'none'; $aiText = $this->generateClinicalTextWithGemini($prompt, 280); if ($aiText === null || trim($aiText) === '') { - return $this->response->setJSON(['update' => 0, 'error_text' => 'AI unavailable. Check AI settings/API key.']); + $fallback = $this->inferMedicineDetailsFromBrandName($name, $formulation); + if (($fallback['genericname'] ?? '') !== '' || ($fallback['salt_name'] ?? '') !== '') { + return $this->response->setJSON([ + 'update' => 1, + 'provider' => 'local-brand-fallback', + 'match_confidence' => 'brand-fallback', + 'matched_item_name' => '', + 'details' => [ + 'genericname' => trim((string) ($fallback['genericname'] ?? '')), + 'salt_name' => trim((string) ($fallback['salt_name'] ?? '')), + 'dosage_restriction' => trim((string) ($fallback['dosage_restriction'] ?? '')), + 'caution_note' => trim((string) ($fallback['caution_note'] ?? '')), + ], + 'error_text' => 'AI unavailable. Fallback generic/salt suggestion prepared.', + 'csrfName' => csrf_token(), + 'csrfHash' => csrf_hash(), + ]); + } + + return $this->response->setJSON(['update' => 0, 'error_text' => 'AI unavailable and no local match found. Check AI settings/API key.']); } $parsed = $this->parseJsonFromAiResponse($aiText); if ($parsed === null) { + $fallback = $this->inferMedicineDetailsFromBrandName($name, $formulation); + if (($fallback['genericname'] ?? '') !== '' || ($fallback['salt_name'] ?? '') !== '') { + return $this->response->setJSON([ + 'update' => 1, + 'provider' => 'local-brand-fallback', + 'match_confidence' => 'brand-fallback', + 'matched_item_name' => '', + 'details' => [ + 'genericname' => trim((string) ($fallback['genericname'] ?? '')), + 'salt_name' => trim((string) ($fallback['salt_name'] ?? '')), + 'dosage_restriction' => trim((string) ($fallback['dosage_restriction'] ?? '')), + 'caution_note' => trim((string) ($fallback['caution_note'] ?? '')), + ], + 'error_text' => 'AI parse failed. Fallback generic/salt suggestion prepared.', + 'csrfName' => csrf_token(), + 'csrfHash' => csrf_hash(), + ]); + } + return $this->response->setJSON(['update' => 0, 'error_text' => 'AI response parse failed. Try again.']); } return $this->response->setJSON([ 'update' => 1, 'provider' => $this->lastAiProvider, + 'match_confidence' => 'ai', + 'matched_item_name' => '', 'details' => [ 'genericname' => trim((string) ($parsed['genericname'] ?? '')), 'salt_name' => trim((string) ($parsed['salt_name'] ?? '')), @@ -2214,6 +2273,174 @@ class Opd_prescription extends BaseController ]); } + /** + * @return array + */ + private function lookupMedicineDetailsFromMaster(string $name, string $formulation = ''): array + { + $table = $this->findExistingTable(['opd_med_master']); + if ($table === null) { + return []; + } + + $fields = $this->db->getFieldNames($table); + $nameField = $this->resolveFirstField($fields, ['item_name', 'med_name']); + $formField = $this->resolveFirstField($fields, ['formulation', 'med_type']); + $genericField = $this->resolveFirstField($fields, ['genericname', 'generic_name']); + $saltField = $this->resolveFirstField($fields, ['salt_name', 'sal_name', 'salt', 'saltname']); + $restrictionField = $this->resolveFirstField($fields, ['dosage_restriction', 'dose_restriction', 'restriction_note', 'restriction']); + + if ($nameField === null || ($genericField === null && $saltField === null)) { + return []; + } + + $name = trim($name); + if ($name === '') { + return []; + } + + $exact = $this->db->table($table) + ->where('UPPER(' . $nameField . ')', strtoupper($name)); + + if ($formField !== null && trim($formulation) !== '') { + $exact->where('UPPER(' . $formField . ')', strtoupper(trim($formulation))); + } + + $row = $exact->get(1)->getRowArray() ?? []; + $matchConfidence = 'partial'; + + if (empty($row)) { + $builder = $this->db->table($table); + $builder->groupStart() + ->like($nameField, $name) + ->orLike($nameField, preg_replace('/\s+/', ' ', $name) ?? $name) + ->groupEnd(); + + if ($formField !== null && trim($formulation) !== '') { + $builder->like($formField, trim($formulation)); + } + + $candidates = $builder->limit(15)->get()->getResultArray(); + if (! empty($candidates)) { + $target = strtoupper($name); + usort($candidates, static function (array $a, array $b) use ($nameField, $target): int { + $aName = strtoupper(trim((string) ($a[$nameField] ?? ''))); + $bName = strtoupper(trim((string) ($b[$nameField] ?? ''))); + $aScore = 0; + $bScore = 0; + if ($aName === $target) { + $aScore += 1000; + } elseif (str_starts_with($aName, $target)) { + $aScore += 600; + } elseif (str_contains($aName, $target)) { + $aScore += 400; + } + if ($bName === $target) { + $bScore += 1000; + } elseif (str_starts_with($bName, $target)) { + $bScore += 600; + } elseif (str_contains($bName, $target)) { + $bScore += 400; + } + + if ($aScore !== $bScore) { + return $bScore <=> $aScore; + } + + return strlen($aName) <=> strlen($bName); + }); + $row = $candidates[0] ?? []; + $picked = strtoupper(trim((string) ($row[$nameField] ?? ''))); + $target = strtoupper($name); + if ($picked === $target) { + $matchConfidence = 'exact'; + } elseif (str_starts_with($picked, $target) || str_contains($picked, $target)) { + $matchConfidence = 'close'; + } + } + } else { + $matchConfidence = 'exact'; + } + + if (empty($row)) { + return []; + } + + return [ + 'genericname' => $genericField !== null ? trim((string) ($row[$genericField] ?? '')) : '', + 'salt_name' => $saltField !== null ? trim((string) ($row[$saltField] ?? '')) : '', + 'dosage_restriction' => $restrictionField !== null ? trim((string) ($row[$restrictionField] ?? '')) : '', + 'caution_note' => '', + 'match_confidence' => $matchConfidence, + 'matched_item_name' => trim((string) ($row[$nameField] ?? '')), + ]; + } + + /** + * @return array + */ + private function inferMedicineDetailsFromBrandName(string $name, string $formulation = ''): array + { + $text = strtoupper(trim($name)); + if ($text === '') { + return []; + } + + preg_match('/(\d{2,4})\s*MG/i', $name, $m); + $strength = isset($m[1]) ? trim((string) $m[1]) : ''; + + $map = [ + 'DOLO' => 'Paracetamol', + 'CROCIN' => 'Paracetamol', + 'CALPOL' => 'Paracetamol', + 'PARACIP' => 'Paracetamol', + 'PANTOCID' => 'Pantoprazole', + 'PAN' => 'Pantoprazole', + 'AZEE' => 'Azithromycin', + 'AZTOR' => 'Atorvastatin', + 'MONTAIR' => 'Montelukast', + 'LEVOCET' => 'Levocetirizine', + 'AUGMENTIN' => 'Amoxicillin + Clavulanic Acid', + ]; + + $generic = ''; + foreach ($map as $brand => $gen) { + if (str_contains($text, $brand)) { + $generic = $gen; + break; + } + } + + if ($generic === '') { + return []; + } + + $salt = $generic; + if ($strength !== '') { + if ($generic === 'Amoxicillin + Clavulanic Acid' && $strength === '625') { + $salt = 'Amoxicillin 500 mg + Clavulanic Acid 125 mg'; + } else { + $salt = $generic . ' ' . $strength . ' mg'; + } + } + + $doseRestriction = ''; + if ($generic === 'Paracetamol') { + $doseRestriction = 'Adults: usually max 4 g/day total from all paracetamol-containing products.'; + } elseif ($generic === 'Pantoprazole') { + $doseRestriction = 'Usually once daily before food unless specifically advised otherwise.'; + } elseif ($generic === 'Azithromycin') { + $doseRestriction = 'Follow fixed daily schedule and complete full course.'; + } + + return [ + 'genericname' => $generic, + 'salt_name' => $salt, + 'dosage_restriction' => $doseRestriction, + 'caution_note' => '', + ]; + } + public function opd_medicince_remove(int $medId) { $table = $this->findExistingTable(['opd_med_master']); diff --git a/app/Controllers/Report.php b/app/Controllers/Report.php index 4caebc2..8be5e74 100644 --- a/app/Controllers/Report.php +++ b/app/Controllers/Report.php @@ -344,6 +344,130 @@ class Report extends BaseController ]); } + public function document_list() + { + $doctors = $this->db->table('doctor_master') + ->select('id, p_fname') + ->where('active', 1) + ->orderBy('p_fname', 'ASC') + ->get() + ->getResult(); + + return view('report/document_list', [ + 'doclist' => $doctors, + ]); + } + + public function document_list_data(string $dateRange, int $drId, int $output = 0) + { + [$minRange, $maxRange] = $this->parseDateRange($dateRange); + $uhidFilter = trim((string) $this->request->getGet('uhid')); + + if (! $this->db->tableExists('patient_doc') || ! $this->db->tableExists('doctor_master') || ! $this->db->tableExists('doc_format_master')) { + $content = '
Document report tables are not available in this database.
'; + return $this->response->setBody($content); + } + + $patientTable = null; + if ($this->db->tableExists('patient_master_exten')) { + $patientTable = 'patient_master_exten'; + } elseif ($this->db->tableExists('patient_master')) { + $patientTable = 'patient_master'; + } + + if ($patientTable === null) { + $content = '
Patient master table not found for Document Issue Report.
'; + return $this->response->setBody($content); + } + + $docFields = $this->db->getFieldNames('patient_doc') ?? []; + $patientFields = $this->db->getFieldNames($patientTable) ?? []; + $doctorFields = $this->db->getFieldNames('doctor_master') ?? []; + $formatFields = $this->db->getFieldNames('doc_format_master') ?? []; + + $dateIssueCol = $this->resolveExistingColumn($docFields, ['date_issue', 'issue_date', 'created_at']); + if ($dateIssueCol === null) { + $content = '
Issue date column was not found in patient_doc table.
'; + return $this->response->setBody($content); + } + + $docPatientFkCol = $this->resolveExistingColumn($docFields, ['p_id', 'patient_id']); + $docDoctorFkCol = $this->resolveExistingColumn($docFields, ['dr_id', 'doc_id', 'doctor_id']); + $docFormatFkCol = $this->resolveExistingColumn($docFields, ['doc_format_id', 'format_id', 'df_id']); + + if ($docPatientFkCol === null || $docDoctorFkCol === null || $docFormatFkCol === null) { + $content = '
Document link columns are missing in patient_doc table.
'; + return $this->response->setBody($content); + } + + $patientPkCol = $this->resolveExistingColumn($patientFields, ['id']); + $patientNameCol = $this->resolveExistingColumn($patientFields, ['p_fname', 'patient_name', 'name']); + $patientRelativeCol = $this->resolveExistingColumn($patientFields, ['p_relative']); + $patientRelativeNameCol = $this->resolveExistingColumn($patientFields, ['p_rname', 'relative_name']); + $patientCodeCol = $this->resolveExistingColumn($patientFields, ['p_code', 'patient_code', 'uhid_no']); + $doctorPkCol = $this->resolveExistingColumn($doctorFields, ['id']); + $doctorNameCol = $this->resolveExistingColumn($doctorFields, ['p_fname', 'name', 'doc_name']); + $formatPkCol = $this->resolveExistingColumn($formatFields, ['df_id', 'id']); + $formatNameCol = $this->resolveExistingColumn($formatFields, ['doc_name', 'name', 'format_name']); + + if ($patientPkCol === null || $patientNameCol === null || $doctorPkCol === null || $doctorNameCol === null || $formatPkCol === null || $formatNameCol === null) { + $content = '
Required patient columns are missing for Document Issue Report.
'; + return $this->response->setBody($content); + } + + try { + $builder = $this->db->table('patient_doc d'); + $builder->select('d.id AS doc_id') + ->select('f.' . $formatNameCol . ' AS doc_name', false) + ->select('doc.' . $doctorNameCol . ' AS dr_name', false) + ->select('doc.' . $doctorPkCol . ' AS dr_id', false) + ->select('p.' . $patientNameCol . ' AS p_fname', false) + ->select('p.' . $patientPkCol . ' AS id', false) + ->select($patientRelativeNameCol !== null ? ('p.' . $patientRelativeNameCol . ' AS p_rname') : "'' AS p_rname", false) + ->select($patientRelativeCol !== null ? ('p.' . $patientRelativeCol . ' AS p_relative') : "'' AS p_relative", false) + ->select($patientCodeCol !== null ? ('p.' . $patientCodeCol . ' AS p_code') : "'' AS p_code", false) + ->select('d.' . $dateIssueCol . ' AS date_issue', false) + ->select("DATE_FORMAT(d." . $dateIssueCol . ", '%d-%m-%Y') AS str_date_issue", false) + ->join($patientTable . ' p', 'p.' . $patientPkCol . '=d.' . $docPatientFkCol, 'inner') + ->join('doctor_master doc', 'd.' . $docDoctorFkCol . '=doc.' . $doctorPkCol, 'inner') + ->join('doc_format_master f', 'd.' . $docFormatFkCol . '=f.' . $formatPkCol, 'inner') + ->where('d.' . $dateIssueCol . ' >=', $minRange) + ->where('d.' . $dateIssueCol . ' <=', $maxRange) + ->orderBy('d.' . $dateIssueCol, 'DESC') + ->orderBy('d.id', 'DESC'); + + if ($drId > 0) { + $builder->where('doc.id', $drId); + } + + if ($uhidFilter !== '' && $patientCodeCol !== null) { + $builder->like('p.' . $patientCodeCol, $uhidFilter); + } + + $rows = $builder->get()->getResult(); + } catch (\Throwable $e) { + log_message('error', 'Document Issue Report query failed: {message}', ['message' => $e->getMessage()]); + $content = '
Unable to load Document Issue Report data. Please check database schema.
'; + return $this->response->setBody($content); + } + + $data = [ + 'rows' => $rows, + 'min_range' => $minRange, + 'max_range' => $maxRange, + 'doctor_id' => $drId, + 'uhid_filter' => $uhidFilter, + ]; + + $content = view('report/document_list_table', $data); + if ($output === 1) { + ExportExcel($content, 'document_List_' . date('YmdHis')); + return $this->response->setBody(''); + } + + return $this->response->setBody($content); + } + public function diagnosis_report_data( string $dateRange, string $invoiceType = '0', @@ -739,7 +863,7 @@ class Report extends BaseController [$minRange, $maxRange] = $this->parseDateRange($dateRange); $module = strtolower(trim($module)); - if (! in_array($module, ['all', 'ipd', 'opd'], true)) { + if (! in_array($module, ['all', 'ipd', 'opd', 'radiology'], true)) { $module = 'all'; } @@ -759,7 +883,12 @@ class Report extends BaseController $opdRows = $this->getOpdNabhAuditRows($minRange, $maxRange); } - $rows = array_merge($ipdRows, $opdRows); + $radiologyRows = []; + if ($module === 'all' || $module === 'radiology') { + $radiologyRows = $this->getRadiologyNabhAuditRows($minRange, $maxRange); + } + + $rows = array_merge($ipdRows, $opdRows, $radiologyRows); if ($status === 'critical-missing') { $rows = array_values(array_filter($rows, static function (array $row): bool { @@ -801,12 +930,14 @@ class Report extends BaseController 'all' => ['label' => 'Overall', 'total' => 0, 'compliant' => 0, 'critical_missing' => 0, 'avg_completion' => 0.0], 'ipd' => ['label' => 'IPD Discharge', 'total' => 0, 'compliant' => 0, 'critical_missing' => 0, 'avg_completion' => 0.0], 'opd' => ['label' => 'OPD Consult', 'total' => 0, 'compliant' => 0, 'critical_missing' => 0, 'avg_completion' => 0.0], + 'radiology' => ['label' => 'Radiology Edit', 'total' => 0, 'compliant' => 0, 'critical_missing' => 0, 'avg_completion' => 0.0], ]; $completionAccumulator = [ 'all' => 0.0, 'ipd' => 0.0, 'opd' => 0.0, + 'radiology' => 0.0, ]; foreach ($rows as $row) { @@ -1187,6 +1318,118 @@ class Report extends BaseController return $finalRows; } + private function getRadiologyNabhAuditRows(string $minRange, string $maxRange): array + { + if (! $this->db->tableExists('lab_log')) { + return []; + } + + $logFields = $this->db->getFieldNames('lab_log') ?? []; + foreach (['lab_repo_id', 'log_insert_time', 'log_type', 'log_Faults', 'comments'] as $requiredField) { + if (! in_array($requiredField, $logFields, true)) { + return []; + } + } + + $builder = $this->db->table('lab_log lg') + ->select('lg.lab_repo_id as encounter_id') + ->select('lg.log_insert_time as encounter_datetime') + ->select('lg.log_by as edited_by') + ->select('lg.comments as comments') + ->where('lg.log_type', 'Report Edit') + ->where('lg.log_Faults', 'Radiology') + ->where('lg.log_insert_time >=', $minRange) + ->where('lg.log_insert_time <=', $maxRange) + ->orderBy('lg.id', 'DESC'); + + if ($this->db->tableExists('lab_request')) { + $labReqFields = $this->db->getFieldNames('lab_request') ?? []; + if (in_array('id', $labReqFields, true)) { + $builder->join('lab_request lr', 'lr.id = lg.lab_repo_id', 'left'); + + if (in_array('report_name', $labReqFields, true)) { + $builder->select('lr.report_name as report_name'); + } else { + $builder->select("'' as report_name", false); + } + + if (in_array('patient_id', $labReqFields, true) && $this->db->tableExists('patient_master')) { + $patientFields = $this->db->getFieldNames('patient_master') ?? []; + if (in_array('id', $patientFields, true)) { + $builder->join('patient_master p', 'p.id = lr.patient_id', 'left'); + if (in_array('p_code', $patientFields, true)) { + $builder->select('p.p_code as patient_code'); + } else { + $builder->select("'' as patient_code", false); + } + if (in_array('p_fname', $patientFields, true)) { + $builder->select('p.p_fname as patient_name'); + } else { + $builder->select("'' as patient_name", false); + } + } + } else { + $builder->select("'' as patient_code", false); + $builder->select("'' as patient_name", false); + } + } + } + + $resultRows = $builder->get()->getResultArray(); + $finalRows = []; + + foreach ($resultRows as $row) { + $reason = $this->extractEditReasonFromLabLogComment((string) ($row['comments'] ?? '')); + $hasReason = $reason !== '' && strtolower($reason) !== 'na'; + $encounterCode = trim((string) ($row['report_name'] ?? '')); + if ($encounterCode === '') { + $encounterCode = 'REQ#' . (int) ($row['encounter_id'] ?? 0); + } + + $finalRows[] = [ + 'module_key' => 'radiology', + 'module_label' => 'Radiology Edit', + 'encounter_id' => (int) ($row['encounter_id'] ?? 0), + 'encounter_code' => $encounterCode, + 'patient_code' => (string) ($row['patient_code'] ?? ''), + 'patient_name' => (string) ($row['patient_name'] ?? ''), + 'encounter_datetime' => (string) ($row['encounter_datetime'] ?? ''), + 'ok_count' => $hasReason ? 1 : 0, + 'total_count' => 1, + 'completion_percent' => $hasReason ? 100.0 : 0.0, + 'critical_missing_count' => $hasReason ? 0 : 1, + 'critical_missing_labels' => $hasReason ? '-' : 'Edit reason missing', + ]; + } + + return $finalRows; + } + + private function extractEditReasonFromLabLogComment(string $comment): string + { + $comment = trim($comment); + if ($comment === '') { + return ''; + } + + if (preg_match('/\[reason:(.*?)(?:\]\s*\[|\]$)/i', $comment, $matches) === 1) { + return trim((string) ($matches[1] ?? '')); + } + + $startPos = stripos($comment, '[reason:'); + if ($startPos === false) { + return ''; + } + + $raw = substr($comment, $startPos + 8); + $beforePos = stripos($raw, '[before:'); + if ($beforePos !== false) { + $raw = substr($raw, 0, $beforePos); + } + + return trim(str_replace(']', '', $raw)); + } + private function buildOpdChecklistForAudit(array $row, array $availableCols): array { $hasComplaints = $this->rowHasAnyNonEmptyValue($row, ['complaints']); diff --git a/app/Controllers/Setting/HospitalProfile.php b/app/Controllers/Setting/HospitalProfile.php new file mode 100644 index 0000000..6087c74 --- /dev/null +++ b/app/Controllers/Setting/HospitalProfile.php @@ -0,0 +1,311 @@ +canManageHospitalProfile()) { + return $this->response->setStatusCode(403)->setBody('Access denied'); + } + + $logo = $this->readSettingValue('H_logo'); + $pharmacyLogo = $this->readSettingValue('H_Med_logo'); + + return view('Setting/Admin/hospital_profile', [ + 'hospital_name' => $this->readSettingValue('H_Name'), + 'hospital_address_1' => $this->readSettingValue('H_address_1'), + 'hospital_address_2' => $this->readSettingValue('H_address_2'), + 'hospital_phone' => $this->readSettingValue('H_phone_No'), + 'hospital_email' => $this->readSettingValue('H_Email'), + 'hospital_logo' => $logo, + 'hospital_logo_url' => $logo !== '' ? base_url('assets/images/' . rawurlencode($logo)) : '', + 'pharmacy_name' => $this->readSettingValue('H_Med_Name'), + 'pharmacy_address' => $this->readSettingValue('H_Med_address_1'), + 'pharmacy_phone' => $this->readSettingValue('H_Med_phone_No'), + 'pharmacy_gst' => $this->readSettingValue('H_Med_GST'), + 'pharmacy_logo' => $pharmacyLogo, + 'pharmacy_logo_url' => $pharmacyLogo !== '' ? base_url('assets/images/' . rawurlencode($pharmacyLogo)) : '', + ]); + } + + public function save() + { + if (! $this->request->isAJAX()) { + return $this->response->setJSON(['update' => 0, 'error_text' => 'Invalid request']); + } + + if (! $this->canManageHospitalProfile()) { + return $this->response->setStatusCode(403)->setJSON(['update' => 0, 'error_text' => 'Access denied']); + } + + if (! $this->db->tableExists('hospital_setting')) { + return $this->response->setJSON(['update' => 0, 'error_text' => 'hospital_setting table not found']); + } + + $name = trim((string) $this->request->getPost('hospital_name')); + $address = trim((string) $this->request->getPost('hospital_address_1')); + $address2 = trim((string) $this->request->getPost('hospital_address_2')); + $phone = trim((string) $this->request->getPost('hospital_phone')); + $email = trim((string) $this->request->getPost('hospital_email')); + + $pharmacyName = trim((string) $this->request->getPost('pharmacy_name')); + $pharmacyAddress = trim((string) $this->request->getPost('pharmacy_address')); + $pharmacyPhone = trim((string) $this->request->getPost('pharmacy_phone')); + $pharmacyGst = trim((string) $this->request->getPost('pharmacy_gst')); + + if ($name === '' || $address === '') { + return $this->response->setJSON([ + 'update' => 0, + 'error_text' => 'Hospital name and address are required.', + 'csrfName' => csrf_token(), + 'csrfHash' => csrf_hash(), + ]); + } + + $savedCount = 0; + if ($this->upsertSettingValue('H_Name', $name)) { + $savedCount++; + } + if ($this->upsertSettingValue('H_address_1', $address)) { + $savedCount++; + } + if ($this->upsertSettingValue('H_address_2', $address2)) { + $savedCount++; + } + if ($this->upsertSettingValue('H_phone_No', $phone)) { + $savedCount++; + } + if ($this->upsertSettingValue('H_Email', $email)) { + $savedCount++; + } + if ($this->upsertSettingValue('H_Med_Name', $pharmacyName)) { + $savedCount++; + } + if ($this->upsertSettingValue('H_Med_address_1', $pharmacyAddress)) { + $savedCount++; + } + if ($this->upsertSettingValue('H_Med_phone_No', $pharmacyPhone)) { + $savedCount++; + } + if ($this->upsertSettingValue('H_Med_GST', $pharmacyGst)) { + $savedCount++; + } + + $logoFile = $this->request->getFile('hospital_logo'); + if ($logoFile && $logoFile->isValid() && ! $logoFile->hasMoved()) { + $ext = strtolower((string) $logoFile->getExtension()); + $allowed = ['png', 'jpg', 'jpeg', 'webp']; + if (! in_array($ext, $allowed, true)) { + return $this->response->setJSON([ + 'update' => 0, + 'error_text' => 'Logo must be png, jpg, jpeg, or webp.', + 'csrfName' => csrf_token(), + 'csrfHash' => csrf_hash(), + ]); + } + + $targetDir = FCPATH . 'assets/images'; + if (! is_dir($targetDir)) { + @mkdir($targetDir, 0775, true); + } + + $newName = 'hospital_logo_' . date('Ymd_His') . '_' . substr(md5((string) mt_rand()), 0, 8) . '.' . $ext; + $logoFile->move($targetDir, $newName, true); + + $oldLogo = $this->readSettingValue('H_logo'); + if ($this->upsertSettingValue('H_logo', $newName)) { + $savedCount++; + } + + if ($oldLogo !== '' && $oldLogo !== $newName) { + $oldPath = $targetDir . DIRECTORY_SEPARATOR . basename($oldLogo); + if (is_file($oldPath)) { + @unlink($oldPath); + } + } + } + + $pharmacyLogoFile = $this->request->getFile('pharmacy_logo'); + if ($pharmacyLogoFile && $pharmacyLogoFile->isValid() && ! $pharmacyLogoFile->hasMoved()) { + $ext = strtolower((string) $pharmacyLogoFile->getExtension()); + $allowed = ['png', 'jpg', 'jpeg', 'webp']; + if (! in_array($ext, $allowed, true)) { + return $this->response->setJSON([ + 'update' => 0, + 'error_text' => 'Pharmacy logo must be png, jpg, jpeg, or webp.', + 'csrfName' => csrf_token(), + 'csrfHash' => csrf_hash(), + ]); + } + + $targetDir = FCPATH . 'assets/images'; + if (! is_dir($targetDir)) { + @mkdir($targetDir, 0775, true); + } + + $newName = 'pharmacy_logo_' . date('Ymd_His') . '_' . substr(md5((string) mt_rand()), 0, 8) . '.' . $ext; + $pharmacyLogoFile->move($targetDir, $newName, true); + + $oldLogo = $this->readSettingValue('H_Med_logo'); + if ($this->upsertSettingValue('H_Med_logo', $newName)) { + $savedCount++; + } + + if ($oldLogo !== '' && $oldLogo !== $newName) { + $oldPath = $targetDir . DIRECTORY_SEPARATOR . basename($oldLogo); + if (is_file($oldPath)) { + @unlink($oldPath); + } + } + } + + return $this->response->setJSON([ + 'update' => 1, + 'error_text' => $savedCount > 0 ? 'Hospital profile saved successfully.' : 'No changes detected.', + 'logo_url' => ($logo = $this->readSettingValue('H_logo')) !== '' ? base_url('assets/images/' . rawurlencode($logo)) : '', + 'logo_name' => $this->readSettingValue('H_logo'), + 'pharmacy_logo_url' => ($logo = $this->readSettingValue('H_Med_logo')) !== '' ? base_url('assets/images/' . rawurlencode($logo)) : '', + 'pharmacy_logo_name' => $this->readSettingValue('H_Med_logo'), + 'csrfName' => csrf_token(), + 'csrfHash' => csrf_hash(), + ]); + } + + public function deleteLogo() + { + if (! $this->request->isAJAX()) { + return $this->response->setJSON(['update' => 0, 'error_text' => 'Invalid request']); + } + + if (! $this->canManageHospitalProfile()) { + return $this->response->setStatusCode(403)->setJSON(['update' => 0, 'error_text' => 'Access denied']); + } + + $type = strtolower(trim((string) $this->request->getPost('type'))); + if ($type !== 'pharmacy') { + $type = 'hospital'; + } + + $settingKey = $type === 'pharmacy' ? 'H_Med_logo' : 'H_logo'; + $oldLogo = $this->readSettingValue($settingKey); + $ok = $this->upsertSettingValue($settingKey, ''); + + if ($oldLogo !== '') { + $oldPath = FCPATH . 'assets/images/' . basename($oldLogo); + if (is_file($oldPath)) { + @unlink($oldPath); + } + } + + return $this->response->setJSON([ + 'update' => $ok ? 1 : 0, + 'error_text' => $ok ? ucfirst($type) . ' logo deleted.' : 'Unable to delete logo.', + 'csrfName' => csrf_token(), + 'csrfHash' => csrf_hash(), + ]); + } + + public function reset() + { + if (! $this->request->isAJAX()) { + return $this->response->setJSON(['update' => 0, 'error_text' => 'Invalid request']); + } + + if (! $this->canManageHospitalProfile()) { + return $this->response->setStatusCode(403)->setJSON(['update' => 0, 'error_text' => 'Access denied']); + } + + $logo = $this->readSettingValue('H_logo'); + $pharmacyLogo = $this->readSettingValue('H_Med_logo'); + $this->db->table('hospital_setting')->whereIn('s_name', [ + 'H_Name', + 'H_address_1', + 'H_address_2', + 'H_phone_No', + 'H_Email', + 'H_logo', + 'H_Med_Name', + 'H_Med_address_1', + 'H_Med_phone_No', + 'H_Med_GST', + 'H_Med_logo', + ])->delete(); + + if ($logo !== '') { + $logoPath = FCPATH . 'assets/images/' . basename($logo); + if (is_file($logoPath)) { + @unlink($logoPath); + } + } + + if ($pharmacyLogo !== '') { + $logoPath = FCPATH . 'assets/images/' . basename($pharmacyLogo); + if (is_file($logoPath)) { + @unlink($logoPath); + } + } + + return $this->response->setJSON([ + 'update' => 1, + 'error_text' => 'Hospital profile settings reset.', + 'csrfName' => csrf_token(), + 'csrfHash' => csrf_hash(), + ]); + } + + private function canManageHospitalProfile(): bool + { + if (! function_exists('auth') || ! auth()->loggedIn()) { + return false; + } + + return true; + } + + private function readSettingValue(string $name): string + { + if (! $this->db->tableExists('hospital_setting')) { + return ''; + } + + $row = $this->db->table('hospital_setting') + ->select('s_value') + ->where('s_name', $name) + ->get(1) + ->getRowArray(); + + return trim((string) ($row['s_value'] ?? '')); + } + + private function upsertSettingValue(string $name, string $value): bool + { + $existing = $this->db->table('hospital_setting') + ->select('id, s_value') + ->where('s_name', $name) + ->get(1) + ->getRowArray(); + + $oldValue = trim((string) ($existing['s_value'] ?? '')); + + if ($existing) { + $ok = $this->db->table('hospital_setting') + ->where('id', (int) ($existing['id'] ?? 0)) + ->update(['s_value' => $value]); + } else { + $ok = $this->db->table('hospital_setting')->insert([ + 's_name' => $name, + 's_value' => $value, + ]); + } + + if ($ok) { + $this->auditClinicalUpdate('hospital_setting', $name, $name, $oldValue, $value); + } + + return (bool) $ok; + } +} diff --git a/app/Controllers/Setting/Template.php b/app/Controllers/Setting/Template.php index 1f0ab5c..639415a 100644 --- a/app/Controllers/Setting/Template.php +++ b/app/Controllers/Setting/Template.php @@ -798,10 +798,10 @@ class Template extends BaseController 'modality' => $modality, 'template_name' => $templateName, 'page_size' => trim((string) ($this->request->getPost('page_size') ?? 'A4')) ?: 'A4', - 'page_margin_top_cm' => $this->normalizeMarginCm($this->request->getPost('page_margin_top_cm'), 1.2), - 'page_margin_bottom_cm' => $this->normalizeMarginCm($this->request->getPost('page_margin_bottom_cm'), 1.2), - 'page_margin_left_cm' => $this->normalizeMarginCm($this->request->getPost('page_margin_left_cm'), 1.0), - 'page_margin_right_cm' => $this->normalizeMarginCm($this->request->getPost('page_margin_right_cm'), 1.0), + 'page_margin_top_cm' => $this->normalizeMarginCm($this->request->getPost('page_margin_top_cm'), 6.1), + 'page_margin_bottom_cm' => $this->normalizeMarginCm($this->request->getPost('page_margin_bottom_cm'), 2.5), + 'page_margin_left_cm' => $this->normalizeMarginCm($this->request->getPost('page_margin_left_cm'), 0.7), + 'page_margin_right_cm' => $this->normalizeMarginCm($this->request->getPost('page_margin_right_cm'), 0.7), 'margin_header_cm' => $this->normalizeMarginCm($this->request->getPost('margin_header_cm'), 0.5), 'margin_footer_cm' => $this->normalizeMarginCm($this->request->getPost('margin_footer_cm'), 1.5), 'page_background_image' => $backgroundPath, @@ -901,6 +901,122 @@ class Template extends BaseController ]); } + public function document_print_settings() + { + if ($resp = $this->requireAnyPermission(['doctor_work.template_workspace.access', 'doctor_work.access', 'template.pathology'])) { + return $resp; + } + + $notice = ''; + $noticeType = 'success'; + $selectedTemplateId = (int) ($this->request->getGet('template_id') ?? 0); + $isNewTemplate = (int) ($this->request->getGet('new') ?? 0) === 1; + + if (! $this->db->tableExists('doc_print_templates')) { + return view('Setting/Template/document_print_settings', [ + 'row' => [], + 'templates' => [], + 'selected_template_id' => 0, + 'notice' => 'doc_print_templates table not found. Please run migration.', + 'notice_type' => 'danger', + 'columns_ready' => false, + ]); + } + + $templateTable = $this->db->table('doc_print_templates'); + + if (strtolower($this->request->getMethod()) === 'post') { + $selectedTemplateId = (int) ($this->request->getPost('template_id') ?? 0); + $existing = []; + + if ($selectedTemplateId > 0) { + $existing = $templateTable + ->where('id', $selectedTemplateId) + ->get(1) + ->getRowArray() ?? []; + } + + $templateName = trim((string) ($this->request->getPost('template_name') ?? '')); + if ($templateName === '') { + $templateName = 'Document Template ' . date('d-m-Y H:i'); + } + + $pageSize = strtoupper(trim((string) ($this->request->getPost('page_size') ?? 'A4'))); + if (! in_array($pageSize, ['A4', 'A4-L', 'LETTER', 'LEGAL'], true)) { + $pageSize = 'A4'; + } + + $data = [ + 'template_name' => $templateName, + 'page_size' => $pageSize, + 'page_margin_top_cm' => $this->normalizeMarginCm($this->request->getPost('page_margin_top_cm'), 6.1), + 'page_margin_bottom_cm' => $this->normalizeMarginCm($this->request->getPost('page_margin_bottom_cm'), 2.5), + 'page_margin_left_cm' => $this->normalizeMarginCm($this->request->getPost('page_margin_left_cm'), 0.7), + 'page_margin_right_cm' => $this->normalizeMarginCm($this->request->getPost('page_margin_right_cm'), 0.7), + 'margin_header_cm' => $this->normalizeMarginCm($this->request->getPost('margin_header_cm'), 0.5), + 'margin_footer_cm' => $this->normalizeMarginCm($this->request->getPost('margin_footer_cm'), 1.5), + 'header_html' => (string) ($this->request->getPost('header_html') ?? ''), + 'footer_html' => (string) ($this->request->getPost('footer_html') ?? ''), + 'is_default' => (int) ($this->request->getPost('is_default') ?? 0) === 1 ? 1 : 0, + 'status' => 1, + ]; + + if ($data['is_default'] === 1) { + $templateTable->set('is_default', 0)->update(); + } + + if (! empty($existing) && $selectedTemplateId > 0) { + $templateTable->where('id', $selectedTemplateId)->update($data); + } else { + $templateTable->insert($data); + $selectedTemplateId = (int) $this->db->insertID(); + } + + $notice = 'Document print template saved.'; + $noticeType = 'success'; + + if ($this->request->isAJAX()) { + return $this->response->setJSON([ + 'status' => 'success', + 'notice' => $notice, + 'notice_type' => $noticeType, + 'selected_template_id' => $selectedTemplateId, + 'csrfName' => csrf_token(), + 'csrfHash' => csrf_hash(), + ]); + } + } + + $templates = $templateTable + ->select('id, template_name, is_default, print_on_type') + ->where('status', 1) + ->orderBy('is_default', 'DESC') + ->orderBy('template_name', 'ASC') + ->get() + ->getResultArray(); + + if (! $isNewTemplate && $selectedTemplateId <= 0 && ! empty($templates)) { + $selectedTemplateId = (int) ($templates[0]['id'] ?? 0); + } + + $row = []; + if ($selectedTemplateId > 0) { + $row = $templateTable + ->where('id', $selectedTemplateId) + ->get(1) + ->getRowArray() ?? []; + } + + return view('Setting/Template/document_print_settings', [ + 'row' => $row, + 'templates' => $templates, + 'selected_template_id' => $selectedTemplateId, + 'notice' => $notice, + 'notice_type' => $noticeType, + 'columns_ready' => true, + ]); + } + private function normalizeWatermarkAlpha($rawValue): float { if ($rawValue === null || $rawValue === '') { diff --git a/app/Database/Migrations/2026-03-10-000011_CreateFinancePhase1Tables.php b/app/Database/Migrations/2026-03-10-000011_CreateFinancePhase1Tables.php new file mode 100644 index 0000000..531d512 --- /dev/null +++ b/app/Database/Migrations/2026-03-10-000011_CreateFinancePhase1Tables.php @@ -0,0 +1,284 @@ +db->query('SHOW TABLES LIKE ' . $this->db->escape($table))->getRowArray(); + + return ! empty($row); + } + + public function up() + { + if (! $this->hasTable('finance_vendors')) { + $this->forge->addField([ + 'id' => [ + 'type' => 'INT', + 'constraint' => 11, + 'unsigned' => true, + 'auto_increment' => true, + ], + 'vendor_code' => [ + 'type' => 'VARCHAR', + 'constraint' => 30, + 'null' => false, + ], + 'vendor_name' => [ + 'type' => 'VARCHAR', + 'constraint' => 160, + 'null' => false, + ], + 'contact_person' => [ + 'type' => 'VARCHAR', + 'constraint' => 120, + 'null' => true, + ], + 'phone' => [ + 'type' => 'VARCHAR', + 'constraint' => 20, + 'null' => true, + ], + 'email' => [ + 'type' => 'VARCHAR', + 'constraint' => 150, + 'null' => true, + ], + 'gst_no' => [ + 'type' => 'VARCHAR', + 'constraint' => 20, + 'null' => true, + ], + 'pan_no' => [ + 'type' => 'VARCHAR', + 'constraint' => 20, + 'null' => true, + ], + 'address' => [ + 'type' => 'TEXT', + 'null' => true, + ], + 'status' => [ + 'type' => 'TINYINT', + 'constraint' => 1, + 'default' => 1, + ], + 'created_by' => [ + 'type' => 'VARCHAR', + 'constraint' => 120, + 'null' => true, + ], + 'created_at' => [ + 'type' => 'DATETIME', + 'null' => true, + ], + 'updated_at' => [ + 'type' => 'DATETIME', + 'null' => true, + ], + ]); + $this->forge->addKey('id', true); + $this->forge->addUniqueKey('vendor_code'); + $this->forge->addKey('vendor_name'); + $this->forge->createTable('finance_vendors', true); + } + + if (! $this->hasTable('finance_purchase_orders')) { + $this->forge->addField([ + 'id' => [ + 'type' => 'INT', + 'constraint' => 11, + 'unsigned' => true, + 'auto_increment' => true, + ], + 'po_no' => [ + 'type' => 'VARCHAR', + 'constraint' => 40, + 'null' => false, + ], + 'po_date' => [ + 'type' => 'DATE', + 'null' => false, + ], + 'vendor_id' => [ + 'type' => 'INT', + 'constraint' => 11, + 'unsigned' => true, + 'null' => false, + ], + 'department' => [ + 'type' => 'VARCHAR', + 'constraint' => 100, + 'null' => true, + ], + 'amount' => [ + 'type' => 'DECIMAL', + 'constraint' => '12,2', + 'default' => 0, + ], + 'approval_status' => [ + 'type' => 'VARCHAR', + 'constraint' => 20, + 'default' => 'draft', + ], + 'remarks' => [ + 'type' => 'TEXT', + 'null' => true, + ], + 'created_by' => [ + 'type' => 'VARCHAR', + 'constraint' => 120, + 'null' => true, + ], + 'created_at' => [ + 'type' => 'DATETIME', + 'null' => true, + ], + 'updated_at' => [ + 'type' => 'DATETIME', + 'null' => true, + ], + ]); + $this->forge->addKey('id', true); + $this->forge->addUniqueKey('po_no'); + $this->forge->addKey('vendor_id'); + $this->forge->addKey('po_date'); + $this->forge->addKey('approval_status'); + $this->forge->createTable('finance_purchase_orders', true); + } + + if (! $this->hasTable('finance_grns')) { + $this->forge->addField([ + 'id' => [ + 'type' => 'INT', + 'constraint' => 11, + 'unsigned' => true, + 'auto_increment' => true, + ], + 'grn_no' => [ + 'type' => 'VARCHAR', + 'constraint' => 40, + 'null' => false, + ], + 'grn_date' => [ + 'type' => 'DATE', + 'null' => false, + ], + 'po_id' => [ + 'type' => 'INT', + 'constraint' => 11, + 'unsigned' => true, + 'null' => false, + ], + 'received_amount' => [ + 'type' => 'DECIMAL', + 'constraint' => '12,2', + 'default' => 0, + ], + 'received_by' => [ + 'type' => 'VARCHAR', + 'constraint' => 120, + 'null' => true, + ], + 'remarks' => [ + 'type' => 'TEXT', + 'null' => true, + ], + 'created_at' => [ + 'type' => 'DATETIME', + 'null' => true, + ], + 'updated_at' => [ + 'type' => 'DATETIME', + 'null' => true, + ], + ]); + $this->forge->addKey('id', true); + $this->forge->addUniqueKey('grn_no'); + $this->forge->addKey('po_id'); + $this->forge->addKey('grn_date'); + $this->forge->createTable('finance_grns', true); + } + + if (! $this->hasTable('finance_vendor_invoices')) { + $this->forge->addField([ + 'id' => [ + 'type' => 'INT', + 'constraint' => 11, + 'unsigned' => true, + 'auto_increment' => true, + ], + 'invoice_no' => [ + 'type' => 'VARCHAR', + 'constraint' => 40, + 'null' => false, + ], + 'invoice_date' => [ + 'type' => 'DATE', + 'null' => false, + ], + 'vendor_id' => [ + 'type' => 'INT', + 'constraint' => 11, + 'unsigned' => true, + 'null' => false, + ], + 'po_id' => [ + 'type' => 'INT', + 'constraint' => 11, + 'unsigned' => true, + 'null' => true, + ], + 'grn_id' => [ + 'type' => 'INT', + 'constraint' => 11, + 'unsigned' => true, + 'null' => true, + ], + 'invoice_amount' => [ + 'type' => 'DECIMAL', + 'constraint' => '12,2', + 'default' => 0, + ], + 'payment_status' => [ + 'type' => 'VARCHAR', + 'constraint' => 20, + 'default' => 'pending', + ], + 'remarks' => [ + 'type' => 'TEXT', + 'null' => true, + ], + 'created_by' => [ + 'type' => 'VARCHAR', + 'constraint' => 120, + 'null' => true, + ], + 'created_at' => [ + 'type' => 'DATETIME', + 'null' => true, + ], + 'updated_at' => [ + 'type' => 'DATETIME', + 'null' => true, + ], + ]); + $this->forge->addKey('id', true); + $this->forge->addKey(['vendor_id', 'invoice_date']); + $this->forge->addKey('payment_status'); + $this->forge->createTable('finance_vendor_invoices', true); + } + } + + public function down() + { + $this->forge->dropTable('finance_vendor_invoices', true); + $this->forge->dropTable('finance_grns', true); + $this->forge->dropTable('finance_purchase_orders', true); + $this->forge->dropTable('finance_vendors', true); + } +} diff --git a/app/Database/Migrations/2026-03-10-000012_AddFinanceInvoiceMatchColumns.php b/app/Database/Migrations/2026-03-10-000012_AddFinanceInvoiceMatchColumns.php new file mode 100644 index 0000000..1674f2c --- /dev/null +++ b/app/Database/Migrations/2026-03-10-000012_AddFinanceInvoiceMatchColumns.php @@ -0,0 +1,106 @@ +db->query('SHOW TABLES LIKE ' . $this->db->escape($table))->getRowArray(); + + return ! empty($row); + } + + private function hasColumn(string $table, string $column): bool + { + if (! $this->hasTable($table)) { + return false; + } + + $row = $this->db->query( + 'SHOW COLUMNS FROM `' . $table . '` LIKE ' . $this->db->escape($column) + )->getRowArray(); + + return ! empty($row); + } + + public function up() + { + $table = 'finance_vendor_invoices'; + if (! $this->hasTable($table)) { + return; + } + + if (! $this->hasColumn($table, 'match_status')) { + $this->forge->addColumn($table, [ + 'match_status' => [ + 'type' => 'VARCHAR', + 'constraint' => 20, + 'default' => 'not_checked', + 'after' => 'payment_status', + ], + ]); + } + + if (! $this->hasColumn($table, 'variance_amount')) { + $this->forge->addColumn($table, [ + 'variance_amount' => [ + 'type' => 'DECIMAL', + 'constraint' => '12,2', + 'default' => 0, + 'after' => 'match_status', + ], + ]); + } + + if (! $this->hasColumn($table, 'match_note')) { + $this->forge->addColumn($table, [ + 'match_note' => [ + 'type' => 'VARCHAR', + 'constraint' => 255, + 'null' => true, + 'after' => 'variance_amount', + ], + ]); + } + + if (! $this->hasColumn($table, 'is_compliance_hold')) { + $this->forge->addColumn($table, [ + 'is_compliance_hold' => [ + 'type' => 'TINYINT', + 'constraint' => 1, + 'default' => 0, + 'after' => 'match_note', + ], + ]); + } + + if (! $this->hasColumn($table, 'match_checked_at')) { + $this->forge->addColumn($table, [ + 'match_checked_at' => [ + 'type' => 'DATETIME', + 'null' => true, + 'after' => 'is_compliance_hold', + ], + ]); + } + + $this->db->query("UPDATE {$table} SET match_status = 'not_checked' WHERE match_status IS NULL OR match_status = ''"); + } + + public function down() + { + $table = 'finance_vendor_invoices'; + if (! $this->hasTable($table)) { + return; + } + + foreach (['match_checked_at', 'is_compliance_hold', 'match_note', 'variance_amount', 'match_status'] as $column) { + if ($this->hasColumn($table, $column)) { + $this->forge->dropColumn($table, $column); + } + } + } +} diff --git a/app/Database/Migrations/2026-03-10-000013_CreateFinanceCashTables.php b/app/Database/Migrations/2026-03-10-000013_CreateFinanceCashTables.php new file mode 100644 index 0000000..6063f2c --- /dev/null +++ b/app/Database/Migrations/2026-03-10-000013_CreateFinanceCashTables.php @@ -0,0 +1,177 @@ +db->query('SHOW TABLES LIKE ' . $this->db->escape($table))->getRowArray(); + + return ! empty($row); + } + + public function up() + { + if (! $this->hasTable('finance_cash_transactions')) { + $this->forge->addField([ + 'id' => [ + 'type' => 'INT', + 'constraint' => 11, + 'unsigned' => true, + 'auto_increment' => true, + ], + 'txn_date' => [ + 'type' => 'DATE', + 'null' => false, + ], + 'txn_type' => [ + 'type' => 'VARCHAR', + 'constraint' => 20, + 'null' => false, + ], + 'flow_type' => [ + 'type' => 'VARCHAR', + 'constraint' => 20, + 'null' => false, + ], + 'department' => [ + 'type' => 'VARCHAR', + 'constraint' => 80, + 'null' => true, + ], + 'reference_no' => [ + 'type' => 'VARCHAR', + 'constraint' => 60, + 'null' => true, + ], + 'amount' => [ + 'type' => 'DECIMAL', + 'constraint' => '12,2', + 'default' => 0, + ], + 'mode' => [ + 'type' => 'VARCHAR', + 'constraint' => 20, + 'null' => false, + ], + 'party_name' => [ + 'type' => 'VARCHAR', + 'constraint' => 160, + 'null' => true, + ], + 'narration' => [ + 'type' => 'TEXT', + 'null' => true, + ], + 'flag_269st' => [ + 'type' => 'TINYINT', + 'constraint' => 1, + 'default' => 0, + ], + 'flag_40a3' => [ + 'type' => 'TINYINT', + 'constraint' => 1, + 'default' => 0, + ], + 'is_compliance_hold' => [ + 'type' => 'TINYINT', + 'constraint' => 1, + 'default' => 0, + ], + 'compliance_note' => [ + 'type' => 'VARCHAR', + 'constraint' => 255, + 'null' => true, + ], + 'created_by' => [ + 'type' => 'VARCHAR', + 'constraint' => 120, + 'null' => true, + ], + 'created_at' => [ + 'type' => 'DATETIME', + 'null' => true, + ], + 'updated_at' => [ + 'type' => 'DATETIME', + 'null' => true, + ], + ]); + $this->forge->addKey('id', true); + $this->forge->addKey(['txn_date', 'txn_type']); + $this->forge->addKey('department'); + $this->forge->addKey('is_compliance_hold'); + $this->forge->createTable('finance_cash_transactions', true); + } + + if (! $this->hasTable('finance_scroll_submissions')) { + $this->forge->addField([ + 'id' => [ + 'type' => 'INT', + 'constraint' => 11, + 'unsigned' => true, + 'auto_increment' => true, + ], + 'scroll_date' => [ + 'type' => 'DATE', + 'null' => false, + ], + 'department' => [ + 'type' => 'VARCHAR', + 'constraint' => 80, + 'null' => false, + ], + 'total_receipts' => [ + 'type' => 'DECIMAL', + 'constraint' => '12,2', + 'default' => 0, + ], + 'submitted_amount' => [ + 'type' => 'DECIMAL', + 'constraint' => '12,2', + 'default' => 0, + ], + 'variance_amount' => [ + 'type' => 'DECIMAL', + 'constraint' => '12,2', + 'default' => 0, + ], + 'reconciliation_status' => [ + 'type' => 'VARCHAR', + 'constraint' => 20, + 'default' => 'pending', + ], + 'submitted_by' => [ + 'type' => 'VARCHAR', + 'constraint' => 120, + 'null' => true, + ], + 'remarks' => [ + 'type' => 'TEXT', + 'null' => true, + ], + 'created_at' => [ + 'type' => 'DATETIME', + 'null' => true, + ], + 'updated_at' => [ + 'type' => 'DATETIME', + 'null' => true, + ], + ]); + $this->forge->addKey('id', true); + $this->forge->addKey(['scroll_date', 'department']); + $this->forge->addKey('reconciliation_status'); + $this->forge->createTable('finance_scroll_submissions', true); + } + } + + public function down() + { + $this->forge->dropTable('finance_scroll_submissions', true); + $this->forge->dropTable('finance_cash_transactions', true); + } +} diff --git a/app/Database/Migrations/2026-03-10-000014_CreateFinanceDoctorPayoutTables.php b/app/Database/Migrations/2026-03-10-000014_CreateFinanceDoctorPayoutTables.php new file mode 100644 index 0000000..cbd2de3 --- /dev/null +++ b/app/Database/Migrations/2026-03-10-000014_CreateFinanceDoctorPayoutTables.php @@ -0,0 +1,189 @@ +db->query('SHOW TABLES LIKE ' . $this->db->escape($table))->getRowArray(); + + return ! empty($row); + } + + public function up() + { + if (! $this->hasTable('finance_doctor_agreements')) { + $this->forge->addField([ + 'id' => [ + 'type' => 'INT', + 'constraint' => 11, + 'unsigned' => true, + 'auto_increment' => true, + ], + 'doctor_code' => [ + 'type' => 'VARCHAR', + 'constraint' => 40, + 'null' => false, + ], + 'doctor_name' => [ + 'type' => 'VARCHAR', + 'constraint' => 150, + 'null' => false, + ], + 'specialization' => [ + 'type' => 'VARCHAR', + 'constraint' => 120, + 'null' => true, + ], + 'consultation_rate' => [ + 'type' => 'DECIMAL', + 'constraint' => '12,2', + 'default' => 0, + ], + 'surgery_rate' => [ + 'type' => 'DECIMAL', + 'constraint' => '12,2', + 'default' => 0, + ], + 'agreement_start_date' => [ + 'type' => 'DATE', + 'null' => true, + ], + 'agreement_end_date' => [ + 'type' => 'DATE', + 'null' => true, + ], + 'status' => [ + 'type' => 'TINYINT', + 'constraint' => 1, + 'default' => 1, + ], + 'created_by' => [ + 'type' => 'VARCHAR', + 'constraint' => 120, + 'null' => true, + ], + 'created_at' => [ + 'type' => 'DATETIME', + 'null' => true, + ], + 'updated_at' => [ + 'type' => 'DATETIME', + 'null' => true, + ], + ]); + $this->forge->addKey('id', true); + $this->forge->addUniqueKey('doctor_code'); + $this->forge->addKey('doctor_name'); + $this->forge->createTable('finance_doctor_agreements', true); + } + + if (! $this->hasTable('finance_doctor_payouts')) { + $this->forge->addField([ + 'id' => [ + 'type' => 'INT', + 'constraint' => 11, + 'unsigned' => true, + 'auto_increment' => true, + ], + 'payout_date' => [ + 'type' => 'DATE', + 'null' => false, + ], + 'doctor_id' => [ + 'type' => 'INT', + 'constraint' => 11, + 'unsigned' => true, + 'null' => false, + ], + 'case_reference' => [ + 'type' => 'VARCHAR', + 'constraint' => 80, + 'null' => true, + ], + 'payout_type' => [ + 'type' => 'VARCHAR', + 'constraint' => 20, + 'null' => false, + ], + 'units' => [ + 'type' => 'INT', + 'constraint' => 11, + 'default' => 1, + ], + 'rate' => [ + 'type' => 'DECIMAL', + 'constraint' => '12,2', + 'default' => 0, + ], + 'calculated_amount' => [ + 'type' => 'DECIMAL', + 'constraint' => '12,2', + 'default' => 0, + ], + 'approved_amount' => [ + 'type' => 'DECIMAL', + 'constraint' => '12,2', + 'default' => 0, + ], + 'status' => [ + 'type' => 'VARCHAR', + 'constraint' => 30, + 'default' => 'draft', + ], + 'remarks' => [ + 'type' => 'TEXT', + 'null' => true, + ], + 'hr_submitted_by' => [ + 'type' => 'VARCHAR', + 'constraint' => 120, + 'null' => true, + ], + 'finance_approved_by' => [ + 'type' => 'VARCHAR', + 'constraint' => 120, + 'null' => true, + ], + 'finance_approved_at' => [ + 'type' => 'DATETIME', + 'null' => true, + ], + 'ceo_approved_by' => [ + 'type' => 'VARCHAR', + 'constraint' => 120, + 'null' => true, + ], + 'ceo_approved_at' => [ + 'type' => 'DATETIME', + 'null' => true, + ], + 'paid_at' => [ + 'type' => 'DATETIME', + 'null' => true, + ], + 'created_at' => [ + 'type' => 'DATETIME', + 'null' => true, + ], + 'updated_at' => [ + 'type' => 'DATETIME', + 'null' => true, + ], + ]); + $this->forge->addKey('id', true); + $this->forge->addKey(['doctor_id', 'payout_date']); + $this->forge->addKey('status'); + $this->forge->createTable('finance_doctor_payouts', true); + } + } + + public function down() + { + $this->forge->dropTable('finance_doctor_payouts', true); + $this->forge->dropTable('finance_doctor_agreements', true); + } +} diff --git a/app/Database/Migrations/2026-03-10-000015_CreateFinanceDepositAndPolicyTables.php b/app/Database/Migrations/2026-03-10-000015_CreateFinanceDepositAndPolicyTables.php new file mode 100644 index 0000000..97c601f --- /dev/null +++ b/app/Database/Migrations/2026-03-10-000015_CreateFinanceDepositAndPolicyTables.php @@ -0,0 +1,152 @@ +db->query('SHOW TABLES LIKE ' . $this->db->escape($table))->getRowArray(); + + return ! empty($row); + } + + public function up() + { + if (! $this->hasTable('finance_bank_deposits')) { + $this->forge->addField([ + 'id' => [ + 'type' => 'INT', + 'constraint' => 11, + 'unsigned' => true, + 'auto_increment' => true, + ], + 'deposit_date' => [ + 'type' => 'DATE', + 'null' => false, + ], + 'department' => [ + 'type' => 'VARCHAR', + 'constraint' => 80, + 'null' => false, + ], + 'bank_name' => [ + 'type' => 'VARCHAR', + 'constraint' => 120, + 'null' => false, + ], + 'slip_no' => [ + 'type' => 'VARCHAR', + 'constraint' => 80, + 'null' => true, + ], + 'deposited_amount' => [ + 'type' => 'DECIMAL', + 'constraint' => '12,2', + 'default' => 0, + ], + 'related_scroll_id' => [ + 'type' => 'INT', + 'constraint' => 11, + 'unsigned' => true, + 'null' => true, + ], + 'reconciliation_status' => [ + 'type' => 'VARCHAR', + 'constraint' => 20, + 'default' => 'pending', + ], + 'remarks' => [ + 'type' => 'TEXT', + 'null' => true, + ], + 'created_by' => [ + 'type' => 'VARCHAR', + 'constraint' => 120, + 'null' => true, + ], + 'created_at' => [ + 'type' => 'DATETIME', + 'null' => true, + ], + 'updated_at' => [ + 'type' => 'DATETIME', + 'null' => true, + ], + ]); + $this->forge->addKey('id', true); + $this->forge->addKey(['deposit_date', 'department']); + $this->forge->addKey('reconciliation_status'); + $this->forge->createTable('finance_bank_deposits', true); + } + + if (! $this->hasTable('finance_policy_settings')) { + $this->forge->addField([ + 'id' => [ + 'type' => 'INT', + 'constraint' => 11, + 'unsigned' => true, + 'auto_increment' => true, + ], + 'setting_key' => [ + 'type' => 'VARCHAR', + 'constraint' => 80, + 'null' => false, + ], + 'setting_value' => [ + 'type' => 'VARCHAR', + 'constraint' => 120, + 'null' => false, + ], + 'description' => [ + 'type' => 'VARCHAR', + 'constraint' => 255, + 'null' => true, + ], + 'created_at' => [ + 'type' => 'DATETIME', + 'null' => true, + ], + 'updated_at' => [ + 'type' => 'DATETIME', + 'null' => true, + ], + ]); + $this->forge->addKey('id', true); + $this->forge->addUniqueKey('setting_key'); + $this->forge->createTable('finance_policy_settings', true); + } + + $this->seedSetting('petty_cash_daily_limit', '50000', 'Daily petty cash disbursement limit per department'); + $this->seedSetting('safe_cash_max_limit', '500000', 'Maximum recommended physical cash retention in safe'); + } + + public function down() + { + $this->forge->dropTable('finance_policy_settings', true); + $this->forge->dropTable('finance_bank_deposits', true); + } + + private function seedSetting(string $key, string $value, string $description): void + { + if (! $this->hasTable('finance_policy_settings')) { + return; + } + + $exists = $this->db->table('finance_policy_settings')->where('setting_key', $key)->countAllResults(); + if ($exists > 0) { + return; + } + + $now = date('Y-m-d H:i:s'); + $this->db->table('finance_policy_settings')->insert([ + 'setting_key' => $key, + 'setting_value' => $value, + 'description' => $description, + 'created_at' => $now, + 'updated_at' => $now, + ]); + } +} diff --git a/app/Database/Migrations/2026-03-15-000020_AddDiagnosisTemplateMarginsCm.php b/app/Database/Migrations/2026-03-15-000020_AddDiagnosisTemplateMarginsCm.php index b6402b9..fc18ab2 100644 --- a/app/Database/Migrations/2026-03-15-000020_AddDiagnosisTemplateMarginsCm.php +++ b/app/Database/Migrations/2026-03-15-000020_AddDiagnosisTemplateMarginsCm.php @@ -37,7 +37,7 @@ class AddDiagnosisTemplateMarginsCm extends Migration 'type' => 'decimal', 'constraint' => '6,2', 'null' => true, - 'default' => '1.20', + 'default' => '6.10', 'after' => 'page_size', ]; } @@ -46,7 +46,7 @@ class AddDiagnosisTemplateMarginsCm extends Migration 'type' => 'decimal', 'constraint' => '6,2', 'null' => true, - 'default' => '1.20', + 'default' => '2.50', 'after' => 'page_margin_top_cm', ]; } @@ -55,7 +55,7 @@ class AddDiagnosisTemplateMarginsCm extends Migration 'type' => 'decimal', 'constraint' => '6,2', 'null' => true, - 'default' => '1.00', + 'default' => '0.70', 'after' => 'page_margin_bottom_cm', ]; } @@ -64,7 +64,7 @@ class AddDiagnosisTemplateMarginsCm extends Migration 'type' => 'decimal', 'constraint' => '6,2', 'null' => true, - 'default' => '1.00', + 'default' => '0.70', 'after' => 'page_margin_left_cm', ]; } diff --git a/app/Database/Migrations/2026-03-15-000021_CreateDoctorDocumentTables.php b/app/Database/Migrations/2026-03-15-000021_CreateDoctorDocumentTables.php new file mode 100644 index 0000000..6cc8d94 --- /dev/null +++ b/app/Database/Migrations/2026-03-15-000021_CreateDoctorDocumentTables.php @@ -0,0 +1,220 @@ +db->tableExists('doc_format_master')) { + $this->forge->addField([ + 'df_id' => [ + 'type' => 'INT', + 'constraint' => 11, + 'unsigned' => true, + 'auto_increment' => true, + ], + 'doc_name' => [ + 'type' => 'VARCHAR', + 'constraint' => 150, + 'null' => false, + ], + 'doc_desc' => [ + 'type' => 'VARCHAR', + 'constraint' => 255, + 'null' => false, + 'default' => '', + ], + 'doc_raw_format' => [ + 'type' => 'LONGTEXT', + 'null' => false, + ], + 'active' => [ + 'type' => 'TINYINT', + 'constraint' => 1, + 'default' => 1, + ], + 'created_at' => [ + 'type' => 'DATETIME', + 'null' => true, + ], + 'updated_at' => [ + 'type' => 'DATETIME', + 'null' => true, + ], + ]); + $this->forge->addKey('df_id', true); + $this->forge->addKey('active'); + $this->forge->createTable('doc_format_master', true); + } + + if (! $this->db->tableExists('doc_format_sub')) { + $this->forge->addField([ + 'id' => [ + 'type' => 'INT', + 'constraint' => 11, + 'unsigned' => true, + 'auto_increment' => true, + ], + 'doc_format_id' => [ + 'type' => 'INT', + 'constraint' => 11, + 'unsigned' => true, + ], + 'input_name' => [ + 'type' => 'VARCHAR', + 'constraint' => 120, + 'null' => false, + ], + 'input_code' => [ + 'type' => 'VARCHAR', + 'constraint' => 80, + 'null' => false, + ], + 'input_type' => [ + 'type' => 'VARCHAR', + 'constraint' => 20, + 'null' => false, + 'default' => 'text', + ], + 'input_default_value' => [ + 'type' => 'TEXT', + 'null' => true, + ], + 'short_order' => [ + 'type' => 'INT', + 'constraint' => 11, + 'default' => 1, + ], + 'active' => [ + 'type' => 'TINYINT', + 'constraint' => 1, + 'default' => 1, + ], + 'created_at' => [ + 'type' => 'DATETIME', + 'null' => true, + ], + 'updated_at' => [ + 'type' => 'DATETIME', + 'null' => true, + ], + ]); + $this->forge->addKey('id', true); + $this->forge->addKey('doc_format_id'); + $this->forge->addKey(['doc_format_id', 'input_code']); + $this->forge->createTable('doc_format_sub', true); + } + + if (! $this->db->tableExists('patient_doc')) { + $this->forge->addField([ + 'id' => [ + 'type' => 'INT', + 'constraint' => 11, + 'unsigned' => true, + 'auto_increment' => true, + ], + 'p_id' => [ + 'type' => 'INT', + 'constraint' => 11, + 'unsigned' => true, + ], + 'doc_format_id' => [ + 'type' => 'INT', + 'constraint' => 11, + 'unsigned' => true, + ], + 'dr_id' => [ + 'type' => 'INT', + 'constraint' => 11, + 'unsigned' => true, + 'default' => 0, + ], + 'date_issue' => [ + 'type' => 'DATE', + 'null' => true, + ], + 'raw_data' => [ + 'type' => 'LONGTEXT', + 'null' => false, + ], + 'update_pre_value' => [ + 'type' => 'TINYINT', + 'constraint' => 1, + 'default' => 0, + ], + 'created_at' => [ + 'type' => 'DATETIME', + 'null' => true, + ], + 'updated_at' => [ + 'type' => 'DATETIME', + 'null' => true, + ], + ]); + $this->forge->addKey('id', true); + $this->forge->addKey('p_id'); + $this->forge->addKey('doc_format_id'); + $this->forge->addKey('dr_id'); + $this->forge->createTable('patient_doc', true); + } + + if (! $this->db->tableExists('patient_doc_raw')) { + $this->forge->addField([ + 'id' => [ + 'type' => 'INT', + 'constraint' => 11, + 'unsigned' => true, + 'auto_increment' => true, + ], + 'p_id' => [ + 'type' => 'INT', + 'constraint' => 11, + 'unsigned' => true, + ], + 'p_doc_id' => [ + 'type' => 'INT', + 'constraint' => 11, + 'unsigned' => true, + ], + 'p_doc_sub_id' => [ + 'type' => 'INT', + 'constraint' => 11, + 'unsigned' => true, + ], + 'p_doc_raw_value' => [ + 'type' => 'TEXT', + 'null' => true, + ], + 'update_data' => [ + 'type' => 'TINYINT', + 'constraint' => 1, + 'default' => 0, + ], + 'created_at' => [ + 'type' => 'DATETIME', + 'null' => true, + ], + 'updated_at' => [ + 'type' => 'DATETIME', + 'null' => true, + ], + ]); + $this->forge->addKey('id', true); + $this->forge->addKey('p_doc_id'); + $this->forge->addKey('p_doc_sub_id'); + $this->forge->addKey('p_id'); + $this->forge->createTable('patient_doc_raw', true); + } + } + + public function down() + { + $this->forge->dropTable('patient_doc_raw', true); + $this->forge->dropTable('patient_doc', true); + $this->forge->dropTable('doc_format_sub', true); + $this->forge->dropTable('doc_format_master', true); + } +} diff --git a/app/Database/Migrations/2026-03-15-000022_AddDefaultPrintTypeToDocFormatMaster.php b/app/Database/Migrations/2026-03-15-000022_AddDefaultPrintTypeToDocFormatMaster.php new file mode 100644 index 0000000..bab1e37 --- /dev/null +++ b/app/Database/Migrations/2026-03-15-000022_AddDefaultPrintTypeToDocFormatMaster.php @@ -0,0 +1,49 @@ +db->query("SHOW TABLES LIKE '" . $safeTable . "'")->getRowArray(); + return is_array($row); + } + + private function hasColumn(string $table, string $column): bool + { + $safeTable = preg_replace('/[^A-Za-z0-9_]/', '', $table) ?? ''; + $safeColumn = preg_replace('/[^A-Za-z0-9_]/', '', $column) ?? ''; + $row = $this->db->query("SHOW COLUMNS FROM `" . $safeTable . "` LIKE '" . $safeColumn . "'")->getRowArray(); + return is_array($row); + } + + public function up() + { + if (! $this->hasTable('doc_format_master')) { + return; + } + + if (! $this->hasColumn('doc_format_master', 'default_print_type')) { + $this->forge->addColumn('doc_format_master', [ + 'default_print_type' => [ + 'type' => 'TINYINT', + 'constraint' => 1, + 'default' => 0, + 'null' => false, + 'after' => 'doc_raw_format', + ], + ]); + } + } + + public function down() + { + if ($this->hasTable('doc_format_master') && $this->hasColumn('doc_format_master', 'default_print_type')) { + $this->forge->dropColumn('doc_format_master', 'default_print_type'); + } + } +} diff --git a/app/Database/Migrations/2026-03-15-000023_AddPrintMarginsToDocFormatMaster.php b/app/Database/Migrations/2026-03-15-000023_AddPrintMarginsToDocFormatMaster.php new file mode 100644 index 0000000..d44c3d1 --- /dev/null +++ b/app/Database/Migrations/2026-03-15-000023_AddPrintMarginsToDocFormatMaster.php @@ -0,0 +1,103 @@ +db->query("SHOW TABLES LIKE '" . $safeTable . "'")->getRowArray(); + return is_array($row); + } + + private function hasColumn(string $table, string $column): bool + { + $safeTable = preg_replace('/[^A-Za-z0-9_]/', '', $table) ?? ''; + $safeColumn = preg_replace('/[^A-Za-z0-9_]/', '', $column) ?? ''; + $row = $this->db->query("SHOW COLUMNS FROM `" . $safeTable . "` LIKE '" . $safeColumn . "'")->getRowArray(); + return is_array($row); + } + + public function up() + { + if (! $this->hasTable('doc_format_master')) { + return; + } + + $columns = [ + 'print_top_margin' => [ + 'type' => 'DECIMAL', + 'constraint' => '5,2', + 'default' => 6.10, + 'null' => false, + 'after' => 'default_print_type', + ], + 'print_bottom_margin' => [ + 'type' => 'DECIMAL', + 'constraint' => '5,2', + 'default' => 2.50, + 'null' => false, + 'after' => 'print_top_margin', + ], + 'print_left_margin' => [ + 'type' => 'DECIMAL', + 'constraint' => '5,2', + 'default' => 0.70, + 'null' => false, + 'after' => 'print_bottom_margin', + ], + 'print_right_margin' => [ + 'type' => 'DECIMAL', + 'constraint' => '5,2', + 'default' => 0.70, + 'null' => false, + 'after' => 'print_left_margin', + ], + 'print_header_margin' => [ + 'type' => 'DECIMAL', + 'constraint' => '5,2', + 'default' => 0.50, + 'null' => false, + 'after' => 'print_right_margin', + ], + 'print_footer_margin' => [ + 'type' => 'DECIMAL', + 'constraint' => '5,2', + 'default' => 1.50, + 'null' => false, + 'after' => 'print_header_margin', + ], + ]; + + foreach ($columns as $column => $definition) { + if (! $this->hasColumn('doc_format_master', $column)) { + $this->forge->addColumn('doc_format_master', [$column => $definition]); + } + } + } + + public function down() + { + if (! $this->hasTable('doc_format_master')) { + return; + } + + $columns = [ + 'print_footer_margin', + 'print_header_margin', + 'print_right_margin', + 'print_left_margin', + 'print_bottom_margin', + 'print_top_margin', + ]; + + foreach ($columns as $column) { + if ($this->hasColumn('doc_format_master', $column)) { + $this->forge->dropColumn('doc_format_master', $column); + } + } + } +} diff --git a/app/Database/Migrations/2026-03-15-000024_CreateDoctorDocumentPrintTemplates.php b/app/Database/Migrations/2026-03-15-000024_CreateDoctorDocumentPrintTemplates.php new file mode 100644 index 0000000..0e3ad61 --- /dev/null +++ b/app/Database/Migrations/2026-03-15-000024_CreateDoctorDocumentPrintTemplates.php @@ -0,0 +1,122 @@ +db->query("SHOW TABLES LIKE '" . $safeTable . "'")->getRowArray(); + return is_array($row); + } + + public function up() + { + if ($this->hasTable('doc_print_templates')) { + return; + } + + $this->forge->addField([ + 'id' => [ + 'type' => 'INT', + 'constraint' => 11, + 'unsigned' => true, + 'auto_increment' => true, + ], + 'template_name' => [ + 'type' => 'VARCHAR', + 'constraint' => 150, + ], + 'is_default' => [ + 'type' => 'TINYINT', + 'constraint' => 1, + 'default' => 0, + ], + 'status' => [ + 'type' => 'TINYINT', + 'constraint' => 1, + 'default' => 1, + ], + 'page_size' => [ + 'type' => 'VARCHAR', + 'constraint' => 20, + 'default' => 'A4', + ], + 'print_on_type' => [ + 'type' => 'TINYINT', + 'constraint' => 1, + 'default' => 1, + ], + 'page_margin_top_cm' => [ + 'type' => 'DECIMAL', + 'constraint' => '5,2', + 'default' => 6.10, + ], + 'page_margin_bottom_cm' => [ + 'type' => 'DECIMAL', + 'constraint' => '5,2', + 'default' => 2.50, + ], + 'page_margin_left_cm' => [ + 'type' => 'DECIMAL', + 'constraint' => '5,2', + 'default' => 0.70, + ], + 'page_margin_right_cm' => [ + 'type' => 'DECIMAL', + 'constraint' => '5,2', + 'default' => 0.70, + ], + 'margin_header_cm' => [ + 'type' => 'DECIMAL', + 'constraint' => '5,2', + 'default' => 0.50, + ], + 'margin_footer_cm' => [ + 'type' => 'DECIMAL', + 'constraint' => '5,2', + 'default' => 1.50, + ], + 'header_html' => [ + 'type' => 'LONGTEXT', + 'null' => true, + ], + 'footer_html' => [ + 'type' => 'LONGTEXT', + 'null' => true, + ], + 'created_at DATETIME DEFAULT CURRENT_TIMESTAMP', + 'updated_at DATETIME DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP', + ]); + + $this->forge->addKey('id', true); + $this->forge->addKey(['is_default', 'status']); + $this->forge->createTable('doc_print_templates', true, ['ENGINE' => 'InnoDB', 'DEFAULT CHARSET' => 'utf8mb4']); + + $this->db->table('doc_print_templates')->insert([ + 'template_name' => 'Default Document Print Template', + 'is_default' => 1, + 'status' => 1, + 'page_size' => 'A4', + 'print_on_type' => 1, + 'page_margin_top_cm' => 6.10, + 'page_margin_bottom_cm' => 2.50, + 'page_margin_left_cm' => 0.70, + 'page_margin_right_cm' => 0.70, + 'margin_header_cm' => 0.50, + 'margin_footer_cm' => 1.50, + 'header_html' => '', + 'footer_html' => '', + ]); + } + + public function down() + { + if ($this->hasTable('doc_print_templates')) { + $this->forge->dropTable('doc_print_templates', true); + } + } +} diff --git a/app/Database/Migrations/2026-03-17-000025_AddFinancePoDocumentColumns.php b/app/Database/Migrations/2026-03-17-000025_AddFinancePoDocumentColumns.php new file mode 100644 index 0000000..7fc8cb7 --- /dev/null +++ b/app/Database/Migrations/2026-03-17-000025_AddFinancePoDocumentColumns.php @@ -0,0 +1,71 @@ +db->query('SHOW TABLES LIKE ' . $this->db->escape($table))->getRowArray(); + + return ! empty($row); + } + + private function hasColumn(string $table, string $column): bool + { + if (! $this->hasTable($table)) { + return false; + } + + $sql = 'SHOW COLUMNS FROM `' . $table . '` LIKE ' . $this->db->escape($column); + $row = $this->db->query($sql)->getRowArray(); + + return ! empty($row); + } + + public function up() + { + if (! $this->hasTable('finance_purchase_orders')) { + return; + } + + if (! $this->hasColumn('finance_purchase_orders', 'po_document_name')) { + $this->forge->addColumn('finance_purchase_orders', [ + 'po_document_name' => [ + 'type' => 'VARCHAR', + 'constraint' => 255, + 'null' => true, + 'after' => 'approval_status', + ], + ]); + } + + if (! $this->hasColumn('finance_purchase_orders', 'po_document_path')) { + $this->forge->addColumn('finance_purchase_orders', [ + 'po_document_path' => [ + 'type' => 'VARCHAR', + 'constraint' => 255, + 'null' => true, + 'after' => 'po_document_name', + ], + ]); + } + } + + public function down() + { + if (! $this->hasTable('finance_purchase_orders')) { + return; + } + + if ($this->hasColumn('finance_purchase_orders', 'po_document_path')) { + $this->forge->dropColumn('finance_purchase_orders', 'po_document_path'); + } + + if ($this->hasColumn('finance_purchase_orders', 'po_document_name')) { + $this->forge->dropColumn('finance_purchase_orders', 'po_document_name'); + } + } +} diff --git a/app/Database/Migrations/2026-03-17-000026_CreateFinancePoDocumentsTable.php b/app/Database/Migrations/2026-03-17-000026_CreateFinancePoDocumentsTable.php new file mode 100644 index 0000000..8119561 --- /dev/null +++ b/app/Database/Migrations/2026-03-17-000026_CreateFinancePoDocumentsTable.php @@ -0,0 +1,65 @@ +db->query('SHOW TABLES LIKE ' . $this->db->escape($table))->getRowArray(); + + return ! empty($row); + } + + public function up() + { + if ($this->hasTable('finance_po_documents')) { + return; + } + + $this->forge->addField([ + 'id' => [ + 'type' => 'INT', + 'constraint' => 11, + 'unsigned' => true, + 'auto_increment' => true, + ], + 'po_id' => [ + 'type' => 'INT', + 'constraint' => 11, + 'unsigned' => true, + 'null' => false, + ], + 'file_name' => [ + 'type' => 'VARCHAR', + 'constraint' => 255, + 'null' => false, + ], + 'file_path' => [ + 'type' => 'VARCHAR', + 'constraint' => 255, + 'null' => false, + ], + 'uploaded_by' => [ + 'type' => 'VARCHAR', + 'constraint' => 120, + 'null' => true, + ], + 'created_at' => [ + 'type' => 'DATETIME', + 'null' => true, + ], + ]); + + $this->forge->addKey('id', true); + $this->forge->addKey('po_id'); + $this->forge->createTable('finance_po_documents', true); + } + + public function down() + { + $this->forge->dropTable('finance_po_documents', true); + } +} diff --git a/app/Database/Migrations/2026-03-17-000027_CreateFinancePharmacyBillsTable.php b/app/Database/Migrations/2026-03-17-000027_CreateFinancePharmacyBillsTable.php new file mode 100644 index 0000000..e2fe4a3 --- /dev/null +++ b/app/Database/Migrations/2026-03-17-000027_CreateFinancePharmacyBillsTable.php @@ -0,0 +1,109 @@ +db->tableExists('finance_pharmacy_bills')) { + return; + } + + $this->forge->addField([ + 'id' => [ + 'type' => 'INT', + 'constraint' => 11, + 'unsigned' => true, + 'auto_increment' => true, + ], + 'bill_no' => [ + 'type' => 'VARCHAR', + 'constraint' => 80, + 'default' => '', + ], + 'bill_date' => [ + 'type' => 'DATE', + 'null' => true, + ], + 'pharmacy_name' => [ + 'type' => 'VARCHAR', + 'constraint' => 200, + 'default' => '', + ], + 'description' => [ + 'type' => 'VARCHAR', + 'constraint' => 255, + 'default' => '', + ], + 'bill_amount' => [ + 'type' => 'DECIMAL', + 'constraint' => '12,2', + 'default' => '0.00', + ], + 'tax_amount' => [ + 'type' => 'DECIMAL', + 'constraint' => '12,2', + 'default' => '0.00', + ], + 'net_amount' => [ + 'type' => 'DECIMAL', + 'constraint' => '12,2', + 'default' => '0.00', + ], + 'payment_status' => [ + 'type' => 'VARCHAR', + 'constraint' => 20, + 'default' => 'pending', + ], + 'paid_amount' => [ + 'type' => 'DECIMAL', + 'constraint' => '12,2', + 'default' => '0.00', + ], + 'payment_date' => [ + 'type' => 'DATE', + 'null' => true, + ], + 'payment_mode' => [ + 'type' => 'VARCHAR', + 'constraint' => 40, + 'default' => '', + ], + 'payment_ref' => [ + 'type' => 'VARCHAR', + 'constraint' => 120, + 'default' => '', + ], + 'remarks' => [ + 'type' => 'TEXT', + 'null' => true, + ], + 'created_by' => [ + 'type' => 'VARCHAR', + 'constraint' => 120, + 'default' => '', + ], + 'created_at' => [ + 'type' => 'DATETIME', + 'null' => true, + ], + 'updated_at' => [ + 'type' => 'DATETIME', + 'null' => true, + ], + ]); + + $this->forge->addPrimaryKey('id'); + $this->forge->addKey('bill_date'); + $this->forge->addKey('payment_status'); + $this->forge->createTable('finance_pharmacy_bills', true); + } + + public function down() + { + $this->forge->dropTable('finance_pharmacy_bills', true); + } +} diff --git a/app/Models/FinanceBankDepositModel.php b/app/Models/FinanceBankDepositModel.php new file mode 100644 index 0000000..4cc9696 --- /dev/null +++ b/app/Models/FinanceBankDepositModel.php @@ -0,0 +1,27 @@ + 'Beta', 'template' => 'Templates', 'pharmacy' => 'Pharmacy', + 'finance' => 'Finance', 'opd' => 'OPD Doctor Panel', 'billing.opd' => 'OPD', 'billing.charges' => 'Charges', @@ -102,6 +103,7 @@ 'users', 'template', 'pharmacy', + 'finance', 'opd', 'billing.opd', 'billing.charges', @@ -110,6 +112,13 @@ 'beta', 'other', ]; + + // Ensure new permission groups are still shown even if not in the predefined display order. + foreach (array_keys($groupedPermissions) as $detectedGroup) { + if (! in_array($detectedGroup, $groupOrder, true)) { + $groupOrder[] = $detectedGroup; + } + } ?>
diff --git a/app/Views/Setting/Admin/hospital_profile.php b/app/Views/Setting/Admin/hospital_profile.php new file mode 100644 index 0000000..d52368b --- /dev/null +++ b/app/Views/Setting/Admin/hospital_profile.php @@ -0,0 +1,280 @@ +
+
+

Hospital Profile

+ Used across HMS reports and headers +
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+ +
+ + +
Accepted: PNG, JPG, JPEG, WEBP
+
+
+ +
+ + Hospital Logo +
+ + No logo uploaded + +
+
+ +

Pharmacy Information
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+
+ + +
Accepted: PNG, JPG, JPEG, WEBP
+
+
+ +
+ + Pharmacy Logo +
+ + No logo uploaded + +
+
+
+ +
+ + + + +
+ +
+
+
+ + diff --git a/app/Views/Setting/Admin/index.php b/app/Views/Setting/Admin/index.php index 8e681e8..835519d 100644 --- a/app/Views/Setting/Admin/index.php +++ b/app/Views/Setting/Admin/index.php @@ -68,6 +68,12 @@ AI Settings
+
- +
- +
- +
- +
diff --git a/app/Views/Setting/Template/document_print_settings.php b/app/Views/Setting/Template/document_print_settings.php new file mode 100644 index 0000000..78c7ed1 --- /dev/null +++ b/app/Views/Setting/Template/document_print_settings.php @@ -0,0 +1,201 @@ + + +
+
+ +
+
+ +
+ +
+ + +
+ Required table is missing. Run migration: php spark migrate +
+ + +
+ + + +
+
+ + +
+
+ + + +
+
+
+ > + +
+
+
+ +
+ +
+ + + + + + New Template +
+
+ +
+
1. Page & Margin Settings
+
+ Equivalent to old @page block values. Example legacy values: top 6.1, bottom 2.5, left 0.7, right 0.7, header 0.5, footer 1.5. +
+ +
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+
+ +
+
2. Header / Footer HTML (Optional)
+
+ If Header HTML is blank, default hospital header logic is used based on print mode. +
+
+
+ + +
+
+ + +
+
+ +
+ +
+
+
+
+
+ + diff --git a/app/Views/Setting/Template/index.php b/app/Views/Setting/Template/index.php index 571479b..fc01c59 100644 --- a/app/Views/Setting/Template/index.php +++ b/app/Views/Setting/Template/index.php @@ -8,12 +8,16 @@ $canMri = $user && method_exists($user, 'can') ? $user->can('template.mri') : fa $canEcho = $user && method_exists($user, 'can') ? $user->can('template.echo') : false; $canDischarge = $user && method_exists($user, 'can') ? $user->can('template.discharge') : false; $canOpdPrintTemplate = $user && method_exists($user, 'can') ? $user->can('billing.opd.edit') : false; +$canDiagnosisPrintTemplate = $canPathology || $canUltrasound || $canXray || $canCt || $canMri || $canEcho; +$canDoctorDocumentPrintTemplate = $user && method_exists($user, 'can') + ? ($user->can('doctor_work.template_workspace.access') || $user->can('doctor_work.access') || $user->can('template.pathology')) + : false; if (! $canOpdPrintTemplate && $user && method_exists($user, 'inGroup')) { $canOpdPrintTemplate = $user->inGroup('OPDEdit', 'admin', 'superadmin', 'developer'); } -$hasTemplateAccess = $canPathology || $canUltrasound || $canXray || $canCt || $canMri || $canEcho || $canDischarge; +$hasTemplateAccess = $canPathology || $canUltrasound || $canXray || $canCt || $canMri || $canEcho || $canDischarge || $canDoctorDocumentPrintTemplate; ?>
@@ -204,6 +208,33 @@ $hasTemplateAccess = $canPathology || $canUltrasound || $canXray || $canCt || $c
+ + + + + + + + + + + +
diff --git a/app/Views/billing/opd_medicince_workspace.php b/app/Views/billing/opd_medicince_workspace.php index cd47027..12a6749 100644 --- a/app/Views/billing/opd_medicince_workspace.php +++ b/app/Views/billing/opd_medicince_workspace.php @@ -237,6 +237,39 @@ $('#med_item_name,#med_formulation,#med_genericname,#med_salt_name,#med_dosage_restriction,#med_company_name').val(''); } + function buildMedicinePayload() { + return { + id: parseInt($('#med_id').val() || '0', 10), + item_name: ($('#med_item_name').val() || '').trim(), + formulation: ($('#med_formulation').val() || '').trim(), + genericname: ($('#med_genericname').val() || '').trim(), + salt_name: ($('#med_salt_name').val() || '').trim(), + dosage_restriction: ($('#med_dosage_restriction').val() || '').trim(), + company_name: ($('#med_company_name').val() || '').trim() + }; + } + + function saveMedicine(payload, afterSave) { + if (!payload.item_name) { + setMsg('err', 'Medicine name is required.'); + return; + } + + apiPost('', payload, function(data) { + if ((data.update || 0) != 1) { + setMsg('err', data.error_text || 'Unable to save medicine'); + return; + } + $('#med_id').val(data.insertid || 0); + setMsg('ok', data.error_text || 'Saved'); + loadList(); + loadDuplicateReport(); + if (typeof afterSave === 'function') { + afterSave(data || {}); + } + }); + } + function fillForm(row) { row = row || {}; $('#med_id').val(row.id || 0); @@ -396,31 +429,7 @@ } $('#btn_med_save').on('click', function() { - var payload = { - id: parseInt($('#med_id').val() || '0', 10), - item_name: ($('#med_item_name').val() || '').trim(), - formulation: ($('#med_formulation').val() || '').trim(), - genericname: ($('#med_genericname').val() || '').trim(), - salt_name: ($('#med_salt_name').val() || '').trim(), - dosage_restriction: ($('#med_dosage_restriction').val() || '').trim(), - company_name: ($('#med_company_name').val() || '').trim() - }; - - if (!payload.item_name) { - setMsg('err', 'Medicine name is required.'); - return; - } - - apiPost('', payload, function(data) { - if ((data.update || 0) != 1) { - setMsg('err', data.error_text || 'Unable to save medicine'); - return; - } - $('#med_id').val(data.insertid || 0); - setMsg('ok', data.error_text || 'Saved'); - loadList(); - loadDuplicateReport(); - }); + saveMedicine(buildMedicinePayload()); }); $(document).on('click', '.btn-med-edit', function() { @@ -578,6 +587,34 @@ } setMsg('ok', (data.error_text || 'AI details prepared') + '. Review and click Update.'); + + var provider = String(data.provider || ''); + var confidence = String(data.match_confidence || ''); + var medId = parseInt($('#med_id').val() || '0', 10); + var isNewMedicine = medId <= 0; + + if (provider === 'local-master' && confidence === 'exact') { + var matchedName = String(data.matched_item_name || '').trim(); + var askExact = 'Exact local match found'; + if (matchedName) { + askExact += ' (' + matchedName + ')'; + } + askExact += '. Auto-save now?'; + if (window.confirm(askExact)) { + saveMedicine(buildMedicinePayload(), function() { + setMsg('ok', 'Auto-saved using exact local master match.'); + }); + } + return; + } + + if (isNewMedicine && (provider === 'gemini' || provider === 'azure' || provider === 'local-brand-fallback')) { + if (window.confirm('Details prepared for a new medicine. Save this new master entry now?')) { + saveMedicine(buildMedicinePayload(), function() { + setMsg('ok', 'New medicine saved with suggested generic/salt details.'); + }); + } + } }); }); diff --git a/app/Views/diagnosis/lab_final_report_editor.php b/app/Views/diagnosis/lab_final_report_editor.php index c462c90..243e683 100644 --- a/app/Views/diagnosis/lab_final_report_editor.php +++ b/app/Views/diagnosis/lab_final_report_editor.php @@ -1,6 +1,7 @@
@@ -20,6 +21,7 @@ $templates = $radiology_ultrasound_template ?? []; + ipd_id ?? 0); @@ -64,6 +66,14 @@ $templates = $radiology_ultrasound_template ?? [];
+
+
+ + + Required when saving changes to an already verified report. +
+
+
@@ -73,6 +83,7 @@ $templates = $radiology_ultrasound_template ?? []; @@ -85,6 +96,7 @@ $templates = $radiology_ultrasound_template ?? []; diff --git a/app/Views/diagnosis/lab_invoice_main_test_list.php b/app/Views/diagnosis/lab_invoice_main_test_list.php index a0021e9..e4653df 100644 --- a/app/Views/diagnosis/lab_invoice_main_test_list.php +++ b/app/Views/diagnosis/lab_invoice_main_test_list.php @@ -6,6 +6,7 @@ $currentLabType = (int) ($lab_type ?? $labType ?? 0); $isRadiologyFlow = !in_array($currentLabType, [5, 30], true); $flowTitle = $isRadiologyFlow ? 'Imaging Worklist' : 'Pathology Worklist'; $statusPendingLabel = $isRadiologyFlow ? 'Report Pending' : 'Data Pending'; +$printTemplates = $print_templates ?? []; if (!empty($lab_invoice_request) && count($lab_invoice_request) > 0) { $labInvoiceData = $lab_invoice_request[0]; @@ -96,10 +97,35 @@ if (!empty($lab_invoice_request) && count($lab_invoice_request) > 0) {
- + + + + + + + + + + + + +
diff --git a/app/Views/doctor_document/doc_letterhead_print.php b/app/Views/doctor_document/doc_letterhead_print.php new file mode 100644 index 0000000..277ea99 --- /dev/null +++ b/app/Views/doctor_document/doc_letterhead_print.php @@ -0,0 +1,60 @@ + + + + + + + + + + + + + +
+ + +

+


+

+
+ +
+ +
+ + + + + + + + + + +
Page : {PAGENO}/{nbpg}
+ +
+ + diff --git a/app/Views/doctor_document/doc_list.php b/app/Views/doctor_document/doc_list.php new file mode 100644 index 0000000..251e129 --- /dev/null +++ b/app/Views/doctor_document/doc_list.php @@ -0,0 +1,55 @@ +
+

Document Template List

+ +
+ +
+
+
+
+
+
+
Templates
+ +
+
+ + + + + + + + + + + + + + + + + +
TitleDescriptionAction
+ + +
+
+
+
+
+
+
+
+ + diff --git a/app/Views/doctor_document/doc_master_edit.php b/app/Views/doctor_document/doc_master_edit.php new file mode 100644 index 0000000..a97477d --- /dev/null +++ b/app/Views/doctor_document/doc_master_edit.php @@ -0,0 +1,165 @@ + + + +
+
+
Template Editor
+
+
+
+ + + +
+
+
+
+ + +
+
+
+
+
+
+ + +
+
+
+
+ + +
+
+
+
+ + +
+
+
+
+ + +
+
+
+
+ + +
+
+
+
+ + +
+
+
+
+ + +
+
+
+
+
+ +
+
+
+ +
+
+
+ +
+
+
Document Parameters
+

Pre-Define

+

+ UHID[p_code] Patient Name[p_fname] Relative Name[p_rname] + Patient Age[str_age] Relation[p_relative] Gender[gender] + Title[p_title] Patient Address[p_address] HE_SHE[p_he_she] + HIS_HER[p_his_her] Doctor Name[dr_name] Doctor Sign[dr_sign] + Current Date[current_date] Issue Date[issue_date] +

+
+

Custom Define Input Parameter

+

+ + [] + +

+ 0): ?> + + +
+
+ + + diff --git a/app/Views/doctor_document/doc_pre_data.php b/app/Views/doctor_document/doc_pre_data.php new file mode 100644 index 0000000..2b3ce3e --- /dev/null +++ b/app/Views/doctor_document/doc_pre_data.php @@ -0,0 +1,85 @@ + +
+

Document Input Preview

+ +
+ +
+ + +
+
+
Patient Name: /
+
+ +
+
+
+
+ + + + + + +
+
+ +
+
+ +
+ +
+ + +
+
+
+
+ + diff --git a/app/Views/doctor_document/patient_doc_edit.php b/app/Views/doctor_document/patient_doc_edit.php new file mode 100644 index 0000000..af3e37e --- /dev/null +++ b/app/Views/doctor_document/patient_doc_edit.php @@ -0,0 +1,175 @@ + +
+

Document Editor

+ +
+ +
+
+ +
+
+
Document Data
+
+

+ Name : {} + / Age : + / Gender : + / P Code : +

+ +
+ + + +
+ + + + +
+ + + + + + +
+ + + Add Print Template + +
+
+
+
+
+ + diff --git a/app/Views/doctor_document/patient_doc_master.php b/app/Views/doctor_document/patient_doc_master.php new file mode 100644 index 0000000..504c6aa --- /dev/null +++ b/app/Views/doctor_document/patient_doc_master.php @@ -0,0 +1,132 @@ + +
+

Patient Document Data

+ +
+ +
+
+ +
+
+
Patient Summary
+
+

+ Name : {} + / Age : + / Gender : + / P Code : +

+ +
+ +
+
+ +
+
+
+ + +
+
+
+
+ + +
+
+
+
+ +
+ + +
+
+
+
+
+ +
+
+
+ +
+
+
+ + + + + + + + + + + + + + + +
#Issue DateDocument Name
+
+
+
+ +
+ + diff --git a/app/Views/doctor_document/workspace.php b/app/Views/doctor_document/workspace.php new file mode 100644 index 0000000..d30cec8 --- /dev/null +++ b/app/Views/doctor_document/workspace.php @@ -0,0 +1,70 @@ +
+

Doctor Documents Workspace

+ +
+ +
+
+
+
+
+
Template Master
+

Create and edit certificate templates with custom fields.

+ +
+
+
+
+
+
+
Patient Document Issue
+
+ + +
+
+ + +
+
+
+
+
+
+ + diff --git a/app/Views/finance/bank_deposits.php b/app/Views/finance/bank_deposits.php new file mode 100644 index 0000000..f5b7348 --- /dev/null +++ b/app/Views/finance/bank_deposits.php @@ -0,0 +1,78 @@ +
+
+

Bank Deposit Register

+

Track cash to bank deposits and reconcile with submitted scrolls.

+
+ +
+ +
+
Today Deposited
+
Pending Reconciliation
+
Matched Deposits
+
+ +
+
Deposit Entry
+
+
+
+
+
+
+
+
+ +
+
+
+
+
+
$deposits ?? []]) ?>
+
+
+
+ + diff --git a/app/Views/finance/cashbook.php b/app/Views/finance/cashbook.php new file mode 100644 index 0000000..24effac --- /dev/null +++ b/app/Views/finance/cashbook.php @@ -0,0 +1,149 @@ +
+
+

Cash Collection & Disbursement SOP

+

Capture receipts/disbursements, scroll submission, and compliance checks for Section 269ST and 40A(3).

+
+ +
+ +
+
+
Today Receipts
+
+
+
Today Disbursements
+
+
+
Compliance Hold
+
+
+
Pending Scrolls
+
+
+ +
+
+
+
1) Cash Entry
+
+
+
+
+ +
+
+ +
+
+
+
+
+ +
+
+
+
+
+
+
$transactions ?? []]) ?>
+
+
+
+ +
+
+
2) Scroll Submission & Reconciliation
+
+
+
+
+
+
+
+
+
+
+
$scrolls ?? []]) ?>
+
+
+
+
+
+ + diff --git a/app/Views/finance/compliance_report.php b/app/Views/finance/compliance_report.php new file mode 100644 index 0000000..cf5f489 --- /dev/null +++ b/app/Views/finance/compliance_report.php @@ -0,0 +1,82 @@ +
+
+

Finance Compliance Report

+

Consolidated risk view across invoice matching, cash compliance, deposits, and doctor payouts.

+
+ +
+
+
+
+ + +
+
+ + +
+
+ + Reset + Export CSV +
+
+
+
+ +
+
Invoice Holds
+
Cash Holds
+
Pending Deposits
+
Draft/Unpaid Payouts
+
+ +
+
Cash Compliance Alerts (Latest 20)
+
+
+ + + + + + + + + + + + + + + +
DateTypeDepartmentAmountNote
No cash alerts.
+
+
+
+ +
+
Invoice Match Exceptions (Latest 20)
+
+
+ + + + + + + + + + + + + + + + +
DateInvoiceVendorStatusVarianceNote
No invoice exceptions.
+
+
+
+
diff --git a/app/Views/finance/doctor_payout.php b/app/Views/finance/doctor_payout.php new file mode 100644 index 0000000..fe6f257 --- /dev/null +++ b/app/Views/finance/doctor_payout.php @@ -0,0 +1,142 @@ +
+
+

Doctor Payout Workflow

+

Agreement rates, payout drafting, and HR -> Finance -> CEO approval flow.

+
+ +
+ +
+
Draft
+
Finance Approved
+
CEO Approved
+
Paid
+
+ +
+
+
+
1) Doctor Agreement
+
+
+
+
+
+
+
+
+
+
+
+
+
$agreements ?? []]) ?>
+
+
+
+ +
+
+
2) Payout Entry & Approval
+
+
+
+
+ +
+
+ +
+
+
+
+
+
+
+
$payouts ?? []]) ?>
+
+
+
+
+
+ + diff --git a/app/Views/finance/index.php b/app/Views/finance/index.php new file mode 100644 index 0000000..024a2e1 --- /dev/null +++ b/app/Views/finance/index.php @@ -0,0 +1,123 @@ +
+
+

Finance & Accounting - Phase 1

+

Vendor onboarding, PO booking, GRN capture, and invoice registration.

+ +
+ +
+
+
+
+
Matched
+
+
+
+
+
+
+
+
Minor Variance
+
+
+
+
+
+
+
+
Mismatch / Not Checked
+
+
+
+
+
+
+
+
Compliance Hold
+
+
+
+
+
+ +
+
+ Vendor Master +
+
+
+
+
+
+ + diff --git a/app/Views/finance/partials/bank_deposits_table.php b/app/Views/finance/partials/bank_deposits_table.php new file mode 100644 index 0000000..58b86b0 --- /dev/null +++ b/app/Views/finance/partials/bank_deposits_table.php @@ -0,0 +1,39 @@ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
#DateDepartmentBankSlipAmountStatus
No bank deposits found.
+ + Matched + + Pending + +
+
diff --git a/app/Views/finance/partials/cash_transactions_table.php b/app/Views/finance/partials/cash_transactions_table.php new file mode 100644 index 0000000..2d1dd85 --- /dev/null +++ b/app/Views/finance/partials/cash_transactions_table.php @@ -0,0 +1,44 @@ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
#DateTypeDepartmentReferenceAmountModeCompliance
No cash transactions yet.
+
+
+
+ + Hold +
+ + Clear + +
+
diff --git a/app/Views/finance/partials/doctor_agreements_table.php b/app/Views/finance/partials/doctor_agreements_table.php new file mode 100644 index 0000000..2068164 --- /dev/null +++ b/app/Views/finance/partials/doctor_agreements_table.php @@ -0,0 +1,39 @@ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + +
#DoctorSpecializationConsultation RateSurgery RateStatus
No agreements found.
+
+
+
+ + Active + + Inactive + +
+
diff --git a/app/Views/finance/partials/doctor_payouts_table.php b/app/Views/finance/partials/doctor_payouts_table.php new file mode 100644 index 0000000..34a7978 --- /dev/null +++ b/app/Views/finance/partials/doctor_payouts_table.php @@ -0,0 +1,57 @@ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
#DateDoctorTypeUnitsCalculatedApprovedStatusActions
No payouts found.
+ + Paid + + CEO Approved + + Finance Approved + + Draft + + + + + + + + + + Completed + +
+
diff --git a/app/Views/finance/partials/grn_table.php b/app/Views/finance/partials/grn_table.php new file mode 100644 index 0000000..5d0accd --- /dev/null +++ b/app/Views/finance/partials/grn_table.php @@ -0,0 +1,36 @@ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
#GRN NoDatePO NoReceived AmountReceived ByNotesAction
No GRN entries yet.
+ Print +
+
diff --git a/app/Views/finance/partials/invoice_table.php b/app/Views/finance/partials/invoice_table.php new file mode 100644 index 0000000..58ba83a --- /dev/null +++ b/app/Views/finance/partials/invoice_table.php @@ -0,0 +1,50 @@ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
#Invoice NoDateVendorPOGRNAmountPaymentMatchVarianceCompliance
No vendor invoices yet.
+ + + + + + Hold + + Clear + +
+
diff --git a/app/Views/finance/partials/pharmacy_bills_table.php b/app/Views/finance/partials/pharmacy_bills_table.php new file mode 100644 index 0000000..abe2c5e --- /dev/null +++ b/app/Views/finance/partials/pharmacy_bills_table.php @@ -0,0 +1,94 @@ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + 'success', + 'part_paid' => 'warning text-dark', + default => 'danger', + }; + ?> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
#Bill NoDatePharmacy / SupplierDescriptionBill AmtTaxNet PayablePaidBalanceStatusModeRemarks
No pharmacy bills registered yet.
+ + + + + + + + + + + +
Totals:
+
diff --git a/app/Views/finance/partials/po_table.php b/app/Views/finance/partials/po_table.php new file mode 100644 index 0000000..e92b83d --- /dev/null +++ b/app/Views/finance/partials/po_table.php @@ -0,0 +1,59 @@ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
#PO NoDateVendorDepartmentAmountStatusDocumentAction
No purchase orders yet.
+ + View + + - + + 0): ?> +
file(s)
+ +
Manage in Edit
+ +
+ +
+
diff --git a/app/Views/finance/partials/scroll_table.php b/app/Views/finance/partials/scroll_table.php new file mode 100644 index 0000000..cd7d818 --- /dev/null +++ b/app/Views/finance/partials/scroll_table.php @@ -0,0 +1,39 @@ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
#DateDepartmentTotal ReceiptsSubmittedVarianceStatus
No scroll submissions yet.
+ + + Matched + + Pending + +
+
diff --git a/app/Views/finance/partials/vendors_table.php b/app/Views/finance/partials/vendors_table.php new file mode 100644 index 0000000..6bc4142 --- /dev/null +++ b/app/Views/finance/partials/vendors_table.php @@ -0,0 +1,39 @@ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + +
#CodeVendorContactPhoneStatus
No vendors yet.
+
+
+
+ + Active + + Inactive + +
+
diff --git a/app/Views/finance/phase2.php b/app/Views/finance/phase2.php new file mode 100644 index 0000000..6d91823 --- /dev/null +++ b/app/Views/finance/phase2.php @@ -0,0 +1,275 @@ +
+
+
+

Finance & Accounting - Phase 2

+

Consolidation layer for receivables, refunds, pharmacy purchase finance, and organization credit reporting.

+
+
+ + +
+
+ + +
+ +
+ Phase 2 started on . +
+ + + + 0): ?> +
+
+ Pharmacy Bills — Payable to Pharmacy (Cr. to Hospital) +
+
+
+
+
+
Total Bills
+
+
+
+
+
+
Net Payable (Total)
+
Rs.
+
+
+
+
+
Total Paid
+
Rs.
+
+
+
+
+
Outstanding Balance
+
Rs.
+
+
+
+
+
+ + +
+
Finance Phase Design
+
+ + + + + + + + + + + + + + + + + + +
PhaseScopeStatus
+ + Live + + Started + + Planned + +
+
+
+ +
+
+
Total Billed (AR)
+
+
+
Total Outstanding
+
+
+
Total Collected
+
+
+
Pending Invoices
+
+
+
Organization Cases
+
+
+
Org Outstanding Exposure
+
+
+ +
+
Receivable Stream Summary (Phase 2 Bridge)
+
+ + + + + + + + + + + + + + + + + + + + + + + +
StreamInvoicesPendingBilledCollectedOutstanding
+
+
+ +
+
+
Refund Requests
+
+
+
Medical Purchase Invoices
+
+
+
Supplier Ledger Entries
+
+
+
Charge Invoices (OPD)
+
+
+ +
+
Refund Lifecycle Bridge (Phase 2)
+
+
+
+
+
Requested
+
/ Rs.
+
+
+
+
+
Pending
+
/ Rs.
+
+
+
+
+
Completed (Cash Impact)
+
/ Rs.
+
+
+
+
+
Cancelled
+
/ Rs.
+
+
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + +
Refund TypeRequestsTotal AmountPendingPending AmountCompleted Amount
+
+
+
+ +
+
Phase 2 Workstream Start
+
+
    +
  1. Receivable summary bridge from patient billing (OPD/IPD/Org) into Finance reporting.
  2. +
  3. Refund lifecycle bridge into Finance compliance and cash register reporting.
  4. +
  5. Pharmacy purchase bills (payable) from the Pharmacy entity — tracked here as Cr. to Hospital.
  6. +
  7. Organization credit exposure summary for insurance and packaged billing.
  8. +
+
+
+ +
+ + + +
+ + +
+ + diff --git a/app/Views/finance/print/grn_vendor_copy.php b/app/Views/finance/print/grn_vendor_copy.php new file mode 100644 index 0000000..976bd2b --- /dev/null +++ b/app/Views/finance/print/grn_vendor_copy.php @@ -0,0 +1,119 @@ + + + + + + GRN Vendor Copy + + + +
+
+
+
+ + + | Phone: + +
+
+
+ GRN QR Code +
GRN Verification QR
+
+
+ +
+
Goods Receipt Note
+
Vendor Copy
+
+ + + + + + + + + + + + + + +
+
GRN No
+
+
+
GRN Date
+
+
+
PO No
+
+
+
PO Date
+
+
+
Vendor
+
+ +
+ +
+
Received By
+
+
Received Amount
+
+
+ +
Notes / Remarks
+
+ +
+
Vendor Signature
+
Store / Receiving Signature
+
+ + + +
+ +
+ + diff --git a/app/Views/finance/sections/grn_entry.php b/app/Views/finance/sections/grn_entry.php new file mode 100644 index 0000000..92b5f18 --- /dev/null +++ b/app/Views/finance/sections/grn_entry.php @@ -0,0 +1,78 @@ +
+
3) GRN Entry
+
+
+
+
+
+
+ +
+
+
+
+ +
+
+
+
+
$grns ?? []]) ?>
+
+
+ + diff --git a/app/Views/finance/sections/pharmacy_bills.php b/app/Views/finance/sections/pharmacy_bills.php new file mode 100644 index 0000000..ca3bd61 --- /dev/null +++ b/app/Views/finance/sections/pharmacy_bills.php @@ -0,0 +1,210 @@ +
+
+ Pharmacy Bills — Payable (Cr. to Hospital) + Pharmacy is a separate entity +
+
+

+ Register bills received from the Pharmacy entity. These are amounts owed by the Hospital to the Pharmacy + (Credit to Hospital). Record each bill on receipt and settle when payment is made. +

+ +
+ +
+
+ +
+
+ +
+
+ +
+
+ +
+
+ +
+
+ +
+
+ +
+
+ +
+
+ + +
+
+ +
+ + + + +
+ $pharmacy_bills ?? []]) ?> +
+
+
+ + diff --git a/app/Views/finance/sections/purchase_order.php b/app/Views/finance/sections/purchase_order.php new file mode 100644 index 0000000..f8a40c4 --- /dev/null +++ b/app/Views/finance/sections/purchase_order.php @@ -0,0 +1,241 @@ +
+
2) Purchase Order (PO)
+
+
+
+ +
+
+
+ +
+
+
+
+ +
+
+ + + Optional. You can upload multiple PO documents (max 5 MB each). +
+
+
+ Existing Documents +
No documents.
+ Tick checkbox to remove document when you click Update PO. +
+
+
+ + +
+
+
+
$purchase_orders ?? []]) ?>
+
+
+ + diff --git a/app/Views/finance/sections/vendor_invoice.php b/app/Views/finance/sections/vendor_invoice.php new file mode 100644 index 0000000..abcb1a5 --- /dev/null +++ b/app/Views/finance/sections/vendor_invoice.php @@ -0,0 +1,97 @@ +
+
4) Vendor Invoice Booking
+
+
+
+
+
+
+ +
+
+ +
+
+ +
+
+
+ +
+
+
+
+
$vendor_invoices ?? []]) ?>
+
+
+ + diff --git a/app/Views/finance/sections/vendor_master.php b/app/Views/finance/sections/vendor_master.php new file mode 100644 index 0000000..f630ad4 --- /dev/null +++ b/app/Views/finance/sections/vendor_master.php @@ -0,0 +1,67 @@ +
+
1) Vendor Master
+
+
+
+
+
+
+
+
+
+
+
$vendors ?? []]) ?>
+
+
+ + diff --git a/app/Views/medical/invoice_print.php b/app/Views/medical/invoice_print.php index 5ada468..20b7618 100644 --- a/app/Views/medical/invoice_print.php +++ b/app/Views/medical/invoice_print.php @@ -25,13 +25,23 @@ + doc_name ?? '')); + $doctorLabel = $doctorName !== '' ? (preg_match('/^dr\.?\s*/i', $doctorName) ? $doctorName : 'Dr. ' . $doctorName) : '-'; + ?> -
Medical Invoice
-
Invoice No: inv_med_code ?? ('M' . date('ym') . str_pad(substr((string) ((int)($invoice->id ?? 0)), -7, 7), 7, '0', STR_PAD_LEFT))) ?>
+
+
| Phone: | GSTIN:
+
Medical Invoice No: inv_med_code ?? ('M' . date('ym') . str_pad(substr((string) ((int)($invoice->id ?? 0)), -7, 7), 7, '0', STR_PAD_LEFT))) ?>
@@ -40,7 +50,7 @@
Patient Code: patient_code ?? '-') ?>
-
Doctor: doc_name ?? '-') ?>
+
Refer By:
Phone: inv_phone_number ?? ($patient->mphone1 ?? '-')) ?>
Type: ipd_credit ?? 0) === 1) ? 'Credit' : 'Cash' ?>
diff --git a/app/Views/medical/invoice_print_pdf.php b/app/Views/medical/invoice_print_pdf.php index e399d53..1d4e0a8 100644 --- a/app/Views/medical/invoice_print_pdf.php +++ b/app/Views/medical/invoice_print_pdf.php @@ -2,16 +2,24 @@ $invoiceCode = (string) ($invoice->inv_med_code ?? ('M' . date('ym') . str_pad(substr((string) ((int) ($invoice->id ?? 0)), -7, 7), 7, '0', STR_PAD_LEFT))); $invoiceDate = ! empty($invoice->inv_date) ? date('d-m-Y', strtotime((string) $invoice->inv_date)) : date('d-m-Y'); -$pharmacyName = defined('M_store') ? (string) M_store : 'Medical Store'; -$pharmacyAddress = defined('M_address') ? (string) M_address : ''; -$pharmacyPhone = defined('M_Phone_Number') ? (string) M_Phone_Number : ''; -$pharmacyState = defined('M_State') ? (string) M_State : ''; -$pharmacyGst = defined('H_Med_GST') ? (string) H_Med_GST : ''; +$pharmacyName = defined('H_Med_Name') ? (string) constant('H_Med_Name') : (defined('M_store') ? (string) constant('M_store') : 'Medical Store'); +$pharmacyAddress = defined('H_Med_address_1') ? (string) constant('H_Med_address_1') : (defined('M_address') ? (string) constant('M_address') : ''); +$pharmacyPhone = defined('H_Med_phone_No') ? (string) constant('H_Med_phone_No') : (defined('M_Phone_Number') ? (string) constant('M_Phone_Number') : ''); +$pharmacyState = defined('M_State') ? (string) constant('M_State') : ''; +$pharmacyGst = defined('H_Med_GST') ? (string) constant('H_Med_GST') : ''; +$pharmacyLogo = defined('H_Med_logo') ? trim((string) constant('H_Med_logo')) : ''; $customerName = trim((string) ($invoice->inv_name ?? 'Walk-in Customer')); $customerCode = trim((string) ($invoice->patient_code ?? '')); $customerPhone = trim((string) ($invoice->inv_phone_number ?? ($patient->mphone1 ?? ''))); $doctorName = trim((string) ($invoice->doc_name ?? '')); +$doctorLabel = $doctorName !== '' ? (preg_match('/^dr\.?\s*/i', $doctorName) ? $doctorName : 'Dr. ' . $doctorName) : '-'; +$addressLine = $pharmacyAddress; +if ($pharmacyState !== '') { + $addressLine .= ($addressLine !== '' ? ', ' : '') . $pharmacyState; +} elseif ($addressLine !== '' && stripos($addressLine, 'uttarakhand') === false) { + $addressLine .= ', Uttarakhand'; +} $grossTotal = 0.0; $discountTotal = 0.0; @@ -35,6 +43,10 @@ $tdPad = $compact ? '4px 4px' : '5px 5px'; .header { border-bottom: 1px solid #d1d5db; padding: 10px 12px; } .store-name { font-size: ; font-weight: 700; letter-spacing: .2px; color:#111827; } .store-meta { font-size: ; color:#374151; margin-top: 2px; line-height: 1.45; } + .store-head { width:100%; border-collapse: collapse; } + .store-head td { vertical-align: top; } + .store-logo { text-align:right; } + .store-logo img { max-height:54px; max-width:130px; } .doc-title { margin-top: 8px; font-weight: 700; font-size: ; color:#111827; } .meta { width: 100%; border-collapse: collapse; } .meta td { border: 1px solid #e5e7eb; padding: ; vertical-align: top; } @@ -57,12 +69,23 @@ $tdPad = $compact ? '4px 4px' : '5px 5px';
-
-
- - | Phone: - | GSTIN: -
+ + + + + +
+
+
+ + | Phone: + | GSTIN: +
+
TAX INVOICE
@@ -73,7 +96,7 @@ $tdPad = $compact ? '4px 4px' : '5px 5px';
Patient Code:
Phone:
-
Doctor:
+
Refer By:
Invoice Details
@@ -142,7 +165,7 @@ $tdPad = $compact ? '4px 4px' : '5px 5px'; price ?? 0), 2)) ?> - + diff --git a/app/Views/medical/new_purchase_return_invoice.php b/app/Views/medical/new_purchase_return_invoice.php new file mode 100644 index 0000000..06f8327 --- /dev/null +++ b/app/Views/medical/new_purchase_return_invoice.php @@ -0,0 +1,47 @@ +
+
New Purchase Return Invoice
+
+
+ + +
+ + +
+ +
+ + +
+ +
+ +
+
+
+
+ + diff --git a/app/Views/medical/purchase_invoice_edit.php b/app/Views/medical/purchase_invoice_edit.php index f56b3f7..2ff987b 100644 --- a/app/Views/medical/purchase_invoice_edit.php +++ b/app/Views/medical/purchase_invoice_edit.php @@ -57,7 +57,7 @@
diff --git a/app/Views/medical/purchase_return.php b/app/Views/medical/purchase_return.php new file mode 100644 index 0000000..7b18145 --- /dev/null +++ b/app/Views/medical/purchase_return.php @@ -0,0 +1,27 @@ +
+
+ +
+ +
+
+ +
+
+ +
+
+ +
+
+ + diff --git a/app/Views/medical/purchase_return_invoice_edit.php b/app/Views/medical/purchase_return_invoice_edit.php new file mode 100644 index 0000000..3e2ed24 --- /dev/null +++ b/app/Views/medical/purchase_return_invoice_edit.php @@ -0,0 +1,136 @@ + + + +
Purchase return invoice not found.
+ +
+
+
Purchase Return Invoice / Supplier : name_supplier ?? '-')) ?>
+ + Invoice No.: Invoice_no ?? '')) ?> | + Invoice Date: str_date_of_invoice ?? '')) ?> + + Print + +
+
+
+
+
+ +
+
+
+
+
+
Item List
+
+ + +
+
+
+
+
+
+
+
+ + + diff --git a/app/Views/medical/purchase_return_invoice_item.php b/app/Views/medical/purchase_return_invoice_item.php new file mode 100644 index 0000000..a349000 --- /dev/null +++ b/app/Views/medical/purchase_return_invoice_item.php @@ -0,0 +1,57 @@ + + +
+ + + + + + + + + + + + + + + + + + + + + + gst_per ?? 0); + $amount = (float) ($row->r_amount ?? 0); + $gstAmount = round(($gstPer * $amount) / 100, 2); + $netAmount = round($amount + $gstAmount, 2); + ?> + + + + + + + + + + + + + + + + + + + + + +
#RecNoItem NameBatch NoExp.MRP / P. RateQty (Unit / Pack)GST %AmountGST AmountNet Amount
r_id ?? 0) ?>Item_name ?? '')) ?>batch_no_r_s ?? '')) ?>exp_date_str ?? '')) ?>mrp ?? 0)) ?> / purchase_unit_rate ?? 0)) ?>r_qty ?? 0))) ?> / qty_pak ?? 0))) ?> + +
No return items added yet.
+
diff --git a/app/Views/medical/purchase_return_invoice_item_print.php b/app/Views/medical/purchase_return_invoice_item_print.php new file mode 100644 index 0000000..e13f948 --- /dev/null +++ b/app/Views/medical/purchase_return_invoice_item_print.php @@ -0,0 +1,123 @@ + + + + + + + + + + + + + + +

+

+ + +
Phone: + + + , Email: + + +
GST: + + + L.No: + +

+
+

+ Invoice To:
+ Supplier: name_supplier ?? '-')) ?>
+ Purchase Return Invoice No.: Invoice_no ?? '')) ?>
+ Invoice Date: str_date_of_invoice ?? '')) ?>
+

+
+

Purchase Return

+
+ + + + + + + +
Page : {PAGENO}/{nbpg}Invoice No.: Invoice_no ?? '')) ?> / Name : name_supplier ?? '-')) ?>
+
+ + + + + + + + + + + + + + + + + + + r_qty ?? 0) * (float) ($row->purchase_unit_rate ?? 0), 2); + $gstPer = (float) ($row->gst_per ?? 0); + $gstAmount = round(($gstPer * $lineAmt) / 100, 2); + $netAmt = round($lineAmt + $gstAmount, 2); + $totalAmt += $netAmt; + ?> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
#RecNoItem NameBatch NoExp.MRP of PackReturn Unit Qty/ Pack.P. Rate/UnitGST %AmountGST AmountNet Amount
r_id ?? 0) ?>Item_name ?? '')) ?>batch_no_r_s ?? ($row->batch_no ?? ''))) ?>exp_date_str ?? '')) ?>mrp ?? 0)) ?>r_qty ?? 0)) ?> / qty_pak ?? 0)) ?>purchase_price ?? 0)) ?> / purchase_unit_rate ?? 0)) ?>
#Total
diff --git a/app/Views/medical/purchase_return_old_invoice_list.php b/app/Views/medical/purchase_return_old_invoice_list.php new file mode 100644 index 0000000..a1819d7 --- /dev/null +++ b/app/Views/medical/purchase_return_old_invoice_list.php @@ -0,0 +1,57 @@ + + +
+ + + + + + + + + + + + + + + + + + isExp ?? 0) === 1) ? 'style="color:red;"' : '' ?>> + + + + + + + + + + + +
#Pur.DateItemBat./Exp.DtRatePur. QtyC.Unit QtyR.Unit Qty
str_date_of_invoice ?? '')) ?>Item_name ?? '')) ?>batch_no ?? '')) ?>
exp_date ?? '')) ?>
mrp ?? 0)) ?>tqty ?? 0)) ?> /packing ?? 1)) ?>cur_qty ?? 0)) ?> + item_return ?? 0) === 0 && (int) ($row->remove_item ?? 0) === 0): ?> +
+ + +
+ +
+
+ + diff --git a/app/Views/medical/purchase_return_product_search.php b/app/Views/medical/purchase_return_product_search.php new file mode 100644 index 0000000..c9bc375 --- /dev/null +++ b/app/Views/medical/purchase_return_product_search.php @@ -0,0 +1,88 @@ +
+
+ + +
+
+ +
+
+ +
+
+ + +

+ + + + +

+
+
+ +
+
+ + +
+
+ + + +
+
+ + +
+
+ + +
+
+ +
+
+ + diff --git a/app/Views/medical/purchase_return_supplier_list.php b/app/Views/medical/purchase_return_supplier_list.php new file mode 100644 index 0000000..d725de8 --- /dev/null +++ b/app/Views/medical/purchase_return_supplier_list.php @@ -0,0 +1,39 @@ +
+ + + + + + + + + + + + + + + + + + + +
Invoice IDSupplierDateAction
p_r_invoice_no ?? '')) ?>name_supplier ?? '')) ?>str_date_of_invoice ?? $row->date_of_invoice ?? '')) ?> + + Print +
+
+ + diff --git a/app/Views/partials/sidebar.php b/app/Views/partials/sidebar.php index 09c6860..0876adf 100644 --- a/app/Views/partials/sidebar.php +++ b/app/Views/partials/sidebar.php @@ -23,6 +23,29 @@ $canIpdBilling = $user && method_exists($user, 'can') || $user->can('billing.access')) : false; +$canBilling = false; +if ($user && method_exists($user, 'can')) { + $canBilling = $user->can('billing.access') + || $user->can('billing.opd.edit') + || $user->can('billing.opd.pay') + || $user->can('billing.charges.view') + || $user->can('billing.charges.edit') + || $user->can('billing.charges.date-edit') + || $user->can('billing.charges.pay') + || $user->can('billing.charges.cancel') + || $user->can('billing.charges.correct') + || $user->can('billing.ipd.access') + || $user->can('billing.ipd.current-admission') + || $user->can('billing.ipd.invoice') + || $user->can('billing.ipd.cash-balance') + || $user->can('billing.ipd.export') + || $user->can('billing.*'); +} + +if (! $canBilling && $user && method_exists($user, 'inGroup')) { + $canBilling = $user->inGroup('superadmin', 'admin', 'developer'); +} + $canPharmacy = true; if ($user && method_exists($user, 'can')) { $canPharmacy = $user->can('pharmacy.access') @@ -32,6 +55,50 @@ if ($user && method_exists($user, 'can')) { if (! $canPharmacy && $user && method_exists($user, 'inGroup')) { $canPharmacy = $user->inGroup('superadmin', 'admin', 'developer'); } + +$canFinance = false; +if ($user && method_exists($user, 'can')) { + $canFinance = $user->can('finance.access') + || $user->can('finance.vendor.manage') + || $user->can('finance.po.manage') + || $user->can('finance.grn.manage') + || $user->can('finance.invoice.manage') + || $user->can('finance.cash.manage') + || $user->can('finance.doctor_payout.manage') + || $user->can('finance.bank_deposit.manage') + || $user->can('finance.compliance.view') + || $user->can('finance.*'); +} + +if (! $canFinance && $user && method_exists($user, 'inGroup')) { + $canFinance = $user->inGroup('superadmin', 'admin', 'developer'); +} + +$canDoctorWork = false; +if ($user && method_exists($user, 'can')) { + $canDoctorWork = $user->can('doctor_work.access') + || $user->can('doctor_work.appointment.view') + || $user->can('doctor_work.rx_group.manage') + || $user->can('doctor_work.medicine.manage') + || $user->can('doctor_work.advice.manage') + || $user->can('doctor_work.template_workspace.access') + || $user->can('doctor_work.*'); +} + +if (! $canDoctorWork && $user && method_exists($user, 'inGroup')) { + $canDoctorWork = $user->inGroup('superadmin', 'admin', 'developer'); +} + +$canDiagnosis = false; +if ($user && method_exists($user, 'can')) { + $canDiagnosis = $user->can('diagnosis.access') + || $user->can('diagnosis.report.view') + || $user->can('diagnosis.*'); +} + +if (! $canDiagnosis && $user && method_exists($user, 'inGroup')) { + $canDiagnosis = $user->inGroup('superadmin', 'admin', 'developer'); +} ?>
@@ -72,7 +78,9 @@
Reports Document
-
Document reports are not migrated yet.
+
diff --git a/app/Views/report/nabh_audit_report.php b/app/Views/report/nabh_audit_report.php index 7df4a25..7af5c7b 100644 --- a/app/Views/report/nabh_audit_report.php +++ b/app/Views/report/nabh_audit_report.php @@ -18,6 +18,7 @@ +
diff --git a/app/Views/report/nabh_audit_report_table.php b/app/Views/report/nabh_audit_report_table.php index 98ee09f..cdbca7a 100644 --- a/app/Views/report/nabh_audit_report_table.php +++ b/app/Views/report/nabh_audit_report_table.php @@ -9,6 +9,7 @@ $statusFilter = $status_filter ?? 'all'; $overall = $summary['all'] ?? ['total' => 0, 'compliant' => 0, 'critical_missing' => 0, 'avg_completion' => 0]; $ipd = $summary['ipd'] ?? ['total' => 0, 'compliant' => 0, 'critical_missing' => 0, 'avg_completion' => 0]; $opd = $summary['opd'] ?? ['total' => 0, 'compliant' => 0, 'critical_missing' => 0, 'avg_completion' => 0]; +$radiology = $summary['radiology'] ?? ['total' => 0, 'compliant' => 0, 'critical_missing' => 0, 'avg_completion' => 0]; ?>
@@ -44,6 +45,15 @@ $opd = $summary['opd'] ?? ['total' => 0, 'compliant' => 0, 'critical_missing' =>
Avg Completion: %
+
+
+
Radiology Edit
+
Total:
+
Compliant:
+
Critical Missing:
+
Avg Completion: %
+
+
diff --git a/app/Views/welcome_message.php b/app/Views/welcome_message.php index a60826e..6c290a9 100644 --- a/app/Views/welcome_message.php +++ b/app/Views/welcome_message.php @@ -94,7 +94,6 @@ @@ -136,6 +135,7 @@ $.ajax({ url: ourl, dataType: "html", + async: true, timeout: REQUEST_TIMEOUT_MS, beforeSend: function() { $('#main').html('loading...'); @@ -176,6 +176,7 @@ $.ajax({ url: ourl, dataType: "html", + async: true, timeout: REQUEST_TIMEOUT_MS }) .done(function(html) { diff --git a/old_code_ci3/controllers/Auth_ihc - Copy.php b/old_code_ci3/controllers/Auth_ihc - Copy.php new file mode 100644 index 0000000..399e6f1 --- /dev/null +++ b/old_code_ci3/controllers/Auth_ihc - Copy.php @@ -0,0 +1,714 @@ +load->database(); + $this->load->library(array('ion_auth','form_validation')); + $this->load->helper(array('url','language')); + + $this->form_validation->set_error_delimiters($this->config->item('error_start_delimiter', 'ion_auth'), $this->config->item('error_end_delimiter', 'ion_auth')); + + $this->lang->load('auth'); + } + + // log the user in + public function login() + { + $this->data['title'] = $this->lang->line('login_heading'); + + //validate form input + $this->form_validation->set_rules('identity', str_replace(':', '', $this->lang->line('login_identity_label')), 'required'); + $this->form_validation->set_rules('password', str_replace(':', '', $this->lang->line('login_password_label')), 'required'); + + if ($this->form_validation->run() == true) + { + // check to see if the user is logging in + // check for "remember me" + $remember = (bool) $this->input->post('remember'); + + if ($this->ion_auth->login($this->input->post('identity'), $this->input->post('password'), $remember)) + { + //if the login is successful + //redirect them back to the home page + $this->session->set_flashdata('message', $this->ion_auth->messages()); + //redirect('/', 'refresh'); + + redirect('welcome',$user); + } + else + { + // if the login was un-successful + // redirect them back to the login page + $this->session->set_flashdata('message', $this->ion_auth->errors()); + redirect('auth_ihc/login', 'refresh'); // use redirects instead of loading views for compatibility with MY_Controller libraries + } + } + else + { + // the user is not logging in so display the login page + // set the flash data error message if there is one + $this->data['message'] = (validation_errors()) ? validation_errors() : $this->session->flashdata('message'); + + $this->data['identity'] = array('name' => 'identity', + 'id' => 'identity', + 'type' => 'text', + 'value' => $this->form_validation->set_value('identity'), + ); + $this->data['password'] = array('name' => 'password', + 'id' => 'password', + 'type' => 'password', + ); + + $this->_render_page('auth_ihc/login', $this->data); + } + } + + // log the user out + public function logout() + { + $this->data['title'] = "Logout"; + + // log the user out + $logout = $this->ion_auth->logout(); + + // redirect them to the login page + $this->session->set_flashdata('message', $this->ion_auth->messages()); + redirect('auth_ihc/login', 'refresh'); + } + + public function create_user_form() + { + $this->data['title'] = $this->lang->line('create_user_heading'); + + if (!$this->ion_auth->logged_in() || !$this->ion_auth->is_admin()) + { + redirect('auth_ihc', 'refresh'); + } + + $tables = $this->config->item('tables','ion_auth'); + $identity_column = $this->config->item('identity','ion_auth'); + $this->data['identity_column'] = $identity_column; + + // validate form input + $this->form_validation->set_rules('first_name', $this->lang->line('create_user_validation_fname_label'), 'required'); + $this->form_validation->set_rules('last_name', $this->lang->line('create_user_validation_lname_label'), 'required'); + if($identity_column!=='email') + { + $this->form_validation->set_rules('identity',$this->lang->line('create_user_validation_identity_label'),'required|is_unique['.$tables['users'].'.'.$identity_column.']'); + $this->form_validation->set_rules('email', $this->lang->line('create_user_validation_email_label'), 'required|valid_email'); + } + else + { + $this->form_validation->set_rules('email', $this->lang->line('create_user_validation_email_label'), 'required|valid_email|is_unique[' . $tables['users'] . '.email]'); + } + $this->form_validation->set_rules('phone', $this->lang->line('create_user_validation_phone_label'), 'trim'); + //$this->form_validation->set_rules('company', $this->lang->line('create_user_validation_company_label'), 'trim'); + $this->form_validation->set_rules('password', $this->lang->line('create_user_validation_password_label'), 'required|min_length[' . $this->config->item('min_password_length', 'ion_auth') . ']|max_length[' . $this->config->item('max_password_length', 'ion_auth') . ']|matches[password_confirm]'); + $this->form_validation->set_rules('password_confirm', $this->lang->line('create_user_validation_password_confirm_label'), 'required'); + + if ($this->form_validation->run() == true) + { + $email = strtolower($this->input->post('email')); + $identity = ($identity_column==='email') ? $email : $this->input->post('identity'); + $password = $this->input->post('password'); + + $additional_data = array( + 'first_name' => $this->input->post('first_name'), + 'last_name' => $this->input->post('last_name'), + 'company' => $this->input->post('company'), + 'phone' => $this->input->post('phone'), + ); + } + if ($this->form_validation->run() == true && $this->ion_auth->register($identity, $password, $email, $additional_data)) + { + // check to see if we are creating the user + // redirect them back to the admin page + $this->session->set_flashdata('message', $this->ion_auth->messages()); + //redirect("auth_ihc", 'refresh'); + + $rvar=array( + 'insertid' =>1 + ); + + $encode_data = json_encode($rvar); + echo $encode_data; + + } + else + { + // display the create user form + // set the flash data error message if there is one + $this->data['message'] = (validation_errors() ? validation_errors() : ($this->ion_auth->errors() ? $this->ion_auth->errors() : $this->session->flashdata('message'))); + $error_text=$this->data['message']; + + $this->data['first_name'] = array( + 'name' => 'first_name', + 'id' => 'first_name', + 'type' => 'text', + 'class' => 'form-control', + 'value' => $this->form_validation->set_value('first_name'), + ); + + $this->data['last_name'] = array( + 'name' => 'last_name', + 'id' => 'last_name', + 'type' => 'text', + 'class' => 'form-control', + 'value' => $this->form_validation->set_value('last_name'), + ); + $this->data['identity'] = array( + 'name' => 'identity', + 'id' => 'identity', + 'type' => 'text', + 'class' => 'form-control', + 'value' => $this->form_validation->set_value('identity'), + ); + + $this->data['email'] = array( + 'name' => 'email', + 'id' => 'email', + 'type' => 'text', + 'class' => 'form-control', + 'value' => $this->form_validation->set_value('email'), + ); + + $this->data['phone'] = array( + 'name' => 'phone', + 'id' => 'phone', + 'type' => 'text', + 'class' => 'form-control', + 'value' => $this->form_validation->set_value('phone'), + ); + $this->data['password'] = array( + 'name' => 'password', + 'id' => 'password', + 'type' => 'password', + 'class' => 'form-control', + 'value' => $this->form_validation->set_value('password'), + ); + $this->data['password_confirm'] = array( + 'name' => 'password_confirm', + 'id' => 'password_confirm', + 'type' => 'password', + 'class' => 'form-control', + 'value' => $this->form_validation->set_value('password_confirm'), + ); + + $this->_render_page('auth_ihc/create_user', $this->data); + } + } + + public function save_new_user() + { + $this->data['title'] = $this->lang->line('create_user_heading'); + + if (!$this->ion_auth->logged_in() || !$this->ion_auth->is_admin()) + { + redirect('auth_ihc', 'refresh'); + } + + $tables = $this->config->item('tables','ion_auth'); + $identity_column = $this->config->item('identity','ion_auth'); + $this->data['identity_column'] = $identity_column; + + // validate form input + $this->form_validation->set_rules('first_name', $this->lang->line('create_user_validation_fname_label'), 'required'); + $this->form_validation->set_rules('last_name', $this->lang->line('create_user_validation_lname_label'), 'required'); + if($identity_column!=='email') + { + $this->form_validation->set_rules('identity',$this->lang->line('create_user_validation_identity_label'),'required|is_unique['.$tables['users'].'.'.$identity_column.']'); + $this->form_validation->set_rules('email', $this->lang->line('create_user_validation_email_label'), 'required|valid_email'); + } + else + { + $this->form_validation->set_rules('email', $this->lang->line('create_user_validation_email_label'), 'required|valid_email|is_unique[' . $tables['users'] . '.email]'); + } + $this->form_validation->set_rules('phone', $this->lang->line('create_user_validation_phone_label'), 'trim'); + //$this->form_validation->set_rules('company', $this->lang->line('create_user_validation_company_label'), 'trim'); + $this->form_validation->set_rules('password', $this->lang->line('create_user_validation_password_label'), 'required|min_length[' . $this->config->item('min_password_length', 'ion_auth') . ']|max_length[' . $this->config->item('max_password_length', 'ion_auth') . ']|matches[password_confirm]'); + $this->form_validation->set_rules('password_confirm', $this->lang->line('create_user_validation_password_confirm_label'), 'required'); + + if ($this->form_validation->run() == true) + { + $email = strtolower($this->input->post('email')); + $identity = ($identity_column==='email') ? $email : $this->input->post('identity'); + $password = $this->input->post('password'); + + $additional_data = array( + 'first_name' => $this->input->post('first_name'), + 'last_name' => $this->input->post('last_name'), + 'company' => $this->input->post('company'), + 'phone' => $this->input->post('phone'), + ); + } + if ($this->form_validation->run() == true && $this->ion_auth->register($identity, $password, $email, $additional_data)) + { + // check to see if we are creating the user + // redirect them back to the admin page + $this->session->set_flashdata('message', $this->ion_auth->messages()); + //redirect("auth_ihc", 'refresh'); + + $rvar=array( + 'insertid' =>1 + ); + + $encode_data = json_encode($rvar); + echo $encode_data; + + } + else + { + // display the create user form + // set the flash data error message if there is one + $this->data['message'] = (validation_errors() ? validation_errors() : ($this->ion_auth->errors() ? $this->ion_auth->errors() : $this->session->flashdata('message'))); + $error_text=$this->data['message']; + + $rvar=array( + 'insertid' =>0, + 'error_text'=>$error_text + ); + + $encode_data = json_encode($rvar); + echo $encode_data; + + } + } + + // edit a user + public function edit_user($id) + { + $this->data['title'] = $this->lang->line('edit_user_heading'); + + if (!$this->ion_auth->logged_in() || (!$this->ion_auth->is_admin() && !($this->ion_auth->user()->row()->id == $id))) + { + redirect('auth_ihc/login', 'refresh'); + } + + $user = $this->ion_auth->user($id)->row(); + $groups=$this->ion_auth->groups()->result_array(); + $currentGroups = $this->ion_auth->get_users_groups($id)->result(); + + $tables = $this->config->item('tables','ion_auth'); + $identity_column = $this->config->item('identity','ion_auth'); + $this->data['identity_column'] = $identity_column; + + // validate form input + $this->form_validation->set_rules('first_name', $this->lang->line('edit_user_validation_fname_label'), 'required'); + $this->form_validation->set_rules('last_name', $this->lang->line('edit_user_validation_lname_label'), 'required'); + $this->form_validation->set_rules('phone', $this->lang->line('edit_user_validation_phone_label'), 'required'); + + if($identity_column!=='email') + { + $this->form_validation->set_rules('identity',$this->lang->line('edit_user_validation_identity_label'),'required'); + $this->form_validation->set_rules('email', $this->lang->line('edit_user_validation_email_label'), 'required|valid_email'); + } + else + { + $this->form_validation->set_rules('email', $this->lang->line('edit_user_validation_email_label'), 'required|valid_email|is_unique[' . $tables['users'] . '.email]'); + } + + if (isset($_POST) && !empty($_POST)) + { + // do we have a valid request? + if ($this->_valid_csrf_nonce() === FALSE || $id != $this->input->post('id')) + { + show_error($this->lang->line('error_csrf')); + } + + // update the password if it was posted + if ($this->input->post('password')) + { + $this->form_validation->set_rules('password', $this->lang->line('edit_user_validation_password_label'), 'required|min_length[' . $this->config->item('min_password_length', 'ion_auth') . ']|max_length[' . $this->config->item('max_password_length', 'ion_auth') . ']|matches[password_confirm]'); + $this->form_validation->set_rules('password_confirm', $this->lang->line('edit_user_validation_password_confirm_label'), 'required'); + } + + if ($this->form_validation->run() === TRUE) + { + $data = array( + 'first_name' => $this->input->post('first_name'), + 'last_name' => $this->input->post('last_name'), + 'phone' => $this->input->post('phone'), + ); + + // update the password if it was posted + if ($this->input->post('password')) + { + $data['password'] = $this->input->post('password'); + } + + // Only allow updating groups if user is admin + if ($this->ion_auth->is_admin()) + { + //Update the groups user belongs to + $groupData = $this->input->post('groups'); + + if (isset($groupData) && !empty($groupData)) { + + $this->ion_auth->remove_from_group('', $id); + + foreach ($groupData as $grp) { + $this->ion_auth->add_to_group($grp, $id); + } + + } + } + + // check to see if we are updating the user + if($this->ion_auth->update($user->id, $data)) + { + // redirect them back to the admin page if admin, or to the base url if non admin + $this->session->set_flashdata('message', $this->ion_auth->messages() ); + $this->data['message']=$this->ion_auth->messages(); + if ($this->ion_auth->is_admin()) + { + if (!$this->ion_auth->logged_in()) + { + // redirect them to the login page + redirect('auth_ihc/login', 'refresh'); + } + elseif (!$this->ion_auth->is_admin()) // remove this elseif if you want to enable this for non-admins + { + // redirect them to the home page because they must be an administrator to view this + return show_error('You must be an administrator to view this page.'); + } + else + { + // set the flash data error message if there is one + //$this->data['message'] = (validation_errors()) ? validation_errors() : $this->session->flashdata('message'); + + //list the users + $this->data['users'] = $this->ion_auth->users()->result(); + foreach ($this->data['users'] as $k => $user) + { + $this->data['users'][$k]->groups = $this->ion_auth->get_users_groups($user->id)->result(); + } + + $this->_render_page('auth_ihc/index', $this->data); + return; + } + } + else + { + //$this->_render_page('/', 'refresh'); + + } + + } + else + { + // redirect them back to the admin page if admin, or to the base url if non admin + $this->session->set_flashdata('message', $this->ion_auth->errors() ); + $this->data['message']=$this->ion_auth->errors(); + if ($this->ion_auth->is_admin()) + { + if (!$this->ion_auth->logged_in()) + { + // redirect them to the login page + redirect('auth_ihc/login', 'refresh'); + } + elseif (!$this->ion_auth->is_admin()) // remove this elseif if you want to enable this for non-admins + { + // redirect them to the home page because they must be an administrator to view this + return show_error('You must be an administrator to view this page.'); + } + else + { + // set the flash data error message if there is one + //$this->data['message'] = (validation_errors()) ? validation_errors() : $this->session->flashdata('message'); + + //list the users + $this->data['users'] = $this->ion_auth->users()->result(); + foreach ($this->data['users'] as $k => $user) + { + $this->data['users'][$k]->groups = $this->ion_auth->get_users_groups($user->id)->result(); + } + + $this->_render_page('auth_ihc/index', $this->data); + return; + } + } + else + { + $this->_render_page('/', 'refresh'); + } + + } + + } + } + + // display the edit user form + $this->data['csrf'] = $this->_get_csrf_nonce(); + + // set the flash data error message if there is one + $this->data['message'] = (validation_errors() ? validation_errors() : ($this->ion_auth->errors() ? $this->ion_auth->errors() : $this->session->flashdata('message'))); + + // pass the user to the view + $this->data['user'] = $user; + $this->data['groups'] = $groups; + $this->data['currentGroups'] = $currentGroups; + + $this->data['first_name'] = array( + 'name' => 'first_name', + 'id' => 'first_name', + 'type' => 'text', + 'class' => 'form-control', + 'value' => $this->form_validation->set_value('first_name', $user->first_name), + ); + $this->data['last_name'] = array( + 'name' => 'last_name', + 'id' => 'last_name', + 'type' => 'text', + 'class' => 'form-control', + 'value' => $this->form_validation->set_value('last_name', $user->last_name), + ); + + $this->data['email'] = array( + 'name' => 'email', + 'id' => 'email', + 'type' => 'text', + 'class' => 'form-control', + 'value' => $this->form_validation->set_value('email', $user->email), + ); + + $this->data['phone'] = array( + 'name' => 'phone', + 'id' => 'phone', + 'type' => 'text', + 'class' => 'form-control', + 'value' => $this->form_validation->set_value('phone', $user->phone), + ); + + + $this->data['identity'] = array( + 'name' => 'identity', + 'id' => 'identity', + 'type' => 'text', + 'class' => 'form-control', + 'readonly' => 'true', + 'value' => $this->form_validation->set_value('identity',$user->username), + ); + + $this->data['password_confirm'] = array( + 'name' => 'password_confirm', + 'id' => 'password_confirm', + 'class' => 'form-control', + 'type' => 'password' + + ); + + $this->data['password'] = array( + 'name' => 'password', + 'id' => 'password', + 'class' => 'form-control', + 'type' => 'password' + ); + + $this->_render_page('auth_ihc/edit_user', $this->data); + } + + + // redirect if needed, otherwise display the user list + public function search() + { + + if (!$this->ion_auth->logged_in()) + { + // redirect them to the login page + redirect('auth_ihc/login', 'refresh'); + } + elseif (!$this->ion_auth->is_admin()) // remove this elseif if you want to enable this for non-admins + { + // redirect them to the home page because they must be an administrator to view this + return show_error('You must be an administrator to view this page.'); + } + else + { + // set the flash data error message if there is one + $this->data['message'] = (validation_errors()) ? validation_errors() : $this->session->flashdata('message'); + + //list the users + $this->data['users'] = $this->ion_auth->users()->result(); + foreach ($this->data['users'] as $k => $user) + { + $this->data['users'][$k]->groups = $this->ion_auth->get_users_groups($user->id)->result(); + } + + $this->_render_page('auth_ihc/index', $this->data); + } + } + + public function create_group() + { + $this->data['title'] = $this->lang->line('create_group_title'); + + if (!$this->ion_auth->logged_in() || !$this->ion_auth->is_admin()) + { + redirect('auth_ihc/login', 'refresh'); + } + + // validate form input + $this->form_validation->set_rules('group_name', $this->lang->line('create_group_validation_name_label'), 'required|alpha_dash'); + + if ($this->form_validation->run() == TRUE) + { + $new_group_id = $this->ion_auth->create_group($this->input->post('group_name'), $this->input->post('description')); + if($new_group_id) + { + // check to see if we are creating the group + // redirect them back to the admin page + $this->session->set_flashdata('message', $this->ion_auth->messages()); + $this->data['message']=$this->ion_auth->messages(); + //redirect("auth", 'refresh'); + $this->data['users'] = $this->ion_auth->users()->result(); + foreach ($this->data['users'] as $k => $user) + { + $this->data['users'][$k]->groups = $this->ion_auth->get_users_groups($user->id)->result(); + } + + $this->_render_page('auth_ihc/index', $this->data); + return; + } + } + else + { + // display the create group form + // set the flash data error message if there is one + $this->data['message'] = (validation_errors() ? validation_errors() : ($this->ion_auth->errors() ? $this->ion_auth->errors() : $this->session->flashdata('message'))); + + $this->data['group_name'] = array( + 'name' => 'group_name', + 'id' => 'group_name', + 'type' => 'text', + 'class' => 'form-control', + 'value' => $this->form_validation->set_value('group_name'), + ); + $this->data['description'] = array( + 'name' => 'description', + 'id' => 'description', + 'type' => 'text', + 'class' => 'form-control', + 'value' => $this->form_validation->set_value('description'), + ); + + $this->_render_page('auth_ihc/create_group', $this->data); + } + } + + // edit a group + public function edit_group($id) + { + // bail if no group id given + if(!$id || empty($id)) + { + redirect('auth', 'refresh'); + } + + $this->data['title'] = $this->lang->line('edit_group_title'); + + if (!$this->ion_auth->logged_in() || !$this->ion_auth->is_admin()) + { + redirect('auth', 'refresh'); + } + + $group = $this->ion_auth->group($id)->row(); + + // validate form input + $this->form_validation->set_rules('group_name', $this->lang->line('edit_group_validation_name_label'), 'required|alpha_dash'); + + if (isset($_POST) && !empty($_POST)) + { + if ($this->form_validation->run() === TRUE) + { + $group_update = $this->ion_auth->update_group($id, $_POST['group_name'], $_POST['group_description']); + + if($group_update) + { + $this->session->set_flashdata('message', $this->lang->line('edit_group_saved')); + $this->data['message']=$this->lang->line('edit_group_saved'); + } + else + { + $this->session->set_flashdata('message', $this->ion_auth->errors()); + $this->data['message']=$this->ion_auth->errors(); + } + + //redirect("auth", 'refresh'); + $this->data['users'] = $this->ion_auth->users()->result(); + foreach ($this->data['users'] as $k => $user) + { + $this->data['users'][$k]->groups = $this->ion_auth->get_users_groups($user->id)->result(); + } + + $this->_render_page('auth_ihc/index', $this->data); + return; + } + } + + // set the flash data error message if there is one + $this->data['message'] = (validation_errors() ? validation_errors() : ($this->ion_auth->errors() ? $this->ion_auth->errors() : $this->session->flashdata('message'))); + + // pass the user to the view + $this->data['group'] = $group; + + $readonly = $this->config->item('admin_group', 'ion_auth') === $group->name ? 'readonly' : ''; + + $this->data['group_name'] = array( + 'name' => 'group_name', + 'id' => 'group_name', + 'type' => 'text', + 'class' => 'form-control', + 'value' => $this->form_validation->set_value('group_name', $group->name), + $readonly => $readonly, + ); + $this->data['group_description'] = array( + 'name' => 'group_description', + 'id' => 'group_description', + 'type' => 'text', + 'class' => 'form-control', + 'value' => $this->form_validation->set_value('group_description', $group->description), + ); + + $this->_render_page('auth_ihc/edit_group', $this->data); + } + + + public function _get_csrf_nonce() + { + $this->load->helper('string'); + $key = random_string('alnum', 8); + $value = random_string('alnum', 20); + $this->session->set_flashdata('csrfkey', $key); + $this->session->set_flashdata('csrfvalue', $value); + + return array($key => $value); + } + + public function _valid_csrf_nonce() + { + if ($this->input->post($this->session->flashdata('csrfkey')) !== FALSE && + $this->input->post($this->session->flashdata('csrfkey')) == $this->session->flashdata('csrfvalue')) + { + return TRUE; + } + else + { + return FALSE; + } + } + + + public function _render_page($view, $data=null, $returnhtml=false)//I think this makes more sense + { + + $this->viewdata = (empty($data)) ? $this->data: $data; + + $view_html = $this->load->view($view, $this->viewdata, $returnhtml); + + if ($returnhtml) return $view_html;//This will return html on 3rd argument being true + } + +} \ No newline at end of file diff --git a/old_code_ci3/controllers/Auth_ihc.php b/old_code_ci3/controllers/Auth_ihc.php new file mode 100644 index 0000000..e6e1fd3 --- /dev/null +++ b/old_code_ci3/controllers/Auth_ihc.php @@ -0,0 +1,853 @@ +load->database(); + $this->load->library(array('ion_auth','form_validation')); + $this->load->helper(array('url','language')); + + $this->form_validation->set_error_delimiters($this->config->item('error_start_delimiter', 'ion_auth'), $this->config->item('error_end_delimiter', 'ion_auth')); + + $this->lang->load('auth'); + } + + // log the user in + public function login() + { + $this->data['title'] = $this->lang->line('login_heading'); + + //validate form input + $this->form_validation->set_rules('identity', str_replace(':', '', $this->lang->line('login_identity_label')), 'required'); + $this->form_validation->set_rules('password', str_replace(':', '', $this->lang->line('login_password_label')), 'required'); + + if ($this->form_validation->run() == true) + { + // check to see if the user is logging in + // check for "remember me" + $remember = (bool) $this->input->post('remember'); + + if ($this->ion_auth->login($this->input->post('identity'), $this->input->post('password'), $remember)) + { + //if the login is successful + //redirect them back to the home page + $this->session->set_flashdata('message', $this->ion_auth->messages()); + //redirect('/', 'refresh'); + + redirect('welcome'); + } + else + { + // if the login was un-successful + // redirect them back to the login page + $this->session->set_flashdata('message', $this->ion_auth->errors()); + redirect('auth_ihc/login', 'refresh'); // use redirects instead of loading views for compatibility with MY_Controller libraries + } + } + else + { + // the user is not logging in so display the login page + // set the flash data error message if there is one + $this->data['message'] = (validation_errors()) ? validation_errors() : $this->session->flashdata('message'); + + $this->data['identity'] = array('name' => 'identity', + 'id' => 'identity', + 'type' => 'text', + 'value' => $this->form_validation->set_value('identity'), + ); + $this->data['password'] = array('name' => 'password', + 'id' => 'password', + 'type' => 'password', + ); + + $this->_render_page('auth_ihc/login', $this->data); + } + } + + // log the user out + public function logout() + { + $this->data['title'] = "Logout"; + + // log the user out + $logout = $this->ion_auth->logout(); + + // redirect them to the login page + $this->session->set_flashdata('message', $this->ion_auth->messages()); + redirect('auth_ihc/login', 'refresh'); + } + + public function create_user_form() + { + $this->data['title'] = $this->lang->line('create_user_heading'); + + if (!$this->ion_auth->logged_in() || !$this->ion_auth->is_admin()) + { + redirect('auth_ihc', 'refresh'); + } + + $tables = $this->config->item('tables','ion_auth'); + $identity_column = $this->config->item('identity','ion_auth'); + $this->data['identity_column'] = $identity_column; + + // validate form input + $this->form_validation->set_rules('first_name', $this->lang->line('create_user_validation_fname_label'), 'required'); + $this->form_validation->set_rules('last_name', $this->lang->line('create_user_validation_lname_label'), 'required'); + if($identity_column!=='email') + { + $this->form_validation->set_rules('identity',$this->lang->line('create_user_validation_identity_label'),'required|is_unique['.$tables['users'].'.'.$identity_column.']'); + $this->form_validation->set_rules('email', $this->lang->line('create_user_validation_email_label'), 'required|valid_email'); + } + else + { + $this->form_validation->set_rules('email', $this->lang->line('create_user_validation_email_label'), 'required|valid_email|is_unique[' . $tables['users'] . '.email]'); + } + $this->form_validation->set_rules('phone', $this->lang->line('create_user_validation_phone_label'), 'trim'); + //$this->form_validation->set_rules('company', $this->lang->line('create_user_validation_company_label'), 'trim'); + $this->form_validation->set_rules('password', $this->lang->line('create_user_validation_password_label'), 'required|min_length[' . $this->config->item('min_password_length', 'ion_auth') . ']|max_length[' . $this->config->item('max_password_length', 'ion_auth') . ']|matches[password_confirm]'); + $this->form_validation->set_rules('password_confirm', $this->lang->line('create_user_validation_password_confirm_label'), 'required'); + + if ($this->form_validation->run() == true) + { + $email = strtolower($this->input->post('email')); + $identity = ($identity_column==='email') ? $email : $this->input->post('identity'); + $password = $this->input->post('password'); + + $additional_data = array( + 'first_name' => $this->input->post('first_name'), + 'last_name' => $this->input->post('last_name'), + 'company' => $this->input->post('company'), + 'phone' => $this->input->post('phone'), + ); + } + if ($this->form_validation->run() == true && $this->ion_auth->register($identity, $password, $email, $additional_data)) + { + // check to see if we are creating the user + // redirect them back to the admin page + $this->session->set_flashdata('message', $this->ion_auth->messages()); + //redirect("auth_ihc", 'refresh'); + + $rvar=array( + 'insertid' =>1 + ); + + $encode_data = json_encode($rvar); + echo $encode_data; + + } + else + { + // display the create user form + // set the flash data error message if there is one + $this->data['message'] = (validation_errors() ? validation_errors() : ($this->ion_auth->errors() ? $this->ion_auth->errors() : $this->session->flashdata('message'))); + $error_text=$this->data['message']; + + $this->data['first_name'] = array( + 'name' => 'first_name', + 'id' => 'first_name', + 'type' => 'text', + 'class' => 'form-control', + 'value' => $this->form_validation->set_value('first_name'), + ); + + $this->data['last_name'] = array( + 'name' => 'last_name', + 'id' => 'last_name', + 'type' => 'text', + 'class' => 'form-control', + 'value' => $this->form_validation->set_value('last_name'), + ); + $this->data['identity'] = array( + 'name' => 'identity', + 'id' => 'identity', + 'type' => 'text', + 'class' => 'form-control', + 'value' => $this->form_validation->set_value('identity'), + ); + + $this->data['email'] = array( + 'name' => 'email', + 'id' => 'email', + 'type' => 'text', + 'class' => 'form-control', + 'value' => $this->form_validation->set_value('email'), + ); + + $this->data['phone'] = array( + 'name' => 'phone', + 'id' => 'phone', + 'type' => 'text', + 'class' => 'form-control', + 'value' => $this->form_validation->set_value('phone'), + ); + $this->data['password'] = array( + 'name' => 'password', + 'id' => 'password', + 'type' => 'password', + 'class' => 'form-control', + 'value' => $this->form_validation->set_value('password'), + ); + $this->data['password_confirm'] = array( + 'name' => 'password_confirm', + 'id' => 'password_confirm', + 'type' => 'password', + 'class' => 'form-control', + 'value' => $this->form_validation->set_value('password_confirm'), + ); + + $this->_render_page('auth_ihc/create_user', $this->data); + } + } + + public function save_new_user() + { + $this->data['title'] = $this->lang->line('create_user_heading'); + + if (!$this->ion_auth->logged_in() || !$this->ion_auth->is_admin()) + { + redirect('auth_ihc', 'refresh'); + } + + $tables = $this->config->item('tables','ion_auth'); + $identity_column = $this->config->item('identity','ion_auth'); + $this->data['identity_column'] = $identity_column; + + // validate form input + $this->form_validation->set_rules('first_name', $this->lang->line('create_user_validation_fname_label'), 'required'); + $this->form_validation->set_rules('last_name', $this->lang->line('create_user_validation_lname_label'), 'required'); + if($identity_column!=='email') + { + $this->form_validation->set_rules('identity',$this->lang->line('create_user_validation_identity_label'),'required|is_unique['.$tables['users'].'.'.$identity_column.']'); + $this->form_validation->set_rules('email', $this->lang->line('create_user_validation_email_label'), 'required|valid_email'); + } + else + { + $this->form_validation->set_rules('email', $this->lang->line('create_user_validation_email_label'), 'required|valid_email|is_unique[' . $tables['users'] . '.email]'); + } + $this->form_validation->set_rules('phone', $this->lang->line('create_user_validation_phone_label'), 'trim'); + //$this->form_validation->set_rules('company', $this->lang->line('create_user_validation_company_label'), 'trim'); + $this->form_validation->set_rules('password', $this->lang->line('create_user_validation_password_label'), 'required|min_length[' . $this->config->item('min_password_length', 'ion_auth') . ']|max_length[' . $this->config->item('max_password_length', 'ion_auth') . ']|matches[password_confirm]'); + $this->form_validation->set_rules('password_confirm', $this->lang->line('create_user_validation_password_confirm_label'), 'required'); + + if ($this->form_validation->run() == true) + { + $email = strtolower($this->input->post('email')); + $identity = ($identity_column==='email') ? $email : $this->input->post('identity'); + $password = $this->input->post('password'); + + $additional_data = array( + 'first_name' => $this->input->post('first_name'), + 'last_name' => $this->input->post('last_name'), + 'company' => $this->input->post('company'), + 'phone' => $this->input->post('phone'), + ); + } + if ($this->form_validation->run() == true && $this->ion_auth->register($identity, $password, $email, $additional_data)) + { + // check to see if we are creating the user + // redirect them back to the admin page + $this->session->set_flashdata('message', $this->ion_auth->messages()); + //redirect("auth_ihc", 'refresh'); + + $rvar=array( + 'insertid' =>1 + ); + + $encode_data = json_encode($rvar); + echo $encode_data; + + } + else + { + // display the create user form + // set the flash data error message if there is one + $this->data['message'] = (validation_errors() ? validation_errors() : ($this->ion_auth->errors() ? $this->ion_auth->errors() : $this->session->flashdata('message'))); + $error_text=$this->data['message']; + + $rvar=array( + 'insertid' =>0, + 'error_text'=>$error_text + ); + + $encode_data = json_encode($rvar); + echo $encode_data; + + } + } + + // edit a user + public function edit_user($id) + { + $this->data['title'] = $this->lang->line('edit_user_heading'); + + if (!$this->ion_auth->logged_in() || (!$this->ion_auth->is_admin() && !($this->ion_auth->user()->row()->id == $id))) + { + redirect('auth_ihc/login', 'refresh'); + } + + $user = $this->ion_auth->user($id)->row(); + $groups=$this->ion_auth->groups()->result_array(); + $currentGroups = $this->ion_auth->get_users_groups($id)->result(); + + $tables = $this->config->item('tables','ion_auth'); + $identity_column = $this->config->item('identity','ion_auth'); + $this->data['identity_column'] = $identity_column; + + + // validate form input + $this->form_validation->set_rules('first_name', $this->lang->line('edit_user_validation_fname_label'), 'required'); + $this->form_validation->set_rules('last_name', $this->lang->line('edit_user_validation_lname_label'), 'required'); + $this->form_validation->set_rules('phone', $this->lang->line('edit_user_validation_phone_label'), 'required'); + + if (isset($_POST) && !empty($_POST)) + { + // do we have a valid request? + /*if ($this->_valid_csrf_nonce() === FALSE || $id != $this->input->post('id')) + { + show_error($this->lang->line('error_csrf')); + } + */ + + // update the password if it was posted + if ($this->input->post('password')) + { + $this->form_validation->set_rules('password', $this->lang->line('edit_user_validation_password_label'), 'required|min_length[' . $this->config->item('min_password_length', 'ion_auth') . ']|max_length[' . $this->config->item('max_password_length', 'ion_auth') . ']|matches[password_confirm]'); + $this->form_validation->set_rules('password_confirm', $this->lang->line('edit_user_validation_password_confirm_label'), 'required'); + } + + if ($this->form_validation->run() === TRUE) + { + $data = array( + 'first_name' => $this->input->post('first_name'), + 'last_name' => $this->input->post('last_name'), + 'phone' => $this->input->post('phone'), + ); + + // update the password if it was posted + if ($this->input->post('password')) + { + $data['password'] = $this->input->post('password'); + } + + // Only allow updating groups if user is admin + if ($this->ion_auth->is_admin()) + { + //Update the groups user belongs to + $groupData = $this->input->post('groups'); + + if (isset($groupData) && !empty($groupData)) { + + $this->ion_auth->remove_from_group('', $id); + + foreach ($groupData as $grp) { + $this->ion_auth->add_to_group($grp, $id); + } + + } + } + + // check to see if we are updating the user + if($this->ion_auth->update($user->id, $data)) + { + // redirect them back to the admin page if admin, or to the base url if non admin + $this->session->set_flashdata('message', $this->ion_auth->messages() ); + $this->data['message']=$this->ion_auth->messages(); + if ($this->ion_auth->is_admin()) + { + if (!$this->ion_auth->logged_in()) + { + // redirect them to the login page + redirect('auth_ihc/login', 'refresh'); + } + elseif (!$this->ion_auth->is_admin()) // remove this elseif if you want to enable this for non-admins + { + // redirect them to the home page because they must be an administrator to view this + return show_error('You must be an administrator to view this page.'); + } + else + { + // set the flash data error message if there is one + //$this->data['message'] = (validation_errors()) ? validation_errors() : $this->session->flashdata('message'); + + //list the users + $this->data['users'] = $this->ion_auth->users()->result(); + foreach ($this->data['users'] as $k => $user) + { + $this->data['users'][$k]->groups = $this->ion_auth->get_users_groups($user->id)->result(); + } + + $this->_render_page('auth_ihc/index', $this->data); + return; + } + } + else + { + //$this->_render_page('/', 'refresh'); + + } + + } + else + { + // redirect them back to the admin page if admin, or to the base url if non admin + $this->session->set_flashdata('message', $this->ion_auth->errors() ); + $this->data['message']=$this->ion_auth->errors(); + if ($this->ion_auth->is_admin()) + { + if (!$this->ion_auth->logged_in()) + { + // redirect them to the login page + redirect('auth_ihc/login', 'refresh'); + } + elseif (!$this->ion_auth->is_admin()) // remove this elseif if you want to enable this for non-admins + { + // redirect them to the home page because they must be an administrator to view this + return show_error('You must be an administrator to view this page.'); + } + else + { + // set the flash data error message if there is one + //$this->data['message'] = (validation_errors()) ? validation_errors() : $this->session->flashdata('message'); + + //list the users + $this->data['users'] = $this->ion_auth->users()->result(); + foreach ($this->data['users'] as $k => $user) + { + $this->data['users'][$k]->groups = $this->ion_auth->get_users_groups($user->id)->result(); + } + + $this->_render_page('auth_ihc/index', $this->data); + return; + } + } + else + { + $this->_render_page('/', 'refresh'); + } + + } + + } + } + + // display the edit user form + $this->data['csrf'] = $this->_get_csrf_nonce(); + + // set the flash data error message if there is one + $this->data['message'] = (validation_errors() ? validation_errors() : ($this->ion_auth->errors() ? $this->ion_auth->errors() : $this->session->flashdata('message'))); + + // pass the user to the view + $this->data['user'] = $user; + $this->data['groups'] = $groups; + $this->data['currentGroups'] = $currentGroups; + + $this->data['first_name'] = array( + 'name' => 'first_name', + 'id' => 'first_name', + 'type' => 'text', + 'class' => 'form-control', + 'value' => $this->form_validation->set_value('first_name', $user->first_name), + ); + $this->data['last_name'] = array( + 'name' => 'last_name', + 'id' => 'last_name', + 'type' => 'text', + 'class' => 'form-control', + 'value' => $this->form_validation->set_value('last_name', $user->last_name), + ); + + $this->data['phone'] = array( + 'name' => 'phone', + 'id' => 'phone', + 'type' => 'text', + 'class' => 'form-control', + 'value' => $this->form_validation->set_value('phone', $user->phone), + ); + $this->data['password'] = array( + 'name' => 'password', + 'id' => 'password', + 'type' => 'password', + 'class' => 'form-control' + ); + + $this->data['password_confirm'] = array( + 'name' => 'password_confirm', + 'id' => 'password_confirm', + 'type' => 'password', + 'class' => 'form-control' + ); + + $this->data['identity'] = array( + 'name' => 'identity', + 'id' => 'identity', + 'type' => 'text', + 'class' => 'form-control', + 'readonly' => 'true', + 'value' => $this->form_validation->set_value('identity',$user->username), + ); + + $this->_render_page('auth_ihc/edit_user', $this->data); + } + + public function edit_user_self($id) + { + $this->data['title'] = $this->lang->line('edit_user_heading'); + + if (!$this->ion_auth->logged_in() || !($this->ion_auth->user()->row()->id == $id)) + { + redirect('auth_ihc/login', 'refresh'); + } + + $user = $this->ion_auth->user($id)->row(); + $groups=$this->ion_auth->groups()->result_array(); + $currentGroups = $this->ion_auth->get_users_groups($id)->result(); + + $tables = $this->config->item('tables','ion_auth'); + $identity_column = $this->config->item('identity','ion_auth'); + $this->data['identity_column'] = $identity_column; + + if (isset($_POST) && !empty($_POST)) + { + // do we have a valid request? + /*if ($this->_valid_csrf_nonce() === FALSE || $id != $this->input->post('id')) + { + show_error($this->lang->line('error_csrf')); + } + */ + + // update the password if it was posted + if ($this->input->post('password')) + { + $this->form_validation->set_rules('password', $this->lang->line('edit_user_validation_password_label'), 'required|min_length[' . $this->config->item('min_password_length', 'ion_auth') . ']|max_length[' . $this->config->item('max_password_length', 'ion_auth') . ']|matches[password_confirm]'); + $this->form_validation->set_rules('password_confirm', $this->lang->line('edit_user_validation_password_confirm_label'), 'required'); + } + + if ($this->form_validation->run() === TRUE) + { + $data = array(); + + // update the password if it was posted + if ($this->input->post('password')) + { + $data['password'] = $this->input->post('password'); + } + + // Only allow updating groups if user is admin + + + // check to see if we are updating the user + if($this->ion_auth->update($user->id, $data)) + { + // redirect them back to the admin page if admin, or to the base url if non admin + $this->session->set_flashdata('message', $this->ion_auth->messages() ); + $this->data['message']=$this->ion_auth->messages(); + if ($this->ion_auth->is_admin()) + { + if (!$this->ion_auth->logged_in()) + { + // redirect them to the login page + redirect('auth_ihc/login', 'refresh'); + } + else + { + // set the flash data error message if there is one + //$this->data['message'] = (validation_errors()) ? validation_errors() : $this->session->flashdata('message'); + + //list the users + $this->data['users'] = $this->ion_auth->users()->result(); + foreach ($this->data['users'] as $k => $user) + { + $this->data['users'][$k]->groups = $this->ion_auth->get_users_groups($user->id)->result(); + } + + $this->_render_page('auth_ihc/index', $this->data); + return; + } + } + else + { + //$this->_render_page('/', 'refresh'); + + } + + } + else + { + // redirect them back to the admin page if admin, or to the base url if non admin + $this->session->set_flashdata('message', $this->ion_auth->errors() ); + $this->data['message']=$this->ion_auth->errors(); + if ($this->ion_auth->is_admin()) + { + if (!$this->ion_auth->logged_in()) + { + // redirect them to the login page + redirect('auth_ihc/login', 'refresh'); + } + elseif (!$this->ion_auth->is_admin()) // remove this elseif if you want to enable this for non-admins + { + // redirect them to the home page because they must be an administrator to view this + return show_error('You must be an administrator to view this page.'); + } + else + { + // set the flash data error message if there is one + //$this->data['message'] = (validation_errors()) ? validation_errors() : $this->session->flashdata('message'); + + //list the users + $this->data['users'] = $this->ion_auth->users()->result(); + foreach ($this->data['users'] as $k => $user) + { + $this->data['users'][$k]->groups = $this->ion_auth->get_users_groups($user->id)->result(); + } + + $this->_render_page('auth_ihc/profile_update', $this->data); + return; + } + } + else + { + $this->_render_page('/', 'refresh'); + } + + } + + } + } + + // display the edit user form + $this->data['csrf'] = $this->_get_csrf_nonce(); + + // set the flash data error message if there is one + $this->data['message'] = (validation_errors() ? validation_errors() : ($this->ion_auth->errors() ? $this->ion_auth->errors() : $this->session->flashdata('message'))); + + // pass the user to the view + $this->data['user'] = $user; + $this->data['groups'] = $groups; + $this->data['currentGroups'] = $currentGroups; + + $this->data['password'] = array( + 'name' => 'password', + 'id' => 'password', + 'type' => 'password', + 'class' => 'form-control' + ); + + $this->data['password_confirm'] = array( + 'name' => 'password_confirm', + 'id' => 'password_confirm', + 'type' => 'password', + 'class' => 'form-control' + ); + + $this->data['identity'] = array( + 'name' => 'identity', + 'id' => 'identity', + 'type' => 'text', + 'class' => 'form-control', + 'readonly' => 'true', + 'value' => $this->form_validation->set_value('identity',$user->username), + ); + + $this->_render_page('auth_ihc/profile_update', $this->data); + } + + + // redirect if needed, otherwise display the user list + public function search() + { + + if (!$this->ion_auth->logged_in()) + { + // redirect them to the login page + redirect('auth_ihc/login', 'refresh'); + } + elseif (!$this->ion_auth->is_admin()) // remove this elseif if you want to enable this for non-admins + { + // redirect them to the home page because they must be an administrator to view this + return show_error('You must be an administrator to view this page.'); + } + else + { + // set the flash data error message if there is one + $this->data['message'] = (validation_errors()) ? validation_errors() : $this->session->flashdata('message'); + + //list the users + $this->data['users'] = $this->ion_auth->users()->result(); + foreach ($this->data['users'] as $k => $user) + { + $this->data['users'][$k]->groups = $this->ion_auth->get_users_groups($user->id)->result(); + } + + $this->_render_page('auth_ihc/index', $this->data); + } + } + + public function create_group() + { + $this->data['title'] = $this->lang->line('create_group_title'); + + if (!$this->ion_auth->logged_in() || !$this->ion_auth->is_admin()) + { + redirect('auth_ihc/login', 'refresh'); + } + + // validate form input + $this->form_validation->set_rules('group_name', $this->lang->line('create_group_validation_name_label'), 'required|alpha_dash'); + + if ($this->form_validation->run() == TRUE) + { + $new_group_id = $this->ion_auth->create_group($this->input->post('group_name'), $this->input->post('description')); + if($new_group_id) + { + // check to see if we are creating the group + // redirect them back to the admin page + $this->session->set_flashdata('message', $this->ion_auth->messages()); + $this->data['message']=$this->ion_auth->messages(); + //redirect("auth", 'refresh'); + $this->data['users'] = $this->ion_auth->users()->result(); + foreach ($this->data['users'] as $k => $user) + { + $this->data['users'][$k]->groups = $this->ion_auth->get_users_groups($user->id)->result(); + } + + $this->_render_page('auth_ihc/index', $this->data); + return; + } + } + else + { + // display the create group form + // set the flash data error message if there is one + $this->data['message'] = (validation_errors() ? validation_errors() : ($this->ion_auth->errors() ? $this->ion_auth->errors() : $this->session->flashdata('message'))); + + $this->data['group_name'] = array( + 'name' => 'group_name', + 'id' => 'group_name', + 'type' => 'text', + 'value' => $this->form_validation->set_value('group_name'), + ); + $this->data['description'] = array( + 'name' => 'description', + 'id' => 'description', + 'type' => 'text', + 'value' => $this->form_validation->set_value('description'), + ); + + $this->_render_page('auth_ihc/create_group', $this->data); + } + } + + // edit a group + public function edit_group($id) + { + // bail if no group id given + if(!$id || empty($id)) + { + redirect('auth', 'refresh'); + } + + $this->data['title'] = $this->lang->line('edit_group_title'); + + if (!$this->ion_auth->logged_in() || !$this->ion_auth->is_admin()) + { + redirect('auth', 'refresh'); + } + + $group = $this->ion_auth->group($id)->row(); + + // validate form input + $this->form_validation->set_rules('group_name', $this->lang->line('edit_group_validation_name_label'), 'required|alpha_dash'); + + if (isset($_POST) && !empty($_POST)) + { + if ($this->form_validation->run() === TRUE) + { + $group_update = $this->ion_auth->update_group($id, $_POST['group_name'], $_POST['group_description']); + + if($group_update) + { + $this->session->set_flashdata('message', $this->lang->line('edit_group_saved')); + $this->data['message']=$this->lang->line('edit_group_saved'); + } + else + { + $this->session->set_flashdata('message', $this->ion_auth->errors()); + $this->data['message']=$this->ion_auth->errors(); + } + + //redirect("auth", 'refresh'); + $this->data['users'] = $this->ion_auth->users()->result(); + foreach ($this->data['users'] as $k => $user) + { + $this->data['users'][$k]->groups = $this->ion_auth->get_users_groups($user->id)->result(); + } + + $this->_render_page('auth_ihc/index', $this->data); + return; + } + } + + // set the flash data error message if there is one + $this->data['message'] = (validation_errors() ? validation_errors() : ($this->ion_auth->errors() ? $this->ion_auth->errors() : $this->session->flashdata('message'))); + + // pass the user to the view + $this->data['group'] = $group; + + $readonly = $this->config->item('admin_group', 'ion_auth') === $group->name ? 'readonly' : ''; + + $this->data['group_name'] = array( + 'name' => 'group_name', + 'id' => 'group_name', + 'type' => 'text', + 'value' => $this->form_validation->set_value('group_name', $group->name), + $readonly => $readonly, + ); + $this->data['group_description'] = array( + 'name' => 'group_description', + 'id' => 'group_description', + 'type' => 'text', + 'value' => $this->form_validation->set_value('group_description', $group->description), + ); + + $this->_render_page('auth_ihc/edit_group', $this->data); + } + + + public function _get_csrf_nonce() + { + $this->load->helper('string'); + $key = random_string('alnum', 8); + $value = random_string('alnum', 20); + $this->session->set_flashdata('csrfkey', $key); + $this->session->set_flashdata('csrfvalue', $value); + + return array($key => $value); + } + + public function _valid_csrf_nonce() + { + if ($this->input->post($this->session->flashdata('csrfkey')) !== FALSE && + $this->input->post($this->session->flashdata('csrfkey')) == $this->session->flashdata('csrfvalue')) + { + return TRUE; + } + else + { + return FALSE; + } + } + + + public function _render_page($view, $data=null, $returnhtml=false)//I think this makes more sense + { + + $this->viewdata = (empty($data)) ? $this->data: $data; + + $view_html = $this->load->view($view, $this->viewdata, $returnhtml); + + if ($returnhtml) return $view_html;//This will return html on 3rd argument being true + } + +} \ No newline at end of file diff --git a/old_code_ci3/controllers/Doc_Admin.php b/old_code_ci3/controllers/Doc_Admin.php index 39eb8d1..256dfc7 100644 --- a/old_code_ci3/controllers/Doc_Admin.php +++ b/old_code_ci3/controllers/Doc_Admin.php @@ -8,12 +8,16 @@ class Doc_Admin extends MY_Controller { } + public function doc_list() { $sql="select * from doc_format_master where active=1"; $query = $this->db->query($sql); $data['doc_master']= $query->result(); + echo 'Test'; + + $this->load->view('DocAdmin/doc_list',$data); } diff --git a/old_code_ci3/controllers/Document_Patient.php b/old_code_ci3/controllers/Document_Patient.php index 5bd89b6..a9d7b3b 100644 --- a/old_code_ci3/controllers/Document_Patient.php +++ b/old_code_ci3/controllers/Document_Patient.php @@ -1,418 +1,438 @@ load->model('DocFormat_M'); } - function p_doc_record($pno) - { - $sql = "select *,IFNULL(GET_AGE_BY_DOB(dob),age) as str_age,Date_Format(insert_date,'%Y-%m-%d') as str_regdate,if(gender=1,'Male','Female') as xgender from patient_master where id=" . $pno; + function p_doc_record($pno) + { + $sql="select *,GET_AGE_1(dob,age,age_in_month,estimate_dob) as str_age,Date_Format(insert_date,'%Y-%m-%d') as str_regdate,if(gender=1,'Male','Female') as xgender from patient_master where id=".$pno; $query = $this->db->query($sql); - $data['person_info'] = $query->result(); - - $sql = "select * from doc_format_master where active=1 "; + $data['person_info']= $query->result(); + + + $sql="select * from doc_format_master where active=1 "; $query = $this->db->query($sql); - $data['doc_format'] = $query->result(); + $data['doc_format']= $query->result(); - $sql = "select * from doctor_master where active=1 order by p_fname"; - $query = $this->db->query($sql); - $data['doclist'] = $query->result(); - - $sql = "select patient_doc.*,date_format(patient_doc.date_issue,'%d-%m-%Y') as str_date_issue,doc_format_master.doc_name + $sql="select * from doctor_master where active=1 order by p_fname"; + $query = $this->db->query($sql); + $data['doclist']= $query->result(); + + $sql="select patient_doc.*,date_format(patient_doc.date_issue,'%d-%m-%Y') as str_date_issue,doc_format_master.doc_name from patient_doc join doc_format_master on patient_doc.doc_format_id = doc_format_master.df_id - where p_id=" . $pno . " order by date_issue desc"; - $query = $this->db->query($sql); - $data['patient_doc'] = $query->result(); - - $data['pno'] = $pno; + where p_id=".$pno." order by date_issue desc"; + $query = $this->db->query($sql); + $data['patient_doc']= $query->result(); - $this->load->view('DocumentPatient/Patient_Doc_master', $data); - } - + $this->load->view('DocumentPatient/Patient_Doc_master',$data); + } + function create_doc() { - - $pno = $this->input->post('patient_id'); - $document_format_id = $this->input->post('document_format_id'); - $dr_id = $this->input->post('doc_id'); - $doc_issue_date = $this->input->post('doc_issue_date'); - - $sql = "Select * from doc_format_master where df_id=" . $document_format_id; + + $pno=$this->input->post('patient_id'); + $document_format_id=$this->input->post('document_format_id'); + $dr_id=$this->input->post('doc_id'); + $doc_issue_date=$this->input->post('doc_issue_date'); + + $sql="Select * from doc_format_master where df_id=".$document_format_id; $query = $this->db->query($sql); - $data_report_format = $query->result(); + $data_report_format= $query->result(); + + if(count($data_report_format)>0){ + $Report_string=$data_report_format[0]->doc_raw_format; + }else{ + $Report_string=""; + } + + $sql="Select * from doc_pre_input where table_name='patient_master_exten'"; + $query = $this->db->query($sql); + $data_pre_input= $query->result(); - if (count($data_report_format) > 0) { - $Report_string = $data_report_format[0]->doc_raw_format; - } else { - $Report_string = ""; + $sql="Select * from doctor_master where id='".$dr_id."'"; + $query = $this->db->query($sql); + $data_doctor_master= $query->result(); + + $sql="Select * from patient_master_exten where id=".$pno; + $query = $this->db->query($sql); + $data_patient_master= $query->result_array();; + + if(count($data_doctor_master)>0) + { + $Report_string=str_replace('{dr_name}',''.$data_doctor_master[0]->p_fname,$Report_string); + $Report_string=str_replace('{dr_sign}',''.$data_doctor_master[0]->doc_sign,$Report_string); } - $sql = "Select * from doc_pre_input where table_name='patient_master_exten'"; - $query = $this->db->query($sql); - $data_pre_input = $query->result(); - - $sql = "Select * from doctor_master where id='" . $dr_id . "'"; - $query = $this->db->query($sql); - $data_doctor_master = $query->result(); - - $sql = "Select * from patient_master_exten where id=" . $pno; - $query = $this->db->query($sql); - $data_patient_master = $query->result_array();; - - if (count($data_doctor_master) > 0) { - $Report_string = str_replace('{dr_name}', '' . $data_doctor_master[0]->p_fname, $Report_string); - $Report_string = str_replace('{dr_sign}', '' . $data_doctor_master[0]->doc_sign, $Report_string); - } - - $Report_string = str_replace('{current_date}', date('d-m-Y'), $Report_string); - $Report_string = str_replace('{issue_date}', $doc_issue_date, $Report_string); + $Report_string=str_replace('{current_date}',date('d-m-Y'),$Report_string); + $Report_string=str_replace('{issue_date}',$doc_issue_date,$Report_string); for ($i = 0; $i < count($data_pre_input); ++$i) { - if (isset($data_patient_master[0][$data_pre_input[$i]->field_name])) { - $Change_Value = $data_patient_master[0][$data_pre_input[$i]->field_name]; - $Report_string = str_replace('{' . $data_pre_input[$i]->input_code . '}', $Change_Value, $Report_string); + if(isset($data_patient_master[0][$data_pre_input[$i]->field_name])) + { + $Change_Value=$data_patient_master[0][$data_pre_input[$i]->field_name]; + $Report_string=str_replace('{'.$data_pre_input[$i]->input_code.'}',$Change_Value,$Report_string); } } - - $udata = array( - 'raw_data' => $Report_string, - 'doc_format_id' => $document_format_id, - 'p_id' => $pno, - 'dr_id' => $dr_id, - 'date_issue' => str_to_MysqlDate($doc_issue_date) - ); - - $insert_id = $this->DocFormat_M->insert_patient_doc($udata); - - $sql = "select * from doc_format_sub s where doc_format_id=" . $document_format_id; + + $udata = array( + 'raw_data'=> $Report_string, + 'doc_format_id'=>$document_format_id, + 'p_id'=> $pno, + 'dr_id'=> $dr_id, + 'date_issue'=>str_to_MysqlDate($doc_issue_date) + ); + + $insert_id=$this->DocFormat_M->insert_patient_doc($udata); + + $sql="select * from doc_format_sub s where doc_format_id=".$document_format_id; $query = $this->db->query($sql); - $doc_format_sub = $query->result_array();; + $doc_format_sub= $query->result_array();; + + foreach($doc_format_sub as $row) + { + $sql="select * from patient_doc_raw + where p_id=".$pno." and p_doc_id=".$insert_id." and p_doc_sub_id='".$row['id']."' "; + $query = $this->db->query($sql); + $chktestlist= $query->result(); - foreach ($doc_format_sub as $row) { - $sql = "select * from patient_doc_raw - where p_id=" . $pno . " and p_doc_id=" . $insert_id . " and p_doc_sub_id='" . $row['id'] . "' "; - $query = $this->db->query($sql); - $chktestlist = $query->result(); + if(count($chktestlist)<1) + { + $udata = array( + 'p_id'=> $pno, + 'p_doc_id'=> $insert_id, + 'p_doc_sub_id'=> $row['id'], + 'p_doc_raw_value'=> $row['input_default_value'], + ); - if (count($chktestlist) < 1) { - $udata = array( - 'p_id' => $pno, - 'p_doc_id' => $insert_id, - 'p_doc_sub_id' => $row['id'], - 'p_doc_raw_value' => $row['input_default_value'], - ); - - $insert_sub_id = $this->DocFormat_M->insert_patient_doc_raw($udata); + $insert_sub_id=$this->DocFormat_M->insert_patient_doc_raw($udata); + } } - } - + echo $insert_id; } function re_create_doc($doc_id) { - $sql = "Select *,date_format(date_issue,'%d-%m-%Y') as str_date_issue from patient_doc where id=" . $doc_id; + $sql="Select *,date_format(date_issue,'%d-%m-%Y') as str_date_issue from patient_doc where id=".$doc_id; $query = $this->db->query($sql); - $patient_doc = $query->result(); + $patient_doc= $query->result(); + + $pno=$patient_doc[0]->p_id; + $document_format_id=$patient_doc[0]->doc_format_id; + $dr_id=$patient_doc[0]->dr_id; + $doc_issue_date=$patient_doc[0]->str_date_issue; - $pno = $patient_doc[0]->p_id; - $document_format_id = $patient_doc[0]->doc_format_id; - $dr_id = $patient_doc[0]->dr_id; - $doc_issue_date = $patient_doc[0]->str_date_issue; - - $sql = "Select * from doc_format_master where df_id=" . $document_format_id; + $sql="Select * from doc_format_master where df_id=".$document_format_id; $query = $this->db->query($sql); - $data_report_format = $query->result(); + $data_report_format= $query->result(); + + if(count($data_report_format)>0){ + $Report_string=$data_report_format[0]->doc_raw_format; + }else{ + $Report_string=""; + } + + $sql="Select * from doc_pre_input where table_name='patient_master_exten'"; + $query = $this->db->query($sql); + $data_pre_input= $query->result(); - if (count($data_report_format) > 0) { - $Report_string = $data_report_format[0]->doc_raw_format; - } else { - $Report_string = ""; + $sql="Select * from doctor_master where id='".$dr_id."'"; + $query = $this->db->query($sql); + $data_doctor_master= $query->result(); + + $sql="Select * from patient_master_exten where id=".$pno; + $query = $this->db->query($sql); + $data_patient_master= $query->result_array();; + + if(count($data_doctor_master)>0) + { + $Report_string=str_replace('{dr_name}',''.$data_doctor_master[0]->p_fname,$Report_string); + $Report_string=str_replace('{dr_sign}',''.nl2br($data_doctor_master[0]->doc_sign),$Report_string); } - $sql = "Select * from doc_pre_input where table_name='patient_master_exten'"; - $query = $this->db->query($sql); - $data_pre_input = $query->result(); - - $sql = "Select * from doctor_master where id='" . $dr_id . "'"; - $query = $this->db->query($sql); - $data_doctor_master = $query->result(); - - $sql = "Select * from patient_master_exten where id=" . $pno; - $query = $this->db->query($sql); - $data_patient_master = $query->result_array();; - - if (count($data_doctor_master) > 0) { - $Report_string = str_replace('{dr_name}', '' . $data_doctor_master[0]->p_fname, $Report_string); - $Report_string = str_replace('{dr_sign}', '' . nl2br($data_doctor_master[0]->doc_sign), $Report_string); - } - - $Report_string = str_replace('{current_date}', date('d-m-Y'), $Report_string); - $Report_string = str_replace('{issue_date}', $doc_issue_date, $Report_string); + $Report_string=str_replace('{current_date}',date('d-m-Y'),$Report_string); + $Report_string=str_replace('{issue_date}',$doc_issue_date,$Report_string); for ($i = 0; $i < count($data_pre_input); ++$i) { - if (isset($data_patient_master[0][$data_pre_input[$i]->field_name])) { - $Change_Value = $data_patient_master[0][$data_pre_input[$i]->field_name]; - $Report_string = str_replace('{' . $data_pre_input[$i]->input_code . '}', $Change_Value, $Report_string); + if(isset($data_patient_master[0][$data_pre_input[$i]->field_name])) + { + $Change_Value=$data_patient_master[0][$data_pre_input[$i]->field_name]; + $Report_string=str_replace('{'.$data_pre_input[$i]->input_code.'}',$Change_Value,$Report_string); } } - - $udata = array( - 'raw_data' => $Report_string, - 'doc_format_id' => $document_format_id, - 'p_id' => $pno, - ); - - $update_id = $this->DocFormat_M->update_patient_doc($udata, $doc_id); - - redirect('/Document_Patient/Pre_Data/' . $doc_id); + + $udata = array( + 'raw_data'=> $Report_string, + 'doc_format_id'=>$document_format_id, + 'p_id'=> $pno, + ); + + $update_id=$this->DocFormat_M->update_patient_doc($udata,$doc_id); + + redirect('/Document_Patient/Pre_Data/'.$doc_id); } function Pre_Data($patient_doc_id) { - $sql = "Select * from patient_doc where id=" . $patient_doc_id; + $sql="Select * from patient_doc where id=".$patient_doc_id; $query = $this->db->query($sql); - $data['patient_doc'] = $query->result(); + $data['patient_doc']= $query->result(); + + $doc_format_id=$data['patient_doc'][0]->doc_format_id; + $pno=$data['patient_doc'][0]->p_id; - $doc_format_id = $data['patient_doc'][0]->doc_format_id; - $pno = $data['patient_doc'][0]->p_id; - - $sql = "select p.*,s.input_name,s.input_type + $sql="select p.*,s.input_name,s.input_type from (patient_doc_raw p join patient_doc m on m.id=p.p_doc_id) join doc_format_sub s on s.doc_format_id=m.doc_format_id and p.p_doc_sub_id=s.id - where p.p_doc_id=" . $patient_doc_id; + where p.p_doc_id=".$patient_doc_id; $query = $this->db->query($sql); - $data['doc_format_sub'] = $query->result(); - - $sql = "select *,IFNULL(GET_AGE_BY_DOB(dob),age) as str_age, + $data['doc_format_sub']= $query->result(); + + $sql="select *,GET_AGE_1(dob,age,age_in_month,estimate_dob) as str_age, Date_Format(insert_date,'%Y-%m-%d') as str_regdate,if(gender=1,'Male','Female') as xgender - from patient_master where id=" . $pno; + from patient_master where id=".$pno; $query = $this->db->query($sql); - $data['person_info'] = $query->result(); + $data['person_info']= $query->result(); - $data['patient_doc_id'] = $patient_doc_id; - - $this->load->view('DocumentPatient/Doc_update_pre_value', $data); + $data['patient_doc_id']=$patient_doc_id; + + $this->load->view('DocumentPatient/Doc_update_pre_value',$data); } public function Entry_Update() { - $test_id = $this->input->post('test_id'); - $test_value = $this->input->post('test_value'); - - $udata = array( - 'p_doc_raw_value' => $test_value, - 'update_data' => '1', - ); - - $this->DocFormat_M->update_patient_doc_raw($udata, $test_id); - - $sql = "select p_doc_raw_value from patient_doc_raw where id=" . $test_id; + $test_id=$this->input->post('test_id'); + $test_value=$this->input->post('test_value'); + + $udata = array( + 'p_doc_raw_value'=> $test_value, + 'update_data'=> '1', + ); + + $this->DocFormat_M->update_patient_doc_raw($udata,$test_id); + + $sql="select p_doc_raw_value from patient_doc_raw where id=".$test_id; $query = $this->db->query($sql); - $data_value = $query->result(); - + $data_value= $query->result(); + echo $data_value[0]->p_doc_raw_value; + } - + public function update_doc_field($p_doc_id) { - $sql = "SELECT * from patient_doc_raw where update_data=0 and p_doc_id=" . $p_doc_id; + $sql="SELECT * from patient_doc_raw where update_data=0 and p_doc_id=".$p_doc_id; $query = $this->db->query($sql); - $data_value_pending = $query->result(); + $data_value_pending= $query->result(); - if (count($data_value_pending) > 0) { - $rvar = array( - 'update' => 0, - 'error_text' => 'Some Field Pending', - ); + if(count($data_value_pending)>0) + { + $rvar=array( + 'update' =>0, + 'error_text'=>'Some Field Pending', + ); + + $encode_data = json_encode($rvar); + echo $encode_data; - $encode_data = json_encode($rvar); - echo $encode_data; - } else { - $sql = "Select * from patient_doc where id=" . $p_doc_id; + }else{ + $sql="Select * from patient_doc where id=".$p_doc_id; $query = $this->db->query($sql); - $data_report_format = $query->result(); + $data_report_format= $query->result(); - if (count($data_report_format) > 0) { - $Report_string = $data_report_format[0]->raw_data; - } else { - $Report_string = ""; + if(count($data_report_format)>0){ + $Report_string=$data_report_format[0]->raw_data; + }else{ + $Report_string=""; } - $sql = "SELECT p.*,s.input_name,s.input_code from patient_doc_raw p join doc_format_sub s ON p.p_doc_sub_id=s.id - where p_doc_id=" . $p_doc_id; + $sql="SELECT p.*,s.input_name,s.input_code from patient_doc_raw p join doc_format_sub s ON p.p_doc_sub_id=s.id + where p_doc_id=".$p_doc_id; $query = $this->db->query($sql); - $data_value = $query->result(); - + $data_value= $query->result(); + for ($i = 0; $i < count($data_value); ++$i) { - if (isset($data_value[$i]->p_doc_raw_value)) { - $Change_Value = nl2br($data_value[$i]->p_doc_raw_value); - $Report_string = str_replace('{' . $data_value[$i]->input_code . '}', $Change_Value, $Report_string); + if(isset($data_value[$i]->p_doc_raw_value)) + { + $Change_Value=nl2br($data_value[$i]->p_doc_raw_value); + $Report_string=str_replace('{'.$data_value[$i]->input_code.'}',$Change_Value,$Report_string); } } + + $udata = array( + 'raw_data'=> $Report_string, + 'update_pre_value'=>1, + ); - $udata = array( - 'raw_data' => $Report_string, - 'update_pre_value' => 1, - ); + $this->DocFormat_M->update_patient_doc($udata,$p_doc_id); - $this->DocFormat_M->update_patient_doc($udata, $p_doc_id); - - $rvar = array( - 'update' => 1, - 'error_text' => 'Complie Done', - ); - - $encode_data = json_encode($rvar); - echo $encode_data; + $rvar=array( + 'update' =>1, + 'error_text'=>'Complie Done', + ); + + $encode_data = json_encode($rvar); + echo $encode_data; } + } - - - + + + function load_doc($patient_doc_id) { - $sql = "Select * from patient_doc where id=" . $patient_doc_id; + $sql="Select * from patient_doc where id=".$patient_doc_id; $query = $this->db->query($sql); - $data['patient_doc'] = $query->result(); - - $pno = 0; - - if (count($data['patient_doc']) > 0) { - $pno = $data['patient_doc'][0]->p_id; + $data['patient_doc']= $query->result(); + + $pno=0; + + if(count($data['patient_doc'])>0) + { + $pno=$data['patient_doc'][0]->p_id; } - - $sql = "Select * from patient_master_exten where id=" . $pno; + + $sql="Select * from patient_master_exten where id=".$pno; $query = $this->db->query($sql); - $data['person_info'] = $query->result(); - - $this->load->view('DocumentPatient/Patient_Doc_Edit', $data); + $data['person_info']= $query->result(); + + $this->load->view('DocumentPatient/Patient_Doc_Edit',$data); } - - function create_final($patient_doc_id, $print_on_type = 0) + + function create_final($patient_doc_id,$print_on_type=0) { - $sql = "Select *,date_format(date_issue,'%d-%m-%Y') as str_date_issue from patient_doc where id=" . $patient_doc_id; + $sql="Select *,date_format(date_issue,'%d-%m-%Y') as str_date_issue from patient_doc where id=".$patient_doc_id; $query = $this->db->query($sql); - $patient_doc = $query->result(); - - $sql = "Select count(*) as No_Rec from file_upload_data where doc_id=" . $patient_doc_id; + $patient_doc= $query->result(); + + $sql="Select count(*) as No_Rec from file_upload_data where doc_id=".$patient_doc_id; $query = $this->db->query($sql); - $print_doc = $query->result(); - + $print_doc= $query->result(); + $user = $this->ion_auth->user()->row(); $user_id = $user->id; - $user_name = $user->first_name . '' . $user->last_name; - - $print_no_rec = $print_doc[0]->No_Rec + 1; - $doc_issue_date = $patient_doc[0]->str_date_issue; - - $content = ''; - if (count($patient_doc) > 0) { - $content = ' + $user_name = $user->first_name.''. $user->last_name; + + $print_no_rec=$print_doc[0]->No_Rec+1; + $doc_issue_date=$patient_doc[0]->str_date_issue; + + $content=''; + if(count($patient_doc)>0) + { + $content='
- - + +
Document Ref. No.' . date('Y') . '/' . $print_no_rec . '/' . $patient_doc_id . 'Date : ' . $doc_issue_date . 'Document Ref. No.'.date('Y').'/'.$print_no_rec.'/'.$patient_doc_id.'Date : '.$doc_issue_date.'
'; + + $content.=$patient_doc[0]->raw_data; + $data['bar_content']='Document Ref. No.'.date('Y').'/'.$print_no_rec.'/'.$patient_doc_id.'/'.$doc_issue_date; - $content .= $patient_doc[0]->raw_data; - $data['bar_content'] = 'Document Ref. No.' . date('Y') . '/' . $print_no_rec . '/' . $patient_doc_id . '/' . $doc_issue_date; } - - $data['content'] = $content; - $data['print_on_type'] = $print_on_type; - - $folder_name = 'uploads/' . date('Ymd'); - + + $data['content']=$content; + $data['print_on_type']=$print_on_type; + + $folder_name='uploads/'.date('Ymd'); + if (!file_exists($folder_name)) { mkdir($folder_name, 0777, true); chmod($folder_name, 0777); } + + $report_head='Patient Document'; + + $file_name='Document-'.$patient_doc_id."-".$print_no_rec."-".date('Ymdhis').".pdf"; - $report_head = 'Patient Document'; + $filepath=$folder_name.'/'.$file_name; - $file_name = 'Document-' . $patient_doc_id . "-" . $print_no_rec . "-" . date('Ymdhis') . ".pdf"; - - $filepath = $folder_name . '/' . $file_name; - - $udata = array( - 'file_name' => $file_name, - 'file_type' => 'pdf', - 'file_path' => $folder_name, - 'full_path' => $filepath, - 'orig_name' => $file_name, - 'client_name' => 'system_genrate', - 'file_ext' => '.pdf', - 'upload_by' => $user_name, - 'pid' => $patient_doc[0]->p_id, - 'doc_id' => $patient_doc_id, - 'case_id' => 0, - 'file_desc' => $report_head, - 'charge_id' => 0 - ); + $udata = array( + 'file_name'=>$file_name, + 'file_type'=>'pdf', + 'file_path'=>$folder_name, + 'full_path'=>$filepath, + 'orig_name'=>$file_name, + 'client_name'=>'system_genrate', + 'file_ext'=>'.pdf', + 'upload_by'=> $user_name, + 'pid'=>$patient_doc[0]->p_id, + 'doc_id'=>$patient_doc_id, + 'case_id'=>0, + 'file_desc'=>$report_head, + 'charge_id'=>0 + ); $this->load->model('File_M'); $this->File_M->insert($udata); - + //load mPDF library - $this->load->library('m_pdf'); + $this->load->library('m_pdf'); //$this->m_pdf->pdf->SetProtection(array(), '1234567', '277395'); - - if ($print_on_type == 1) { + + if($print_on_type==1) + { $this->m_pdf->pdf->SetWatermarkText(H_Name); - $this->m_pdf->pdf->showWatermarkText = true; + $this->m_pdf->pdf->showWatermarkText = true; } - $doc_content = $this->load->view('DocAdmin/doc_letterhead_print', $data, TRUE); + $doc_content=$this->load->view('DocAdmin/doc_letterhead_print',$data,TRUE); - //echo $content; + //echo $content; - //generate the PDF from the given html - $this->m_pdf->pdf->WriteHTML($doc_content); + //generate the PDF from the given html + $this->m_pdf->pdf->WriteHTML($doc_content); + + //download it. + $this->m_pdf->pdf->Output($filepath,"I"); - //download it. - $this->m_pdf->pdf->Output($filepath, "I"); + + } - + function update_doc() { - $document_id = $this->input->post('document_id'); - $HTMLData = $this->input->post('HTMLData'); - - $udata = array( - 'raw_data' => $HTMLData - ); - - $update_value = 1; - $showcontent = ""; - - $update_value = $this->DocFormat_M->update_patient_doc($udata, $document_id); - - if ($update_value > 0) { - $showcontent = Show_Alert('success', 'Saved', 'Data Saved successfully'); - } else { - $showcontent = Show_Alert('danger', 'Error', validation_errors()); + $document_id=$this->input->post('document_id'); + $HTMLData=$this->input->post('HTMLData'); + + $udata = array( + 'raw_data'=> $HTMLData + ); + + $update_value=1; + $showcontent=""; + + $update_value=$this->DocFormat_M->update_patient_doc($udata,$document_id); + + if($update_value>0) + { + $showcontent=Show_Alert('success','Saved','Data Saved successfully'); + }else{ + $showcontent =Show_Alert('danger','Error',validation_errors()); } - - $rvar = array( - 'update_value' => $update_value, - 'showcontent' => $showcontent + + $rvar=array( + 'update_value' => $update_value, + 'showcontent'=> $showcontent ); - + $encode_data = json_encode($rvar); echo $encode_data; + } + } + diff --git a/old_code_ci3/controllers/IPD_Nursing.php b/old_code_ci3/controllers/IPD_Nursing.php index 97352d0..64d1c59 100644 --- a/old_code_ci3/controllers/IPD_Nursing.php +++ b/old_code_ci3/controllers/IPD_Nursing.php @@ -42,7 +42,7 @@ class IPD_Nursing extends MY_Controller { $p_id=$data['ipd_info'][0]->p_id; $sql="select *,if(gender=1,'Male','FeMale') as xgender, - IFNULL(GET_AGE_BY_DOB(dob),age) AS age + GET_AGE_1(dob,age,age_in_month,estimate_dob) AS age from patient_master where id='".$p_id."' "; $query = $this->db->query($sql); $data['person_info']= $query->result(); @@ -86,7 +86,7 @@ class IPD_Nursing extends MY_Controller { $data['ipd_list']= $query->result(); $sql="select *,if(gender=1,'Male','FeMale') as xgender, - IFNULL(GET_AGE_BY_DOB(dob),age) AS age from patient_master where id='".$data['ipd_info'][0]->p_id."' "; + GET_AGE_1(dob,age,age_in_month,estimate_dob) AS age from patient_master where id='".$data['ipd_info'][0]->p_id."' "; $query = $this->db->query($sql); $data['person_info']= $query->result(); diff --git a/old_code_ci3/controllers/Invoice.php b/old_code_ci3/controllers/Invoice.php index f387cca..c95a062 100644 --- a/old_code_ci3/controllers/Invoice.php +++ b/old_code_ci3/controllers/Invoice.php @@ -65,7 +65,7 @@ class Invoice extends MY_Controller { $data['opd_master']= $query->result(); $sql="select *,if(gender=1,'Male','FeMale') as xgender, - IFNULL(GET_AGE_BY_DOB(dob),age) AS age from patient_master where id='".$data['opd_master'][0]->p_id."' "; + GET_AGE_1(dob,age,age_in_month,estimate_dob) AS age from patient_master where id='".$data['opd_master'][0]->p_id."' "; $query = $this->db->query($sql); $data['patient_master']= $query->result(); @@ -117,7 +117,7 @@ class Invoice extends MY_Controller { $data['payment_history']= $query->result(); $sql="select *,if(gender=1,'Male','FeMale') as xgender, - IFNULL(GET_AGE_BY_DOB(dob),age) AS age from patient_master where id=".$data['invoice_master'][0]->attach_id; + GET_AGE_1(dob,age,age_in_month,estimate_dob) AS age from patient_master where id=".$data['invoice_master'][0]->attach_id; $query = $this->db->query($sql); $data['patient_master']= $query->result(); @@ -728,7 +728,7 @@ class Invoice extends MY_Controller { $data['org_info']= $query->result(); $sql="select *,if(gender=1,'Male','Female') as xgender, - IFNULL(GET_AGE_BY_DOB(dob),age) as str_age from patient_master where id='".$data['req_payment_order'][0]->patient_id."' "; + GET_AGE_1(dob,age,age_in_month,estimate_dob) as str_age from patient_master where id='".$data['req_payment_order'][0]->patient_id."' "; $query = $this->db->query($sql); $data['person_info']= $query->result(); @@ -845,7 +845,7 @@ class Invoice extends MY_Controller { $data['org_info']= $query->result(); $sql="select *,if(gender=1,'Male','Female') as xgender, - IFNULL(GET_AGE_BY_DOB(dob),age) as str_age from patient_master where id='".$data['req_payment_order'][0]->patient_id."' "; + GET_AGE_1(dob,age,age_in_month,estimate_dob) as str_age from patient_master where id='".$data['req_payment_order'][0]->patient_id."' "; $query = $this->db->query($sql); $data['patient_master']= $query->result(); diff --git a/old_code_ci3/controllers/InvoiceShow.php b/old_code_ci3/controllers/InvoiceShow.php index 4722e7a..c60edd2 100644 --- a/old_code_ci3/controllers/InvoiceShow.php +++ b/old_code_ci3/controllers/InvoiceShow.php @@ -48,7 +48,7 @@ class InvoiceShow extends MY_Controller { $data['invoice_master']= $query->result(); $sql="select *,if(gender=1,'Male','FeMale') as xgender, - IFNULL(GET_AGE_BY_DOB(dob),age) AS age from patient_master where id=".$data['invoice_master'][0]->attach_id; + GET_AGE_1(dob,age,age_in_month,estimate_dob) AS age from patient_master where id=".$data['invoice_master'][0]->attach_id; $query = $this->db->query($sql); $data['patient_master']= $query->result(); diff --git a/old_code_ci3/controllers/Ipd.php b/old_code_ci3/controllers/Ipd.php index 29f1005..8e7e562 100644 --- a/old_code_ci3/controllers/Ipd.php +++ b/old_code_ci3/controllers/Ipd.php @@ -187,7 +187,7 @@ class Ipd extends MY_Controller { $tcharge=$charge1+$charge2; $sql="select *,if(gender=1,'Male','FeMale') as xgender, - IFNULL(GET_AGE_BY_DOB(dob),age) AS age from patient_master where id='".$pno."' "; + GET_AGE_1(dob,age,age_in_month,estimate_dob) AS age from patient_master where id='".$pno."' "; $query = $this->db->query($sql); $data['person_info']= $query->result(); @@ -296,7 +296,7 @@ class Ipd extends MY_Controller { $pno=$data['ipdmaster'][0]->p_id; $sql="select *,if(gender=1,'Male','FeMale') as xgender, - IFNULL(GET_AGE_BY_DOB(dob),age) AS age from patient_master where id='".$pno."' "; + GET_AGE_1(dob,age,age_in_month,estimate_dob) AS age from patient_master where id='".$pno."' "; $query = $this->db->query($sql); $data['person_info']= $query->result(); @@ -740,7 +740,7 @@ class Ipd extends MY_Controller { $data['ipd_list']= $query->result(); $sql="select *,if(gender=1,'Male','FeMale') as xgender, - IFNULL(GET_AGE_BY_DOB(dob),age) AS age from patient_master where id='".$data['ipd_info'][0]->p_id."' "; + GET_AGE_1(dob,age,age_in_month,estimate_dob) AS age from patient_master where id='".$data['ipd_info'][0]->p_id."' "; $query = $this->db->query($sql); $data['person_info']= $query->result(); @@ -783,7 +783,7 @@ class Ipd extends MY_Controller { $tcharge=$charge1+$charge2; $sql="select *,if(gender=1,'Male','FeMale') as xgender, - IFNULL(GET_AGE_BY_DOB(dob),age) AS age from patient_master where id='".$data['ipd_info'][0]->p_id."' "; + GET_AGE_1(dob,age,age_in_month,estimate_dob) AS age from patient_master where id='".$data['ipd_info'][0]->p_id."' "; $query = $this->db->query($sql); $data['person_info']= $query->result(); @@ -879,7 +879,7 @@ class Ipd extends MY_Controller { $ipdno=$data['ipd_info'][0]->id; $sql="select *,if(gender=1,'Male','FeMale') as xgender, - IFNULL(GET_AGE_BY_DOB(dob),age) AS age from patient_master where id='".$data['ipd_info'][0]->p_id."' "; + GET_AGE_1(dob,age,age_in_month,estimate_dob) AS age from patient_master where id='".$data['ipd_info'][0]->p_id."' "; $query = $this->db->query($sql); $data['person_info']= $query->result(); @@ -1015,7 +1015,7 @@ class Ipd extends MY_Controller { $data['ipd_info']= $query->result(); $sql="select *,if(gender=1,'Male','FeMale') as xgender, - IFNULL(GET_AGE_BY_DOB(dob),age) AS age from patient_master where id='".$data['ipd_info'][0]->p_id."' "; + GET_AGE_1(dob,age,age_in_month,estimate_dob) AS age from patient_master where id='".$data['ipd_info'][0]->p_id."' "; $query = $this->db->query($sql); $data['person_info']= $query->result(); @@ -1078,7 +1078,7 @@ class Ipd extends MY_Controller { redirect('Ipd/ipd_panel/'.$data['ipd_info'][0]->id); }else{ $sql="select *,if(gender=1,'Male','FeMale') as xgender, - IFNULL(GET_AGE_BY_DOB(dob),age) AS age from patient_master where id='".$pno."' "; + GET_AGE_1(dob,age,age_in_month,estimate_dob) AS age from patient_master where id='".$pno."' "; $query = $this->db->query($sql); $data['person_info']= $query->result(); @@ -1138,7 +1138,7 @@ class Ipd extends MY_Controller { $pno=$data['ipd_master'][0]->p_id; $sql="select *,if(gender=1,'Male','FeMale') as xgender, - IFNULL(GET_AGE_BY_DOB(dob),age) AS age from patient_master where id='".$pno."' "; + GET_AGE_1(dob,age,age_in_month,estimate_dob) AS age from patient_master where id='".$pno."' "; $query = $this->db->query($sql); $data['person_info']= $query->result(); @@ -1159,7 +1159,7 @@ class Ipd extends MY_Controller { $data['ipd_info']= $query->result(); $sql="select *,if(gender=1,'Male','FeMale') as xgender, - IFNULL(GET_AGE_BY_DOB(dob),age) as str_age from patient_master where id='".$data['ipd_info'][0]->p_id."' "; + GET_AGE_1(dob,age,age_in_month,estimate_dob) as str_age from patient_master where id='".$data['ipd_info'][0]->p_id."' "; $query = $this->db->query($sql); $data['person_info']= $query->result(); @@ -1444,7 +1444,7 @@ class Ipd extends MY_Controller { $discount=$data['ipd_info'][0]->Discount; $sql="select *,if(gender=1,'Male','FeMale') as xgender, - IFNULL(GET_AGE_BY_DOB(dob),age) AS age from patient_master where id='".$data['ipd_info'][0]->p_id."' "; + GET_AGE_1(dob,age,age_in_month,estimate_dob) AS age from patient_master where id='".$data['ipd_info'][0]->p_id."' "; $query = $this->db->query($sql); $data['person_info']= $query->result(); diff --git a/old_code_ci3/controllers/IpdNew.php b/old_code_ci3/controllers/IpdNew.php index a6e246b..6d2f1f3 100644 --- a/old_code_ci3/controllers/IpdNew.php +++ b/old_code_ci3/controllers/IpdNew.php @@ -324,6 +324,8 @@ class IpdNew extends MY_Controller { $content=$this->load->view('IPD2/ipd_invoice_print_TPA_V',$data,TRUE); }else if($print==5){ $content=$this->load->view('IPD2/ipd_invoice_print_on_letterhead',$data,TRUE); + }else if($print==6){ + $content=$this->load->view('IPD2/ipd_invoice_print_on_letterhead_wo_payment',$data,TRUE); }else{ $content='Blank'; } @@ -666,6 +668,10 @@ class IpdNew extends MY_Controller { $query = $this->db->query($sql); $data['refer_list']= $query->result(); + $sql="select * from hc_department order by vName"; + $query = $this->db->query($sql); + $data['hc_department']= $query->result(); + $this->load->view('IPD2/ipd_main_panel',$data); } @@ -711,6 +717,26 @@ class IpdNew extends MY_Controller { $ipdno=$ipdcode; } + $sql="select * from ipd_master where id='".$ipdno."' "; + $query = $this->db->query($sql); + $ipd_master= $query->result(); + + $data['ipd_master']=$ipd_master; + //Check IPD Bill lock + + if(isset($ipd_master[0]->cr_to_cash_medical)) + { + if($ipd_master[0]->cr_to_cash_medical==1){ + echo 'Please contact Admin'; + exit(); + } + } + + if($ipd_master[0]->Discount3>0){ + echo 'Please contact Admin'; + exit(); + } + //calculate_IPD @@ -740,11 +766,7 @@ class IpdNew extends MY_Controller { $query = $this->db->query($sql); $data['case_master']= $query->result(); - $sql="select * from ipd_master where id='".$ipdno."' "; - $query = $this->db->query($sql); - $ipd_master= $query->result(); - - $data['ipd_master']=$ipd_master; + $sql="select *,Date_Format(payment_date,'%d-%M-%Y') as pay_date_str, Concat(if(payment_mode=1,'Cash','BANK'),if(credit_debit=0,'','-Return')) as pay_mode @@ -939,8 +961,12 @@ class IpdNew extends MY_Controller { }elseif($form_no==9){ $this->m_pdf->pdf->showWatermarkText = false; $content=$this->load->view('IPD_Format/form_fluid_in_out',$data,TRUE); - }elseif($form_no==13){ - $content=$this->load->view('IPD2/print_ipd_form4',$data,TRUE); + }elseif($form_no==10){ + $this->m_pdf->pdf->showWatermarkText = false; + $content=$this->load->view('IPD_Format/ipd_sticker_print',$data,TRUE); + }elseif($form_no==11){ + $this->m_pdf->pdf->showWatermarkText = false; + $content=$this->load->view('IPD_Format/ipd_sticker_print_2',$data,TRUE); }else{ $content=""; } @@ -1003,16 +1029,17 @@ class IpdNew extends MY_Controller { $query = $this->db->query($sql); $data['refer_master']= $query->result(); + $sql="select * from hc_department order by vName"; + $query = $this->db->query($sql); + $data['hc_department']= $query->result(); $this->load->view('IPD2/Ipd_Registration_V',$data); } - } public function AddNew() { if (!$this->input->is_ajax_request()) { exit('no valid req.'); } - $data['master'] = array( 'p_id' => $this->input->post('pid'), 'P_name' => $this->input->post('pname'), @@ -1028,7 +1055,8 @@ class IpdNew extends MY_Controller { 'case_type' => $this->input->post('optionsRadios_mlc'), 'case_id' => $this->input->post('optionsRadios_org'), 'reg_time' => $this->input->post('res_time'), - 'refer_by' => $this->input->post('refer_by_list') + 'refer_by' => $this->input->post('refer_by_list'), + 'dept_id' => $this->input->post('dept_id') ); $groupData = $this->input->post('doc_id'); @@ -1245,6 +1273,29 @@ echo $encode_data; echo $encode_data; } + public function update_department($ipd_id) + { + if (!$this->input->is_ajax_request()) { exit('no valid req.'); } + + $dept_id=$this->input->post('dept_id'); + + $data['master'] = array( + 'dept_id' => $dept_id + ); + + $this->Ipd_M->update($data['master'],$ipd_id); + + $inser_id=1; + + $rvar=array( + 'insertid' =>$inser_id, + 'showcontent' => "Department Updated" + ); + + $encode_data = json_encode($rvar); + echo $encode_data; + } + public function update_relative_update() { if (!$this->input->is_ajax_request()) { exit('no valid req.'); } diff --git a/old_code_ci3/controllers/Ipd_Report.php b/old_code_ci3/controllers/Ipd_Report.php index 508c07b..6f6207f 100644 --- a/old_code_ci3/controllers/Ipd_Report.php +++ b/old_code_ci3/controllers/Ipd_Report.php @@ -5,6 +5,7 @@ class Ipd_Report extends MY_Controller { public function __construct() { parent::__construct(); + $this->load->library("Pdf"); } public function Ipd_bal_panel() diff --git a/old_code_ci3/controllers/Ipd_discharge.php b/old_code_ci3/controllers/Ipd_discharge.php index 2c3d936..d34bd8c 100644 --- a/old_code_ci3/controllers/Ipd_discharge.php +++ b/old_code_ci3/controllers/Ipd_discharge.php @@ -184,7 +184,7 @@ class Ipd_discharge extends MY_Controller WHERE m.attach_id=" . $p_id . " and m.inv_date between '" . $ipd_admit_date . "' and '" . $ipd_discharge_date . "' GROUP BY m.inv_date"; - echo $sql; + //echo $sql; $query = $this->db->query($sql); $data['lab_request'] = $query->result(); diff --git a/old_code_ci3/controllers/Ipd_discharge1.php b/old_code_ci3/controllers/Ipd_discharge1.php new file mode 100644 index 0000000..73df575 --- /dev/null +++ b/old_code_ci3/controllers/Ipd_discharge1.php @@ -0,0 +1,2569 @@ +load->model('ipdDischarge_M'); + $this->load->model('Ipd_M'); + } + + public function search_ipd() + { + $this->load->view('IPD_Discharge/main'); + } + + public function search_ipd_result() + { + $sdata=$this->input->post('txtsearch'); + + $sdata = preg_replace('/[^A-Za-z0-9_ \-]/', '', $sdata); + + $sql_where=""; + + if(trim($sdata)=='') + { + $sql="select * from v_ipd_list order by id desc limit 200"; + }else{ + if (!$this->ion_auth->in_group('IPDOLD')) { + $sql_where=" and Date(register_date) > '2019-03-31'"; + } + + $sql="select * from v_ipd_list + where ipd_code like '%".$sdata."' or p_code LIKE '%".$sdata."' + OR p_fname LIKE '%".$sdata."%' + OR doc_name LIKE '%".$sdata."%' + ".$sql_where." + group by id order by id desc limit 100"; + } + + $query = $this->db->query($sql); + $data['ipd_master']= $query->result(); + + $this->load->view('IPD_Discharge/search_ipd_result',$data); + } + + public function ipd_select($ipdno,$re_create=0) + { + + $user = $this->ion_auth->user()->row(); + $user_id = $user->id; + $user_name = $user->first_name.''. $user->last_name.'['.$user->id.']:T-'.date('d-m-Y h:m:s'); + + $sql="select * from ipd_discharg_status "; + $query = $this->db->query($sql); + $data['ipd_discharge_status']= $query->result(); + + $sql="select * from v_ipd_list where id='".$ipdno."' "; + $query = $this->db->query($sql); + $data['ipd_master']= $query->result(); + + $ipd_create=$data['ipd_master'][0]->ipd_create; + + if($ipd_create==1 && $re_create==0) + { + redirect('Ipd_discharge/preview_discharge_report/'.$ipdno); + } + + $dataupdate = array( + 'discharge_time'=>date('H:i'), + ); + + $this->Ipd_M->update($dataupdate,$ipdno); + + $sql="select * from v_ipd_list where id='".$ipdno."' "; + $query = $this->db->query($sql); + $data['ipd_master']= $query->result(); + + + $p_id=$data['ipd_master'][0]->p_id; + $ipd_admit_date=$data['ipd_master'][0]->register_date; + + if($data['ipd_master'][0]->discharge_date==null || $data['ipd_master'][0]->discharge_date=='0000-00-00' || $data['ipd_master'][0]->discharge_date=='1901-01-01' ) + { + $ipd_discharge_date=date('Y-m-d'); + }else{ + $ipd_discharge_date=$data['ipd_master'][0]->discharge_date; + } + + $sql="select * from ipd_discharge + where ipd_id='".$ipdno."' "; + $query = $this->db->query($sql); + $data['ipd_discharge']= $query->result(); + + //Surgery + $sql="select * from ipd_discharge_surgery where ipd_id='".$ipdno."' "; + $query = $this->db->query($sql); + $data['ipd_discharge_surgery']= $query->result(); + + //Procedure + $sql="select * from ipd_discharge_procedure where ipd_id='".$ipdno."' "; + $query = $this->db->query($sql); + $data['ipd_discharge_procedure']= $query->result(); + + if(count($data['ipd_discharge'])==0) + { + $datainsert = array( + 'ipd_id' => $ipdno, + 'created_datetime'=>$user_name.'['.$user_id.']', + ); + $this->ipdDischarge_M->insert_ipdDischarge($datainsert); + } + + //General examination + + $sql="select g.id,g.col_name,g.col_description,d.col_id,d.short_head, + if(d.rdata is null,col_pre_value,d.rdata) as rdata_text,g.col_type,col_pre_value,d.rdata + from ipd_discharge_general_exam_col g left join ipd_discharge_1_b d on g.id=d.col_id and d.ipd_d_id='".$ipdno."' where cat_group=1"; + $query = $this->db->query($sql); + $data['ipd_discharge_general_exam_col_1']= $query->result(); + + $sql="select g.id,g.col_name,g.col_description,d.col_id,d.short_head,d.rdata,g.col_type,col_pre_value, + if(d.rdata is null,col_pre_value,d.rdata) as rdata_text,g.col_type,col_pre_value,d.rdata + from ipd_discharge_general_exam_col g left join ipd_discharge_1_b d on g.id=d.col_id and d.ipd_d_id='".$ipdno."' where cat_group=2"; + $query = $this->db->query($sql); + $data['ipd_discharge_general_exam_col_2']= $query->result(); + + $sql="select g.id,g.sys_exam_name,g.sys_format,d.rdata + from ipd_discharge_sys_exam g left join ipd_discharge_1_a d on g.id=d.head_id and d.ipd_d_id='".$ipdno."' where g.id=9 "; + $query = $this->db->query($sql); + $data['ipd_discharge_sys_exam']= $query->result(); + + //Examination at the time of Discharge + + $sql="select g.id,g.col_name,g.col_description,d.col_id,d.short_head,d.rdata, + if(d.rdata is null,col_pre_value,d.rdata) as rdata_text + from ipd_discharge_general_exam_col g left join ipd_discharge_1_b_final d on g.id=d.col_id and d.ipd_d_id='".$ipdno."' "; + $query = $this->db->query($sql); + $data['ipd_discharge_exam_on_discharge_col']= $query->result(); + + //CLINICAL INVESTIGATION REPORTS + + $sql="select * from ipd_discharge_2 where ipd_d_id='".$ipdno."' and CHAR_LENGTH(lab_investigation_list)>0 "; + $query = $this->db->query($sql); + $data['ipd_discharge_2']= $query->result(); + + $lab_list="0"; + if(count($data['ipd_discharge_2'])>0) + { + $lab_list=$data['ipd_discharge_2'][0]->lab_investigation_list; + } + + $sql="select *,if(id in (".$lab_list."),'checked','') as chked from lab_request where patient_id=".$p_id." + and (ipd_id=".$ipdno." or (Request_Date between '".$ipd_admit_date."' and '".$ipd_discharge_date."' ))"; + + $sql= " SELECT QUOTE(m.inv_date) AS sDate, date_format(m.inv_date,'%d-%m-%Y') AS sInd_Date, + group_CONCAT(t.Test ORDER BY t.Test) AS test_list,if(m.inv_date in (".$lab_list."),'checked','') as chked + FROM (((invoice_master m JOIN lab_request l ON m.id=l.charge_id) + JOIN lab_request_item i ON l.id=i.lab_request_id) + JOIN lab_tests t ON i.lab_test_id=t.mstTestKey) + JOIN ipd_discharge_investigation_template d ON t.TestID=d.test_code + WHERE m.attach_id=".$p_id." and m.inv_date between '".$ipd_admit_date."' and '".$ipd_discharge_date."' + GROUP BY m.inv_date"; + + $query = $this->db->query($sql); + $data['lab_request']= $query->result(); + + $sql="select * from ipd_discharge_2 where ipd_d_id='".$ipdno."' "; + $query = $this->db->query($sql); + $data['ipd_discharge_2']= $query->result(); + + + //Presenting Complaints with Duration and Reason for Admission + + $sql="select * from ipd_discharge_complaint where ipd_id='".$ipdno."' "; + $query = $this->db->query($sql); + $data['ipd_discharge_complaint']= $query->result(); + + $sql="select * from ipd_discharge_complaint_remark where ipd_id='".$ipdno."' "; + $query = $this->db->query($sql); + $data['ipd_discharge_complaint_remark']= $query->result(); + + //Final Diagnosis at the time of Discharge + + $sql="select * from ipd_discharge_diagnosis where ipd_id='".$ipdno."' "; + $query = $this->db->query($sql); + $data['ipd_discharge_diagnosis']= $query->result(); + + $sql="select * from ipd_discharge_diagnosis_remark where ipd_id='".$ipdno."' "; + $query = $this->db->query($sql); + $data['ipd_discharge_diagnosis_remark']= $query->result(); + + //Summary of key investigtions during Hospitalization + + $sql="select * from ipd_discharge_investigtions_inhos where ipd_id='".$ipdno."' "; + $query = $this->db->query($sql); + $data['ipd_discharge_investigtions_inhos']= $query->result(); + + + //Course in the hospital + + $sql="select * from ipd_discharge_course where ipd_id='".$ipdno."' "; + $query = $this->db->query($sql); + $data['ipd_discharge_course']= $query->result(); + + $sql="select * from ipd_discharge_course_remark where ipd_id='".$ipdno."' "; + $query = $this->db->query($sql); + $data['ipd_discharge_course_remark']= $query->result(); + + //Discharge Medications + + $sql="select * from ipd_discharge_drug where ipd_id='".$ipdno."' "; + $query = $this->db->query($sql); + $data['ipd_discharge_drug']= $query->result(); + + //Discharge Instructions + + $sql="select * from ipd_discharge_instructions where ipd_id='".$ipdno."' "; + $query = $this->db->query($sql); + $data['ipd_discharge_instructions']= $query->result(); + + //Discharge FOOD DRUG INTERACTION + $sql="select * from ipd_discharge_drug_food_interaction where ipd_id='".$ipdno."' "; + $query = $this->db->query($sql); + $data['ipd_discharge_drug_food_interaction']= $query->result(); + + $food_list="0"; + if(count($data['ipd_discharge_drug_food_interaction'])>0) + { + if(strlen($data['ipd_discharge_drug_food_interaction'][0]->food_id_list)>0) + { + $food_list=$data['ipd_discharge_drug_food_interaction'][0]->food_id_list; + } + } + + $sql="SELECT m.id,m.food_short,if(m.id IN (".$food_list."),'Checked','') AS food_exist + FROM ipd_discharge_master_food m "; + $query = $this->db->query($sql); + $data['dis_food_interaction']= $query->result(); + + $foot_banner_list="0"; + if(count($data['ipd_discharge_instructions'])>0) + { + if(strlen($data['ipd_discharge_instructions'][0]->footer_banner)>0) + { + $foot_banner_list=$data['ipd_discharge_instructions'][0]->footer_banner; + } + } + + $sql="SELECT m.id,m.banner_name,if(m.id IN (".$foot_banner_list."),'Checked','') AS banner_exist + FROM ipd_discharge_banner m "; + $query = $this->db->query($sql); + $data['dis_banner_list']= $query->result(); + + //Discharge Medicine + + $sql="select * from opd_dose_shed "; + $query = $this->db->query($sql); + $data['opd_dose_shed']= $query->result(); + + $sql="select * from opd_dose_when"; + $query = $this->db->query($sql); + $data['opd_dose_when']= $query->result(); + + $sql="select * from opd_dose_frequency"; + $query = $this->db->query($sql); + $data['opd_dose_frequency']= $query->result(); + + $sql="select * from opd_dose_where"; + $query = $this->db->query($sql); + $data['opd_dose_where']= $query->result(); + + $sql="select * from opd_dose_duration"; + $query = $this->db->query($sql); + $opd_dose_duration= $query->result(); + + $sql="select * from med_formulation"; + $query = $this->db->query($sql); + $med_formulation= $query->result(); + + + + $this->load->view('IPD_Discharge/ipd_discharge_edit',$data); + } + + + // Get Combo Value + + public function get_complaints(){ + + if (isset($_GET['term'])){ + $q = strtolower($_GET['term']); + + $sql="select * from complaints_master where Name like '%".$q."%' "; + + $sql=$sql." limit 20"; + + $query = $this->db->query($sql); + + if($query->num_rows() > 0){ + foreach ($query->result_array() as $row){ + $new_row['label']=htmlentities(stripslashes($row['Name'])); + $new_row['value']=htmlentities(stripslashes($row['Name'])); + + $new_row['complaints_no']=htmlentities(stripslashes($row['Code'])); + + $new_row['sql']=$sql; + $row_set[] = $new_row; //build an array + } + echo json_encode($row_set); //format the array into json data + } + } + } + + // Get Combo Value + + public function get_hospital_course_master(){ + + if (isset($_GET['term'])){ + $q = strtolower($_GET['term']); + + $sql="select * from hospital_course_master where Name like '%".$q."%' "; + + $sql=$sql." limit 20"; + + $query = $this->db->query($sql); + + if($query->num_rows() > 0){ + foreach ($query->result_array() as $row){ + $new_row['label']=htmlentities(stripslashes($row['Name'])); + $new_row['value']=htmlentities(stripslashes($row['Name'])); + + $new_row['complaints_no']=htmlentities(stripslashes($row['Code'])); + + $new_row['sql']=$sql; + $row_set[] = $new_row; //build an array + } + echo json_encode($row_set); //format the array into json data + } + } + } + + + public function get_surgery(){ + + if (isset($_GET['term'])){ + $q = strtolower($_GET['term']); + + $sql="select * from surgery where Name like '%".$q."%' "; + + $sql=$sql." limit 20"; + + $query = $this->db->query($sql); + + if($query->num_rows() > 0){ + foreach ($query->result_array() as $row){ + $new_row['label']=htmlentities(stripslashes($row['Name'])); + $new_row['value']=htmlentities(stripslashes($row['Name'])); + + $new_row['surgery_no']=htmlentities(stripslashes($row['Code'])); + + $new_row['sql']=$sql; + $row_set[] = $new_row; //build an array + } + echo json_encode($row_set); //format the array into json data + } + } + } + + public function get_drug_timing(){ + + if (isset($_GET['term'])){ + $q = strtolower($_GET['term']); + + $sql="select * from drug_timing where dosage_desc like '%".$q."%' or dosage_code like '".$q."%' "; + + $sql=$sql." limit 20"; + + $query = $this->db->query($sql); + + if($query->num_rows() > 0){ + foreach ($query->result_array() as $row){ + $new_row['label']=htmlentities(stripslashes($row['dosage_desc'])); + $new_row['value']=htmlentities(stripslashes($row['dosage_desc'])); + + $new_row['surgery_no']=htmlentities(stripslashes($row['id'])); + + $new_row['sql']=$sql; + $row_set[] = $new_row; //build an array + } + echo json_encode($row_set); //format the array into json data + } + } + } + + public function get_disease(){ + if (isset($_GET['term'])){ + $q = strtolower($_GET['term']); + + $sql="select * from disease_master where Name like '%".$q."%' order by Name"; + + $sql=$sql." limit 20"; + + $query = $this->db->query($sql); + + if($query->num_rows() > 0){ + foreach ($query->result_array() as $row){ + $new_row['label']=htmlentities(stripslashes($row['Name'])); + $new_row['value']=htmlentities(stripslashes($row['Name'])); + + $new_row['complaints_no']=htmlentities(stripslashes($row['Code'])); + + $new_row['sql']=$sql; + $row_set[] = $new_row; //build an array + } + echo json_encode($row_set); //format the array into json data + } + } + } + + public function get_medical(){ + if (isset($_GET['term'])){ + $q = strtolower($_GET['term']); + + $sql="select * from opd_med_master + where item_name like '%".$q."%' order by item_name"; + + $sql=$sql." limit 20"; + + $query = $this->db->query($sql); + + if($query->num_rows() > 0){ + foreach ($query->result_array() as $row){ + $new_row['label']=htmlentities(stripslashes($row['item_name'])).' ['.htmlentities(stripslashes($row['formulation'])).']'; + $new_row['value']=htmlentities(stripslashes($row['item_name'])).' ['.htmlentities(stripslashes($row['formulation'])).']'; + $row_set[] = $new_row; //build an array + } + echo json_encode($row_set); //format the array into json data + } + } + } + + // Data Saving + + public function update_Sys_Exam() + { + $editor_Sys_Exam=$this->input->post('editor_Sys_Exam'); + $IPD_id=$this->input->post('IPD_id'); + $sys_exam_id=$this->input->post('sys_exam_id'); + + $sql="select * from ipd_discharge_sys_exam where id=".$sys_exam_id; + $query = $this->db->query($sql); + $short_head_sys_exam= $query->result(); + + $short_head=""; + if(count($short_head_sys_exam)>0) + { + $short_head=$short_head_sys_exam[0]->sys_exam_name; + } + + $datainsert = array( + 'ipd_d_id' => $IPD_id, + 'head_id' => $sys_exam_id, + 'short_head' => $short_head, + 'rdata' => $editor_Sys_Exam, + ); + + $sql="select * from ipd_discharge_1_a where ipd_d_id=".$IPD_id. " and head_id=".$sys_exam_id; + $query = $this->db->query($sql); + $chk_exist= $query->result(); + + if(count($chk_exist)>0) + { + $this->ipdDischarge_M->update_ipd_discharge_1_a($datainsert,$chk_exist[0]->id); + }else{ + $this->ipdDischarge_M->insert_ipd_discharge_1_a($datainsert); + } + + echo 'Saved'; + } + + public function update_gen_Exam() + { + + $IPD_id=$this->input->post('gen_exam_ipd_id'); + + $sql="select g.id,g.col_name,g.col_description,d.col_id,d.short_head,d.rdata, + if(d.id is null,1,0) as insert_data + from ipd_discharge_general_exam_col g + left join ipd_discharge_1_b d on g.id=d.col_id and d.ipd_d_id=".$IPD_id; + $query = $this->db->query($sql); + $discharge_general_exam= $query->result(); + + foreach($discharge_general_exam as $row) + { + $rdata=$this->input->post('input_g_exam_'.$row->id); + + $datainsert = array( + 'ipd_d_id' => $IPD_id, + 'col_id' => $row->id, + 'short_head' => $row->col_name, + 'rdata' => $rdata, + ); + + $this->ipdDischarge_M->update_insert_ipd_discharge_1_b($datainsert,$IPD_id, $row->id); + + } + + echo 'Saved'; + } + + + public function update_dis_Exam() + { + + $IPD_id=$this->input->post('dis_exam_ipd_id'); + + $sql="select g.id,g.col_name,g.col_description,d.col_id,d.short_head,d.rdata, + if(d.id is null,1,0) as insert_data + from ipd_discharge_general_exam_col g + left join ipd_discharge_1_b_final d on g.id=d.col_id and d.ipd_d_id=".$IPD_id; + $query = $this->db->query($sql); + $discharge_general_exam= $query->result(); + + foreach($discharge_general_exam as $row) + { + $rdata=$this->input->post('input_d_exam_'.$row->id); + + $datainsert = array( + 'ipd_d_id' => $IPD_id, + 'col_id' => $row->id, + 'short_head' => $row->col_name, + 'rdata' => $rdata, + ); + + $this->ipdDischarge_M->update_insert_ipd_discharge_1_b_final($datainsert,$IPD_id, $row->id); + + } + + echo 'Saved'; + } + + public function update_Provisional_Exam() + { + $editor_data=$this->input->post('editor_data'); + $ipd_id=$this->input->post('ipd_id'); + $lab_investigation_list=$this->input->post('lab_investigation_list'); + + $lab_investigation_list=str_replace(":",",",$lab_investigation_list); + + $short_head="Other Examinations or Provisional Diagnosis"; + + $datainsert = array( + 'ipd_d_id' => $ipd_id, + 'lab_investigation_list' => $lab_investigation_list, + 'short_head' => $short_head, + 'rdata' => $editor_data, + ); + + $return_id=$this->ipdDischarge_M->update_insert_ipd_discharge_2($datainsert,$ipd_id); + + echo 'Saved : With Return Code ->'.$return_id; + } + + //FOOD_DRUG_INTERACTION + + public function update_food_interaction() + { + $editor_data=$this->input->post('editor_data'); + + $ipd_id=$this->input->post('ipd_id'); + $food_interaction_list=$this->input->post('food_interaction_list'); + + $food_interaction_list=str_replace(":",",",$food_interaction_list); + + $datainsert = array( + 'ipd_id' => $ipd_id, + 'food_id_list' => $food_interaction_list, + 'food_text' => $editor_data, + ); + + $return_id=$this->ipdDischarge_M->update_insert_ipd_discharge_drug_food_interaction($datainsert,$ipd_id); + + echo 'Saved : With Return Code ->'.$return_id; + } + + //Footer Banner + + public function update_footer_banner() + { + $editor_data=$this->input->post('editor_data'); + + $ipd_id=$this->input->post('ipd_id'); + $footer_banner_list=$this->input->post('footer_banner_list'); + + $footer_banner_list=str_replace(":",",",$footer_banner_list); + + $datainsert = array( + 'ipd_id' => $ipd_id, + 'footer_banner' => $footer_banner_list, + ); + + $return_id=$this->ipdDischarge_M->update_insert_ipd_discharge_instructions($datainsert,$ipd_id); + + echo 'Saved : With Return Code ->'.$return_id; + } + + + + //Compalint Part Add Update Renove + + public function add_complaints() + { + if (!$this->input->is_ajax_request()) { exit('no valid req.'); } + + $user = $this->ion_auth->user()->row(); + $user_id = $user->id; + $user_name = $user->first_name.''. $user->last_name.'['.$user->id.']:T-'.date('d-m-Y h:m:s'); + + $complaint=$this->input->post('input_complaints'); + $complaint_value=$this->input->post('input_complaints_value'); + $complaint_remarks=$this->input->post('input_complaints_remarks'); + $ipd_id=$this->input->post('ipd_id'); + + $datainsert = array( + 'ipd_id' => $ipd_id, + 'comp_code' => $complaint_value, + 'comp_report' => $complaint, + 'comp_remark' => $complaint_remarks, + 'update_by' => $user_name + ); + + $this->ipdDischarge_M->insert_p_complaint($datainsert); + + $content=""; + + $sql="select * from ipd_discharge_complaint where ipd_id=".$ipd_id; + $query = $this->db->query($sql); + $dataRec= $query->result(); + + $content="
"; + + foreach($dataRec as $row) + { + $content.= ' + + + + + '; + } + + $content.='
'.$row->comp_report.' + + UpdateRemove
'; + + echo $content; + + } + + + public function update_complaint() + { + if (!$this->input->is_ajax_request()) { exit('no valid req.'); } + + $user = $this->ion_auth->user()->row(); + $user_id = $user->id; + $user_name = $user->first_name.''. $user->last_name.'['.$user->id.']:T-'.date('d-m-Y h:m:s'); + + $complaint_remarks=$this->input->post('complaint_remarks'); + $ipd_id=$this->input->post('ipd_id'); + $rec_id=$this->input->post('invACode'); + + $sql="select * from ipd_discharge_complaint where id=".$rec_id." and ipd_id=".$ipd_id; + $query = $this->db->query($sql); + $dataRec= $query->result(); + + $content="Nothing Done"; + + if(count($dataRec)>0) + { + $dataupdate = array( + 'comp_remark' => $complaint_remarks, + 'update_by' => $user_name + ); + + + $this->ipdDischarge_M->update_p_complaint($dataupdate,$rec_id); + + $content="Update Done"; + } + + echo $content; + } + + + public function remove_complaint($invRecID,$ipd_id) + { + if (!$this->input->is_ajax_request()) { exit('no valid req.'); } + + $sql="select * from ipd_discharge_complaint where ipd_id=".$ipd_id." and id=".$invRecID; + $query = $this->db->query($sql); + $dataRec= $query->result(); + + if(count($dataRec)>0) + { + + $this->ipdDischarge_M->remove_p_complaint($invRecID); + } + + $content=""; + + $sql="select * from ipd_discharge_complaint where ipd_id=".$ipd_id; + $query = $this->db->query($sql); + $dataRec= $query->result(); + + $content="
"; + + foreach($dataRec as $row) + { + $content.= ' + + + + + '; + } + + $content.='
'.$row->comp_report.' + + UpdateRemove
'; + + echo $content; + + } + + public function update_complaint_edit() + { + $editor_Sys_Exam=$this->input->post('editor_Sys_Exam'); + $ipd_id=$this->input->post('ipd_id'); + + $datainsert = array( + 'ipd_id' => $ipd_id, + 'comp_remark' => $editor_Sys_Exam, + ); + + $this->ipdDischarge_M->update_insert_ipd_discharge_complaint_remark($datainsert,$ipd_id); + + echo 'Saved'; + } + + //procedure Update and Add + public function add_procedure() + { + if (!$this->input->is_ajax_request()) { exit('no valid req.'); } + + $user = $this->ion_auth->user()->row(); + $user_id = $user->id; + $user_name = $user->first_name.''. $user->last_name.'['.$user->id.']:T-'.date('d-m-Y h:m:s'); + + $input_procedure_name=$this->input->post('input_procedure_name'); + $input_procedure_id=$this->input->post('input_procedure_id'); + $input_procedure_remark=$this->input->post('input_procedure_remark'); + $procedure_date=$this->input->post('procedure_date'); + $ipd_id=$this->input->post('ipd_id'); + + $datainsert = array( + 'ipd_id' => $ipd_id, + 'procedure_id' => $input_procedure_id, + 'procedure_name' => $input_procedure_name, + 'procedure_remark' => $input_procedure_remark, + 'procedure_date' => str_to_MysqlDate($procedure_date), + 'update_by' => $user_name + ); + + $this->ipdDischarge_M->insert_p_procedure($datainsert); + + $content=""; + + $sql="select * from ipd_discharge_procedure where ipd_id=".$ipd_id; + $query = $this->db->query($sql); + $data['ipd_discharge_procedure']= $query->result(); + + $content=$this->load->view('IPD_Discharge/ipd_procedure',$data,true); + + echo $content; + + } + + + public function update_procedure() + { + if (!$this->input->is_ajax_request()) { exit('no valid req.'); } + + $user = $this->ion_auth->user()->row(); + $user_id = $user->id; + $user_name = $user->first_name.''. $user->last_name.'['.$user->id.']:T-'.date('d-m-Y h:m:s'); + + $procedure_name=$this->input->post('procedure_name'); + $procedure_remark=$this->input->post('procedure_remark'); + $procedure_date=$this->input->post('procedure_date'); + + $ipd_id=$this->input->post('ipd_id'); + $rec_id=$this->input->post('invACode'); + + $sql="select * from ipd_discharge_procedure where id=".$rec_id." and ipd_id=".$ipd_id; + $query = $this->db->query($sql); + $dataRec= $query->result(); + + $content="Nothing Done"; + + if(count($dataRec)>0) + { + $dataupdate = array( + 'procedure_name' => $procedure_name, + 'procedure_remark' => $procedure_remark, + 'procedure_date' => str_to_MysqlDate($procedure_date), + 'update_by' => $user_name + ); + + $this->ipdDischarge_M->update_p_procedure($dataupdate,$rec_id); + + $content="Update Done"; + } + + echo $content; + } + + public function remove_procedure($invRecID,$ipd_id) + { + if (!$this->input->is_ajax_request()) { exit('no valid req.'); } + + $sql="select * from ipd_discharge_procedure where ipd_id=".$ipd_id." and id=".$invRecID; + $query = $this->db->query($sql); + $dataRec= $query->result(); + + if(count($dataRec)>0) + { + $this->ipdDischarge_M->remove_p_procedure($invRecID); + } + + $content=""; + + $sql="select * from ipd_discharge_procedure where ipd_id=".$ipd_id; + $query = $this->db->query($sql); + $data['ipd_discharge_procedure']= $query->result(); + + $content=$this->load->view('IPD_Discharge/ipd_procedure',$data,true); + + echo $content; + + } + + //surgery Update and Add + public function add_surgery() + { + if (!$this->input->is_ajax_request()) { exit('no valid req.'); } + + $user = $this->ion_auth->user()->row(); + $user_id = $user->id; + $user_name = $user->first_name.''. $user->last_name.'['.$user->id.']:T-'.date('d-m-Y h:m:s'); + + $input_surgery_name=$this->input->post('input_surgery_name'); + $input_surgery_id=$this->input->post('input_surgery_id'); + $input_surgery_remark=$this->input->post('input_surgery_remark'); + $surgery_date=$this->input->post('surgery_date'); + $ipd_id=$this->input->post('ipd_id'); + + $datainsert = array( + 'ipd_id' => $ipd_id, + 'surgery_id' => $input_surgery_id, + 'surgery_name' => $input_surgery_name, + 'surgery_remark' => $input_surgery_remark, + 'surgery_date' => str_to_MysqlDate($surgery_date), + 'update_by' => $user_name + ); + + $this->ipdDischarge_M->insert_p_surgery($datainsert); + + $content=""; + + $sql="select * from ipd_discharge_surgery where ipd_id=".$ipd_id; + $query = $this->db->query($sql); + $data['ipd_discharge_surgery']= $query->result(); + + $content=$this->load->view('IPD_Discharge/ipd_surgery',$data,true); + + echo $content; + + } + + + public function update_surgery() + { + if (!$this->input->is_ajax_request()) { exit('no valid req.'); } + + $user = $this->ion_auth->user()->row(); + $user_id = $user->id; + $user_name = $user->first_name.''. $user->last_name.'['.$user->id.']:T-'.date('d-m-Y h:m:s'); + + $surgery_name=$this->input->post('surgery_name'); + $surgery_remark=$this->input->post('surgery_remark'); + $surgery_date=$this->input->post('surgery_date'); + + $ipd_id=$this->input->post('ipd_id'); + $rec_id=$this->input->post('invACode'); + + $sql="select * from ipd_discharge_surgery where id=".$rec_id." and ipd_id=".$ipd_id; + $query = $this->db->query($sql); + $dataRec= $query->result(); + + $content="Nothing Done"; + + if(count($dataRec)>0) + { + $dataupdate = array( + 'surgery_name' => $surgery_name, + 'surgery_remark' => $surgery_remark, + 'surgery_date' => str_to_MysqlDate($surgery_date), + 'update_by' => $user_name + ); + + $this->ipdDischarge_M->update_p_surgery($dataupdate,$rec_id); + + $content="Update Done"; + } + + echo $content; + } + + public function remove_surgery($invRecID,$ipd_id) + { + if (!$this->input->is_ajax_request()) { exit('no valid req.'); } + + $sql="select * from ipd_discharge_surgery where ipd_id=".$ipd_id." and id=".$invRecID; + $query = $this->db->query($sql); + $dataRec= $query->result(); + + if(count($dataRec)>0) + { + $this->ipdDischarge_M->remove_p_surgery($invRecID); + } + + $content=""; + + $sql="select * from ipd_discharge_surgery where ipd_id=".$ipd_id; + $query = $this->db->query($sql); + $data['ipd_discharge_surgery']= $query->result(); + + $content=$this->load->view('IPD_Discharge/ipd_surgery',$data,true); + + echo $content; + + } + + //Delivery Update + public function update_delivery() + { + if (!$this->input->is_ajax_request()) { exit('no valid req.'); } + + $this->load->model('Ipd_M'); + + + $user = $this->ion_auth->user()->row(); + $user_id = $user->id; + $user_name = $user->first_name.''. $user->last_name.'['.$user->id.']:T-'.date('d-m-Y h:m:s'); + + $ipd_id=$this->input->post('ipd_id'); + $isdelivery=$this->input->post('isdelivery'); + $delivery_date=$this->input->post('delivery_date'); + $delivery_time=$this->input->post('delivery_time'); + $delivery_sex_of_baby=$this->input->post('delivery_sex_of_baby'); + $delivery_sex_of_baby2=$this->input->post('delivery_sex_of_baby2'); + $delivery_sex_of_baby3=$this->input->post('delivery_sex_of_baby3'); + + + $dataupdate = array( + 'isdelivery' => $isdelivery, + 'delivery_time' => $delivery_time, + 'delivery_date' => str_to_MysqlDate($delivery_date), + 'delivery_sex_of_baby' => $delivery_sex_of_baby, + 'delivery_sex_of_baby2' => $delivery_sex_of_baby2, + 'delivery_sex_of_baby3' => $delivery_sex_of_baby3 + ); + + $this->Ipd_M->update($dataupdate,$ipd_id); + $content="Update Done"; + + echo $content; + } + + + + + + //Delivery End + + + + + //diagnosis Part Add Update Renove + + public function add_diagnosis() + { + if (!$this->input->is_ajax_request()) { exit('no valid req.'); } + + $user = $this->ion_auth->user()->row(); + $user_id = $user->id; + $user_name = $user->first_name.''. $user->last_name.'['.$user->id.']:T-'.date('d-m-Y h:m:s'); + + $diagnosis=$this->input->post('input_diagnosis'); + $diagnosis_value=$this->input->post('input_diagnosis_value'); + $diagnosis_remarks=$this->input->post('input_diagnosis_remarks'); + $ipd_id=$this->input->post('ipd_id'); + + $datainsert = array( + 'ipd_id' => $ipd_id, + 'comp_code' => $diagnosis_value, + 'comp_report' => $diagnosis, + 'comp_remark' => $diagnosis_remarks, + 'update_by' => $user_name + ); + + $this->ipdDischarge_M->insert_p_diagnosis($datainsert); + + $content=""; + + $sql="select * from ipd_discharge_diagnosis where ipd_id=".$ipd_id; + $query = $this->db->query($sql); + $dataRec= $query->result(); + + $content="
"; + + foreach($dataRec as $row) + { + $content.= ' + + + + + '; + } + + $content.='
'.$row->comp_report.' + + UpdateRemove
'; + + echo $content; + + } + + + public function update_diagnosis() + { + if (!$this->input->is_ajax_request()) { exit('no valid req.'); } + + $user = $this->ion_auth->user()->row(); + $user_id = $user->id; + $user_name = $user->first_name.''. $user->last_name.'['.$user->id.']:T-'.date('d-m-Y h:m:s'); + + $diagnosis_remarks=$this->input->post('diagnosis_remarks'); + $ipd_id=$this->input->post('ipd_id'); + $rec_id=$this->input->post('invACode'); + + $sql="select * from ipd_discharge_diagnosis where id=".$rec_id." and ipd_id=".$ipd_id; + $query = $this->db->query($sql); + $dataRec= $query->result(); + + $content="Nothing Done"; + + if(count($dataRec)>0) + { + $dataupdate = array( + 'comp_remark' => $diagnosis_remarks, + 'update_by' => $user_name + ); + + + $this->ipdDischarge_M->update_p_diagnosis($dataupdate,$rec_id); + + $content="Update Done"; + } + + echo $content; + } + + + public function remove_diagnosis($invRecID,$ipd_id) + { + if (!$this->input->is_ajax_request()) { exit('no valid req.'); } + + $sql="select * from ipd_discharge_diagnosis where ipd_id=".$ipd_id." and id=".$invRecID; + $query = $this->db->query($sql); + $dataRec= $query->result(); + + if(count($dataRec)>0) + { + + $this->ipdDischarge_M->remove_p_diagnosis($invRecID); + } + + $content=""; + + $sql="select * from ipd_discharge_diagnosis where ipd_id=".$ipd_id; + $query = $this->db->query($sql); + $dataRec= $query->result(); + + $content="
"; + + foreach($dataRec as $row) + { + $content.= ' + + + + + '; + } + + $content.='
'.$row->comp_report.' + + UpdateRemove
'; + + echo $content; + + } + + public function update_diagnosis_edit() + { + $editor_Sys_Exam=$this->input->post('editor_Sys_Exam'); + $ipd_id=$this->input->post('ipd_id'); + + $datainsert = array( + 'ipd_id' => $ipd_id, + 'comp_remark' => $editor_Sys_Exam, + ); + + $this->ipdDischarge_M->update_insert_ipd_discharge_diagnosis_remark($datainsert,$ipd_id); + + echo 'Saved'; + } + + //Summary of Key investigtion during Hospitalization + public function update_investigtions_inhos() + { + $editor_Sys_Exam=$this->input->post('editor_Sys_Exam'); + $ipd_id=$this->input->post('ipd_id'); + + $datainsert = array( + 'ipd_id' => $ipd_id, + 'comp_remark' => $editor_Sys_Exam, + ); + + $this->ipdDischarge_M->update_insert_ipd_discharge_investigtions_inhos($datainsert,$ipd_id); + + echo 'Saved'; + } + + //Course in the Hospitalization + + + public function add_course() + { + if (!$this->input->is_ajax_request()) { exit('no valid req.'); } + + $user = $this->ion_auth->user()->row(); + $user_id = $user->id; + $user_name = $user->first_name.''. $user->last_name.'['.$user->id.']:T-'.date('d-m-Y h:m:s'); + + $diagnosis=$this->input->post('input_course'); + $diagnosis_value=$this->input->post('input_course_value'); + $diagnosis_remarks=$this->input->post('input_course_remarks'); + $ipd_id=$this->input->post('ipd_id'); + + $datainsert = array( + 'ipd_id' => $ipd_id, + 'comp_code' => $diagnosis_value, + 'comp_report' => $diagnosis, + 'comp_remark' => $diagnosis_remarks, + 'update_by' => $user_name + ); + + $this->ipdDischarge_M->insert_p_course($datainsert); + + $content=""; + + $sql="select * from ipd_discharge_course where ipd_id=".$ipd_id; + $query = $this->db->query($sql); + $dataRec= $query->result(); + + $content="
"; + + foreach($dataRec as $row) + { + $content.= ' + + + + + '; + } + + $content.='
'.$row->comp_report.' + + UpdateRemove
'; + + echo $content; + + } + + + public function update_course() + { + if (!$this->input->is_ajax_request()) { exit('no valid req.'); } + + $user = $this->ion_auth->user()->row(); + $user_id = $user->id; + $user_name = $user->first_name.''. $user->last_name.'['.$user->id.']:T-'.date('d-m-Y h:m:s'); + + $diagnosis_remarks=$this->input->post('course_remarks'); + $ipd_id=$this->input->post('ipd_id'); + $rec_id=$this->input->post('invACode'); + + $sql="select * from ipd_discharge_course where id=".$rec_id." and ipd_id=".$ipd_id; + $query = $this->db->query($sql); + $dataRec= $query->result(); + + $content="Nothing Done"; + + if(count($dataRec)>0) + { + $dataupdate = array( + 'comp_remark' => $diagnosis_remarks, + 'update_by' => $user_name + ); + + + $this->ipdDischarge_M->update_p_course($dataupdate,$rec_id); + + $content="Update Done"; + } + + echo $content; + } + + + public function remove_course($invRecID,$ipd_id) + { + if (!$this->input->is_ajax_request()) { exit('no valid req.'); } + + $sql="select * from ipd_discharge_course where ipd_id=".$ipd_id." and id=".$invRecID; + $query = $this->db->query($sql); + $dataRec= $query->result(); + + if(count($dataRec)>0) + { + + $this->ipdDischarge_M->remove_p_course($invRecID); + } + + $content=""; + + $sql="select * from ipd_discharge_course where ipd_id=".$ipd_id; + $query = $this->db->query($sql); + $dataRec= $query->result(); + + $content="
"; + + foreach($dataRec as $row) + { + $content.= ' + + + + + '; + } + + $content.='
'.$row->comp_report.' + + UpdateRemove
'; + + echo $content; + + } + + public function update_course_remark() + { + $editor_Sys_Exam=$this->input->post('editor_Sys_Exam'); + $ipd_id=$this->input->post('ipd_id'); + + $datainsert = array( + 'ipd_id' => $ipd_id, + 'comp_remark' => $editor_Sys_Exam, + ); + + $this->ipdDischarge_M->update_insert_ipd_discharge_course_remark($datainsert,$ipd_id); + + echo 'Saved'; + } + + + //Discharge Instructions + public function save_Instructions() + { + $editor_Sys_Exam=$this->input->post('editor_Sys_Exam'); + $ipd_id=$this->input->post('ipd_id'); + + $datainsert = array( + 'ipd_id' => $ipd_id, + 'comp_remark' => $editor_Sys_Exam, + ); + + $this->ipdDischarge_M->update_insert_ipd_discharge_instructions($datainsert,$ipd_id); + + echo 'Saved'; + } + + public function save_Footer() + { + $editor_Sys_Exam=$this->input->post('editor_Sys_Exam'); + $ipd_id=$this->input->post('ipd_id'); + + $datainsert = array( + 'ipd_id' => $ipd_id, + 'footer_text' => $editor_Sys_Exam, + ); + + $this->ipdDischarge_M->update_insert_ipd_discharge_instructions($datainsert,$ipd_id); + + echo 'Saved'; + } + + //Drugs + + public function add_drug() + { + if (!$this->input->is_ajax_request()) { exit('no valid req.'); } + + $user = $this->ion_auth->user()->row(); + $user_id = $user->id; + $user_name = $user->first_name.''. $user->last_name.'['.$user->id.']:T-'.date('d-m-Y h:m:s'); + + $drug_name=$this->input->post('input_drug'); + $drug_day=$this->input->post('input_days'); + $drug_dose=$this->input->post('input_dosage'); + $ipd_id=$this->input->post('ipd_id'); + $drug_ipd_id=$this->input->post('input_drug_ipd_id'); + + $datainsert = array( + 'ipd_id' => $ipd_id, + 'drug_name' => $drug_name, + 'drug_day' => $drug_day, + 'drug_dose' => $drug_dose, + 'update_by' => $user_name + ); + + if($drug_ipd_id>0){ + $this->ipdDischarge_M->update_p_drug($datainsert,$drug_ipd_id); + }else{ + $this->ipdDischarge_M->insert_p_drug($datainsert); + } + + $content=""; + + $sql="select * from ipd_discharge_drug where ipd_id=".$ipd_id; + $query = $this->db->query($sql); + $dataRec= $query->result(); + + $content="
+ "; + + foreach($dataRec as $row) + { + $content.= ' + + + + + + + '; + } + + $content.='
Medicine NameTimingNo. of Days
'.$row->drug_name.''.$row->drug_dose.''.$row->drug_day.'RemoveUpdate
'; + + echo $content; + + } + + + public function update_drug() + { + if (!$this->input->is_ajax_request()) { exit('no valid req.'); } + + $user = $this->ion_auth->user()->row(); + $user_id = $user->id; + $user_name = $user->first_name.''. $user->last_name.'['.$user->id.']:T-'.date('d-m-Y h:m:s'); + + $drug_remarks=$this->input->post('drug_remarks'); + $ipd_id=$this->input->post('ipd_id'); + $rec_id=$this->input->post('invACode'); + + $sql="select * from ipd_discharge_drug where id=".$rec_id." and ipd_id=".$ipd_id; + $query = $this->db->query($sql); + $dataRec= $query->result(); + + $content="Nothing Done"; + + if(count($dataRec)>0) + { + $dataupdate = array( + 'drug_dose' => $drug_remarks, + 'update_by' => $user_name + ); + + + $this->ipdDischarge_M->update_p_drug($dataupdate,$rec_id); + + $content="Update Done"; + } + + echo $content; + } + + + + + + + public function remove_drug($invRecID,$ipd_id) + { + if (!$this->input->is_ajax_request()) { exit('no valid req.'); } + + $sql="select * from ipd_discharge_drug where ipd_id=".$ipd_id." and id=".$invRecID; + $query = $this->db->query($sql); + $dataRec= $query->result(); + + if(count($dataRec)>0) + { + + $this->ipdDischarge_M->remove_p_drug($invRecID); + } + + $content=""; + + $sql="select * from ipd_discharge_drug where ipd_id=".$ipd_id; + $query = $this->db->query($sql); + $dataRec= $query->result(); + + $content="
+ + "; + + + foreach($dataRec as $row) + { + $content.= ' + + + + + '; + } + + $content.='
Medicine NameTimingNo. of Days
'.$row->drug_name.''.$row->drug_dose.''.$row->drug_day.'Remove
'; + + echo $content; + + } + + public function preview_discharge_report($ipdno) + { + $content=""; + + $dataupdate = array( + 'ipd_create'=>1, + ); + + $this->Ipd_M->update($dataupdate,$ipdno); + + $sql="select * from v_ipd_list where id='".$ipdno."' "; + $query = $this->db->query($sql); + $ipd_master= $query->result(); + + $p_id=$ipd_master[0]->p_id; + $ipd_admit_date=$ipd_master[0]->register_date; + + $sql="select * from patient_master_exten where id='".$p_id."' "; + $query = $this->db->query($sql); + $patient_master= $query->result(); + + if($ipd_master[0]->discharge_date==null || $ipd_master[0]->discharge_date=='0000-00-00' || $ipd_master[0]->discharge_date=='1901-01-01' ) + { + $ipd_discharge_date=date('Y-m-d'); + }else{ + $ipd_discharge_date=$ipd_master[0]->discharge_date; + } + + if($ipd_master[0]->case_id==0 ) + { + $Discharge_time=$ipd_master[0]->discharge_time; + $Reg_time=$ipd_master[0]->reg_time; + }else{ + $Discharge_time=''; + $Reg_time=''; + } + + + $sql="select * from ipd_discharge where ipd_id='".$ipdno."' "; + $query = $this->db->query($sql); + $ipd_discharge= $query->result(); + + $doc_list=$ipd_master[0]->doc_list; + + $sql="select d.id,d.p_fname,d.p_title,d.mphone1,d.mphone2, + if(d.gender=1,'Male','Female') as xgender,Get_Age(d.dob) as age, + d.dob,d.zip,d.email1,d.email2, + group_concat(distinct m.SpecName) as SpecName,d.doc_sign + from (doctor_master d left join (doc_spec s join med_spec m on s.med_spec_id=m.id) on d.id=s.doc_id) + where d.id in (".$doc_list.") group by d.id"; + $query = $this->db->query($sql); + $doc_master= $query->result(); + + $doc_list=""; + $doc_list_sign=' '; + + $doc_list_main_sign='

Treating Consultant / Authorized Team Doctor

'; + + $row_num=0; + foreach($doc_master as $row) + { + $row_num=$row_num+1; + + $doc_list.="Dr. ".$row->p_fname." [".$row->SpecName."]
"; + + $doc_list_sign.=' + + + + '; + + $mod_r=$row_num % 2; + if($mod_r>0) + { + $doc_list_main_sign.=''; + } + + $doc_list_main_sign.=' + '; + + if($mod_r==0) + { + $doc_list_main_sign.=''; + } + } + $row_num=$row_num+1; + $mod_r=$row_num % 2; + if($mod_r==0) + { + + $doc_list_main_sign.=' + '; + } + + + $doc_list_sign.="

Treating Consultant/Department/Specialty

Dr. '.$row->p_fname.' +
'.$row->SpecName.' +
+
+
Signature of Consultant
Dr. '.$row->p_fname.'
['.$row->SpecName.']
+ '.nl2br($row->doc_sign).' +
"; + + $doc_list_main_sign.=""; + + //Presenting Complaints with Duration and Reason for Admission + + $sql="select * from ipd_discharge_complaint where ipd_id='".$ipdno."' "; + $query = $this->db->query($sql); + $ipd_discharge_complaint= $query->result(); + + $sql="select * from ipd_discharge_complaint_remark where ipd_id='".$ipdno."' "; + $query = $this->db->query($sql); + $ipd_discharge_complaint_remark= $query->result(); + + + //Surgery + $sql="select * from ipd_discharge_surgery where ipd_id='".$ipdno."' "; + $query = $this->db->query($sql); + $ipd_discharge_surgery= $query->result(); + + //Prosedure + $sql="select * from ipd_discharge_procedure where ipd_id='".$ipdno."' "; + $query = $this->db->query($sql); + $ipd_discharge_procedure= $query->result(); + + //General examination + + $sql="select g.id,g.col_name,g.col_description,d.col_id,d.short_head,d.rdata,d.ipd_d_id,g.col_unit + from ipd_discharge_general_exam_col g left join ipd_discharge_1_b d on g.id=d.col_id and d.ipd_d_id='".$ipdno."' + where CHAR_LENGTH(d.rdata)>0 "; + $query = $this->db->query($sql); + $ipd_discharge_general_exam_col= $query->result(); + + $sql="select g.id,g.sys_exam_name,g.sys_format,d.rdata + from ipd_discharge_sys_exam g left join ipd_discharge_1_a d on g.id=d.head_id and d.ipd_d_id='".$ipdno."' "; + $query = $this->db->query($sql); + $ipd_discharge_sys_exam= $query->result(); + + + //CLINICAL INVESTIGATION REPORTS + + $sql="select * from ipd_discharge_2 where ipd_d_id='".$ipdno."' and CHAR_LENGTH(lab_investigation_list)>0"; + $query = $this->db->query($sql); + $ipd_discharge_2= $query->result(); + + $sql="select * from ipd_discharge_2 where ipd_d_id='".$ipdno."' "; + $query = $this->db->query($sql); + $ipd_discharge_2_rdata= $query->result(); + + $lab_list=""; + + if(count($ipd_discharge_2)>0) + { + $lab_list=$ipd_discharge_2[0]->lab_investigation_list; + } + + if(strlen($lab_list)>0) + { + $lab_list_array=explode(",",$lab_list); + $sql_lab_test="SELECT t.Test,t.Unit,t.FixedNormals"; + + foreach($lab_list_array as $key => $value) + { + $sql_lab_test.=","."group_concat(if(m.inv_date=".$value.",i.lab_test_value,null)) AS lab_test_value_".$key; + } + + $sql_lab_test.=" FROM ((((invoice_master m JOIN lab_request l ON m.id=l.charge_id) + JOIN lab_request_item i ON l.id=i.lab_request_id) + JOIN lab_tests t ON i.lab_test_id=t.mstTestKey) + JOIN ipd_discharge_investigation_template d ON t.TestID=d.test_code) + JOIN lab_rgroups g ON d.group_test=g.mstRGrpKey + WHERE m.attach_id=".$p_id." and m.inv_date IN (".$lab_list.") + GROUP BY d.test_code + ORDER BY g.sort_order,t.mstTestKey"; + + + $query = $this->db->query($sql_lab_test); + $lab_request= $query->result_array(); + } + + //Final Diagnosis + + $sql="select * from ipd_discharge_diagnosis where ipd_id='".$ipdno."' "; + $query = $this->db->query($sql); + $ipd_discharge_diagnosis= $query->result(); + + $sql="select * from ipd_discharge_diagnosis_remark where ipd_id='".$ipdno."' "; + $query = $this->db->query($sql); + $ipd_discharge_diagnosis_remark= $query->result(); + + + //Summary of key investigtions during Hospitalization + + $sql="select * from ipd_discharge_investigtions_inhos where ipd_id='".$ipdno."' "; + $query = $this->db->query($sql); + $ipd_discharge_investigtions_inhos= $query->result(); + + //Course in the hospital + + $sql="select * from ipd_discharge_course where ipd_id='".$ipdno."' "; + $query = $this->db->query($sql); + $ipd_discharge_course= $query->result(); + + $sql="select * from ipd_discharge_course_remark where ipd_id='".$ipdno."' "; + $query = $this->db->query($sql); + $ipd_discharge_course_remark= $query->result(); + + //Exam. in Discharge + + $sql="select g.id,g.col_name,g.col_description,d.col_id,d.short_head,d.rdata,g.col_unit + from ipd_discharge_general_exam_col g left join ipd_discharge_1_b_final d on g.id=d.col_id and d.ipd_d_id='".$ipdno."' + where CHAR_LENGTH(d.rdata)>0 "; + $query = $this->db->query($sql); + $ipd_discharge_exam_on_discharge_col= $query->result(); + + + //Discharge Medications + + $sql="select * from ipd_discharge_drug where ipd_id='".$ipdno."' "; + $query = $this->db->query($sql); + $ipd_discharge_drug= $query->result(); + + //Discharge Instructions + + $sql="select * from ipd_discharge_instructions where ipd_id='".$ipdno."' "; + $query = $this->db->query($sql); + $ipd_discharge_instructions= $query->result(); + + //Discharge FOOD DRUG INTERACTION + $sql="select * from ipd_discharge_drug_food_interaction where ipd_id='".$ipdno."' "; + $query = $this->db->query($sql); + $ipd_discharge_drug_food_interaction= $query->result(); + + $food_list="0"; + if(count($ipd_discharge_drug_food_interaction)>0) + { + if(strlen($ipd_discharge_drug_food_interaction[0]->food_id_list)>0) + { + $food_list=$ipd_discharge_drug_food_interaction[0]->food_id_list; + } + } + + $sql="SELECT m.id,m.food_short + FROM ipd_discharge_master_food m where m.id IN (".$food_list.")"; + $query = $this->db->query($sql); + $dis_food_interaction= $query->result(); + + //HTML Style + + $style_tag_P="LINE-HEIGHT:20px;"; + + $content_space_line=' + + + + + +
+ +
'; + + + //Content Start + $sql="SELECT * FROM ipd_discharg_status where id =".$ipd_master[0]->discarge_patient_status; + $query = $this->db->query($sql); + $ipd_discharge_status= $query->result(); + + if(count($ipd_discharge_status)<1) + { + $h1_head=''; + }else{ + $h1_head=$ipd_discharge_status[0]->status_details; + } + + $content.=' + + + + + + +
+

'.$h1_head.'

+
'; + + $content.=$doc_list_main_sign; + + $content.=$content_space_line; + + if($ipd_master[0]->case_id=='0'){ + $discharge_date_time=$ipd_master[0]->discharge_time; + }else{ + $discharge_date_time=''; + } + + $discharge_date_time=$ipd_master[0]->discharge_time; + + $p_address=""; + + if(strlen($patient_master[0]->p_address)>2) + { + $p_address="
Address : ".$patient_master[0]->p_address; + } + + if(strtoupper($patient_master[0]->blood_group)=='NOT DEFINE') + { + $blood_group_show=''; + }else{ + $blood_group_show='Blood Group : '.$patient_master[0]->blood_group; + } + + + + + + $content.=' + + + + + + + + + + + + + + + + + + + + + + + +
+

Patient Information

+
Name of Patient  : '.ucwords($ipd_master[0]->p_fname).' +
'.ucwords($ipd_master[0]->p_relative).' '.ucwords($ipd_master[0]->p_rname).''.$p_address.'
UHID:'.$ipd_master[0]->p_code.'IPD No. : '.$ipd_master[0]->ipd_code.'
Age : '.$ipd_master[0]->str_age.' /  Gender :  '.$ipd_master[0]->xgender.' TPA:'.$ipd_master[0]->admit_type.'Discharge Status : '.$ipd_master[0]->status_desc.'
Date of Admission : '.$ipd_master[0]->str_register_date.' '.$Reg_time.' Date of Discharge : '.$ipd_master[0]->str_discharge_date.' '.$Discharge_time.'
MLC :'.$ipd_master[0]->mlc_type.''.$blood_group_show.'
'; + + $content.=$content_space_line; + + if($ipd_master[0]->issurgery==1 || $ipd_master[0]->isdelivery==1 || count($ipd_discharge_surgery)>0 || count($ipd_discharge_procedure)>0) + { + $content.=' + + '; + + if($ipd_master[0]->issurgery==1) + { + $content.=' + + + + + '; + } + + if(count($ipd_discharge_surgery)>0) + { + foreach($ipd_discharge_surgery as $row) + { + $content.=' + + + + + '; + } + } + + if(count($ipd_discharge_procedure)>0) + { + foreach($ipd_discharge_procedure as $row) + { + $content.=' + + + + + '; + } + } + + + + if($ipd_master[0]->isdelivery==1) + { + $baby_desc='Sex of baby: '.$ipd_master[0]->delivery_sex_of_baby.''; + + if($ipd_master[0]->delivery_sex_of_baby2<>'') + { + $baby_desc.='Sex of Second Baby :'.$ipd_master[0]->delivery_sex_of_baby2.''; + } + + if($ipd_master[0]->delivery_sex_of_baby3<>'') + { + $baby_desc.='Sex of Third Baby :'.$ipd_master[0]->delivery_sex_of_baby3.''; + } + + $content.=' + + + + + '; + } + + $content.=' + +
+

Surgery

+
'.$ipd_master[0]->surgery_name.'Date of Surgery : '.MysqlDate_to_str($ipd_master[0]->surgery_date).'
+

Surgery

+
'.$row->surgery_name.'Date of Surgery : '.MysqlDate_to_str($row->surgery_date).'
+

Procedure

+
'.$row->procedure_name.'Date of Procedure : '.MysqlDate_to_str($row->procedure_date).'
+

Child Birth

+
Delivery Date and Time : '.MysqlDate_to_str($ipd_master[0]->delivery_date).' '.$ipd_master[0]->delivery_time.''.$baby_desc.'
'; + } + + + + //Presenting Complaints with Duration and Reason for Admission + + $content.='

Presenting Complaints and Reason for Admission

'; + + foreach($ipd_discharge_complaint as $row) + { + $content.=''.$row->comp_report.'
'; + $content.=''.$row->comp_remark.''; + } + + if(count($ipd_discharge_complaint_remark)>0){ + if($ipd_discharge_complaint_remark[0]->comp_remark!='') + { + $content.=''.nl2br($ipd_discharge_complaint_remark[0]->comp_remark).' '; + } + } + + //Provisional Diagnosis at the time of Admission + + $content.=' +

General Examination on Admission

+ + '; + $icol=0; + $no_col=4; + foreach($ipd_discharge_general_exam_col as $row) + { + if($icol%$no_col==0) + { + $content.=''; + } + $content.=''; + + if($icol%$no_col==$no_col-1) + { + $content.=''; + } + + $icol=$icol+1; + } + + while($icol%$no_col>0) { + $content.=''; + + if($icol%$no_col==$no_col-1) + { + $content.=''; + } + $icol=$icol+1; + } + + $content.='
'.$row->col_name.': '.$row->rdata.' '.$row->col_unit.'
  
'; + + foreach($ipd_discharge_sys_exam as $row) + { + if($row->rdata==null || $row->rdata=='') + { + + }else{ + //$content.='

'.$row->sys_exam_name.'

'; + $content.='
'.$row->rdata.'
'; + } + } + + //CLINICAL INVESTIGATION REPORTS + if(isset($lab_request)) + { + $content.='

Clinical Investigation Reports

'; + $content.=' + '; + + $content.=''; + $content.=''; + $content.=''; + foreach($lab_list_array as $key => $value) + { + $content.=''; + } + $content.=''; + + foreach($lab_request as $row) + { + $content.=''; + $content.=''; + $content.=''; + foreach($lab_list_array as $key => $value) + { + $content.=''; + } + $content.=''; + } + + $content.='
Fixed Normals'.MysqlDate_to_str(str_replace("'","",$value)).'
'.$row['Test'].''.$row['FixedNormals'].''.$row['lab_test_value_'.$key].'
'; + } + + if(count($ipd_discharge_2_rdata)>0){ + if($ipd_discharge_2_rdata[0]->rdata!='') + { + $content.='
'.$ipd_discharge_2_rdata[0]->rdata.'
'; + } + } + + //Final Diagnosis at the time of Discharge + + $content.='

Final Diagnosis

'; + + foreach($ipd_discharge_diagnosis as $row) + { + $content.='
'.$row->comp_report.' '; + $content.=''.$row->comp_remark.''; + } + + if(count($ipd_discharge_diagnosis_remark)>0){ + if($ipd_discharge_diagnosis_remark[0]->comp_remark!='') + { + $content.='
'.$ipd_discharge_diagnosis_remark[0]->comp_remark.'
'; + } + } + + //Summary of key investigtions during Hospitalization + if(count($ipd_discharge_investigtions_inhos)>0){ + if($ipd_discharge_investigtions_inhos[0]->comp_remark!='') + { + $content.="

Summary of key investigtions during Hospitalization

"; + $content.='
'.$ipd_discharge_investigtions_inhos[0]->comp_remark.'
'; + } + } + + //Course in the hospital + + $content.='
+

Course in the hospital

'; + + foreach($ipd_discharge_course as $row) + { + $content.='
'.$row->comp_report.' '; + $content.=''.$row->comp_remark.''; + } + + if(count($ipd_discharge_course_remark)>0){ + if($ipd_discharge_course_remark[0]->comp_remark!='') + { + $content.='
'.$ipd_discharge_course_remark[0]->comp_remark.'
'; + } + } + + //Exam in Discharge + + $content.='

Examination on Discharge

'; + + $content.=' + + '; + $icol=0; + $no_col=4; + foreach($ipd_discharge_exam_on_discharge_col as $row) + { + if($icol%$no_col==0) + { + $content.=''; + } + $content.=''; + + if($icol%$no_col==$no_col-1) + { + $content.=''; + } + + $icol=$icol+1; + } + + while($icol%$no_col>0) { + $content.=''; + + if($icol%$no_col==$no_col-1) + { + $content.=''; + } + $icol=$icol+1; + } + + $content.='
'.$row->col_name.': '.$row->rdata.' '.$row->col_unit.'
  
'; + + $content.='

Discharge Medications

'; + $content.="
    "; + foreach($ipd_discharge_drug as $row) + { + $content.='
  1. '.$row->drug_name.' ----------> '; + + $content.=' '.$row->drug_dose.''; + + if(strlen($row->drug_day)>0) + { + $content.=' [ '.$row->drug_day." days] "; + }else{ + $content.=' '; + } + + $content.='
  2. '; + } + $content.="
"; + + $content.="

Dietary

"; + + //FOOD DRUG INTERACTION + if(count($ipd_discharge_drug_food_interaction)>0){ + if(strlen($ipd_discharge_drug_food_interaction[0]->food_text)>0 || count($dis_food_interaction)>0) + { + //$content.="

Food Drug Interaction

"; + } + } + + if(count($ipd_discharge_drug_food_interaction)>0){ + if($ipd_discharge_drug_food_interaction[0]->food_text!='') + { + $content.=nl2br($ipd_discharge_drug_food_interaction[0]->food_text); + } + } + + foreach($dis_food_interaction as $row) + { + $content.=$row->food_short.'
'; + //$content.=''.$row->food_desc.''; + } + + //Discharge Instructions + if(count($ipd_discharge_instructions)>0){ + if($ipd_discharge_instructions[0]->comp_remark!='') + { + $content.="

Discharge Instructions

"; + $content.='
'.$ipd_discharge_instructions[0]->comp_remark.'
'; + } + + if($ipd_discharge_instructions[0]->footer_text!='') + { + $content.=$ipd_discharge_instructions[0]->footer_text; + } + } + + + + + //FOOD DRUG INTERACTION + //$content.=$doc_list_sign; + + //Foot Banner + $foot_banner_list="0"; + if(count($ipd_discharge_instructions)>0) + { + if(strlen($ipd_discharge_instructions[0]->footer_banner)>0) + { + $foot_banner_list=$ipd_discharge_instructions[0]->footer_banner; + } + } + + $sql="SELECT m.id,m.banner_name,m.banner_image_name + FROM ipd_discharge_banner m where m.id IN (".$foot_banner_list.") order by id desc"; + $query = $this->db->query($sql); + $dis_banner_list= $query->result(); + + foreach($dis_banner_list as $row){ + $content.='

' ; + } + + // Update in Database + $dataupdate = array( + 'ipd_id' => $ipdno, + 'content'=>$content + ); + $this->ipdDischarge_M->update_ipdDischarge($dataupdate,$ipd_discharge[0]->id); + + $sql="select * from ipd_discharge where ipd_id='".$ipdno."' "; + $query = $this->db->query($sql); + $data['ipd_discharge']= $query->result(); + + $this->load->view('IPD_Discharge/ipd_discharge_preview',$data); + } + + public function edit_discharge_report($ipdno) + { + $sql="select * from ipd_discharge where ipd_id='".$ipdno."' "; + $query = $this->db->query($sql); + $data['ipd_discharge']= $query->result(); + + $this->load->view('IPD_Discharge/ipd_discharge_preview',$data); + } + + + public function show_file($ipdno) + { + $user = $this->ion_auth->user()->row(); + $user_id = $user->id; + $user_name = $user->first_name.''. $user->last_name; + + $sql="select * from ipd_discharge where ipd_id='".$ipdno."' "; + $query = $this->db->query($sql); + $ipd_discharge= $query->result(); + + $sql="select * from v_ipd_list where id='".$ipdno."' "; + $query = $this->db->query($sql); + $ipd_master= $query->result(); + + // Doctor Name + + $docname=''; + $docedu=''; + + $report_head='Patient Name :'.$ipd_master[0]->p_fname.' / Age :'.$ipd_master[0]->str_age.' / Gender :'.$ipd_master[0]->xgender.' / IPD ID :'.$ipd_master[0]->ipd_code; + + $complete_report=$ipd_discharge[0]->content; + + $folder_name='uploads/'.date('Ymd'); + + if (!file_exists($folder_name)) { + mkdir($folder_name, 0777, true); + chmod($folder_name, 0777); + } + + $file_name='Report-IPD-Discharge-'.$ipdno."-".date('Ymdhis').".pdf"; + + $filepath=$folder_name.'/'.$file_name; + + $udata = array( + 'file_name'=>$file_name, + 'file_type'=>'pdf', + 'file_path'=>$folder_name, + 'full_path'=>$filepath, + 'orig_name'=>$file_name, + 'client_name'=>'system_genrate', + 'file_ext'=>'.pdf', + 'upload_by'=> $user_name, + 'pid'=>$ipd_master[0]->p_id, + 'ipd_id'=>$ipd_master[0]->id, + 'case_id'=>0, + 'file_desc'=>$report_head, + 'charge_id'=>0 + ); + + $this->load->model('File_M'); + + $sql="select * from file_upload_data where Date(insert_date)=Date(sysdate()) and file_name='".$file_name."'"; + $query = $this->db->query($sql); + $check_file_exist= $query->result(); + + if(count($check_file_exist)<1){ + $this->File_M->insert($udata); + }else + { + $this->File_M->update($udata,$check_file_exist[0]->id); + } + + create_Discharge_report_pdf($complete_report,$filepath,'',$report_head,$docname,$docedu); + + + + } + + + + public function show_file2($ipdno) + { + $user = $this->ion_auth->user()->row(); + $user_id = $user->id; + $user_name = $user->first_name.''. $user->last_name; + + $sql="select * from ipd_discharge where ipd_id='".$ipdno."' "; + $query = $this->db->query($sql); + $ipd_discharge= $query->result(); + + $sql="select * from v_ipd_list where id='".$ipdno."' "; + $query = $this->db->query($sql); + $ipd_master= $query->result(); + + // Doctor Name + + $docname=''; + $docedu=''; + + $report_head='Patient Name :'.$ipd_master[0]->p_fname.' / Age :'.$ipd_master[0]->str_age.' / Gender :'.$ipd_master[0]->xgender.' / IPD ID :'.$ipd_master[0]->ipd_code; + + $complete_report=$ipd_discharge[0]->content; + + $folder_name='uploads/'.date('Ymd'); + + if (!file_exists($folder_name)) { + mkdir($folder_name, 0777, true); + chmod($folder_name, 0777); + } + + $file_name='Report-IPD-Discharge-'.$ipdno."-".date('Ymdhis').".pdf"; + + $filepath=$folder_name.'/'.$file_name; + + $udata = array( + 'file_name'=>$file_name, + 'file_type'=>'pdf', + 'file_path'=>$folder_name, + 'full_path'=>$filepath, + 'orig_name'=>$file_name, + 'client_name'=>'system_genrate', + 'file_ext'=>'.pdf', + 'upload_by'=> $user_name, + 'pid'=>$ipd_master[0]->p_id, + 'ipd_id'=>$ipd_master[0]->id, + 'case_id'=>0, + 'file_desc'=>$report_head, + 'charge_id'=>0 + ); + + $this->load->model('File_M'); + + $sql="select * from file_upload_data where Date(insert_date)=Date(sysdate()) and file_name='".$file_name."'"; + $query = $this->db->query($sql); + $check_file_exist= $query->result(); + + if(count($check_file_exist)<1){ + $this->File_M->insert($udata); + }else + { + $this->File_M->update($udata,$check_file_exist[0]->id); + } + + create_discharge_logo_pdf($complete_report,$filepath); + } + + public function show_file3($ipdno) + { + $user = $this->ion_auth->user()->row(); + $user_id = $user->id; + $user_name = $user->first_name.''. $user->last_name; + + $sql="select * from ipd_discharge where ipd_id='".$ipdno."' "; + $query = $this->db->query($sql); + $ipd_discharge= $query->result(); + + $sql="select * from v_ipd_list where id='".$ipdno."' "; + $query = $this->db->query($sql); + $ipd_master= $query->result(); + + // Doctor Name + + $docname=''; + $docedu=''; + + $report_head='Patient Name :'.$ipd_master[0]->p_fname.' / Age :'.$ipd_master[0]->str_age.' / Gender :'.$ipd_master[0]->xgender.' / IPD ID :'.$ipd_master[0]->ipd_code; + + $report_foot='P:'.$ipd_master[0]->p_fname.' / A:'.$ipd_master[0]->str_age.' /G:'.$ipd_master[0]->xgender.' /'.$ipd_master[0]->ipd_code; + + $complete_report=$ipd_discharge[0]->content; + + $folder_name='uploads/'.date('Ymd'); + + if (!file_exists($folder_name)) { + mkdir($folder_name, 0777, true); + chmod($folder_name, 0777); + } + + $file_name='Report-IPD-Discharge-'.$ipdno."-".date('Ymdhis').".pdf"; + + $filepath=$folder_name.'/'.$file_name; + + $udata = array( + 'file_name'=>$file_name, + 'file_type'=>'pdf', + 'file_path'=>$folder_name, + 'full_path'=>$filepath, + 'orig_name'=>$file_name, + 'client_name'=>'system_genrate', + 'file_ext'=>'.pdf', + 'upload_by'=> $user_name, + 'pid'=>$ipd_master[0]->p_id, + 'ipd_id'=>$ipd_master[0]->id, + 'case_id'=>0, + 'file_desc'=>$report_head, + 'charge_id'=>0 + ); + + $this->load->model('File_M'); + + $sql="select * from file_upload_data where Date(insert_date)=Date(sysdate()) and file_name='".$file_name."'"; + $query = $this->db->query($sql); + $check_file_exist= $query->result(); + + if(count($check_file_exist)<1){ + $this->File_M->insert($udata); + }else + { + $this->File_M->update($udata,$check_file_exist[0]->id); + } + + //create_Discharge_report_pdf($complete_report,$filepath,'',$report_head,$docname,$docedu); + + $content=''; + + $filename = '/uploads/'.time()."_order.pdf"; + + //load mPDF library + $this->load->library('m_pdf'); + + //$this->m_pdf->pdf->SetProtection(array(), '1234567', '277395'); + + $this->m_pdf->pdf->SetWatermarkText(H_Name); + $this->m_pdf->pdf->showWatermarkText = true; + + $Head_Print=' + + + + + +
+
+
+
+
+
+
+
+
+
+
'; + + $this->m_pdf->pdf->SetHTMLFooter(' + + + + + + +
Page : {PAGENO}/{nbpg}'.$report_foot.'
'); + + //generate the PDF from the given html + $this->m_pdf->pdf->WriteHTML($Head_Print.$content.$complete_report); + + //download it. + $this->m_pdf->pdf->Output($filepath, "I"); + + + } + + public function show_discharge($ipdno,$print_type=0) + { + $user = $this->ion_auth->user()->row(); + $user_id = $user->id; + $user_name = $user->first_name.''. $user->last_name; + + $sql="select * from ipd_discharge where ipd_id='".$ipdno."' "; + $query = $this->db->query($sql); + $ipd_discharge= $query->result(); + + $sql="select * from v_ipd_list where id='".$ipdno."' "; + $query = $this->db->query($sql); + $ipd_master= $query->result(); + + // Doctor Name + + $docname=''; + $docedu=''; + + $data['report_head']='Patient Name :'.$ipd_master[0]->p_fname.' / Age :'.$ipd_master[0]->str_age.' / Gender :'.$ipd_master[0]->xgender.' / IPD ID :'.$ipd_master[0]->ipd_code; + + $data['report_foot']='P:'.$ipd_master[0]->p_fname.' / A:'.$ipd_master[0]->str_age.' /G:'.$ipd_master[0]->xgender.' /'.$ipd_master[0]->ipd_code; + + $data['complete_report']=$ipd_discharge[0]->content; + + $data['print_type']=$print_type; + + $folder_name='uploads/'.date('Ymd'); + + if (!file_exists($folder_name)) { + mkdir($folder_name, 0777, true); + chmod($folder_name, 0777); + } + + $file_name='Report-IPD-Discharge-'.$ipdno."-".date('Ymdhis').".pdf"; + + $filepath=$folder_name.'/'.$file_name; + + $udata = array( + 'file_name'=>$file_name, + 'file_type'=>'pdf', + 'file_path'=>$folder_name, + 'full_path'=>$filepath, + 'orig_name'=>$file_name, + 'client_name'=>'system_genrate', + 'file_ext'=>'.pdf', + 'upload_by'=> $user_name, + 'pid'=>$ipd_master[0]->p_id, + 'ipd_id'=>$ipd_master[0]->id, + 'case_id'=>0, + 'file_desc'=>$data['report_head'], + 'charge_id'=>0 + ); + + $this->load->model('File_M'); + + $sql="select * from file_upload_data where Date(insert_date)=Date(sysdate()) and file_name='".$file_name."'"; + $query = $this->db->query($sql); + $check_file_exist= $query->result(); + + if(count($check_file_exist)<1){ + $this->File_M->insert($udata); + }else + { + $this->File_M->update($udata,$check_file_exist[0]->id); + } + + //create_Discharge_report_pdf($complete_report,$filepath,'',$report_head,$docname,$docedu); + + $print_content=$this->load->view('IPD_Discharge/ipd_discharge_print_format',$data,TRUE); + + //$print_content=$this->load->view('IPD_Discharge/ipd_discharge_print_format_1',$data,TRUE); + + $filename = '/uploads/'.time()."_order.pdf"; + + //load mPDF library + $this->load->library('m_pdf'); + + //$this->m_pdf->pdf->SetProtection(array(), '1234567', '277395'); + + $this->m_pdf->pdf->SetWatermarkText(H_Name); + $this->m_pdf->pdf->showWatermarkText = true; + + //generate the PDF from the given html + $this->m_pdf->pdf->WriteHTML($print_content); + + //download it. + $this->m_pdf->pdf->Output($filepath, "I"); + + + } + +} \ No newline at end of file diff --git a/old_code_ci3/controllers/Lab_Admin.php b/old_code_ci3/controllers/Lab_Admin.php index 6f1edb6..009d4cf 100644 --- a/old_code_ci3/controllers/Lab_Admin.php +++ b/old_code_ci3/controllers/Lab_Admin.php @@ -10,22 +10,19 @@ class Lab_Admin extends MY_Controller { public function report_list() { $sql="select g.RepoGrp,r.Title,r.mstRepoKey - FROM (lab_repo r join lab_rgroups g on r.GrpKey=g.mstRGrpKey) - JOIN hc_items i ON r.charge_id=i.id AND i.itype in (5,6)"; + from lab_repo r join lab_rgroups g on r.GrpKey=g.mstRGrpKey"; $query = $this->db->query($sql); $data['labReport_master']= $query->result(); $this->load->view('PathLab_Report/lab_report_list',$data); } - public function report_ultrasound_list($modality=2) + public function report_ultrasound_list() { - $sql="select * from radiology_ultrasound_template where modality=".$modality; + $sql="select * from radiology_ultrasound_template "; $query = $this->db->query($sql); $data['labReport_master']= $query->result(); - $data['modality']=$modality; - $this->load->view('PathLab_Report/ultrasound_template_list',$data); } @@ -559,7 +556,7 @@ class Lab_Admin extends MY_Controller { } //$sql="select * from hc_items where itype=5 and id not in (select charge_id from lab_repo where charge_id>0 and charge_id<>".$item_id.")"; - $sql="select * from hc_items where itype in (5,30,6) and id not in (select charge_id from lab_repo where charge_id>0 and charge_id<>".$item_id.") order by idesc "; + $sql="select * from hc_items where itype in (5,30) and id not in (select charge_id from lab_repo where charge_id>0 and charge_id<>".$item_id.") order by idesc "; $query = $this->db->query($sql); $data['hc_items']= $query->result(); @@ -583,9 +580,9 @@ class Lab_Admin extends MY_Controller { $this->load->view('PathLab_Report/lab_report_edit',$data); } - public function reportedit_ultrasound_load($modality=2,$repo_id=0) + public function reportedit_ultrasound_load($repo_id=0) { - $sql="select * from radiology_ultrasound_template where modality=$modality and id=".$repo_id; + $sql="select * from radiology_ultrasound_template where id=".$repo_id; $query = $this->db->query($sql); $data['labReport_master']= $query->result(); @@ -595,17 +592,13 @@ class Lab_Admin extends MY_Controller { { $item_id=$data['labReport_master'][0]->charge_id; } - - - $sql="select * from hc_items where itype=$modality order by idesc "; + $sql="select * from hc_items where itype=1 order by idesc "; $query = $this->db->query($sql); $data['hc_items']= $query->result(); $data['repo_id']=$repo_id; - - $data['modality']=$modality; $this->load->view('PathLab_Report/ultrasound_report_edit',$data); } @@ -665,7 +658,7 @@ class Lab_Admin extends MY_Controller { 'Title'=> $this->input->post('input_Reportname'), 'GrpKey'=> $this->input->post('group_id'), 'charge_id'=> $this->input->post('charge_id'), - 'HTMLData'=> $this->input->post('HTMLData'), + 'HTMLData'=> $this->input->post('HTMLData') ); $this->PathLab_M->update_report($data,$id_key); @@ -688,7 +681,7 @@ class Lab_Admin extends MY_Controller { echo $encode_data; } - public function report_ultrasound_insert($modality) + public function report_ultrasound_insert() { if (!$this->input->is_ajax_request()) { exit('no valid req.'); } @@ -714,14 +707,14 @@ class Lab_Admin extends MY_Controller { 'title'=> $this->input->post('group_id'), 'charge_id'=> $this->input->post('charge_id'), 'Findings'=> $this->input->post('HTMLData'), - 'Impression'=> $this->input->post('Impression'), - 'modality'=> $modality + 'Impression'=> $this->input->post('Impression') ); $insertid=$this->PathLab_M->insert_ultrasound_report($data); - $showcontent="Data Saved successfully"; + $showcontent=Show_Alert('success','Saved','Data Saved successfully'); + }else{ - $showcontent =validation_errors(); + $showcontent =Show_Alert('danger','Error',validation_errors()); } $rvar=array( @@ -734,7 +727,7 @@ class Lab_Admin extends MY_Controller { } - public function report_ultrasound_update($modality=2) + public function report_ultrasound_update() { $this->load->model('PathLab_M'); @@ -777,8 +770,7 @@ class Lab_Admin extends MY_Controller { 'title'=> $this->input->post('group_id'), 'charge_id'=> $charge_id_post, 'Findings'=> $this->input->post('HTMLData'), - 'Impression'=> $this->input->post('Impression'), - 'modality'=> $modality + 'Impression'=> $this->input->post('Impression') ); $this->PathLab_M->update_ultrasound_report($data,$id_key); @@ -1933,7 +1925,7 @@ class Lab_Admin extends MY_Controller { $RawData=$RawData.$report_data_Impression; } - $complete_report=$RawData; + $complete_report=$Header.'
'.$RawData; $sql="select * from diagnosis_head_name where d_type=".$lab_type; $query = $this->db->query($sql); @@ -1984,7 +1976,6 @@ class Lab_Admin extends MY_Controller { $data['complete_report']=$complete_report; $data['report_head']=$report_head; - $data['report_header']=$Header; $data['print_on_type']=$print_on_type; @@ -2636,7 +2627,7 @@ class Lab_Admin extends MY_Controller { } - //$this->m_pdf->pdf->curlAllowUnsafeSslRequests = true; + $this->m_pdf->pdf->curlAllowUnsafeSslRequests = true; $this->m_pdf->pdf->shrink_tables_to_fit = 1; @@ -2645,7 +2636,6 @@ class Lab_Admin extends MY_Controller { $this->m_pdf->pdf->Output($filepath,"I"); - //echo $content; }else{ $this->load->view('PathLab_Report/lab_final_print',$data); } diff --git a/old_code_ci3/controllers/Lab_Report.php b/old_code_ci3/controllers/Lab_Report.php index 736cbf9..3b63339 100644 --- a/old_code_ci3/controllers/Lab_Report.php +++ b/old_code_ci3/controllers/Lab_Report.php @@ -1,80 +1,83 @@ load->view('Lab_Panel/lab_main'); } - + public function lab_path($lab_type) { - $data['lab_type'] = $lab_type; - $this->load->view('Lab_Panel/pathlab_request_list', $data); + $data['lab_type']=$lab_type; + $this->load->view('Lab_Panel/pathlab_request_list',$data); } - + public function search_lab_4($lab_type) { - $sdata = $this->input->post('txtsearch'); - + $sdata=$this->input->post('txtsearch'); + $sdata = preg_replace('/[^A-Za-z0-9_ \-]/', '', $sdata); - - if (trim($sdata) == '') { - $sql = "select m.id as inv_id,m.invoice_code,m.inv_date, + + if(trim($sdata)=='') + { + $sql="select m.id as inv_id,m.invoice_code,m.inv_date, Concat(p_fname,'/',if(gender=1,'M','F'),'/',p_rname) as inv_name, - GET_AGE_1(dob,age,age_in_month,estimate_dob) AS age, + GET_AGE_1(p.dob,p.age,p.age_in_month,p.estimate_dob) AS age, group_concat(concat_ws(';',t.item_name,t.item_name,t.id,check_item_request(m.id,t.id)) SEPARATOR '#') as data_array, r.daily_sr_no,r.lab_test_no from ( invoice_item t join invoice_master m join hc_item_type y join patient_master p on m.id=t.inv_master_id and t.item_type=y.itype_id and p.id=m.attach_id) Left JOIN lab_invoice_request r ON m.id=r.invoice_id - where m.payment_status=1 and y.itype_id=" . $lab_type . " + where m.payment_status=1 and y.itype_id=".$lab_type." group by m.id order by m.id desc limit 200"; - } else { - $sql = "select m.id as inv_id,m.invoice_code,m.inv_date,Concat(p_fname,'/',if(gender=1,'M','F'),'/',p_rname) as inv_name, - GET_AGE_1(dob,age,age_in_month,estimate_dob) AS age, + }else{ + $sql="select m.id as inv_id,m.invoice_code,m.inv_date,Concat(p_fname,'/',if(gender=1,'M','F'),'/',p_rname) as inv_name, + GET_AGE_1(p.dob,p.age,p.age_in_month,p.estimate_dob) AS age, group_concat(concat_ws(';',t.item_name,t.id,m.id,check_item_request(m.id,t.id)) SEPARATOR '#') as data_array, r.daily_sr_no,r.lab_test_no from ( invoice_item t join invoice_master m join hc_item_type y join patient_master p on m.id=t.inv_master_id and t.item_type=y.itype_id and p.id=m.attach_id) Left JOIN lab_invoice_request r ON m.id=r.invoice_id - where m.payment_status=1 and y.itype_id= " . $lab_type . " AND (m.invoice_code LIKE '%" . $sdata . "' - OR p.p_fname LIKE '%" . $sdata . "%' - OR p.p_code LIKE '%" . $sdata . "' ) + where m.payment_status=1 and y.itype_id= ".$lab_type." AND (m.invoice_code LIKE '%".$sdata."' + OR p.p_fname LIKE '%".$sdata."%' + OR p.p_code LIKE '%".$sdata."' ) group by m.id order by m.id desc limit 50"; } $query = $this->db->query($sql); - $data['labreport_preprocess'] = $query->result(); + $data['labreport_preprocess']= $query->result(); - if ($lab_type == 5 or $lab_type == 6) // Pathology or Biopsy + if($lab_type==5) { - $this->load->view('Lab_Panel/lab_report_tab_path', $data); - } else { - $this->load->view('Lab_Panel/lab_report_tab_1', $data); + $this->load->view('Lab_Panel/lab_report_tab_path',$data); + }else{ + $this->load->view('Lab_Panel/lab_report_tab_1',$data); } + + } public function search_lab_4_labno($lab_type) { - $sdata = $this->input->post('txtsearch_labno'); - + $sdata=$this->input->post('txtsearch_labno'); + $sdata = preg_replace('/[^A-Za-z0-9_ \-]/', '', $sdata); - - if (trim($sdata) == '') { - $sql = "select m.id as inv_id,m.invoice_code,m.inv_date, + + if(trim($sdata)=='') + { + $sql="select m.id as inv_id,m.invoice_code,m.inv_date, Concat(p_fname,'/',if(gender=1,'M','F'),'/',p_rname) as inv_name, - GET_AGE_1(dob,age,age_in_month,estimate_dob) AS age, + GET_AGE_1(p.dob,p.age,p.age_in_month,p.estimate_dob) AS age, group_concat(concat_ws(';',t.item_name,t.item_name,t.id,check_item_request(m.id,t.id)) SEPARATOR '#') as data_array, r.daily_sr_no,r.lab_test_no from ( invoice_item t join invoice_master m join hc_item_type y join patient_master p @@ -82,10 +85,10 @@ class Lab_Report extends MY_Controller JOIN lab_invoice_request r ON m.id=r.invoice_id And r.lab_test_no>0 where m.payment_status=1 and y.itype_id=$lab_type and m.inv_date >=date_add(curdate(),interval -3 day) group by m.id order by m.id desc limit 50"; - } else { - $sql = "select m.id as inv_id,m.invoice_code,m.inv_date, + }else{ + $sql="select m.id as inv_id,m.invoice_code,m.inv_date, Concat(p_fname,'/',if(gender=1,'M','F'),'/',p_rname) as inv_name, - GET_AGE_1(dob,age,age_in_month,estimate_dob) AS age, + GET_AGE_1(p.dob,p.age,p.age_in_month,p.estimate_dob) AS age, group_concat(concat_ws(';',t.item_name,t.item_name,t.id,check_item_request(m.id,t.id)) SEPARATOR '#') as data_array, r.daily_sr_no,r.lab_test_no from ( invoice_item t join invoice_master m join hc_item_type y join patient_master p @@ -98,22 +101,24 @@ class Lab_Report extends MY_Controller } $query = $this->db->query($sql); - $data['labreport_preprocess'] = $query->result(); - - $this->load->view('Lab_Panel/lab_report_tab_1', $data); + $data['labreport_preprocess']= $query->result(); + + $this->load->view('Lab_Panel/lab_report_tab_1',$data); + } - - + + public function search_lab_4_srno($lab_type) { - $sdata = $this->input->post('txtsearch_srno'); - + $sdata=$this->input->post('txtsearch_srno'); + $sdata = preg_replace('/[^A-Za-z0-9_ \-]/', '', $sdata); - - if (trim($sdata) == '') { - $sql = "select m.id as inv_id,m.invoice_code,m.inv_date, + + if(trim($sdata)=='') + { + $sql="select m.id as inv_id,m.invoice_code,m.inv_date, Concat(p_fname,'/',if(gender=1,'M','F'),'/',p_rname) as inv_name, - GET_AGE_1(dob,age,age_in_month,estimate_dob) AS age, + GET_AGE_1(p.dob,p.age,p.age_in_month,p.estimate_dob) AS age, group_concat(concat_ws(';',t.item_name,t.item_name,t.id,check_item_request(m.id,t.id)) SEPARATOR '#') as data_array, r.daily_sr_no,r.lab_test_no from ( invoice_item t join invoice_master m join hc_item_type y join patient_master p @@ -121,10 +126,10 @@ class Lab_Report extends MY_Controller JOIN lab_invoice_request r ON m.id=r.invoice_id And r.daily_sr_no>0 where m.payment_status=1 and y.itype_id=$lab_type and m.inv_date >=date_add(curdate(),interval -3 day) group by m.id order by m.id desc limit 50"; - } else { - $sql = "select m.id as inv_id,m.invoice_code,m.inv_date, + }else{ + $sql="select m.id as inv_id,m.invoice_code,m.inv_date, Concat(p_fname,'/',if(gender=1,'M','F'),'/',p_rname) as inv_name, - GET_AGE_1(dob,age,age_in_month,estimate_dob) AS age, + GET_AGE_1(p.dob,p.age,p.age_in_month,p.estimate_dob) AS age, group_concat(concat_ws(';',t.item_name,t.item_name,t.id,check_item_request(m.id,t.id)) SEPARATOR '#') as data_array, r.daily_sr_no,r.lab_test_no from ( invoice_item t join invoice_master m join hc_item_type y join patient_master p @@ -137,15 +142,16 @@ class Lab_Report extends MY_Controller } $query = $this->db->query($sql); - $data['labreport_preprocess'] = $query->result(); - - $this->load->view('Lab_Panel/lab_report_tab_1', $data); + $data['labreport_preprocess']= $query->result(); + + $this->load->view('Lab_Panel/lab_report_tab_1',$data); + } - - public function lab_tab_1_process($test_id, $lab_type) + + public function lab_tab_1_process($test_id,$lab_type) { - $sql = "select m.invoice_code,p.p_fname as inv_name,t.item_name,t.id as test_id, - GET_AGE_1(dob,age,age_in_month,estimate_dob) AS age, + $sql="select m.invoice_code,p.p_fname as inv_name,t.item_name,t.id as test_id, + GET_AGE_1(p.dob,p.age,p.age_in_month,p.estimate_dob) AS age, if(l.mstRepoKey is null,0,l.mstRepoKey) as mstRepoKey,if(l.mstRepoKey is null,item_name,l.Title) as Title,m.inv_date, r.lab_repo_id,y.group_desc as item_type_desc,y.itype_id,m.insurance_case_id,m.ipd_id, m.id as inv_id,m.attach_id,m.insurance_case_id,m.net_amount @@ -153,90 +159,95 @@ class Lab_Report extends MY_Controller on m.id=t.inv_master_id and t.item_type=y.itype_id and p.id=m.attach_id) left join lab_request r on t.id=r.charge_item_id) left join lab_repo l on t.item_id=l.charge_id - where m.payment_status=1 and y.itype_id=" . $lab_type . " and r.id is null and t.id=" . $test_id; - + where m.payment_status=1 and y.itype_id=".$lab_type." and r.id is null and t.id=".$test_id; + $query = $this->db->query($sql); - $data['labreport_preprocess'] = $query->result(); - + $data['labreport_preprocess']= $query->result(); + $user = $this->ion_auth->user()->row(); $user_id = $user->id; - $user_name = $user->first_name . '' . $user->last_name; + $user_name = $user->first_name.''. $user->last_name; + + $print_allowed=0; + $insert_id=0; - $print_allowed = 0; - $insert_id = 0; - - if (count($data['labreport_preprocess']) > 0) { - if ($data['labreport_preprocess'][0]->insurance_case_id > 0 || $data['labreport_preprocess'][0]->ipd_id > 0) { - $print_allowed = 1; - } else { - $sql = "select sum(if(credit_debit=0,amount,amount*-1)) as paid_amount from payment_history where payof_type=2 and payof_id=" . $data['labreport_preprocess'][0]->inv_id; + if(count($data['labreport_preprocess'])>0) + { + if($data['labreport_preprocess'][0]->insurance_case_id>0 || $data['labreport_preprocess'][0]->ipd_id>0) + { + $print_allowed=1; + }else{ + $sql="select sum(if(credit_debit=0,amount,amount*-1)) as paid_amount from payment_history where payof_type=2 and payof_id=".$data['labreport_preprocess'][0]->inv_id; $query = $this->db->query($sql); - $data['inv_amount'] = $query->result(); - - if (count($data['inv_amount']) < 1) { - $paid_Amount = 0; - } else { - $paid_Amount = $data['inv_amount'][0]->paid_amount; - $inv_amount = $data['labreport_preprocess'][0]->net_amount; - - if ($inv_amount <= $paid_Amount) { - $print_allowed = 1; + $data['inv_amount']= $query->result(); + + if(count($data['inv_amount'])<1 ) + { + $paid_Amount=0; + }else{ + $paid_Amount=$data['inv_amount'][0]->paid_amount; + $inv_amount=$data['labreport_preprocess'][0]->net_amount; + + if($inv_amount<=$paid_Amount) + { + $print_allowed=1; } } } $this->load->model('PathLab_M'); - - $udata = array( - 'lab_repo_id' => $data['labreport_preprocess'][0]->mstRepoKey, - 'charge_id' => $data['labreport_preprocess'][0]->inv_id, - 'lab_type' => $data['labreport_preprocess'][0]->itype_id, - 'charge_item_id' => $data['labreport_preprocess'][0]->test_id, - 'invoice_code' => $data['labreport_preprocess'][0]->invoice_code, - 'patient_name' => $data['labreport_preprocess'][0]->inv_name, - 'patient_id' => $data['labreport_preprocess'][0]->attach_id, - 'ipd_id' => $data['labreport_preprocess'][0]->ipd_id, - 'org_id' => $data['labreport_preprocess'][0]->insurance_case_id, - 'Request_Date' => $data['labreport_preprocess'][0]->inv_date, - 'report_name' => $data['labreport_preprocess'][0]->Title, - 'insert_by' => $user_name, - 'print_allowed' => $print_allowed, - 'collected_time' => date('Y-m-d H:i:s') - ); + + $udata = array( + 'lab_repo_id'=> $data['labreport_preprocess'][0]->mstRepoKey, + 'charge_id'=> $data['labreport_preprocess'][0]->inv_id, + 'lab_type'=> $data['labreport_preprocess'][0]->itype_id, + 'charge_item_id'=> $data['labreport_preprocess'][0]->test_id, + 'invoice_code'=> $data['labreport_preprocess'][0]->invoice_code, + 'patient_name'=> $data['labreport_preprocess'][0]->inv_name, + 'patient_id'=> $data['labreport_preprocess'][0]->attach_id, + 'ipd_id'=> $data['labreport_preprocess'][0]->ipd_id, + 'org_id'=> $data['labreport_preprocess'][0]->insurance_case_id, + 'Request_Date'=> $data['labreport_preprocess'][0]->inv_date, + 'report_name'=> $data['labreport_preprocess'][0]->Title, + 'insert_by'=> $user_name, + 'print_allowed'=> $print_allowed, + 'collected_time'=> date('Y-m-d H:i:s') + ); //print_r ($udata); - $insert_id = $this->PathLab_M->insert_test_request($udata); - - $sql = "select id from lab_invoice_request - where lab_type=$lab_type and invoice_id=" . $data['labreport_preprocess'][0]->inv_id; + $insert_id=$this->PathLab_M->insert_test_request($udata); + + $sql="select id from lab_invoice_request + where lab_type=$lab_type and invoice_id=".$data['labreport_preprocess'][0]->inv_id; $query = $this->db->query($sql); - $lab_invoice_request = $query->result(); - - if (count($lab_invoice_request) < 1) { - $sql = "select count(*) as no_rec from lab_invoice_request + $lab_invoice_request= $query->result(); + + if(count($lab_invoice_request)<1) + { + $sql="select count(*) as no_rec from lab_invoice_request where lab_type=$lab_type and date(report_insert)=curdate()"; $query = $this->db->query($sql); - $lab_invoice_count = $query->result(); + $lab_invoice_count= $query->result(); - $count_rec = $lab_invoice_count[0]->no_rec; + $count_rec=$lab_invoice_count[0]->no_rec; - $count_rec = $count_rec + 1; + $count_rec=$count_rec+1; - $udata = array( - 'invoice_id' => $data['labreport_preprocess'][0]->inv_id, - 'invoice_code' => $data['labreport_preprocess'][0]->invoice_code, - 'lab_type' => $data['labreport_preprocess'][0]->itype_id, - 'print_allowed' => $print_allowed, - 'collected_time' => date('Y-m-d H:i:s'), - 'daily_sr_no' => $count_rec - ); - $insert_invoice_request = $this->PathLab_M->insert_invoice_report($udata); - } else { - $udata = array( - 'print_allowed' => $print_allowed, - 'collected_time' => date('Y-m-d H:i:s') - ); - $insert_invoice_request = $this->PathLab_M->update_invoice_report($udata, $lab_invoice_request[0]->id); + $udata = array( + 'invoice_id'=> $data['labreport_preprocess'][0]->inv_id, + 'invoice_code'=> $data['labreport_preprocess'][0]->invoice_code, + 'lab_type'=> $data['labreport_preprocess'][0]->itype_id, + 'print_allowed'=> $print_allowed, + 'collected_time'=>date('Y-m-d H:i:s'), + 'daily_sr_no'=>$count_rec + ); + $insert_invoice_request=$this->PathLab_M->insert_invoice_report($udata); + }else{ + $udata = array( + 'print_allowed'=> $print_allowed, + 'collected_time'=>date('Y-m-d H:i:s') + ); + $insert_invoice_request=$this->PathLab_M->update_invoice_report($udata,$lab_invoice_request[0]->id); } } @@ -245,243 +256,233 @@ class Lab_Report extends MY_Controller echo $insert_id; } - - public function create_report_xray($req_id) - { - + + public function create_report_xray($req_id) { + $this->load->model('PathLab_M'); - - $sql = "select * from lab_request where id=" . $req_id; + + $sql="select * from lab_request where id=".$req_id; $query = $this->db->query($sql); - $data_lab_request = $query->result(); + $data_lab_request= $query->result(); - $p_id = $data_lab_request[0]->patient_id; + $p_id=$data_lab_request[0]->patient_id; - $sql = "select * from patient_master_exten where id=$p_id"; + $sql="select * from patient_master_exten where id=$p_id"; $query = $this->db->query($sql); - $data_patient_data = $query->result(); + $data_patient_data= $query->result(); - - $sql = "select mstRepoKey,Title,HTMLData,GrpKey,charge_id,RepoGrp + + $sql="select mstRepoKey,Title,HTMLData,GrpKey,charge_id,RepoGrp from lab_repo join lab_rgroups on lab_repo.GrpKey=lab_rgroups.mstRGrpKey - where mstRepoKey=" . $data_lab_request[0]->lab_repo_id; - + where mstRepoKey=".$data_lab_request[0]->lab_repo_id; + $query = $this->db->query($sql); - $data_report_format = $query->result(); - - $sql = "select * from invoice_master where attach_type=0 and id=" . $data_lab_request[0]->charge_id; + $data_report_format= $query->result(); + + $sql="select * from invoice_master where attach_type=0 and id=".$data_lab_request[0]->charge_id; $query = $this->db->query($sql); - $data_invoice_master = $query->result(); - - $sql = "select id from lab_invoice_request where invoice_id=" . $data_lab_request[0]->charge_id . " and lab_type=" . $data_lab_request[0]->lab_type; + $data_invoice_master= $query->result(); + + $sql="select id from lab_invoice_request where invoice_id=".$data_lab_request[0]->charge_id." and lab_type=".$data_lab_request[0]->lab_type ; $query = $this->db->query($sql); - $lab_invoice_request = $query->result(); - - $sql = "select * from invoice_item where id=" . $data_lab_request[0]->charge_item_id;; - $query = $this->db->query($sql); - $invoice_item = $query->result(); - - - - - - if (count($data_report_format) > 0) { - - $Report_Head_H3 = '

' . $data_report_format[0]->Title . '

'; - $Report_string = $data_report_format[0]->HTMLData; - } else { - - $Report_Head_H3 = '

' . $data_lab_request[0]->report_name . '

'; - $Report_string = ""; + $lab_invoice_request= $query->result(); + + if(count($data_report_format)>0) + { + + $Report_Head_H3='

'.$data_report_format[0]->Title.'

'; + $Report_string=$data_report_format[0]->HTMLData; + + }else{ + + $Report_Head_H3='

'.$data_lab_request[0]->report_name.'

'; + $Report_string=""; } - - $Report_Header = ' + + $Report_Header='
- +
' . $Report_Head_H3 . ''.$Report_Head_H3.'
'; - - $Report_Footer = $data_lab_request[0]->Remark; + + $Report_Footer=$data_lab_request[0]->Remark; //update report_string with test parameter + + $complete_report=$Report_Header.$Report_string.$Report_Footer; + + $udata = array( + 'Report_Data'=> $complete_report, + 'status'=>1, + 'reported_time'=> date('Y-m-d H:i:s') + ); - $complete_report = $Report_Header . $Report_string . $Report_Footer; - - $udata = array( - 'Report_Data' => $complete_report, - 'status' => 1, - 'reported_time' => date('Y-m-d H:i:s') - ); - - $this->PathLab_M->update_test_request($udata, $req_id); - - $udata = array( - 'reported_time' => date('Y-m-d H:i:s') - ); - $this->PathLab_M->update_invoice_report($udata, $lab_invoice_request[0]->id); - - $sql = "select * from lab_request where id=" . $req_id; + $this->PathLab_M->update_test_request($udata,$req_id); + + $udata = array( + 'reported_time'=> date('Y-m-d H:i:s') + ); + $this->PathLab_M->update_invoice_report($udata,$lab_invoice_request[0]->id); + + $sql="select * from lab_request where id=".$req_id; $query = $this->db->query($sql); - $data['report_format'] = $query->result(); + $data['report_format']= $query->result(); - $sql = "select * from radiology_ultrasound_template where charge_id=" . $invoice_item[0]->item_id; - $sql = "select * from radiology_ultrasound_template order by Template_Name"; + $sql="select * from radiology_ultrasound_template "; $query = $this->db->query($sql); - $data['radiology_ultrasound_template'] = $query->result(); + $data['radiology_ultrasound_template']= $query->result(); - $this->load->view('PathLab_Report/lab_final_report_show_xray', $data); + $this->load->view('PathLab_Report/lab_final_report_show_xray',$data); //redirect('Lab_Admin/show_report_final/'.$req_id); - } + } public function show_report_final($req_id) { - $sql = "select * from lab_request where id=" . $req_id; + $sql="select * from lab_request where id=".$req_id; $query = $this->db->query($sql); - $data['report_format'] = $query->result(); + $data['report_format']= $query->result(); - $sql = "select * from invoice_item where id=" . $data['report_format'][0]->charge_item_id; + $sql="select * from radiology_ultrasound_template "; $query = $this->db->query($sql); - $data['invoice_item'] = $query->result(); + $data['radiology_ultrasound_template']= $query->result(); - $sql = "select * from radiology_ultrasound_template where charge_id=" . $data['invoice_item'][0]->item_id; - $sql = "select * from radiology_ultrasound_template order by Template_Name"; - $query = $this->db->query($sql); - $data['radiology_ultrasound_template'] = $query->result(); - - $this->load->view('PathLab_Report/lab_final_report_show_xray', $data); + $this->load->view('PathLab_Report/lab_final_report_show_xray',$data); } public function get_template_xray($req_id) { - $sql = "select * from radiology_ultrasound_template where id=$req_id"; + $sql="select * from radiology_ultrasound_template where id=$req_id"; $query = $this->db->query($sql); - $radiology_ultrasound_template = $query->result(); + $radiology_ultrasound_template= $query->result(); - $Findings = ""; - $Impression = ""; + $Findings=""; + $Impression=""; - if (count($radiology_ultrasound_template) > 0) { - $Findings = $radiology_ultrasound_template[0]->Findings; - $Impression = $radiology_ultrasound_template[0]->Impression; + if(count($radiology_ultrasound_template)>0){ + $Findings=$radiology_ultrasound_template[0]->Findings; + $Impression=$radiology_ultrasound_template[0]->Impression; } - $rvar = array( + $rvar=array( 'Findings' => $Findings, 'Impression' => $Impression, ); - + $encode_data = json_encode($rvar); echo $encode_data; + } - + public function Final_Update_xray($req_id) { $this->load->model('PathLab_M'); + + $udata = array( + 'Report_Data'=> $this->input->post('HTMLData'), + 'report_data_Impression'=> $this->input->post('report_data_Impression') + ); - $udata = array( - 'Report_Data' => $this->input->post('HTMLData'), - 'report_data_Impression' => $this->input->post('report_data_Impression') - ); - - $this->PathLab_M->update_test_request($udata, $req_id); - + $this->PathLab_M->update_test_request($udata,$req_id); + echo "Saved"; + } public function confirm_report_xray($req_id) { $this->load->model('PathLab_M'); - + $user = $this->ion_auth->user()->row(); $user_id = $user->id; - $user_name = $user->first_name . '' . $user->last_name; - - $udata = array( - 'confirm_by' => $user_name, - 'status' => 2 - ); - - $this->PathLab_M->update_test_request($udata, $req_id); + $user_name = $user->first_name.''. $user->last_name; + + $udata = array( + 'confirm_by'=> $user_name, + 'status'=>2 + ); + $this->PathLab_M->update_test_request($udata,$req_id); + echo "Verified and Ready for Print"; + } + - - - public function select_lab_invoice_path($inv_id, $lab_type) + + public function select_lab_invoice_path($inv_id,$lab_type) { - $sql = "select * from invoice_master where id=" . $inv_id; + $sql="select * from invoice_master where id=".$inv_id; $query = $this->db->query($sql); - $data['inv_master'] = $query->result(); - - $pno = $data['inv_master'][0]->attach_id; - - $sql = "select *,GET_AGE_1(dob,age,age_in_month,estimate_dob) as str_age, + $data['inv_master']= $query->result(); + + $pno=$data['inv_master'][0]->attach_id; + + $sql="select *,GET_AGE_1(dob,age,age_in_month,estimate_dob) as str_age, Date_Format(insert_date,'%Y-%m-%d') as str_regdate, if(gender=1,'Male','Female') as xgender ,if(date_add(insert_date,interval 12 hour)>sysdate(),1,0) as p_edit - from patient_master where id=" . $pno; + from patient_master where id=".$pno; $query = $this->db->query($sql); - $data['data'] = $query->result(); - - $sql = "select * from lab_invoice_request - where invoice_id='" . $inv_id . "' and lab_type='" . $lab_type . "'"; + $data['data']= $query->result(); + + $sql="select * from lab_invoice_request + where invoice_id='".$inv_id."' and lab_type='".$lab_type."'"; $query = $this->db->query($sql); - $data['lab_invoice_request'] = $query->result(); - - $data['inv_id'] = $inv_id; - $data['lab_type'] = $lab_type; - $data['inv_code'] = $data['inv_master'][0]->invoice_code;; - - $this->load->view('Lab_Panel/lab_invoice_main', $data); + $data['lab_invoice_request']= $query->result(); + + $data['inv_id']=$inv_id; + $data['lab_type']=$lab_type; + $data['inv_code']=$data['inv_master'][0]->invoice_code;; + + $this->load->view('Lab_Panel/lab_invoice_main',$data); } //Other then XRay - public function select_lab_invoice($inv_id, $lab_type) + public function select_lab_invoice($inv_id,$lab_type) { - $sql = "select * from invoice_master where id=" . $inv_id; + $sql="select * from invoice_master where id=".$inv_id; $query = $this->db->query($sql); - $data['inv_master'] = $query->result(); - - $pno = $data['inv_master'][0]->attach_id; - - $sql = "select *,GET_AGE_1(dob,age,age_in_month,estimate_dob) as str_age, + $data['inv_master']= $query->result(); + + $pno=$data['inv_master'][0]->attach_id; + + $sql="select *,GET_AGE_1(dob,age,age_in_month,estimate_dob) as str_age, Date_Format(insert_date,'%Y-%m-%d') as str_regdate, if(gender=1,'Male','Female') as xgender ,if(date_add(insert_date,interval 12 hour)>sysdate(),1,0) as p_edit - from patient_master where id=" . $pno; + from patient_master where id=".$pno; $query = $this->db->query($sql); - $data['data'] = $query->result(); - - $sql = "select * from lab_invoice_request - where invoice_id='" . $inv_id . "' and lab_type='" . $lab_type . "'"; + $data['data']= $query->result(); + + $sql="select * from lab_invoice_request + where invoice_id='".$inv_id."' and lab_type='".$lab_type."'"; $query = $this->db->query($sql); - $data['lab_invoice_request'] = $query->result(); - - $data['inv_id'] = $inv_id; - $data['lab_type'] = $lab_type; - $data['inv_code'] = $data['inv_master'][0]->invoice_code;; - - $this->load->view('Lab_Panel/lab_invoice_xray', $data); + $data['lab_invoice_request']= $query->result(); + + $data['inv_id']=$inv_id; + $data['lab_type']=$lab_type; + $data['inv_code']=$data['inv_master'][0]->invoice_code;; + + $this->load->view('Lab_Panel/lab_invoice_xray',$data); } - - public function lab_date_show($inv_id, $lab_type) + + public function lab_date_show($inv_id,$lab_type) { - $sql = "select * from lab_invoice_request where invoice_id='" . $inv_id . "' and lab_type='" . $lab_type . "'"; + $sql="select * from lab_invoice_request where invoice_id='".$inv_id."' and lab_type='".$lab_type."'"; $query = $this->db->query($sql); - $data['lab_invoice_request'] = $query->result(); - - $this->load->view('Lab_Panel/lab_date_show', $data); + $data['lab_invoice_request']= $query->result(); + + $this->load->view('Lab_Panel/lab_date_show',$data); } - - public function test_list($inv_id, $lab_type) + + public function test_list($inv_id,$lab_type) { - $sql = "select m.id as inv_id,m.invoice_code,m.inv_date,Concat(p_fname,'/',if(gender=1,'M','F'),'/',p_rname) as inv_name, + $sql="select m.id as inv_id,m.invoice_code,m.inv_date,Concat(p_fname,'/',if(gender=1,'M','F'),'/',p_rname) as inv_name, t.item_name,t.item_name,t.id as test_id,check_item_request(m.id,t.id) as check_sample, r.lab_repo_id,y.group_desc as item_type_desc,r.`status`, r.id as req_id,r.charge_item_id,r.print_combine @@ -489,22 +490,22 @@ class Lab_Report extends MY_Controller on m.id=t.inv_master_id and t.item_type=y.itype_id and p.id=m.attach_id) left join lab_request r on t.id=r.charge_item_id) left join lab_repo l on t.item_id=l.charge_id - where y.itype_id=" . $lab_type . " and m.id=" . $inv_id . " + where y.itype_id=".$lab_type." and m.id=".$inv_id." order by t.item_name"; $query = $this->db->query($sql); - $data['testlist'] = $query->result(); + $data['testlist']= $query->result(); - $sql = "select * from lab_invoice_request where invoice_id='" . $inv_id . "' and lab_type='" . $lab_type . "'"; + $sql="select * from lab_invoice_request where invoice_id='".$inv_id."' and lab_type='".$lab_type."'"; $query = $this->db->query($sql); - $data['lab_invoice_request'] = $query->result(); - - $this->load->view('Lab_Panel/lab_invoice_main_test_list', $data); + $data['lab_invoice_request']= $query->result(); + + $this->load->view('Lab_Panel/lab_invoice_main_test_list',$data); } // Report Test List - public function xray_test_list($inv_id, $lab_type) + public function xray_test_list($inv_id,$lab_type) { - $sql = "select m.id as inv_id,m.invoice_code,m.inv_date,Concat(p_fname,'/',if(gender=1,'M','F'),'/',p_rname) as inv_name, + $sql="select m.id as inv_id,m.invoice_code,m.inv_date,Concat(p_fname,'/',if(gender=1,'M','F'),'/',p_rname) as inv_name, t.item_name,t.item_name,t.id as test_id,check_item_request(m.id,t.id) as check_sample, r.lab_repo_id,y.group_desc as item_type_desc,r.`status`, r.id as req_id,r.charge_item_id,r.print_combine @@ -512,53 +513,55 @@ class Lab_Report extends MY_Controller on m.id=t.inv_master_id and t.item_type=y.itype_id and p.id=m.attach_id) left join lab_request r on t.id=r.charge_item_id) left join lab_repo l on t.item_id=l.charge_id - where y.itype_id=" . $lab_type . " and m.id=" . $inv_id . " + where y.itype_id=".$lab_type." and m.id=".$inv_id." order by t.item_name"; $query = $this->db->query($sql); - $data['testlist'] = $query->result(); + $data['testlist']= $query->result(); - $sql = "select * from lab_invoice_request where invoice_id='" . $inv_id . "' and lab_type='" . $lab_type . "'"; + $sql="select * from lab_invoice_request where invoice_id='".$inv_id."' and lab_type='".$lab_type."'"; $query = $this->db->query($sql); - $data['lab_invoice_request'] = $query->result(); - - $this->load->view('Lab_Panel/lab_invoice_main_xray_test_list', $data); + $data['lab_invoice_request']= $query->result(); + + $this->load->view('Lab_Panel/lab_invoice_main_xray_test_list',$data); } - - public function report_file_list($inv_id, $lab_type, $delete = 0) + + public function report_file_list($inv_id,$lab_type,$delete=0) { - $sql = "select * from file_upload_data where isdelete=" . $delete . " and charge_id='" . $inv_id . "' and charge_type='" . $lab_type . "'"; + $sql="select * from file_upload_data where isdelete=".$delete." and charge_id='".$inv_id."' and charge_type='".$lab_type."'"; $query = $this->db->query($sql); - $data['lab_file_list'] = $query->result(); - - $this->load->view('Lab_Panel/lab_report_file_list', $data); + $data['lab_file_list']= $query->result(); + + $this->load->view('Lab_Panel/lab_report_file_list',$data); } // Other Then Pathology like Xray , MRI , Ultra sound - public function select_lab_radiology($inv_id, $lab_type) + public function select_lab_radiology($inv_id,$lab_type) { - $sql = "select * from invoice_master where id=" . $inv_id; + $sql="select * from invoice_master where id=".$inv_id; $query = $this->db->query($sql); - $data['inv_master'] = $query->result(); - - $pno = $data['inv_master'][0]->attach_id; - - $sql = "select *,GET_AGE_1(dob,age,age_in_month,estimate_dob) as str_age, + $data['inv_master']= $query->result(); + + $pno=$data['inv_master'][0]->attach_id; + + $sql="select *,GET_AGE_1(dob,age,age_in_month,estimate_dob) as str_age, Date_Format(insert_date,'%Y-%m-%d') as str_regdate, if(gender=1,'Male','Female') as xgender ,if(date_add(insert_date,interval 12 hour)>sysdate(),1,0) as p_edit - from patient_master where id=" . $pno; + from patient_master where id=".$pno; $query = $this->db->query($sql); - $data['data'] = $query->result(); - - $sql = "select * from lab_invoice_request - where invoice_id='" . $inv_id . "' and lab_type='" . $lab_type . "'"; + $data['data']= $query->result(); + + $sql="select * from lab_invoice_request + where invoice_id='".$inv_id."' and lab_type='".$lab_type."'"; $query = $this->db->query($sql); - $data['lab_invoice_request'] = $query->result(); - - $data['inv_id'] = $inv_id; - $data['lab_type'] = $lab_type; - $data['inv_code'] = $data['inv_master'][0]->invoice_code;; - - $this->load->view('Lab_Panel/lab_invoice_XRay', $data); + $data['lab_invoice_request']= $query->result(); + + $data['inv_id']=$inv_id; + $data['lab_type']=$lab_type; + $data['inv_code']=$data['inv_master'][0]->invoice_code;; + + $this->load->view('Lab_Panel/lab_invoice_XRay',$data); } -} + + +} \ No newline at end of file diff --git a/old_code_ci3/controllers/Medical.php b/old_code_ci3/controllers/Medical.php index dbd9066..46930b8 100644 --- a/old_code_ci3/controllers/Medical.php +++ b/old_code_ci3/controllers/Medical.php @@ -1,36 +1,35 @@ load->view('Medical/Dashboard'); } - + public function select_store($store_id) - { - $sql = "select * from store_master where store_id=" . $store_id; + { + $sql="select * from store_master where store_id=".$store_id; $query = $this->db->query($sql); - $data['store_master'] = $query->result(); + $data['store_master']= $query->result(); - $this->load->view('Medical/Store_Dashboard', $data); + $this->load->view('Medical/Store_Dashboard',$data); } public function main_store() - { + { $this->load->view('Medical/Stock/main_store_dashboard'); } - + public function DrugList() - { + { $this->load->view('Medical/Drug_Details'); //$sql="select item_id,itemname,dosage from drug_temp_25072017"; @@ -41,198 +40,102 @@ class Medical extends MY_Controller } public function Purchase() - { + { $this->load->view('Medical/Purchase/supplier_list'); } - + public function PurchaseMasterEdit($inv_id) { - $sql = "select * from med_supplier order by name_supplier"; + $sql="select * from med_supplier order by name_supplier"; $query = $this->db->query($sql); - $data['supplier_data'] = $query->result(); - - $sql = "select p.*,s.name_supplier from purchase_invoice p join med_supplier s on p.sid=s.sid where p.id=" . $inv_id; + $data['supplier_data']= $query->result(); + + $sql="select p.*,s.name_supplier from purchase_invoice p join med_supplier s on p.sid=s.sid where p.id=".$inv_id; $query = $this->db->query($sql); - $data['inv_master_data'] = $query->result(); + $data['inv_master_data']= $query->result(); - $sql = "select * from purchase_invoice_item where purchase_id='" . $inv_id . "' "; - $query = $this->db->query($sql); - $data['purchase_item'] = $query->result(); + $sql="select * from purchase_invoice_item where purchase_id='".$inv_id."' "; + $query = $this->db->query($sql); + $data['purchase_item']= $query->result(); + + $this->load->view('Medical/Purchase/purchase_invoice_master_edit',$data); - $this->load->view('Medical/Purchase/purchase_invoice_master_edit', $data); } - + public function UpdatePurchase() { - $rec_id = $this->input->post('hid_purchaseid'); - $sid = $this->input->post('input_supplier'); - $invoice_code = $this->input->post('input_invoicecode'); - $d_invoice = $this->input->post('datepicker_invoice'); - $ischallan = $this->input->post('cbo_billtype'); - - $Udata = array( - 'sid' => $sid, - 'date_of_invoice' => str_to_MysqlDate($d_invoice), - 'Invoice_no' => $invoice_code, - 'ischallan' => $ischallan - ); - - $this->load->model('Medical_M'); - - $update_id = $this->Medical_M->update_purchase($Udata, $rec_id); - - $rvar = array( - 'insertid' => 1, - 'show_text' => 'Data Update' - ); - - $encode_data = json_encode($rvar); - echo $encode_data; - } - - public function UpdatePurchaseInvoiceStatus($purchase_inv_id, $inv_status) - { - $user = $this->ion_auth->user()->row(); - $user_id = $user->id; - $user_name_info = $user->first_name . '' . $user->last_name . '[' . $user_id . ']' . date('d-m-Y H:i:s'); - - $Udata = array( - 'inv_status' => $inv_status, - 'inv_status_update_by' => $user_name_info, - ); - - $this->load->model('Medical_M'); - - $update_id = $this->Medical_M->update_purchase($Udata, $purchase_inv_id); - - redirect('Medical/PurchaseMasterEdit/' . $purchase_inv_id); - } - - public function purchase_scan_doc($purchase_inv_id) - { - $data['purchase_inv_id'] = $purchase_inv_id; - - $sql = "select * from purchase_invoice where id='" . $purchase_inv_id . "' "; - $query = $this->db->query($sql); - $data['purchase_invoice'] = $query->result(); - - $sql = "select * from purchase_invoice_scan_file where purchase_id='" . $purchase_inv_id . "' "; - $query = $this->db->query($sql); - $data['purchase_invoice_scan_file'] = $query->result(); - - $this->load->view('Medical/Purchase/purchase_invoice_scan', $data); - } - - public function purchase_file_list($inv_id) - { - $sql = "select * from purchase_invoice_scan_file where purchase_id=$inv_id"; - $query = $this->db->query($sql); - $data['purchase_file_rec'] = $query->result(); - - $this->load->view('Medical/Purchase/purchase_file_show', $data); - } - - public function save_image($purchase_id) - { - $filename = 'purchase-' . $purchase_id . '-' . time() . '.jpg'; - - $folder_name = 'medical_uploads/purchase_invoice/' . date('Ymd'); - - if (!file_exists($folder_name)) { - mkdir($folder_name, 0777, true); - } - - $user = $this->ion_auth->user()->row(); - $user_id = $user->id; - $user_name = $user->first_name . '' . $user->last_name; - - //echo $folder_name; - - $config['upload_path'] = $folder_name; - $config['allowed_types'] = 'gif|jpg|png|jpeg'; - - //$new_name = time().$_FILES["webcam"]['name']; - $config['file_name'] = $filename; - - $this->load->library('upload', $config); - - if (!$this->upload->do_upload('webcam')) { - $error = array('error' => $this->upload->display_errors()); - echo $error['error']; - } else { - $data = array('upload_data' => $this->upload->data()); - - $this->load->model('FileMedical_M'); - - $file_insert_id = $this->FileMedical_M->insert_purchase_scan($data['upload_data']); - - $udata = array( - 'upload_by' => $user_name, - 'purchase_id' => $purchase_id, - 'upload_by_id' => $user_id - ); - - if ($file_insert_id > 0) { - $this->FileMedical_M->update_purchase_scan($udata, $file_insert_id); - } - - echo $filename; - } - } - - public function purchase_file_last_list($purchase_id = '') - { + $rec_id=$this->input->post('hid_purchaseid'); + $sid=$this->input->post('input_supplier'); + $invoice_code=$this->input->post('input_invoicecode'); + $d_invoice=$this->input->post('datepicker_invoice'); + $ischallan=$this->input->post('cbo_billtype'); - $sql = "select * from purchase_invoice_scan_file where purchase_id=$purchase_id order by id desc limit 5"; - $query = $this->db->query($sql); - $data['purchase_invoice_scan_file'] = $query->result(); - - $this->load->view('Medical/Purchase/scan_purchase_list', $data); + $Udata = array( + 'sid'=> $sid, + 'date_of_invoice'=> str_to_MysqlDate($d_invoice), + 'Invoice_no'=> $invoice_code, + 'ischallan'=>$ischallan + ); + + $this->load->model('Medical_M'); + + $update_id=$this->Medical_M->update_purchase($Udata,$rec_id); + + $rvar=array( + 'insertid' =>1, + 'show_text'=>'Data Update' + ); + + $encode_data = json_encode($rvar); + echo $encode_data; } - public function purchase_file_hide($file_id, $purchase_id = '') + public function UpdatePurchaseInvoiceStatus($purchase_inv_id,$inv_status) { $user = $this->ion_auth->user()->row(); - $upload_by_id = $user->id; - - $udata = array( - 'show_type' => '1', - 'upload_by_id' => $upload_by_id - ); - $this->load->model('FileMedical_M'); - - $this->FileMedical_M->delete_purchase_scan_fileupload( $file_id); - - redirect('/Medical/purchase_file_last_list/' . $purchase_id); + $user_id = $user->id; + $user_name_info = $user->first_name.''. $user->last_name .'['.$user_id.']'.date('d-m-Y H:i:s'); + + $Udata = array( + 'inv_status'=> $inv_status, + 'inv_status_update_by'=> $user_name_info, + ); + + $this->load->model('Medical_M'); + + $update_id=$this->Medical_M->update_purchase($Udata,$purchase_inv_id); + + redirect('Medical/PurchaseMasterEdit/'.$purchase_inv_id); + } - public function PurchaseNew() - { - $sql = "select * from med_supplier where active=1 order by name_supplier"; + { + $sql="select * from med_supplier where active=1 order by name_supplier"; $query = $this->db->query($sql); - $data['supplier_data'] = $query->result(); - - $this->load->view('Medical/Purchase/new_purchase_invoice', $data); + $data['supplier_data']= $query->result(); + + $this->load->view('Medical/Purchase/new_purchase_invoice',$data); } - + public function SupplierList() - { - $sql = "select * from med_supplier"; + { + $sql="select * from med_supplier"; $query = $this->db->query($sql); - $data['supplier_data'] = $query->result(); + $data['supplier_data']= $query->result(); - $this->load->view('Medical/Purchase/supplier_master', $data); + $this->load->view('Medical/Purchase/supplier_master',$data); } - + public function PurchaseInvoice() { - $sdata = trim($this->input->post('txtsearch')); - + $sdata=trim($this->input->post('txtsearch')); + //$sdata = preg_replace('/[^A-Za-z0-9_ \-]/', '', $sdata); - - if (trim($sdata) == '') { - $sql = "select p.id,p.Invoice_no,p.date_of_invoice, + + if(trim($sdata)=='') + { + $sql="select p.id,p.Invoice_no,p.date_of_invoice, date_format(p.date_of_invoice,'%d-%m-%Y') as str_date_of_invoice,p.sid,s.name_supplier, s.short_name,s.gst_no, p.T_Net_Amount as tamount,p.ischallan @@ -240,52 +143,53 @@ class Medical extends MY_Controller group by p.id order by p.id desc limit 50"; - } else { + }else{ - $numric_condition = ""; + $numric_condition=""; - if (is_numeric($sdata)) { - $numric_condition = " OR p.Invoice_no=" . $sdata; + if(is_numeric($sdata)) + { + $numric_condition=" OR p.Invoice_no=".$sdata ; } - $sql = "select p.id,p.Invoice_no,p.date_of_invoice, + $sql="select p.id,p.Invoice_no,p.date_of_invoice, date_format(p.date_of_invoice,'%d-%m-%Y') as str_date_of_invoice, p.sid,s.name_supplier,s.short_name,s.gst_no, p.T_Net_Amount as tamount,p.ischallan from (purchase_invoice p join med_supplier s on p.sid=s.sid) - where (p.Invoice_no LIKE '%" . $sdata . "%' " . $numric_condition . " ) + where (p.Invoice_no LIKE '%".$sdata."%' ".$numric_condition." ) group by p.id order by p.id desc limit 50"; } $query = $this->db->query($sql); - $data['purchase_list'] = $query->result(); - - $this->load->view('Medical/Purchase/purchase_supp_list', $data); + $data['purchase_list']= $query->result(); + + $this->load->view('Medical/Purchase/purchase_supp_list',$data); } - + public function PurchaseInvoiceEdit($inv_id) { - $sql = "select p.id,p.Invoice_no,p.date_of_invoice,date_format(p.date_of_invoice,'%d/%m/%Y') as str_date_of_invoice, + $sql="select p.id,p.Invoice_no,p.date_of_invoice,date_format(p.date_of_invoice,'%d/%m/%Y') as str_date_of_invoice, p.sid,s.name_supplier,s.short_name,s.gst_no,p.inv_status,p.ischallan from purchase_invoice p join med_supplier s on p.sid=s.sid - where p.id=" . $inv_id; + where p.id=".$inv_id; $query = $this->db->query($sql); - $data['purchase_invoice'] = $query->result(); + $data['purchase_invoice']= $query->result(); - $sql = "select * from purchase_invoice_item where purchase_id=" . $inv_id; + $sql="select * from purchase_invoice_item where purchase_id=".$inv_id; $query = $this->db->query($sql); - $data['purchase_invoice_item'] = $query->result(); + $data['purchase_invoice_item']= $query->result(); - $sql = "select * from med_gst_per "; - $query = $this->db->query($sql); - $data['med_gst_per'] = $query->result(); + $sql="select * from med_gst_per "; + $query = $this->db->query($sql); + $data['med_gst_per']= $query->result(); - $this->load->view('Medical/Purchase/purchase_invoice_edit', $data); + $this->load->view('Medical/Purchase/purchase_invoice_edit',$data); } public function challan_invoice($supplier_id) { - $sql = "SELECT p.id,t.id AS ss_no,p.Invoice_no,p.date_of_invoice, + $sql="SELECT p.id,t.id AS ss_no,p.Invoice_no,p.date_of_invoice, date_format(p.date_of_invoice,'%d-%m-%Y') as str_date_of_invoice,p.sid,s.name_supplier, s.short_name,s.gst_no, p.T_Net_Amount as tamount,p.ischallan, @@ -296,873 +200,909 @@ class Medical extends MY_Controller group by p.id,t.id "; $query = $this->db->query($sql); - $data['purchase_challan_item'] = $query->result(); - - $this->load->view('Medical/Purchase/purchase_challan_list', $data); + $data['purchase_challan_item']= $query->result(); + + $this->load->view('Medical/Purchase/purchase_challan_list',$data); } - public function challan_item_to_purchase($ss_no, $purchase_id) + public function challan_item_to_purchase($ss_no,$purchase_id) { - $sql = "select * from purchase_invoice_item where id=$ss_no"; + $sql="select * from purchase_invoice_item where id=$ss_no"; $query = $this->db->query($sql); - $purchase_invoice_item = $query->result(); + $purchase_invoice_item= $query->result(); - if (count($purchase_invoice_item) > 0) { - $old_purchase_id = $purchase_invoice_item[0]->purchase_id; + if(count($purchase_invoice_item)>0) + { + $old_purchase_id=$purchase_invoice_item[0]->purchase_id; $Pdata = array( 'purchase_id' => $purchase_id, 'old_purchase_id' => $old_purchase_id, - ); - + ); + $this->load->model('Medical_M'); - $is_update_stock = $this->Medical_M->update_purchase_item($Pdata, $ss_no); - $this->db->query("CALL p_purchase_invoice(" . $old_purchase_id . ")"); + $is_update_stock=$this->Medical_M->update_purchase_item($Pdata,$ss_no); + $this->db->query("CALL p_purchase_invoice(".$old_purchase_id.")"); - $rvar = array( - 'is_transfer' => $is_update_stock, - 'show_text' => "Item Addedd Successfully", + $rvar=array( + 'is_transfer' =>$is_update_stock, + 'show_text'=>"Item Addedd Successfully", ); - } else { - $rvar = array( - 'is_transfer' => 0, - 'show_text' => "Item Not Found ", + + }else{ + $rvar=array( + 'is_transfer' =>0, + 'show_text'=>"Item Not Found ", ); } $encode_data = json_encode($rvar); echo $encode_data; + } public function challan_item_return($ss_no) { - $sql = "select * from purchase_invoice_item where old_purchase_id>0 and id=$ss_no"; + $sql="select * from purchase_invoice_item where old_purchase_id>0 and id=$ss_no"; $query = $this->db->query($sql); - $purchase_invoice_item = $query->result(); + $purchase_invoice_item= $query->result(); - if (count($purchase_invoice_item) > 0) { - $old_challan_id = $purchase_invoice_item[0]->old_purchase_id; - $current_pur_id = $purchase_invoice_item[0]->purchase_id; + if(count($purchase_invoice_item)>0) + { + $old_challan_id=$purchase_invoice_item[0]->old_purchase_id; + $current_pur_id=$purchase_invoice_item[0]->purchase_id; - $sql = "select * from purchase_invoice where id=$old_challan_id"; + $sql="select * from purchase_invoice where id=$old_challan_id"; $query = $this->db->query($sql); - $challan_invoice = $query->result(); + $challan_invoice= $query->result(); - if (count($challan_invoice) > 0) { + if(count($challan_invoice)>0) + { $Pdata = array( 'purchase_id' => $old_challan_id, 'old_purchase_id' => 0, - ); - + ); + $this->load->model('Medical_M'); - $is_update_stock = $this->Medical_M->update_purchase_item($Pdata, $ss_no); - $this->db->query("CALL p_purchase_invoice(" . $current_pur_id . ")"); + $is_update_stock=$this->Medical_M->update_purchase_item($Pdata,$ss_no); + $this->db->query("CALL p_purchase_invoice(".$current_pur_id.")"); - $rvar = array( - 'is_transfer' => $is_update_stock, - 'show_text' => "Item Addedd Successfully", + $rvar=array( + 'is_transfer' =>$is_update_stock, + 'show_text'=>"Item Addedd Successfully", ); - } else { + }else{ $Pdata = array( 'purchase_id' => $old_challan_id, 'old_purchase_id' => 0, - ); - + ); + $this->load->model('Medical_M'); - $is_update_stock = $this->Medical_M->update_purchase_item($Pdata, $ss_no); + $is_update_stock=$this->Medical_M->update_purchase_item($Pdata,$ss_no); + - - $rvar = array( - 'is_transfer' => 0, - 'show_text' => "Challan Not Found ", + $rvar=array( + 'is_transfer' =>0, + 'show_text'=>"Challan Not Found ", ); } - } else { - $rvar = array( - 'is_transfer' => 0, - 'show_text' => "Item Not Found ", + + + }else{ + $rvar=array( + 'is_transfer' =>0, + 'show_text'=>"Item Not Found ", ); } $encode_data = json_encode($rvar); echo $encode_data; + } public function purchase_invoice_delete($inv_id) { - - $sql = "select * from purchase_invoice_item where purchase_id=$inv_id"; + + $sql="select * from purchase_invoice_item where purchase_id=$inv_id"; $query = $this->db->query($sql); - $purchase_invoice_item = $query->result(); + $purchase_invoice_item= $query->result(); - if (count($purchase_invoice_item) > 0) { - $rvar = array( - 'is_delete' => 0, - 'show_text' => "Invoice has Items, Empty the item list", + if (count($purchase_invoice_item)>0){ + $rvar=array( + 'is_delete' =>0, + 'show_text'=>"Invoice has Items, Empty the item list", ); - } else { + }else{ $this->load->model('Medical_M'); - $is_delete = $this->Medical_M->delete_purchase($inv_id); - $rvar = array( - 'is_delete' => 1, - 'show_text' => "Invoice has been deleted", + $is_delete=$this->Medical_M->delete_purchase($inv_id); + $rvar=array( + 'is_delete' =>1, + 'show_text'=>"Invoice has been deleted", ); } - + $encode_data = json_encode($rvar); echo $encode_data; - } + } + public function SupplierListSub() - { - $sql = "select * from med_supplier order by name_supplier"; + { + $sql="select * from med_supplier order by name_supplier"; $query = $this->db->query($sql); - $data['supplier_data'] = $query->result(); + $data['supplier_data']= $query->result(); - $this->load->view('Medical/Purchase/supplier_master_sub', $data); + $this->load->view('Medical/Purchase/supplier_master_sub',$data); } - - public function SupplierEdit($sid = 0) - { - $sql = "select * from med_supplier where sid=" . $sid; + + public function SupplierEdit($sid=0) + { + $sql="select * from med_supplier where sid=".$sid; $query = $this->db->query($sql); - $data['supplier_data'] = $query->result(); + $data['supplier_data']= $query->result(); - $sql = "select * from india_state "; + $sql="select * from india_state "; $query = $this->db->query($sql); - $data['india_state'] = $query->result(); + $data['india_state']= $query->result(); - $this->load->view('Medical/Purchase/supplier_Edit', $data); + $this->load->view('Medical/Purchase/supplier_Edit',$data); } - + public function CreatePurchase() - { - if (!$this->input->is_ajax_request()) { - exit('no valid req.'); - } + { + if (!$this->input->is_ajax_request()) { exit('no valid req.'); } + + $FormRules = array( + array( + 'field' => 'input_invoicecode', + 'label' => 'Invoice No', + 'rules' => 'required|min_length[3]|max_length[30]' + ) + ); - $FormRules = array( - array( - 'field' => 'input_invoicecode', - 'label' => 'Invoice No', - 'rules' => 'required|min_length[3]|max_length[30]' - ) - ); + $this->form_validation->set_rules($FormRules); + + if ($this->form_validation->run() == TRUE) + { + $sid=$this->input->post('input_supplier'); + $invoice_code=$this->input->post('input_invoicecode'); + $d_invoice=$this->input->post('datepicker_invoice'); + $ischallan=$this->input->post('cbo_billtype'); - $this->form_validation->set_rules($FormRules); + $where=" where sid=$sid"; - if ($this->form_validation->run() == TRUE) { - $sid = $this->input->post('input_supplier'); - $invoice_code = $this->input->post('input_invoicecode'); - $d_invoice = $this->input->post('datepicker_invoice'); - $ischallan = $this->input->post('cbo_billtype'); - - $where = " where sid=$sid"; - - if (is_numeric($invoice_code)) - $where .= " and Invoice_no=" . $invoice_code; + if(is_numeric($invoice_code)) + $where.=" and Invoice_no=".$invoice_code ; else - $where .= " and Invoice_no='" . $invoice_code . "'"; + $where.=" and Invoice_no='".$invoice_code."'"; - $sql = "select count(*) as no_rec from purchase_invoice " . $where; + $sql="select count(*) as no_rec from purchase_invoice ".$where; $query = $this->db->query($sql); - $chk_rec = $query->result(); + $chk_rec= $query->result(); - if ($chk_rec[0]->no_rec == 0) { - $Udata = array( - 'sid' => $sid, - 'date_of_invoice' => str_to_MysqlDate($d_invoice), - 'Invoice_no' => $invoice_code, - 'ischallan' => $ischallan + if($chk_rec[0]->no_rec==0) + { + $Udata = array( + 'sid'=> $sid, + 'date_of_invoice'=> str_to_MysqlDate($d_invoice), + 'Invoice_no'=> $invoice_code, + 'ischallan'=>$ischallan ); - + $this->load->model('Medical_M'); + + $inser_id=$this->Medical_M->insert_purchase($Udata); + $send_msg="Added Successfully"; - $inser_id = $this->Medical_M->insert_purchase($Udata); - $send_msg = "Added Successfully"; - - if ($inser_id > 0) { - $show_text = $send_msg; - } else { - $show_text = $send_msg; + if($inser_id>0) + { + $show_text=$send_msg; + }else{ + $show_text=$send_msg; } - } else { - $show_text = 'Record Already Exist'; - $inser_id = 0; + }else{ + $show_text='Record Already Exist'; + $inser_id=0; } - - $rvar = array( - 'insertid' => $inser_id, - 'show_text' => $show_text - ); - + + $rvar=array( + 'insertid' =>$inser_id, + 'show_text'=>$show_text + ); + $encode_data = json_encode($rvar); echo $encode_data; - } else { - $send_msg = validation_errors(); - $rvar = array( - 'insertid' => 0, - 'show_text' => $send_msg + + } + else{ + $send_msg=validation_errors(); + $rvar=array( + 'insertid' =>0, + 'show_text'=>$send_msg ); $encode_data = json_encode($rvar); echo $encode_data; } } + + + public function SupplierUpdate($sid=0) + { + if (!$this->input->is_ajax_request()) { exit('no valid req.'); } + + $FormRules = array( + array( + 'field' => 'input_name_supplier', + 'label' => 'Supplier Name', + 'rules' => 'required|min_length[3]|max_length[100]' + ), + array( + 'field' => 'input_short_name', + 'label' => 'Short Name', + 'rules' => 'required|min_length[1]|max_length[30]' + ), + array( + 'field' => 'input_gst_no', + 'label' => 'GST No.', + 'rules' => 'required|min_length[5]|max_length[15]' + ), + array( + 'field' => 'input_state', + 'label' => 'State', + 'rules' => 'required|min_length[1]|max_length[20]' + ) + ); - - public function SupplierUpdate($sid = 0) - { - if (!$this->input->is_ajax_request()) { - exit('no valid req.'); - } - - $FormRules = array( - array( - 'field' => 'input_name_supplier', - 'label' => 'Supplier Name', - 'rules' => 'required|min_length[3]|max_length[100]' - ), - array( - 'field' => 'input_short_name', - 'label' => 'Short Name', - 'rules' => 'required|min_length[1]|max_length[30]' - ), - array( - 'field' => 'input_gst_no', - 'label' => 'GST No.', - 'rules' => 'required|min_length[5]|max_length[15]' - ), - array( - 'field' => 'input_state', - 'label' => 'State', - 'rules' => 'required|min_length[1]|max_length[20]' - ) - ); - - $this->form_validation->set_rules($FormRules); - - if ($this->form_validation->run() == TRUE) { - $sid = $this->input->post('hid_sid'); - $name_supplier = $this->input->post('input_name_supplier'); - $short_name = $this->input->post('input_short_name'); - $contact_no = $this->input->post('input_contact_no'); - $gst_no = $this->input->post('input_gst_no'); - $city = $this->input->post('input_city'); - $state = $this->input->post('input_state'); - $active = ($this->input->post('chk_active') == 'on' ? 1 : 0); - - $Udata = array( - 'name_supplier' => $name_supplier, - 'short_name' => $short_name, - 'contact_no' => $contact_no, - 'gst_no' => $gst_no, - 'city' => $city, - 'state' => $state, - 'active' => $active - ); - + $this->form_validation->set_rules($FormRules); + + if ($this->form_validation->run() == TRUE) + { + $sid=$this->input->post('hid_sid'); + $name_supplier=$this->input->post('input_name_supplier'); + $short_name=$this->input->post('input_short_name'); + $contact_no=$this->input->post('input_contact_no'); + $gst_no=$this->input->post('input_gst_no'); + $city=$this->input->post('input_city'); + $state=$this->input->post('input_state'); + $active = ($this->input->post('chk_active')=='on'?1:0); + + $Udata = array( + 'name_supplier'=> $name_supplier, + 'short_name'=> $short_name, + 'contact_no'=> $contact_no, + 'gst_no'=> $gst_no, + 'city'=> $city, + 'state'=> $state, + 'active'=>$active + ); + $this->load->model('Medical_M'); - - if ($sid > 0) { - $inser_id = $this->Medical_M->update_supplier($Udata, $sid); - $send_msg = "Saved Successfully"; - } else { - $inser_id = $this->Medical_M->insert_supplier($Udata); - $send_msg = "Added Successfully"; + + if($sid>0) + { + $inser_id=$this->Medical_M->update_supplier($Udata,$sid); + $send_msg="Saved Successfully"; + }else{ + $inser_id=$this->Medical_M->insert_supplier($Udata); + $send_msg="Added Successfully"; } - if ($inser_id > 0) { - $show_text = Show_Alert('success', 'Success', $send_msg); - } else { - $show_text = Show_Alert('danger', 'Error', $send_msg); + if($inser_id>0) + { + $show_text=Show_Alert('success','Success',$send_msg); + }else{ + $show_text=Show_Alert('danger','Error',$send_msg); } - - $rvar = array( - 'insertid' => $inser_id, - 'show_text' => $show_text - ); - + + $rvar=array( + 'insertid' =>$inser_id, + 'show_text'=>$show_text + ); + $encode_data = json_encode($rvar); echo $encode_data; - } else { - $send_msg = validation_errors(); - $rvar = array( - 'insertid' => 0, - 'show_text' => Show_Alert('danger', 'Error', $send_msg) + + } + else{ + $send_msg=validation_errors(); + $rvar=array( + 'insertid' =>0, + 'show_text'=>Show_Alert('danger','Error',$send_msg) ); $encode_data = json_encode($rvar); echo $encode_data; } + } - + public function StockDrugList() - { + { $this->load->view('Medical/Medical_stock_drug'); } - + public function add_stock() { - if (!$this->input->is_ajax_request()) { - exit('no valid req.'); - } + if (!$this->input->is_ajax_request()) { exit('no valid req.'); } + + $FormRules = array( + array( + 'field' => 'input_product_code', + 'label' => 'Product Code', + 'rules' => 'required|min_length[3]|max_length[30]' + ), + array( + 'field' => 'input_product_name', + 'label' => 'Product Name', + 'rules' => 'required|min_length[3]|max_length[100]' + ), + array( + 'field' => 'input_product_mrp', + 'label' => 'Product MRP', + 'rules' => 'required|min_length[1]|max_length[10]' + ), + array( + 'field' => 'input_selling_price', + 'label' => 'Selling Price', + 'rules' => 'required|min_length[1]|max_length[10]' + ), + array( + 'field' => 'input_qty', + 'label' => 'Product Qty', + 'rules' => 'required|min_length[1]|max_length[10]' + ), + array( + 'field' => 'input_package', + 'label' => 'Package', + 'rules' => 'required|min_length[1]|max_length[10]' + ), + array( + 'field' => 'input_HSNCODE', + 'label' => 'HSNCODE', + 'rules' => 'required|min_length[1]|max_length[10]' + ), + array( + 'field' => 'input_CGST', + 'label' => 'CGST', + 'rules' => 'required|min_length[1]|max_length[10]' + ), + array( + 'field' => 'input_SGST', + 'label' => 'SGST', + 'rules' => 'required|min_length[1]|max_length[10]' + ) + ); - $FormRules = array( - array( - 'field' => 'input_product_code', - 'label' => 'Product Code', - 'rules' => 'required|min_length[3]|max_length[30]' - ), - array( - 'field' => 'input_product_name', - 'label' => 'Product Name', - 'rules' => 'required|min_length[3]|max_length[100]' - ), - array( - 'field' => 'input_product_mrp', - 'label' => 'Product MRP', - 'rules' => 'required|min_length[1]|max_length[10]' - ), - array( - 'field' => 'input_selling_price', - 'label' => 'Selling Price', - 'rules' => 'required|min_length[1]|max_length[10]' - ), - array( - 'field' => 'input_qty', - 'label' => 'Product Qty', - 'rules' => 'required|min_length[1]|max_length[10]' - ), - array( - 'field' => 'input_package', - 'label' => 'Package', - 'rules' => 'required|min_length[1]|max_length[10]' - ), - array( - 'field' => 'input_HSNCODE', - 'label' => 'HSNCODE', - 'rules' => 'required|min_length[1]|max_length[10]' - ), - array( - 'field' => 'input_CGST', - 'label' => 'CGST', - 'rules' => 'required|min_length[1]|max_length[10]' - ), - array( - 'field' => 'input_SGST', - 'label' => 'SGST', - 'rules' => 'required|min_length[1]|max_length[10]' - ) - ); - - $this->form_validation->set_rules($FormRules); - - if ($this->form_validation->run() == TRUE) { - $item_code = $this->input->post('input_product_code'); - - if ($item_code == 'IC0000000') { - $item_code = 'MC' . date('ymdhis'); - } - - $selling_price = $this->input->post('input_selling_price'); - - $package = $this->input->post('input_package'); - $qty = $this->input->post('input_qty'); - $total_unit = $package * $qty; - $unit_rate = $selling_price / $qty; - - $datepicker_doe_month = $this->input->post('datepicker_doe_month'); - $datepicker_doe_year = $this->input->post('datepicker_doe_year'); - - $datepicker_doe = "20" . $datepicker_doe_year . "-" . $datepicker_doe_month . "-01"; - - $this->load->model('Medical_M'); - $data = array( - 'item_code' => $item_code, - 'item_name' => $this->input->post('input_product_name'), - 'rack_no' => $this->input->post('input_rack_no'), - 'shelf_no' => $this->input->post('input_shelf_no'), - 'cold_storage' => $this->input->post('input_storage'), - 'batch_no' => $this->input->post('input_batch_code'), - 'qty' => $this->input->post('input_qty'), - 'packing' => $this->input->post('input_package'), - 'expiry_date' => $datepicker_doe, - 'mrp' => $this->input->post('input_product_mrp'), - 'purchase_price' => $this->input->post('input_purchase_price'), - 'selling_price' => $this->input->post('input_selling_price'), - 'total_unit' => $total_unit, - 'unit_rate' => $unit_rate, - 'margin' => $this->input->post('input_margin'), - 'formulation' => $this->input->post('input_formulation'), - 'stock_date' => str_to_MysqlDate($this->input->post('datepicker_stock')), - 'min_qty' => $this->input->post('input_minqty'), - 'HSNCODE' => $this->input->post('input_HSNCODE'), - 'CGST' => $this->input->post('input_CGST'), - 'SGST' => $this->input->post('input_SGST'), - 'IGST' => $this->input->post('input_IGST'), - 'dosage' => $this->input->post('input_dosage'), - 'supplier_id' => $this->input->post('input_supplier') - ); - - $data_drug = array( - 'item_id' => $item_code, - 'itemname' => $this->input->post('input_product_name'), - 'mrp' => $this->input->post('input_product_mrp'), - 'formulation' => $this->input->post('input_formulation'), - 'HSNCODE' => $this->input->post('input_HSNCODE'), - 'CGST' => $this->input->post('input_CGST'), - 'SGST' => $this->input->post('input_SGST'), - 'IGST' => $this->input->post('input_IGST'), - 'dosage' => $this->input->post('input_dosage') - ); - $show_text = ''; - - $sql = "select * from drug_temp where item_id='" . $item_code . "'"; - $query = $this->db->query($sql); - $drug_item = $query->result(); - - if (count($drug_item) > 0) { - $inser_id = $this->Medical_M->update_drug($data_drug, $item_code); - } else { - $inser_id = $this->Medical_M->insert_drug_add($data_drug); - } - - if ($inser_id > 0) { - $inser_id = 0; - $inser_id = $this->Medical_M->insert_stock_add($data); - if ($inser_id > 0) { - $send_msg = "Added"; - } else { - $send_msg = "Error : Add in Stock Table"; + $this->form_validation->set_rules($FormRules); + + if ($this->form_validation->run() == TRUE) + { + $item_code=$this->input->post('input_product_code'); + + if($item_code=='IC0000000') + { + $item_code='MC'.date('ymdhis'); } - } else { - $send_msg = "Error : Addition data in Master Drug Table"; - } + + $selling_price=$this->input->post('input_selling_price'); + + $package=$this->input->post('input_package'); + $qty=$this->input->post('input_qty'); + $total_unit=$package*$qty; + $unit_rate=$selling_price/$qty; - if ($inser_id > 0) { - $show_text = Show_Alert('success', 'Success', $send_msg); - } else { - $show_text = Show_Alert('danger', 'Error', $send_msg); - } + $datepicker_doe_month=$this->input->post('datepicker_doe_month'); + $datepicker_doe_year=$this->input->post('datepicker_doe_year'); - $rvar = array( - 'insertid' => $inser_id, - 'product_code' => $item_code, - 'show_text' => $show_text - ); + $datepicker_doe="20".$datepicker_doe_year."-".$datepicker_doe_month."-01"; - $encode_data = json_encode($rvar); - echo $encode_data; - } else { - $send_msg = validation_errors(); - $rvar = array( - 'insertid' => 0, - 'show_text' => Show_Alert('danger', 'Error', $send_msg) - ); - $encode_data = json_encode($rvar); - echo $encode_data; - } + $this->load->model('Medical_M'); + $data = array( + 'item_code' => $item_code, + 'item_name' => $this->input->post('input_product_name'), + 'rack_no' => $this->input->post('input_rack_no'), + 'shelf_no' => $this->input->post('input_shelf_no'), + 'cold_storage' => $this->input->post('input_storage'), + 'batch_no' => $this->input->post('input_batch_code'), + 'qty' => $this->input->post('input_qty'), + 'packing' => $this->input->post('input_package'), + 'expiry_date' => $datepicker_doe, + 'mrp' => $this->input->post('input_product_mrp'), + 'purchase_price' => $this->input->post('input_purchase_price'), + 'selling_price' => $this->input->post('input_selling_price'), + 'total_unit' => $total_unit, + 'unit_rate' => $unit_rate, + 'margin' => $this->input->post('input_margin'), + 'formulation' => $this->input->post('input_formulation'), + 'stock_date' => str_to_MysqlDate($this->input->post('datepicker_stock')), + 'min_qty' => $this->input->post('input_minqty'), + 'HSNCODE' => $this->input->post('input_HSNCODE'), + 'CGST' => $this->input->post('input_CGST'), + 'SGST' => $this->input->post('input_SGST'), + 'IGST' => $this->input->post('input_IGST'), + 'dosage' => $this->input->post('input_dosage'), + 'supplier_id' => $this->input->post('input_supplier') + ); + + $data_drug = array( + 'item_id' => $item_code, + 'itemname' => $this->input->post('input_product_name'), + 'mrp' => $this->input->post('input_product_mrp'), + 'formulation' => $this->input->post('input_formulation'), + 'HSNCODE' => $this->input->post('input_HSNCODE'), + 'CGST' => $this->input->post('input_CGST'), + 'SGST' => $this->input->post('input_SGST'), + 'IGST' => $this->input->post('input_IGST'), + 'dosage' => $this->input->post('input_dosage') + ); + $show_text=''; + + $sql="select * from drug_temp where item_id='".$item_code."'"; + $query = $this->db->query($sql); + $drug_item= $query->result(); + + if(count($drug_item)>0) + { + $inser_id=$this->Medical_M->update_drug($data_drug,$item_code); + }else{ + $inser_id=$this->Medical_M->insert_drug_add($data_drug); + } + + if($inser_id>0) + { + $inser_id=0; + $inser_id=$this->Medical_M->insert_stock_add($data); + if($inser_id>0) + { + $send_msg="Added"; + }else{ + $send_msg="Error : Add in Stock Table"; + } + }else{ + $send_msg="Error : Addition data in Master Drug Table"; + } + + if($inser_id>0) + { + $show_text=Show_Alert('success','Success',$send_msg); + }else{ + $show_text=Show_Alert('danger','Error',$send_msg); + } + + $rvar=array( + 'insertid' =>$inser_id, + 'product_code' => $item_code, + 'show_text'=>$show_text + ); + + $encode_data = json_encode($rvar); + echo $encode_data; + + } + else + { + $send_msg=validation_errors(); + $rvar=array( + 'insertid' =>0, + 'show_text'=>Show_Alert('danger','Error',$send_msg) + ); + $encode_data = json_encode($rvar); + echo $encode_data; + } } - + public function update_master() { - if (!$this->input->is_ajax_request()) { - exit('no valid req.'); - } + if (!$this->input->is_ajax_request()) { exit('no valid req.'); } + + $FormRules = array( + array( + 'field' => 'input_product_code', + 'label' => 'Product Code', + 'rules' => 'required|min_length[3]|max_length[30]' + ), + array( + 'field' => 'input_product_name', + 'label' => 'Product Name', + 'rules' => 'required|min_length[3]|max_length[100]' + ), + array( + 'field' => 'input_product_mrp', + 'label' => 'Product MRP', + 'rules' => 'required|min_length[1]|max_length[10]' + ), + array( + 'field' => 'input_selling_price', + 'label' => 'Selling Price', + 'rules' => 'required|min_length[1]|max_length[10]' + ), + array( + 'field' => 'input_HSNCODE', + 'label' => 'HSNCODE', + 'rules' => 'required|min_length[1]|max_length[10]' + ), + array( + 'field' => 'input_CGST', + 'label' => 'CGST', + 'rules' => 'required|min_length[1]|max_length[10]' + ), + array( + 'field' => 'input_SGST', + 'label' => 'SGST', + 'rules' => 'required|min_length[1]|max_length[10]' + ) + ); - $FormRules = array( - array( - 'field' => 'input_product_code', - 'label' => 'Product Code', - 'rules' => 'required|min_length[3]|max_length[30]' - ), - array( - 'field' => 'input_product_name', - 'label' => 'Product Name', - 'rules' => 'required|min_length[3]|max_length[100]' - ), - array( - 'field' => 'input_product_mrp', - 'label' => 'Product MRP', - 'rules' => 'required|min_length[1]|max_length[10]' - ), - array( - 'field' => 'input_selling_price', - 'label' => 'Selling Price', - 'rules' => 'required|min_length[1]|max_length[10]' - ), - array( - 'field' => 'input_HSNCODE', - 'label' => 'HSNCODE', - 'rules' => 'required|min_length[1]|max_length[10]' - ), - array( - 'field' => 'input_CGST', - 'label' => 'CGST', - 'rules' => 'required|min_length[1]|max_length[10]' - ), - array( - 'field' => 'input_SGST', - 'label' => 'SGST', - 'rules' => 'required|min_length[1]|max_length[10]' - ) - ); + $this->form_validation->set_rules($FormRules); + + if ($this->form_validation->run() == TRUE) + { + $item_code=$this->input->post('input_product_code'); - $this->form_validation->set_rules($FormRules); - - if ($this->form_validation->run() == TRUE) { - $item_code = $this->input->post('input_product_code'); - - $this->load->model('Medical_M'); - - $data_drug = array( - 'item_id' => $item_code, - 'itemname' => $this->input->post('input_product_name'), - 'mrp' => $this->input->post('input_product_mrp'), - 'formulation' => $this->input->post('input_formulation'), - 'HSNCODE' => $this->input->post('input_HSNCODE'), - 'CGST' => $this->input->post('input_CGST'), - 'SGST' => $this->input->post('input_SGST'), - 'IGST' => $this->input->post('input_IGST'), - 'dosage' => $this->input->post('input_dosage') - ); - $show_text = ''; - - $sql = "select * from drug_temp where item_id='" . $item_code . "'"; - $query = $this->db->query($sql); - $drug_item = $query->result(); - - if (count($drug_item) > 0) { - $inser_id = $this->Medical_M->update_drug($data_drug, $item_code); - } else { - $inser_id = $this->Medical_M->insert_drug_add($data_drug); - } - - if ($inser_id > 0) { - $inser_id = 0; - $inser_id = $this->Medical_M->insert_stock_add($data); - if ($inser_id > 0) { - $send_msg = "Update"; - } else { - $send_msg = "Error : Edit in Drug Master"; + $this->load->model('Medical_M'); + + $data_drug = array( + 'item_id' => $item_code, + 'itemname' => $this->input->post('input_product_name'), + 'mrp' => $this->input->post('input_product_mrp'), + 'formulation' => $this->input->post('input_formulation'), + 'HSNCODE' => $this->input->post('input_HSNCODE'), + 'CGST' => $this->input->post('input_CGST'), + 'SGST' => $this->input->post('input_SGST'), + 'IGST' => $this->input->post('input_IGST'), + 'dosage' => $this->input->post('input_dosage') + ); + $show_text=''; + + $sql="select * from drug_temp where item_id='".$item_code."'"; + $query = $this->db->query($sql); + $drug_item= $query->result(); + + if(count($drug_item)>0) + { + $inser_id=$this->Medical_M->update_drug($data_drug,$item_code); + }else{ + $inser_id=$this->Medical_M->insert_drug_add($data_drug); } - } else { - $send_msg = "Error : Addition data in Master Drug Table"; - } - - if ($inser_id > 0) { - $show_text = Show_Alert('success', 'Success', $send_msg); - } else { - $show_text = Show_Alert('danger', 'Error', $send_msg); - } - - $rvar = array( - 'insertid' => $inser_id, - 'product_code' => $item_code, - 'show_text' => $show_text - ); - - $encode_data = json_encode($rvar); - echo $encode_data; - } else { - $send_msg = validation_errors(); - $rvar = array( - 'insertid' => 0, - 'show_text' => Show_Alert('danger', 'Error', $send_msg) - ); - $encode_data = json_encode($rvar); - echo $encode_data; - } + + if($inser_id>0) + { + $inser_id=0; + $inser_id=$this->Medical_M->insert_stock_add($data); + if($inser_id>0) + { + $send_msg="Update"; + }else{ + $send_msg="Error : Edit in Drug Master"; + } + }else{ + $send_msg="Error : Addition data in Master Drug Table"; + } + + if($inser_id>0) + { + $show_text=Show_Alert('success','Success',$send_msg); + }else{ + $show_text=Show_Alert('danger','Error',$send_msg); + } + + $rvar=array( + 'insertid' =>$inser_id, + 'product_code' => $item_code, + 'show_text'=>$show_text + ); + + $encode_data = json_encode($rvar); + echo $encode_data; + + } + else + { + $send_msg=validation_errors(); + $rvar=array( + 'insertid' =>0, + 'show_text'=>Show_Alert('danger','Error',$send_msg) + ); + $encode_data = json_encode($rvar); + echo $encode_data; + } } - + public function update_stock($ss_no) { - if (!$this->input->is_ajax_request()) { - exit('no valid req.'); - } + if (!$this->input->is_ajax_request()) { exit('no valid req.'); } + + $FormRules = array( + array( + 'field' => 'input_product_code', + 'label' => 'Product Code', + 'rules' => 'required|min_length[3]|max_length[30]' + ), + array( + 'field' => 'input_product_name', + 'label' => 'Product Name', + 'rules' => 'required|min_length[3]|max_length[100]' + ) + , + array( + 'field' => 'input_product_mrp', + 'label' => 'Product MRP', + 'rules' => 'required|min_length[1]|max_length[10]' + ), + array( + 'field' => 'input_selling_price', + 'label' => 'Selling Price', + 'rules' => 'required|min_length[1]|max_length[10]' + ), + array( + 'field' => 'input_qty', + 'label' => 'Product Qty', + 'rules' => 'required|min_length[1]|max_length[10]' + ), + array( + 'field' => 'input_package', + 'label' => 'Package', + 'rules' => 'required|min_length[1]|max_length[10]' + ), + array( + 'field' => 'input_HSNCODE', + 'label' => 'HSNCODE', + 'rules' => 'required|min_length[1]|max_length[10]' + ), + array( + 'field' => 'input_CGST', + 'label' => 'CGST', + 'rules' => 'required|min_length[1]|max_length[10]' + ), + array( + 'field' => 'input_SGST', + 'label' => 'SGST', + 'rules' => 'required|min_length[1]|max_length[10]' + ) + ); - $FormRules = array( - array( - 'field' => 'input_product_code', - 'label' => 'Product Code', - 'rules' => 'required|min_length[3]|max_length[30]' - ), - array( - 'field' => 'input_product_name', - 'label' => 'Product Name', - 'rules' => 'required|min_length[3]|max_length[100]' - ), - array( - 'field' => 'input_product_mrp', - 'label' => 'Product MRP', - 'rules' => 'required|min_length[1]|max_length[10]' - ), - array( - 'field' => 'input_selling_price', - 'label' => 'Selling Price', - 'rules' => 'required|min_length[1]|max_length[10]' - ), - array( - 'field' => 'input_qty', - 'label' => 'Product Qty', - 'rules' => 'required|min_length[1]|max_length[10]' - ), - array( - 'field' => 'input_package', - 'label' => 'Package', - 'rules' => 'required|min_length[1]|max_length[10]' - ), - array( - 'field' => 'input_HSNCODE', - 'label' => 'HSNCODE', - 'rules' => 'required|min_length[1]|max_length[10]' - ), - array( - 'field' => 'input_CGST', - 'label' => 'CGST', - 'rules' => 'required|min_length[1]|max_length[10]' - ), - array( - 'field' => 'input_SGST', - 'label' => 'SGST', - 'rules' => 'required|min_length[1]|max_length[10]' - ) - ); + $this->form_validation->set_rules($FormRules); + + if ($this->form_validation->run() == TRUE) + { + $item_code=$this->input->post('input_product_code'); + + $selling_price=$this->input->post('input_selling_price'); + + $package=$this->input->post('input_package'); + $qty=$this->input->post('input_qty'); + $total_unit=$package*$qty; + $unit_rate=$selling_price/$qty; - $this->form_validation->set_rules($FormRules); + $datepicker_doe_month=$this->input->post('datepicker_doe_month'); + $datepicker_doe_year=$this->input->post('datepicker_doe_year'); - if ($this->form_validation->run() == TRUE) { - $item_code = $this->input->post('input_product_code'); + $datepicker_doe="20".$datepicker_doe_year."-".$datepicker_doe_month."-01"; - $selling_price = $this->input->post('input_selling_price'); + $this->load->model('Medical_M'); + $data = array( + 'item_code' => $item_code, + 'item_name' => $this->input->post('input_product_name'), + 'rack_no' => $this->input->post('input_rack_no'), + 'shelf_no' => $this->input->post('input_shelf_no'), + 'cold_storage' => $this->input->post('input_storage'), + 'batch_no' => $this->input->post('input_batch_code'), + 'qty' => $this->input->post('input_qty'), + 'packing' => $this->input->post('input_package'), + 'expiry_date' => $datepicker_doe, + 'mrp' => $this->input->post('input_product_mrp'), + 'purchase_price' => $this->input->post('input_purchase_price'), + 'selling_price' => $this->input->post('input_selling_price'), + 'total_unit' => $total_unit, + 'unit_rate' => $unit_rate, + 'margin' => $this->input->post('input_margin'), + 'formulation' => $this->input->post('input_formulation'), + 'stock_date' => str_to_MysqlDate($this->input->post('datepicker_stock')), + 'min_qty' => $this->input->post('input_minqty'), + 'HSNCODE' => $this->input->post('input_HSNCODE'), + 'CGST' => $this->input->post('input_CGST'), + 'SGST' => $this->input->post('input_SGST'), + 'IGST' => $this->input->post('input_IGST'), + 'supplier_id' => $this->input->post('input_supplier') + ); + + $show_text=''; + + $is_update_stock=0; + + $is_update_stock=$this->Medical_M->update_stock_upd($data,$ss_no); + + if($is_update_stock>0) + { + $send_msg="Updated"; + }else{ + $send_msg="Error : Update in Stock Table"; + } + + if($is_update_stock>0) + { + $show_text=Show_Alert('success','Updated',$send_msg); + }else{ + $show_text=Show_Alert('danger','Error',$send_msg); + } + + $rvar=array( + 'is_update_stock' =>$is_update_stock, + 'product_code' => $item_code, + 'show_text'=>$show_text + ); + + $encode_data = json_encode($rvar); + echo $encode_data; - $package = $this->input->post('input_package'); - $qty = $this->input->post('input_qty'); - $total_unit = $package * $qty; - $unit_rate = $selling_price / $qty; - - $datepicker_doe_month = $this->input->post('datepicker_doe_month'); - $datepicker_doe_year = $this->input->post('datepicker_doe_year'); - - $datepicker_doe = "20" . $datepicker_doe_year . "-" . $datepicker_doe_month . "-01"; - - $this->load->model('Medical_M'); - $data = array( - 'item_code' => $item_code, - 'item_name' => $this->input->post('input_product_name'), - 'rack_no' => $this->input->post('input_rack_no'), - 'shelf_no' => $this->input->post('input_shelf_no'), - 'cold_storage' => $this->input->post('input_storage'), - 'batch_no' => $this->input->post('input_batch_code'), - 'qty' => $this->input->post('input_qty'), - 'packing' => $this->input->post('input_package'), - 'expiry_date' => $datepicker_doe, - 'mrp' => $this->input->post('input_product_mrp'), - 'purchase_price' => $this->input->post('input_purchase_price'), - 'selling_price' => $this->input->post('input_selling_price'), - 'total_unit' => $total_unit, - 'unit_rate' => $unit_rate, - 'margin' => $this->input->post('input_margin'), - 'formulation' => $this->input->post('input_formulation'), - 'stock_date' => str_to_MysqlDate($this->input->post('datepicker_stock')), - 'min_qty' => $this->input->post('input_minqty'), - 'HSNCODE' => $this->input->post('input_HSNCODE'), - 'CGST' => $this->input->post('input_CGST'), - 'SGST' => $this->input->post('input_SGST'), - 'IGST' => $this->input->post('input_IGST'), - 'supplier_id' => $this->input->post('input_supplier') - ); - - $show_text = ''; - - $is_update_stock = 0; - - $is_update_stock = $this->Medical_M->update_stock_upd($data, $ss_no); - - if ($is_update_stock > 0) { - $send_msg = "Updated"; - } else { - $send_msg = "Error : Update in Stock Table"; - } - - if ($is_update_stock > 0) { - $show_text = Show_Alert('success', 'Updated', $send_msg); - } else { - $show_text = Show_Alert('danger', 'Error', $send_msg); - } - - $rvar = array( - 'is_update_stock' => $is_update_stock, - 'product_code' => $item_code, - 'show_text' => $show_text - ); - - $encode_data = json_encode($rvar); - echo $encode_data; - } else { - $send_msg = validation_errors(); - $rvar = array( - 'is_update_stock' => 0, - 'show_text' => Show_Alert('danger', 'Error', $send_msg) - ); - $encode_data = json_encode($rvar); - echo $encode_data; - } + } + else + { + $send_msg=validation_errors(); + $rvar=array( + 'is_update_stock' =>0, + 'show_text'=>Show_Alert('danger','Error',$send_msg) + ); + $encode_data = json_encode($rvar); + echo $encode_data; + } } - - public function purchase_update_stock($inv_id, $return_stock = 0) + + public function purchase_update_stock($inv_id,$return_stock=0) { - if (!$this->input->is_ajax_request()) { - exit('no valid req.'); - } - - $sql = "select * from purchase_invoice where id=" . $inv_id; + if (!$this->input->is_ajax_request()) { exit('no valid req.'); } + + $sql="select * from purchase_invoice where id=".$inv_id; $query = $this->db->query($sql); - $purchase_invoice = $query->result(); + $purchase_invoice= $query->result(); $user = $this->ion_auth->user()->row(); $user_id = $user->id; - $user_name_info = $user->first_name . '' . $user->last_name . '[' . $user_id . ']' . date('d-m-Y H:i:s'); + $user_name_info = $user->first_name.''. $user->last_name .'['.$user_id.']'.date('d-m-Y H:i:s'); - $FormRules = array( - array( - 'field' => 'input_product_code', - 'label' => 'Not Found in Database', - 'rules' => 'required|min_length[1]|max_length[30]' - ), - array( - 'field' => 'input_drug_hid', - 'label' => 'Product Name', - 'rules' => 'required|min_length[3]|max_length[100]' - ), - array( - 'field' => 'input_product_mrp', - 'label' => 'Product MRP', - 'rules' => 'required|min_length[1]|max_length[10]' - ), - array( - 'field' => 'input_selling_price', - 'label' => 'Selling Price', - 'rules' => 'required|min_length[1]|max_length[10]' - ), - array( - 'field' => 'input_Qty', - 'label' => 'Product Qty', - 'rules' => 'required|min_length[1]|max_length[10]' - ), - array( - 'field' => 'input_package', - 'label' => 'Package', - 'rules' => 'required|min_length[1]|max_length[10]' - ), - array( - 'field' => 'input_HSNCODE', - 'label' => 'HSNCODE', - 'rules' => 'required|min_length[1]|max_length[10]' - ), - array( - 'field' => 'input_CGST', - 'label' => 'CGST', - 'rules' => 'required|min_length[1]|max_length[10]' - ), - array( - 'field' => 'input_SGST', - 'label' => 'SGST', - 'rules' => 'required|min_length[1]|max_length[10]' - ), - array( - 'field' => 'input_purchase_price', - 'label' => 'Purchase Price', - 'rules' => 'required|min_length[1]|max_length[10]' - ) - ); + $FormRules = array( + array( + 'field' => 'input_product_code', + 'label' => 'Not Found in Database', + 'rules' => 'required|min_length[1]|max_length[30]' + ), + array( + 'field' => 'input_drug_hid', + 'label' => 'Product Name', + 'rules' => 'required|min_length[3]|max_length[100]' + ), + array( + 'field' => 'input_product_mrp', + 'label' => 'Product MRP', + 'rules' => 'required|min_length[1]|max_length[10]' + ), + array( + 'field' => 'input_selling_price', + 'label' => 'Selling Price', + 'rules' => 'required|min_length[1]|max_length[10]' + ), + array( + 'field' => 'input_Qty', + 'label' => 'Product Qty', + 'rules' => 'required|min_length[1]|max_length[10]' + ), + array( + 'field' => 'input_package', + 'label' => 'Package', + 'rules' => 'required|min_length[1]|max_length[10]' + ), + array( + 'field' => 'input_HSNCODE', + 'label' => 'HSNCODE', + 'rules' => 'required|min_length[1]|max_length[10]' + ), + array( + 'field' => 'input_CGST', + 'label' => 'CGST', + 'rules' => 'required|min_length[1]|max_length[10]' + ), + array( + 'field' => 'input_SGST', + 'label' => 'SGST', + 'rules' => 'required|min_length[1]|max_length[10]' + ), + array( + 'field' => 'input_purchase_price', + 'label' => 'Purchase Price', + 'rules' => 'required|min_length[1]|max_length[10]' + ) + ); - $this->form_validation->set_rules($FormRules); + $this->form_validation->set_rules($FormRules); + + if ($this->form_validation->run() == TRUE) + { + $item_code=$this->input->post('input_product_code'); + $item_id=$this->input->post('invoice_item_id'); - if ($this->form_validation->run() == TRUE) { - $item_code = $this->input->post('input_product_code'); - $item_id = $this->input->post('invoice_item_id'); + $datepicker_doe_month=$this->input->post('datepicker_doe_month'); + $datepicker_doe_year=$this->input->post('datepicker_doe_year'); - $datepicker_doe_month = $this->input->post('datepicker_doe_month'); - $datepicker_doe_year = $this->input->post('datepicker_doe_year'); + $datepicker_doe="20".$datepicker_doe_year."-".$datepicker_doe_month."-01"; + + $this->load->model('Medical_M'); - $datepicker_doe = "20" . $datepicker_doe_year . "-" . $datepicker_doe_month . "-01"; + $Pdata = array( + 'purchase_id' => $inv_id, + 'item_code' => $item_code, + 'item_name' => $this->input->post('input_drug_hid'), + 'packing' => $this->input->post('input_package'), + 'batch_no' => $this->input->post('input_batch_code'), + 'purchase_price' => $this->input->post('input_purchase_price'), + 'expiry_date' => $datepicker_doe, + 'mrp' => $this->input->post('input_product_mrp'), + + 'qty' => $this->input->post('input_Qty'), + 'qty_free' => $this->input->post('input_Qty_Free'), + + 'discount' => $this->input->post('input_disc_price'), + + 'CGST_per' => $this->input->post('input_CGST'), + 'SGST_per' => $this->input->post('input_SGST'), - $this->load->model('Medical_M'); + 'HSNCODE' => $this->input->post('input_HSNCODE'), + + 'cold_storage' => $this->input->post('input_storage'), + 'shelf_no' => $this->input->post('input_shelf_no'), + 'rack_no' => $this->input->post('input_rack_no'), + 'stock_date' => $purchase_invoice[0]->date_of_invoice, + + 'selling_price' => $this->input->post('input_selling_price'), + + 'sch_disc_amt' => $this->input->post('input_sch_amount'), + 'sch_disc_per' => $this->input->post('input_sch_disc'), - $Pdata = array( - 'purchase_id' => $inv_id, - 'item_code' => $item_code, - 'item_name' => $this->input->post('input_drug_hid'), - 'packing' => $this->input->post('input_package'), - 'batch_no' => $this->input->post('input_batch_code'), - 'purchase_price' => $this->input->post('input_purchase_price'), - 'expiry_date' => $datepicker_doe, - 'mrp' => $this->input->post('input_product_mrp'), + 'insert_by' => $user_name_info, + + 'item_return' => $return_stock + ); - 'qty' => $this->input->post('input_Qty'), - 'qty_free' => $this->input->post('input_Qty_Free'), + $show_text=''; + + $is_update_stock=0; + + $send_msg=""; + + if($item_id<1) + { + $is_update_stock=$this->Medical_M->insert_purchase_item($Pdata); + $send_msg="Added"; + }else{ + $sql="select * from purchase_invoice_item where id='$item_id' "; + $query = $this->db->query($sql); + $drug_item= $query->result(); - 'discount' => $this->input->post('input_disc_price'), + if(count($drug_item)>0){ + $tot_sale_qty=$drug_item[0]->total_sale_unit; - 'CGST_per' => $this->input->post('input_CGST'), - 'SGST_per' => $this->input->post('input_SGST'), + $qty = $this->input->post('input_Qty'); + $qty_free= $this->input->post('input_Qty_Free'); - 'HSNCODE' => $this->input->post('input_HSNCODE'), + $packing=$this->input->post('input_package'); - 'cold_storage' => $this->input->post('input_storage'), - 'shelf_no' => $this->input->post('input_shelf_no'), - 'rack_no' => $this->input->post('input_rack_no'), - 'stock_date' => $purchase_invoice[0]->date_of_invoice, + $tot_qty=($qty+$qty_free)*$packing; - 'selling_price' => $this->input->post('input_selling_price'), + if($tot_sale_qty<=$tot_qty) + { + $is_update_stock=$this->Medical_M->update_purchase_item($Pdata,$item_id); + if($is_update_stock>0) + { + $send_msg="Updated"; + }else{ + $send_msg="Error : Update in Stock Table"; + } + }else{ + $send_msg="Error : Update Qty is Less then saled Qty :".$tot_qty." / Saled :".$tot_sale_qty; + + //Update While Qty in Minus - 'sch_disc_amt' => $this->input->post('input_sch_amount'), - 'sch_disc_per' => $this->input->post('input_sch_disc'), - - 'insert_by' => $user_name_info, - - 'item_return' => $return_stock - ); - - $show_text = ''; - - $is_update_stock = 0; - - $send_msg = ""; - - if ($item_id < 1) { - $is_update_stock = $this->Medical_M->insert_purchase_item($Pdata); - $send_msg = "Added"; - } else { - $sql = "select * from purchase_invoice_item where id='$item_id' "; - $query = $this->db->query($sql); - $drug_item = $query->result(); - - if (count($drug_item) > 0) { - $tot_sale_qty = $drug_item[0]->total_sale_unit; - - $qty = $this->input->post('input_Qty'); - $qty_free = $this->input->post('input_Qty_Free'); - - $packing = $this->input->post('input_package'); - - $tot_qty = ($qty + $qty_free) * $packing; - - if ($tot_sale_qty <= $tot_qty) { - $is_update_stock = $this->Medical_M->update_purchase_item($Pdata, $item_id); - if ($is_update_stock > 0) { - $send_msg = "Updated"; - } else { - $send_msg = "Error : Update in Stock Table"; - } - } else { - $send_msg = "Error : Update Qty is Less then saled Qty :" . $tot_qty . " / Saled :" . $tot_sale_qty; - - //Update While Qty in Minus - - //$is_update_stock=$this->Medical_M->update_purchase_item($Pdata,$item_id); - /* + //$is_update_stock=$this->Medical_M->update_purchase_item($Pdata,$item_id); + /* if($is_update_stock>0) { $send_msg="Updated : But Error : Update Qty is Less then saled Qty :".$tot_qty." / Saled :".$tot_sale_qty; @@ -1170,129 +1110,140 @@ class Medical extends MY_Controller $send_msg="Error : Update in Stock Table"; } */ + + } + + }else{ + $send_msg="Error : Record Not Found in Stock Table"; } - } else { - $send_msg = "Error : Record Not Found in Stock Table"; } - } - - $rvar = array( - 'is_update_stock' => $is_update_stock, - 'product_code' => $item_code, - 'show_text' => $send_msg - ); - - $encode_data = json_encode($rvar); - echo $encode_data; - } else { - $send_msg = validation_errors(); - $rvar = array( - 'is_update_stock' => 0, - 'show_text' => $send_msg - ); - $encode_data = json_encode($rvar); - echo $encode_data; - } + + $rvar=array( + 'is_update_stock' =>$is_update_stock, + 'product_code' => $item_code, + 'show_text'=>$send_msg + ); + + $encode_data = json_encode($rvar); + echo $encode_data; + + } + else + { + $send_msg=validation_errors(); + $rvar=array( + 'is_update_stock' =>0, + 'show_text'=>$send_msg + ); + $encode_data = json_encode($rvar); + echo $encode_data; + } } - - function purchase_invoice_item_edit($inv_id, $inv_item_id) + + function purchase_invoice_item_edit($inv_id,$inv_item_id) { - $sql = "select *, + $sql="select *, date_format(expiry_date,'%m') as str_expiry_month , date_format(expiry_date,'%y') as str_expiry_year - from purchase_invoice_item where id=" . $inv_item_id . " and purchase_id=" . $inv_id; + from purchase_invoice_item where id=".$inv_item_id." and purchase_id=".$inv_id; $query = $this->db->query($sql); - $purchase_invoice_item = $query->result(); + $purchase_invoice_item= $query->result(); + + if(count($purchase_invoice_item)>0) + { + $rvar=array( + 'is_update_stock'=>'1', + 'item_id' =>$purchase_invoice_item[0]->id, + 'product_code' =>$purchase_invoice_item[0]->item_code, + 'product_mrp' => $purchase_invoice_item[0]->mrp, + 'selling_price'=>$purchase_invoice_item[0]->selling_price, + 'batch_code'=>$purchase_invoice_item[0]->batch_no, + 'disc_price'=>$purchase_invoice_item[0]->discount, + 'qty'=>$purchase_invoice_item[0]->qty, + 'qty_free'=>$purchase_invoice_item[0]->qty_free, + 'package'=>$purchase_invoice_item[0]->packing, + 'purchase_price'=>$purchase_invoice_item[0]->purchase_price, + 'datepicker_doe_month'=>$purchase_invoice_item[0]->str_expiry_month, + 'datepicker_doe_year'=>$purchase_invoice_item[0]->str_expiry_year, + 'drug'=>$purchase_invoice_item[0]->Item_name, - if (count($purchase_invoice_item) > 0) { - $rvar = array( - 'is_update_stock' => '1', - 'item_id' => $purchase_invoice_item[0]->id, - 'product_code' => $purchase_invoice_item[0]->item_code, - 'product_mrp' => $purchase_invoice_item[0]->mrp, - 'selling_price' => $purchase_invoice_item[0]->selling_price, - 'batch_code' => $purchase_invoice_item[0]->batch_no, - 'disc_price' => $purchase_invoice_item[0]->discount, - 'qty' => $purchase_invoice_item[0]->qty, - 'qty_free' => $purchase_invoice_item[0]->qty_free, - 'package' => $purchase_invoice_item[0]->packing, - 'purchase_price' => $purchase_invoice_item[0]->purchase_price, - 'datepicker_doe_month' => $purchase_invoice_item[0]->str_expiry_month, - 'datepicker_doe_year' => $purchase_invoice_item[0]->str_expiry_year, - 'drug' => $purchase_invoice_item[0]->Item_name, + 'sch_disc_amt'=>$purchase_invoice_item[0]->sch_disc_amt, + 'sch_disc_per'=>$purchase_invoice_item[0]->sch_disc_per, - 'sch_disc_amt' => $purchase_invoice_item[0]->sch_disc_amt, - 'sch_disc_per' => $purchase_invoice_item[0]->sch_disc_per, + 'HSNCODE'=>$purchase_invoice_item[0]->HSNCODE, + 'CGST_per'=>$purchase_invoice_item[0]->CGST_per, + 'SGST_per'=>$purchase_invoice_item[0]->SGST_per, - 'HSNCODE' => $purchase_invoice_item[0]->HSNCODE, - 'CGST_per' => $purchase_invoice_item[0]->CGST_per, - 'SGST_per' => $purchase_invoice_item[0]->SGST_per, + 'cold_storage'=>$purchase_invoice_item[0]->cold_storage, + 'shelf_no'=>$purchase_invoice_item[0]->shelf_no, + 'rack_no'=>$purchase_invoice_item[0]->rack_no, - 'cold_storage' => $purchase_invoice_item[0]->cold_storage, - 'shelf_no' => $purchase_invoice_item[0]->shelf_no, - 'rack_no' => $purchase_invoice_item[0]->rack_no, - - ); - } else { - $rvar = array( - 'is_update_stock' => '0', - 'show_text' => $sql - ); + ); + }else{ + $rvar=array( + 'is_update_stock'=>'0', + 'show_text'=>$sql + ); } - - $encode_data = json_encode($rvar); - echo $encode_data; + + $encode_data = json_encode($rvar); + echo $encode_data; + } - + public function purchase_invoice_item_list($inv_id) { - $sql = "select *,date_format(expiry_date,'%m/%y') as exp_date_str from purchase_invoice_item where purchase_id='" . $inv_id . "' "; - $query = $this->db->query($sql); - $data['purchase_item'] = $query->result(); + $sql="select *,date_format(expiry_date,'%m/%y') as exp_date_str from purchase_invoice_item where purchase_id='".$inv_id."' "; + $query = $this->db->query($sql); + $data['purchase_item']= $query->result(); + + $sql="select * from purchase_invoice where id='".$inv_id."' "; + $query = $this->db->query($sql); + $data['purchase_invoice']= $query->result(); - $sql = "select * from purchase_invoice where id='" . $inv_id . "' "; - $query = $this->db->query($sql); - $data['purchase_invoice'] = $query->result(); - - - - $this->load->view('Medical/Purchase/purchase_invoice_item', $data); + + + $this->load->view('Medical/Purchase/purchase_invoice_item',$data); + } public function purchase_invoice_item_list_old($item_code) { - $sql = "SELECT s.name_supplier, date_format(p.date_of_invoice,'%d-%m-%Y') as date_of_invoice_str, + $sql="SELECT s.name_supplier, date_format(p.date_of_invoice,'%d-%m-%Y') as date_of_invoice_str, i.Item_name,i.packing,i.purchase_price,i.qty,i.qty_free,i.mrp,i.discount,i.sch_disc_per,i.purchase_unit_rate,p.Invoice_no FROM (purchase_invoice p JOIN purchase_invoice_item i ON p.id=i.purchase_id) JOIN med_supplier s ON p.sid=s.sid WHERE i.item_code=$item_code ORDER BY i.id DESC LIMIT 5 "; - $query = $this->db->query($sql); - $data['purchase_item_old'] = $query->result(); - - $this->load->view('Medical/Purchase/purchase_item_old', $data); + $query = $this->db->query($sql); + $data['purchase_item_old']= $query->result(); + + $this->load->view('Medical/Purchase/purchase_item_old',$data); + } - - public function purchase_invoice_item_delete($inv_id, $inv_item_del) + + public function purchase_invoice_item_delete($inv_id,$inv_item_del) { $this->load->model('Medical_M'); - $sql = "select * from purchase_invoice_item where id='$inv_item_del' "; - $query = $this->db->query($sql); - $drug_item = $query->result(); + $sql="select * from purchase_invoice_item where id='$inv_item_del' "; + $query = $this->db->query($sql); + $drug_item= $query->result(); + + if(count($drug_item)>0){ + $sale_qty=$drug_item[0]->total_sale_unit; - if (count($drug_item) > 0) { - $sale_qty = $drug_item[0]->total_sale_unit; - - if ($sale_qty > 0) { - $rvar = array( - 'is_update_stock' => 0, - 'show_text' => 'Sold some Quantity of this Item', + if($sale_qty>0) + { + $rvar=array( + 'is_update_stock' =>0, + 'show_text'=>'Sold some Quantity of this Item', ); - } else { - $is_update_stock = $this->Medical_M->delete_purchase_item($inv_id, $inv_item_del); - $rvar = array( - 'is_update_stock' => 1, - 'show_text' => 'Removed Successfully', + + }else{ + $is_update_stock=$this->Medical_M->delete_purchase_item($inv_id,$inv_item_del); + $rvar=array( + 'is_update_stock' =>1, + 'show_text'=>'Removed Successfully', ); } } @@ -1300,42 +1251,42 @@ class Medical extends MY_Controller $encode_data = json_encode($rvar); echo $encode_data; } - + public function AddDrugStock($drug_item_code) - { - $sql = "select * from drug_temp where item_id='" . $drug_item_code . "' "; - $query = $this->db->query($sql); - $data['drug_item'] = $query->result(); + { + $sql="select * from drug_temp where item_id='".$drug_item_code."' "; + $query = $this->db->query($sql); + $data['drug_item']= $query->result(); + + $sql="select * from stock_addition where item_code='".$drug_item_code."' "; + $query = $this->db->query($sql); + $data['drug_stock_item']= $query->result(); + + $sql="select * from med_supplier "; + $query = $this->db->query($sql); + $data['med_supplier']= $query->result(); - $sql = "select * from stock_addition where item_code='" . $drug_item_code . "' "; - $query = $this->db->query($sql); - $data['drug_stock_item'] = $query->result(); - - $sql = "select * from med_supplier "; - $query = $this->db->query($sql); - $data['med_supplier'] = $query->result(); - - $this->load->view('Medical/Drug_Stock_Add', $data); + $this->load->view('Medical/Drug_Stock_Add',$data); } - + public function UpdateDrugStock($ss_no) - { - $sql = "select * from stock_addition where ss_no='" . $ss_no . "' "; - $query = $this->db->query($sql); - $data['stock_item'] = $query->result(); - - $sql = "select * from med_supplier "; - $query = $this->db->query($sql); - $data['med_supplier'] = $query->result(); - - $this->load->view('Medical/Stock_Update', $data); + { + $sql="select * from stock_addition where ss_no='".$ss_no."' "; + $query = $this->db->query($sql); + $data['stock_item']= $query->result(); + + $sql="select * from med_supplier "; + $query = $this->db->query($sql); + $data['med_supplier']= $query->result(); + + $this->load->view('Medical/Stock_Update',$data); } - + public function load_stock_data($item_code) { - $sql = "select * from stock_addition where item_code='" . $item_code . "' "; + $sql="select * from stock_addition where item_code='".$item_code."' "; $query = $this->db->query($sql); - $data['drug_stock_item'] = $query->result(); + $data['drug_stock_item']= $query->result(); echo ' @@ -1353,25 +1304,26 @@ class Medical extends MY_Controller '; - $srno = 0; + $srno=0; - foreach ($data['drug_stock_item'] as $row) { - $srno = $srno + 1; + foreach($data['drug_stock_item'] as $row) + { + $srno=$srno+1; echo ''; - echo ''; - echo ''; - echo ''; - echo ''; - echo ''; - echo ''; - echo ''; - echo ''; - echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; echo ''; - } - - echo ''; - + } + + echo ''; + echo ' @@ -1387,37 +1339,39 @@ class Medical extends MY_Controller
' . $row->item_code . '' . $row->item_name . '' . $row->formulation . '' . $row->cold_storage . '/' . $row->shelf_no . '/' . $row->rack_no . '' . $row->batch_no . '' . $row->total_unit . '/' . $row->total_sale_unit . '' . $row->expiry_date . '' . $row->mrp . '' . $row->unit_rate . ''.$row->item_code.''.$row->item_name.''.$row->formulation.''.$row->cold_storage.'/'.$row->shelf_no.'/'.$row->rack_no.''.$row->batch_no.''.$row->total_unit.'/'.$row->total_sale_unit.''.$row->expiry_date.''.$row->mrp.''.$row->unit_rate.'
'; } - + public function Invoice_counter() - { - $sql = "select * from invoice_med_master"; + { + $sql="select * from invoice_med_master"; $query = $this->db->query($sql); - $data['invoiceMaster'] = $query->result(); - - $sql = "select * from inv_med_item"; + $data['invoiceMaster']= $query->result(); + + $sql="select * from inv_med_item"; $query = $this->db->query($sql); - $data['inv_items'] = $query->result(); - - $sql = "select sum(amount) as Gtotal from inv_med_item"; + $data['inv_items']= $query->result(); + + $sql="select sum(amount) as Gtotal from inv_med_item"; $query = $this->db->query($sql); - $data['invoiceGtotal'] = $query->result(); + $data['invoiceGtotal']= $query->result(); - $sql = "select * from doctor_master where active=1"; + $sql="select * from doctor_master where active=1"; $query = $this->db->query($sql); - $data['doclist'] = $query->result(); - - if ($data['invoiceMaster'][0]->case_id > 0) { - $sql = "select * from organization_case_master where id=" . $data['invoiceMaster'][0]->case_id; + $data['doclist']= $query->result(); + + if($data['invoiceMaster'][0]->case_id > 0) + { + $sql="select * from organization_case_master where id=".$data['invoiceMaster'][0]->case_id; $query = $this->db->query($sql); - $data['OCaseMaster'] = $query->result(); + $data['OCaseMaster']= $query->result(); } $user = $this->ion_auth->user()->row(); $data['user_id'] = $user->id; - - $this->load->view('Medical/Medical_Invoice_V', $data); + + $this->load->view('Medical/Medical_Invoice_V',$data); + } - + public function Invoice_Med_Draft() { $this->load->view('Medical/Draft_Med_Invoice'); @@ -1427,81 +1381,88 @@ class Medical extends MY_Controller { $this->load->view('Medical/Draft_Med_Return_Invoice'); } - + public function Invoice_med_show($inv_id) { - $sql = "select *,if(ipd_credit>0,'Credit to IPD','CASH') as credit_status, + $sql="select *,if(ipd_credit>0,'Credit to IPD','CASH') as credit_status, if(case_credit>0,'Credit to Org','CASH') as credit_org_status from invoice_med_master where id=$inv_id"; $query = $this->db->query($sql); - $data['invoiceMaster'] = $query->result(); + $data['invoiceMaster']= $query->result(); - $patient_id = $data['invoiceMaster'][0]->patient_id; - $inv_phone_number = $data['invoiceMaster'][0]->inv_phone_number; + $patient_id=$data['invoiceMaster'][0]->patient_id; + $inv_phone_number=$data['invoiceMaster'][0]->inv_phone_number; - if ($patient_id == 0) { + if($patient_id==0) + { + } - $sql = "SELECT i.*,ifnull(DATEDIFF(expiry,CURDATE()),1000) AS no_day, + $sql="SELECT i.*,ifnull(DATEDIFF(expiry,CURDATE()),1000) AS no_day, SUM(p.total_unit-p.total_sale_unit-total_return_unit-total_lost_unit)/p.packing AS cur_qty FROM (inv_med_item i JOIN purchase_invoice_item p ON i.item_code=p.item_code AND p.remove_item=0 ) - where inv_med_id=" . $inv_id . " GROUP BY i.id"; + where inv_med_id=".$inv_id." GROUP BY i.id"; $query = $this->db->query($sql); - $data['inv_items'] = $query->result(); + $data['inv_items']= $query->result(); - $sql = "select item_code - from inv_med_item where inv_med_id=" . $inv_id . " Group by item_code Having count(id)>1"; + $sql="select item_code + from inv_med_item where inv_med_id=".$inv_id." Group by item_code Having count(id)>1"; $query = $this->db->query($sql); - $data['inv_items_multiple'] = $query->result(); + $data['inv_items_multiple']= $query->result(); - $sql = "select sum(amount) as Gtotal,sum(tamount) as tamt,sum(CGST) as TCGST,sum(SGST) as TSGST,sum(disc_amount) as t_dis_amt from inv_med_item where inv_med_id=" . $inv_id; + $sql="select sum(amount) as Gtotal,sum(tamount) as tamt,sum(CGST) as TCGST,sum(SGST) as TSGST,sum(disc_amount) as t_dis_amt from inv_med_item where inv_med_id=".$inv_id; $query = $this->db->query($sql); - $data['invoiceGtotal'] = $query->result(); + $data['invoiceGtotal']= $query->result(); - $sql = "select * from doctor_master where active=1"; + $sql="select * from doctor_master where active=1"; $query = $this->db->query($sql); - $data['doclist'] = $query->result(); + $data['doclist']= $query->result(); - $sql = "select *, - GET_AGE_1(dob,age,age_in_month,estimate_dob) AS age from patient_master where id='" . $data['invoiceMaster'][0]->patient_id . "' "; + $sql="select *, + GET_AGE_1(dob,age,age_in_month,estimate_dob) AS age from patient_master where id='".$data['invoiceMaster'][0]->patient_id."' "; $query = $this->db->query($sql); - $data['person_info'] = $query->result(); - - $data['org_Name'] = ""; - $ipd_id = $data['invoiceMaster'][0]->ipd_id; - - if ($ipd_id > 0) { - $sql = "select * from ipd_master where id=" . $ipd_id; + $data['person_info']= $query->result(); + + $data['org_Name']=""; + $ipd_id=$data['invoiceMaster'][0]->ipd_id; + + if($ipd_id>0) + { + $sql="select * from ipd_master where id=".$ipd_id; $query = $this->db->query($sql); - $ipd_master = $query->result(); + $ipd_master= $query->result(); - $sql = "select * from v_ipd_list m join patient_master p on m.p_id=p.id - where m.id=" . $ipd_id; + $sql="select * from v_ipd_list m join patient_master p on m.p_id=p.id + where m.id=".$ipd_id; $query = $this->db->query($sql); - $data['ipd_list'] = $query->result(); + $data['ipd_list']= $query->result(); - $data['ipd_master'] = $ipd_master; - - if (count($ipd_master) > 0) { - $p_ipd_id = $ipd_master[0]->id; - $p_ipd_code = $ipd_master[0]->ipd_code; - - if ($ipd_master[0]->case_id > 0) { - $sql = "select * from organization_case_master where id=" . $ipd_master[0]->case_id; + $data['ipd_master']=$ipd_master; + + if(count($ipd_master)>0) + { + $p_ipd_id=$ipd_master[0]->id; + $p_ipd_code=$ipd_master[0]->ipd_code; + + if($ipd_master[0]->case_id>0) + { + $sql="select * from organization_case_master where id=".$ipd_master[0]->case_id; $query = $this->db->query($sql); - $org_master = $query->result(); - - if (count($org_master) > 0) { - $data['org_Name'] = $org_master[0]->insurance_company_name; + $org_master= $query->result(); + + if(count($org_master)>0) + { + $data['org_Name']=$org_master[0]->insurance_company_name; } } } } - - if ($data['invoiceMaster'][0]->case_id > 0) { - $sql = "select * from organization_case_master where id=" . $data['invoiceMaster'][0]->case_id; + + if($data['invoiceMaster'][0]->case_id > 0) + { + $sql="select * from organization_case_master where id=".$data['invoiceMaster'][0]->case_id; $query = $this->db->query($sql); - $data['OCaseMaster'] = $query->result(); + $data['OCaseMaster']= $query->result(); } @@ -1509,98 +1470,108 @@ class Medical extends MY_Controller $user = $this->ion_auth->user()->row(); $data['user_id'] = $user->id; - $data['sale_return'] = $data['invoiceMaster'][0]->sale_return; + $data['sale_return']=$data['invoiceMaster'][0]->sale_return; - $data['content'] = $this->load->view('Medical/Med_Item_List', $data, true); + $data['content']=$this->load->view('Medical/Med_Item_List',$data,true); - if ($data['invoiceMaster'][0]->sale_return == 0) { - $this->load->view('Medical/Medical_Invoice_V', $data); - } else { - $this->load->view('Medical/Medical_Invoice_Return_V', $data); + if($data['invoiceMaster'][0]->sale_return==0) + { + $this->load->view('Medical/Medical_Invoice_V',$data); + }else{ + $this->load->view('Medical/Medical_Invoice_Return_V',$data); } + } //New Invoice Edit public function Invoice_med_datasheet($inv_id) { - $sql = "SELECT i.*,ifnull(DATEDIFF(expiry,CURDATE()),1000) AS no_day, + $sql="SELECT i.*,ifnull(DATEDIFF(expiry,CURDATE()),1000) AS no_day, SUM(p.total_unit-p.total_sale_unit-total_return_unit-total_lost_unit)/p.packing AS cur_qty FROM (inv_med_item i JOIN purchase_invoice_item p ON i.item_code=p.item_code AND p.remove_item=0 ) - where inv_med_id=" . $inv_id . " GROUP BY i.id"; + where inv_med_id=".$inv_id." GROUP BY i.id"; $query = $this->db->query($sql); - $data['invoiceMaster'] = $query->result(); + $data['invoiceMaster']= $query->result(); - $sql = "select *,ifnull(DATEDIFF(expiry,CURDATE()),1000) AS no_day from inv_med_item where inv_med_id=" . $inv_id; + $sql="select *,ifnull(DATEDIFF(expiry,CURDATE()),1000) AS no_day from inv_med_item where inv_med_id=".$inv_id; $query = $this->db->query($sql); - $data['inv_items'] = $query->result(); + $data['inv_items']= $query->result(); - $sql = "select item_code - from inv_med_item where inv_med_id=" . $inv_id . " Group by item_code Having count(id)>1"; + $sql="select item_code + from inv_med_item where inv_med_id=".$inv_id." Group by item_code Having count(id)>1"; $query = $this->db->query($sql); - $data['inv_items_multiple'] = $query->result(); + $data['inv_items_multiple']= $query->result(); - $sql = "select sum(amount) as Gtotal,sum(tamount) as tamt,sum(CGST) as TCGST,sum(SGST) as TSGST,sum(disc_amount) as t_dis_amt from inv_med_item where inv_med_id=" . $inv_id; + $sql="select sum(amount) as Gtotal,sum(tamount) as tamt,sum(CGST) as TCGST,sum(SGST) as TSGST,sum(disc_amount) as t_dis_amt from inv_med_item where inv_med_id=".$inv_id; $query = $this->db->query($sql); - $data['invoiceGtotal'] = $query->result(); + $data['invoiceGtotal']= $query->result(); - $sql = "select * from doctor_master where active=1"; + $sql="select * from doctor_master where active=1"; $query = $this->db->query($sql); - $data['doclist'] = $query->result(); + $data['doclist']= $query->result(); - $sql = "select *, - GET_AGE_1(dob,age,age_in_month,estimate_dob) AS age from patient_master where id='" . $data['invoiceMaster'][0]->patient_id . "' "; + $sql="select *, + GET_AGE_1(dob,age,age_in_month,estimate_dob) AS age from patient_master where id='".$data['invoiceMaster'][0]->patient_id."' "; $query = $this->db->query($sql); - $data['person_info'] = $query->result(); - - $data['org_Name'] = ""; - $ipd_id = $data['invoiceMaster'][0]->ipd_id; - - if ($ipd_id > 0) { - $sql = "select * from ipd_master where id=" . $ipd_id; + $data['person_info']= $query->result(); + + $data['org_Name']=""; + $ipd_id=$data['invoiceMaster'][0]->ipd_id; + + if($ipd_id>0) + { + $sql="select * from ipd_master where id=".$ipd_id; $query = $this->db->query($sql); - $ipd_master = $query->result(); + $ipd_master= $query->result(); - $sql = "select * from v_ipd_list m join patient_master p on m.p_id=p.id - where m.id=" . $ipd_id; + $sql="select * from v_ipd_list m join patient_master p on m.p_id=p.id + where m.id=".$ipd_id; $query = $this->db->query($sql); - $data['ipd_list'] = $query->result(); + $data['ipd_list']= $query->result(); - $data['ipd_master'] = $ipd_master; - - if (count($ipd_master) > 0) { - $p_ipd_id = $ipd_master[0]->id; - $p_ipd_code = $ipd_master[0]->ipd_code; - - if ($ipd_master[0]->case_id > 0) { - $sql = "select * from organization_case_master where id=" . $ipd_master[0]->case_id; + $data['ipd_master']=$ipd_master; + + if(count($ipd_master)>0) + { + $p_ipd_id=$ipd_master[0]->id; + $p_ipd_code=$ipd_master[0]->ipd_code; + + if($ipd_master[0]->case_id>0) + { + $sql="select * from organization_case_master where id=".$ipd_master[0]->case_id; $query = $this->db->query($sql); - $org_master = $query->result(); - - if (count($org_master) > 0) { - $data['org_Name'] = $org_master[0]->insurance_company_name; + $org_master= $query->result(); + + if(count($org_master)>0) + { + $data['org_Name']=$org_master[0]->insurance_company_name; } } } } - - if ($data['invoiceMaster'][0]->case_id > 0) { - $sql = "select * from organization_case_master where id=" . $data['invoiceMaster'][0]->case_id; + + if($data['invoiceMaster'][0]->case_id > 0) + { + $sql="select * from organization_case_master where id=".$data['invoiceMaster'][0]->case_id; $query = $this->db->query($sql); - $data['OCaseMaster'] = $query->result(); + $data['OCaseMaster']= $query->result(); } $user = $this->ion_auth->user()->row(); $data['user_id'] = $user->id; - $data['sale_return'] = $data['invoiceMaster'][0]->sale_return; + $data['sale_return']=$data['invoiceMaster'][0]->sale_return; - $data['content'] = $this->load->view('Medical/Med_Item_List', $data, true); + $data['content']=$this->load->view('Medical/Med_Item_List',$data,true); - if ($data['invoiceMaster'][0]->sale_return == 0) { - $this->load->view('Medical/Medical_Invoice_V', $data); - } else { - $this->load->view('Medical/Medical_Invoice_Return_V', $data); + if($data['invoiceMaster'][0]->sale_return==0) + { + $this->load->view('Medical/Medical_Invoice_V',$data); + }else{ + $this->load->view('Medical/Medical_Invoice_Return_V',$data); } + + } @@ -1613,46 +1584,48 @@ class Medical extends MY_Controller $user = $this->ion_auth->user()->row(); $data['user_id'] = $user->id; - $inv_id = $this->input->post('med_invoice_id'); - $pid = $this->input->post('pid'); + $inv_id=$this->input->post('med_invoice_id'); + $pid=$this->input->post('pid'); - $sql = "select * from invoice_med_master where id=" . $inv_id; + $sql="select * from invoice_med_master where id=".$inv_id; $query = $this->db->query($sql); - $invoice_master = $query->result(); + $invoice_master= $query->result(); - $sql = "select * from patient_master_exten where id='" . $pid . "' "; + $sql="select * from patient_master_exten where id='".$pid."' "; $query = $this->db->query($sql); - $person_info = $query->result(); + $person_info= $query->result(); - if (count($person_info) > 0) { - $patient_id = $person_info[0]->id; - $patient_code_u = $person_info[0]->p_code; - $custmer_Name = $person_info[0]->p_fname; + if(count($person_info)>0) + { + $patient_id=$person_info[0]->id; + $patient_code_u=$person_info[0]->p_code; + $custmer_Name=$person_info[0]->p_fname; $data = array( - 'customer_type' => 1, + 'customer_type'=>1, 'patient_id' => $patient_id, - 'patient_code' => $patient_code_u, + 'patient_code' => $patient_code_u, 'inv_name' => $custmer_Name, - 'ipd_credit' => 0, - 'case_credit' => 0, - 'case_credit' => 0, - ); + 'ipd_credit'=>0, + 'case_credit'=>0, + 'case_credit'=>0, + ); - $inser_id = $this->Medical_M->update_in_upv_item($data, $inv_id); + $inser_id=$this->Medical_M->update_in_upv_item($data,$inv_id); $this->Medical_M->update_invoice_group($inv_id); $this->Medical_M->update_invoice_final($inv_id); - $status = 1; - $remark = "Done"; - } else { - $status = 0; - $remark = "Not Done"; + $status= 1; + $remark="Done"; + + }else{ + $status=0; + $remark="Not Done"; } - $rvar = array( - 'status' => $status, - 'remark' => $remark - ); + $rvar=array( + 'status' =>$status, + 'remark'=>$remark + ); $encode_data = json_encode($rvar); echo $encode_data; @@ -1665,56 +1638,58 @@ class Medical extends MY_Controller $user = $this->ion_auth->user()->row(); $data['user_id'] = $user->id; - $inv_id = $this->input->post('med_invoice_id'); - $ipd_id = $this->input->post('ipd_id'); + $inv_id=$this->input->post('med_invoice_id'); + $ipd_id=$this->input->post('ipd_id'); - $sql = "select * from invoice_med_master where id=" . $inv_id; + $sql="select * from invoice_med_master where id=".$inv_id; $query = $this->db->query($sql); - $invoice_master = $query->result(); + $invoice_master= $query->result(); - $sql = "select * from ipd_master where id=" . $ipd_id; + $sql="select * from ipd_master where id=".$ipd_id; $query = $this->db->query($sql); - $ipd_master = $query->result(); + $ipd_master= $query->result(); - $pid = $ipd_master[0]->p_id; + $pid=$ipd_master[0]->p_id; - $sql = "select * from patient_master_exten where id='" . $pid . "' "; + $sql="select * from patient_master_exten where id='".$pid."' "; $query = $this->db->query($sql); - $person_info = $query->result(); + $person_info= $query->result(); - if (count($person_info) > 0) { - $patient_id = $person_info[0]->id; - $patient_code_u = $person_info[0]->p_code; - $custmer_Name = $person_info[0]->p_fname; + if(count($person_info)>0) + { + $patient_id=$person_info[0]->id; + $patient_code_u=$person_info[0]->p_code; + $custmer_Name=$person_info[0]->p_fname; - $ipd_id = $ipd_master[0]->id; - $ipd_code = $ipd_master[0]->ipd_code; + $ipd_id=$ipd_master[0]->id; + $ipd_code=$ipd_master[0]->ipd_code; $data = array( - 'customer_type' => 1, + 'customer_type'=>1, 'patient_id' => $patient_id, - 'patient_code' => $patient_code_u, + 'patient_code' => $patient_code_u, 'inv_name' => $custmer_Name, - 'ipd_credit' => 0, - 'case_credit' => 0, - 'ipd_id' => $ipd_id, - 'ipd_code' => $ipd_code, - ); + 'ipd_credit'=>0, + 'case_credit'=>0, + 'ipd_id'=> $ipd_id, + 'ipd_code'=>$ipd_code, + ); - $inser_id = $this->Medical_M->update_in_upv_item($data, $inv_id); + $inser_id=$this->Medical_M->update_in_upv_item($data,$inv_id); $this->Medical_M->update_invoice_group($inv_id); $this->Medical_M->update_invoice_final($inv_id); - $status = 1; - $remark = "Done"; - } else { - $status = 0; - $remark = "Not Done"; + $status= 1; + $remark="Done"; + + }else{ + $status=0; + $remark="Not Done"; } - $rvar = array( - 'status' => $status, - 'remark' => $remark - ); + $rvar=array( + 'status' =>$status, + 'remark'=>$remark + ); $encode_data = json_encode($rvar); echo $encode_data; } @@ -1726,57 +1701,59 @@ class Medical extends MY_Controller $user = $this->ion_auth->user()->row(); $data['user_id'] = $user->id; - $inv_id = $this->input->post('med_invoice_id'); - $org_id = $this->input->post('org_id'); + $inv_id=$this->input->post('med_invoice_id'); + $org_id=$this->input->post('org_id'); - $sql = "select * from invoice_med_master where id=" . $inv_id; + $sql="select * from invoice_med_master where id=".$inv_id; $query = $this->db->query($sql); - $invoice_master = $query->result(); + $invoice_master= $query->result(); - $sql = "select * from organization_case_master where case_type=0 and id=" . $org_id; + $sql="select * from organization_case_master where case_type=0 and id=".$org_id; $query = $this->db->query($sql); - $org_master = $query->result(); + $org_master= $query->result(); - $pid = $org_master[0]->p_id; + $pid=$org_master[0]->p_id; - $sql = "select * from patient_master_exten where id='" . $pid . "' "; + $sql="select * from patient_master_exten where id='".$pid."' "; $query = $this->db->query($sql); - $person_info = $query->result(); + $person_info= $query->result(); - if (count($person_info) > 0) { - $patient_id = $person_info[0]->id; - $patient_code_u = $person_info[0]->p_code; - $custmer_Name = $person_info[0]->p_fname; + if(count($person_info)>0) + { + $patient_id=$person_info[0]->id; + $patient_code_u=$person_info[0]->p_code; + $custmer_Name=$person_info[0]->p_fname; - $org_id = $org_master[0]->id; - $org_code = $org_master[0]->case_id_code; + $org_id=$org_master[0]->id; + $org_code=$org_master[0]->case_id_code; $data = array( - 'customer_type' => 1, + 'customer_type'=>1, 'patient_id' => $patient_id, - 'patient_code' => $patient_code_u, + 'patient_code' => $patient_code_u, 'inv_name' => $custmer_Name, - 'ipd_credit' => 0, - 'case_credit' => 1, - 'ipd_id' => 0, - 'ipd_code' => '', - 'case_id' => $org_id, - ); + 'ipd_credit'=>0, + 'case_credit'=>1, + 'ipd_id'=> 0, + 'ipd_code'=>'', + 'case_id'=>$org_id, + ); - $inser_id = $this->Medical_M->update_in_upv_item($data, $inv_id); + $inser_id=$this->Medical_M->update_in_upv_item($data,$inv_id); $this->Medical_M->update_invoice_group($inv_id); $this->Medical_M->update_invoice_final($inv_id); - $status = 1; - $remark = "Done"; - } else { - $status = 0; - $remark = "Not Done"; + $status= 1; + $remark="Done"; + + }else{ + $status=0; + $remark="Not Done"; } - $rvar = array( - 'status' => $status, - 'remark' => $remark - ); + $rvar=array( + 'status' =>$status, + 'remark'=>$remark + ); $encode_data = json_encode($rvar); echo $encode_data; } @@ -1785,28 +1762,28 @@ class Medical extends MY_Controller { $this->load->model('Medical_M'); - $inv_id = $this->input->post('med_invoice_id'); - $inv_date = $this->input->post('inv_date'); + $inv_id=$this->input->post('med_invoice_id'); + $inv_date=$this->input->post('inv_date'); - $sql = "select * from invoice_med_master where id=" . $inv_id; + $sql="select * from invoice_med_master where id=".$inv_id; $query = $this->db->query($sql); - $invoice_master = $query->result(); - - $inv_date = str_to_MysqlDate($inv_date); + $invoice_master= $query->result(); + $inv_date=str_to_MysqlDate($inv_date); + $data = array( 'inv_date' => $inv_date, - ); + ); - $inser_id = $this->Medical_M->update_in_upv_item($data, $inv_id); - - $status = 1; - $remark = "Done"; - - $rvar = array( - 'status' => $status, - 'remark' => $remark - ); + $inser_id=$this->Medical_M->update_in_upv_item($data,$inv_id); + + $status= 1; + $remark="Done"; + + $rvar=array( + 'status' =>$status, + 'remark'=>$remark + ); $encode_data = json_encode($rvar); echo $encode_data; } @@ -1815,50 +1792,51 @@ class Medical extends MY_Controller { $this->load->model('Medical_M'); - $inv_id = $this->input->post('med_invoice_id'); - $pid = $this->input->post('pid'); - $customer_type = $this->input->post('customer_type'); - $P_Name = $this->input->post('P_Name'); - $P_Phone = $this->input->post('P_Phone'); + $inv_id=$this->input->post('med_invoice_id'); + $pid=$this->input->post('pid'); + $customer_type=$this->input->post('customer_type'); + $P_Name=$this->input->post('P_Name'); + $P_Phone=$this->input->post('P_Phone'); - $doc_id = $this->input->post('doc_id'); - $doc_name = $this->input->post('doc_name'); + $doc_id=$this->input->post('doc_id'); + $doc_name=$this->input->post('doc_name'); + + $refername=$doc_name; - $refername = $doc_name; - - $sql = "select * from doctor_master where id='" . $doc_id . "' "; + $sql="select * from doctor_master where id='".$doc_id."' "; $query = $this->db->query($sql); - $doc_info = $query->result(); - - if (count($doc_info) > 0) { - $refername = $doc_info[0]->p_fname; + $doc_info= $query->result(); + + if(count($doc_info)>0) + { + $refername=$doc_info[0]->p_fname; } - + $data = array( - 'customer_type' => $customer_type, + 'customer_type'=>$customer_type, 'patient_id' => '0', - 'patient_code' => '', + 'patient_code' => '', 'inv_name' => $P_Name, 'inv_phone_number' => $P_Phone, - 'ipd_credit' => 0, - 'case_credit' => 0, - 'ipd_id' => 0, - 'ipd_code' => '', - 'case_id' => '0', + 'ipd_credit'=>0, + 'case_credit'=>0, + 'ipd_id'=> 0, + 'ipd_code'=>'', + 'case_id'=>'0', 'doc_id' => $doc_id, - 'doc_name' => $refername, - ); + 'doc_name' => $refername, + ); - $inser_id = $this->Medical_M->update_in_upv_item($data, $inv_id); - - $status = 1; - $remark = "Done"; - - $rvar = array( - 'status' => $status, - 'remark' => $remark - ); + $inser_id=$this->Medical_M->update_in_upv_item($data,$inv_id); + + $status= 1; + $remark="Done"; + + $rvar=array( + 'status' =>$status, + 'remark'=>$remark + ); $encode_data = json_encode($rvar); echo $encode_data; } @@ -1867,35 +1845,36 @@ class Medical extends MY_Controller { $this->load->model('Medical_M'); - $inv_id = $this->input->post('med_invoice_id'); + $inv_id=$this->input->post('med_invoice_id'); + + $doc_id=$this->input->post('doc_id'); + $doc_name=$this->input->post('doc_name'); + + $refername=$doc_name; - $doc_id = $this->input->post('doc_id'); - $doc_name = $this->input->post('doc_name'); - - $refername = $doc_name; - - $sql = "select * from doctor_master where id='" . $doc_id . "' "; + $sql="select * from doctor_master where id='".$doc_id."' "; $query = $this->db->query($sql); - $doc_info = $query->result(); - - if (count($doc_info) > 0) { - $refername = $doc_info[0]->p_fname; + $doc_info= $query->result(); + + if(count($doc_info)>0) + { + $refername=$doc_info[0]->p_fname; } - + $data = array( 'doc_id' => $doc_id, - 'doc_name' => $refername, - ); + 'doc_name' => $refername, + ); - $inser_id = $this->Medical_M->update_in_upv_item($data, $inv_id); - - $status = 1; - $remark = "Done"; - - $rvar = array( - 'status' => $status, - 'remark' => $remark - ); + $inser_id=$this->Medical_M->update_in_upv_item($data,$inv_id); + + $status= 1; + $remark="Done"; + + $rvar=array( + 'status' =>$status, + 'remark'=>$remark + ); $encode_data = json_encode($rvar); echo $encode_data; } @@ -1905,50 +1884,50 @@ class Medical extends MY_Controller { $this->load->model('Medical_M'); - $inv_id = $this->input->post('med_invoice_id'); - $credit_ipd = $this->input->post('credit_ipd'); + $inv_id=$this->input->post('med_invoice_id'); + $credit_ipd=$this->input->post('credit_ipd'); - $sql = "select * from invoice_med_master where id=" . $inv_id; + $sql="select * from invoice_med_master where id=".$inv_id; $query = $this->db->query($sql); - $invoice_master = $query->result(); - - $ipd_id = $invoice_master[0]->ipd_id; + $invoice_master= $query->result(); + $ipd_id=$invoice_master[0]->ipd_id; + $data = array( 'ipd_credit' => $credit_ipd, - ); + ); - $inser_id = $this->Medical_M->update_in_upv_item($data, $inv_id); + $inser_id=$this->Medical_M->update_in_upv_item($data,$inv_id); + + $status= 1; + $remark="Done"; - $status = 1; - $remark = "Done"; - - $this->Medical_M->update_invoice_group_gst($ipd_id, '1'); - $this->Medical_M->update_invoice_group_gst($ipd_id, '2'); - $this->Medical_M->update_invoice_group_gst($ipd_id, '3'); - - $rvar = array( - 'status' => $status, - 'remark' => $remark - ); + $this->Medical_M->update_invoice_group_gst($ipd_id,'1'); + $this->Medical_M->update_invoice_group_gst($ipd_id,'2'); + $this->Medical_M->update_invoice_group_gst($ipd_id,'3'); + + $rvar=array( + 'status' =>$status, + 'remark'=>$remark + ); $encode_data = json_encode($rvar); echo $encode_data; } // End Update Medical Invoice Master - - public function search_customer($sale = 0) + + public function search_customer($sale=0) { - $data['sale'] = $sale; - $this->load->view('Medical/Search_Patient', $data); + $data['sale']=$sale; + $this->load->view('Medical/Search_Patient',$data); } - public function check_invoice($pno, $ipd_id, $case_id) + public function check_invoice($pno,$ipd_id,$case_id) { - $sql = "select * - from invoice_med_master where inv_date=curdate() and patient_id='" . $pno . "' "; + $sql="select * + from invoice_med_master where inv_date=curdate() and patient_id='".$pno."' "; - $sql = "SELECT m.id AS inv_id,m.inv_med_code,m.inv_date,m.inv_name,m.inv_phone_number, + $sql="SELECT m.id AS inv_id,m.inv_med_code,m.inv_date,m.inv_name,m.inv_phone_number, i.*,date_format(i.expiry,'%m-%Y') as exp_date,(i.disc_amount+disc_whole) as t_discount, m.net_amount FROM (invoice_med_master m JOIN inv_med_item i ON m.id=i.inv_med_id AND m.sale_return=0) @@ -1956,88 +1935,95 @@ class Medical extends MY_Controller order by m.id desc"; $query = $this->db->query($sql); - $data['med_inv_item_list'] = $query->result(); + $data['med_inv_item_list']= $query->result(); - $data['pno'] = $pno; - $data['ipd_id'] = $ipd_id; - $data['case_id'] = $case_id; + $data['pno']=$pno; + $data['ipd_id']=$ipd_id; + $data['case_id']=$case_id; - $content = ""; + $content=""; - if (count($data['med_inv_item_list']) > 0) { + if(count($data['med_inv_item_list'])>0){ + + $this->load->view('Medical/mini_invoice',$data); - $this->load->view('Medical/mini_invoice', $data); - } else { - redirect('Medical/Invoice_counter_new/' . $pno . '/' . $ipd_id . '/' . $case_id); + }else{ + redirect('Medical/Invoice_counter_new/'.$pno.'/'.$ipd_id.'/'.$case_id); } - } - public function Invoice_counter_new($pno, $ipd_id, $case_id) - { + } + + public function Invoice_counter_new($pno,$ipd_id,$case_id) + { + + $select_doc=0; + $p_fname=''; + $p_pcode=''; + $p_pid=$pno; + $p_ipd_id=$ipd_id; + $p_ipd_code=''; + $customer_type=0; + $group_invoice_id=0; + + $select_doc=0; + $data['org_Name']=""; + $data['content']=""; - $select_doc = 0; - $p_fname = ''; - $p_pcode = ''; - $p_pid = $pno; - $p_ipd_id = $ipd_id; - $p_ipd_code = ''; - $customer_type = 0; - $group_invoice_id = 0; - - $select_doc = 0; - $data['org_Name'] = ""; - $data['content'] = ""; - - if ($pno > 0) { - $sql = "select *,if(gender=1,'Male','Female') as xgender, - GET_AGE_1(dob,age,age_in_month,estimate_dob) AS age from patient_master where id='" . $pno . "' "; + if($pno>0) + { + $sql="select *,if(gender=1,'Male','Female') as xgender, + GET_AGE_1(dob,age,age_in_month,estimate_dob) AS age from patient_master where id='".$pno."' "; $query = $this->db->query($sql); - $person_info = $query->result(); + $person_info= $query->result(); - $sql = "select doc_id from opd_master where p_id='" . $pno . "' order by opd_id desc limit 1"; + $sql="select doc_id from opd_master where p_id='".$pno."' order by opd_id desc limit 1"; $query = $this->db->query($sql); - $data['opd_master'] = $query->result(); + $data['opd_master']= $query->result(); - $p_fname = $person_info[0]->p_fname; - $p_pcode = $person_info[0]->p_code; + $p_fname=$person_info[0]->p_fname; + $p_pcode=$person_info[0]->p_code; - if (count($data['opd_master']) > 0) { - $select_doc = $data['opd_master'][0]->doc_id; - } else { - $select_doc = 0; + if(count($data['opd_master'])>0) + { + $select_doc=$data['opd_master'][0]->doc_id; + }else{ + $select_doc=0; } - $customer_type = 1; + $customer_type=1; } - - if ($ipd_id > 0) { - $sql = "select * from ipd_master where id=" . $ipd_id; + + if($ipd_id>0) + { + $sql="select * from ipd_master where id=".$ipd_id; $query = $this->db->query($sql); - $data['ipd_master'] = $query->result(); + $data['ipd_master']= $query->result(); - $sql = "select * from v_ipd_list m join patient_master p on m.p_id=p.id - where m.id=" . $ipd_id; + $sql="select * from v_ipd_list m join patient_master p on m.p_id=p.id + where m.id=".$ipd_id; $query = $this->db->query($sql); - $data['ipd_list'] = $query->result(); + $data['ipd_list']= $query->result(); - $p_ipd_code = $data['ipd_master'][0]->ipd_code; + $p_ipd_code=$data['ipd_master'][0]->ipd_code; - $group_invoice_id = 1; + $group_invoice_id=1; - if ($data['ipd_master'][0]->case_id > 0) { - $sql = "select * from organization_case_master where id=" . $data['ipd_master'][0]->case_id; + if($data['ipd_master'][0]->case_id>0) + { + $sql="select * from organization_case_master where id=".$data['ipd_master'][0]->case_id; $query = $this->db->query($sql); - $org_master = $query->result(); - - if (count($org_master) > 0) { - $data['org_Name'] = $org_master[0]->insurance_company_name; + $org_master= $query->result(); + + if(count($org_master)>0) + { + $data['org_Name']=$org_master[0]->insurance_company_name; } } } - + $this->load->model('Medical_M'); - - $data['invoice_med_master'] = array( + + $data['invoice_med_master'] = array( 'patient_id' => $p_pid, 'ipd_id' => $p_ipd_id, 'ipd_code' => $p_ipd_code, @@ -2046,127 +2032,131 @@ class Medical extends MY_Controller 'inv_name' => $p_fname, 'patient_code' => $p_pcode, 'doc_id' => $select_doc, - 'sale_return' => 0, - 'case_credit' => 0, - 'customer_type' => $customer_type, - 'group_invoice_id' => $group_invoice_id, + 'sale_return'=>0, + 'case_credit'=>0, + 'customer_type'=>$customer_type, + 'group_invoice_id'=>$group_invoice_id, ); - if ($case_id > 0) { - $data['invoice_med_master']['case_credit'] = 1; + if($case_id>0) + { + $data['invoice_med_master']['case_credit']=1; } + + + $inser_id=$this->Medical_M->add_invoice( $data['invoice_med_master']); - - $inser_id = $this->Medical_M->add_invoice($data['invoice_med_master']); - - if ($inser_id) { - $sql = "select *,if(ipd_credit>0,'Credit to IPD','CASH') as credit_status from invoice_med_master where id=" . $inser_id; + if($inser_id) + { + $sql="select *,if(ipd_credit>0,'Credit to IPD','CASH') as credit_status from invoice_med_master where id=".$inser_id; $query = $this->db->query($sql); - $data['invoiceMaster'] = $query->result(); + $data['invoiceMaster']= $query->result(); - $sql = "SELECT i.*,ifnull(DATEDIFF(expiry,CURDATE()),1000) AS no_day, + $sql="SELECT i.*,ifnull(DATEDIFF(expiry,CURDATE()),1000) AS no_day, SUM(p.total_unit-p.total_sale_unit-total_return_unit-total_lost_unit)/p.packing AS cur_qty FROM (inv_med_item i JOIN purchase_invoice_item p ON i.item_code=p.item_code AND p.remove_item=0 ) - where inv_med_id=" . $inser_id . " GROUP BY i.id"; + where inv_med_id=".$inser_id." GROUP BY i.id"; $query = $this->db->query($sql); - $data['inv_items'] = $query->result(); + $data['inv_items']= $query->result(); - $sql = "select item_code - from inv_med_item where inv_med_id=" . $inser_id . " Group by item_code Having count(id)>1"; + $sql="select item_code + from inv_med_item where inv_med_id=".$inser_id." Group by item_code Having count(id)>1"; $query = $this->db->query($sql); - $data['inv_items_multiple'] = $query->result(); + $data['inv_items_multiple']= $query->result(); - $sql = "select sum(amount) as Gtotal,sum(tamount) as tamt,sum(CGST) as TCGST,sum(SGST) as TSGST,sum(disc_amount) as t_dis_amt from inv_med_item where inv_med_id=" . $inser_id; + $sql="select sum(amount) as Gtotal,sum(tamount) as tamt,sum(CGST) as TCGST,sum(SGST) as TSGST,sum(disc_amount) as t_dis_amt from inv_med_item where inv_med_id=".$inser_id; $query = $this->db->query($sql); - $data['invoiceGtotal'] = $query->result(); + $data['invoiceGtotal']= $query->result(); - $sql = "select * from doctor_master where active=1"; + $sql="select * from doctor_master where active=1"; $query = $this->db->query($sql); - $data['doclist'] = $query->result(); + $data['doclist']= $query->result(); - $sql = "select * from organization_case_master where id=" . $case_id; + $sql="select * from organization_case_master where id=".$case_id; $query = $this->db->query($sql); - $data['OCaseMaster'] = $query->result(); + $data['OCaseMaster']= $query->result(); - $data['sale_return'] = $data['invoiceMaster'][0]->sale_return; + $data['sale_return']=$data['invoiceMaster'][0]->sale_return; - $data['content'] = $this->load->view('Medical/Med_Item_List', $data, true); - - $this->load->view('Medical/Medical_Invoice_V', $data); + $data['content']=$this->load->view('Medical/Med_Item_List',$data,true); + + $this->load->view('Medical/Medical_Invoice_V',$data); } } public function Invoice_Return_new($pno) - { + { + + $select_doc=0; + $p_fname=''; + $p_pcode=''; + $p_pid=$pno; + $inv_phone_number=''; - $select_doc = 0; - $p_fname = ''; - $p_pcode = ''; - $p_pid = $pno; - $inv_phone_number = ''; - - $data['content'] = ''; - - if ($pno > 0) { - $sql = "select *,if(gender=1,'Male','Female') as xgender, - GET_AGE_1(dob,age,age_in_month,estimate_dob) AS age from patient_master where id='" . $pno . "' "; + $data['content']=''; + + if($pno>0) + { + $sql="select *,if(gender=1,'Male','Female') as xgender, + GET_AGE_1(dob,age,age_in_month,estimate_dob) AS age from patient_master where id='".$pno."' "; $query = $this->db->query($sql); - $person_info = $query->result(); + $person_info= $query->result(); - $p_fname = $person_info[0]->p_fname; - $p_pcode = $person_info[0]->p_code; - $inv_phone_number = $person_info[0]->mphone1; + $p_fname=$person_info[0]->p_fname; + $p_pcode=$person_info[0]->p_code; + $inv_phone_number=$person_info[0]->mphone1; - $select_doc = 0; + $select_doc=0; } $this->load->model('Medical_M'); - - $data['invoice_med_master'] = array( - 'patient_id' => $p_pid, - 'inv_date' => str_to_MysqlDate(date('d/m/Y')), + + $data['invoice_med_master'] = array( + 'patient_id' => $p_pid, + 'inv_date' => str_to_MysqlDate(date('d/m/Y')), 'inv_name' => $p_fname, 'patient_code' => $p_pcode, 'doc_id' => $select_doc, - 'inv_phone_number' => $inv_phone_number, - 'sale_return' => 1 + 'inv_phone_number'=>$inv_phone_number, + 'sale_return'=>1 ); + + $inser_id=$this->Medical_M->add_invoice( $data['invoice_med_master']); - $inser_id = $this->Medical_M->add_invoice($data['invoice_med_master']); - - if ($inser_id) { - $sql = "select *,if(ipd_credit>0,'Credit to IPD','CASH') as credit_status from invoice_med_master where id=" . $inser_id; + if($inser_id) + { + $sql="select *,if(ipd_credit>0,'Credit to IPD','CASH') as credit_status from invoice_med_master where id=".$inser_id; $query = $this->db->query($sql); - $data['invoiceMaster'] = $query->result(); + $data['invoiceMaster']= $query->result(); - $sql = "SELECT i.*,ifnull(DATEDIFF(expiry,CURDATE()),1000) AS no_day, + $sql="SELECT i.*,ifnull(DATEDIFF(expiry,CURDATE()),1000) AS no_day, SUM(p.total_unit-p.total_sale_unit-total_return_unit-total_lost_unit)/p.packing AS cur_qty FROM (inv_med_item i JOIN purchase_invoice_item p ON i.item_code=p.item_code AND p.remove_item=0 ) - where inv_med_id=" . $inser_id . " GROUP BY i.id"; + where inv_med_id=".$inser_id." GROUP BY i.id"; $query = $this->db->query($sql); - $data['inv_items'] = $query->result(); + $data['inv_items']= $query->result(); - $sql = "select item_code - from inv_med_item where inv_med_id=" . $inser_id . " Group by item_code Having count(id)>1"; + $sql="select item_code + from inv_med_item where inv_med_id=".$inser_id." Group by item_code Having count(id)>1"; $query = $this->db->query($sql); - $data['inv_items_multiple'] = $query->result(); + $data['inv_items_multiple']= $query->result(); - $sql = "select sum(amount) as Gtotal,sum(tamount) as tamt,sum(CGST) as TCGST,sum(SGST) as TSGST,sum(disc_amount) as t_dis_amt from inv_med_item where inv_med_id=" . $inser_id; + $sql="select sum(amount) as Gtotal,sum(tamount) as tamt,sum(CGST) as TCGST,sum(SGST) as TSGST,sum(disc_amount) as t_dis_amt from inv_med_item where inv_med_id=".$inser_id; $query = $this->db->query($sql); - $data['invoiceGtotal'] = $query->result(); + $data['invoiceGtotal']= $query->result(); - $data['sale_return'] = $data['invoiceMaster'][0]->sale_return; + $data['sale_return']=$data['invoiceMaster'][0]->sale_return; - $data['content'] = $this->load->view('Medical/Med_Item_List', $data, true); + $data['content']=$this->load->view('Medical/Med_Item_List',$data,true); - $this->load->view('Medical/Medical_Invoice_Return_V', $data); + $this->load->view('Medical/Medical_Invoice_Return_V',$data); } } public function item_stock_list($item_code) { - $sql = "SELECT p.item_name,t.batch_no,t.expiry_date as expiry_date_str,t.expiry_date, + $sql="SELECT p.item_name,t.batch_no,t.expiry_date as expiry_date_str,t.expiry_date, (t.total_unit-t.total_sale_unit-total_lost_unit-t.total_return_unit) AS c_qty, t.id,t.mrp,t.selling_unit_rate,p.id AS item_code FROM med_product_master p @@ -2176,86 +2166,82 @@ class Medical extends MY_Controller and p.id =$item_code"; $query = $this->db->query($sql); - $data['Item_list'] = $query->result_array(); + $data['Item_list']=$query->result_array() ; - $this->load->view('Medical/sale_item_list_for_add', $data); + $this->load->view('Medical/sale_item_list_for_add',$data); } - - public function get_drug() - { - if (isset($_GET['term'])) { + + public function get_drug(){ + if (isset($_GET['term'])){ $q = strtolower($_GET['term']); - $sql = "SELECT p.item_name as item_name,p.formulation,t.batch_no,t.expiry_date as expiry_date_str,t.expiry_date, - DATEDIFF(LAST_DAY(t.expiry_date),curdate()) as expiry_month_pending, + $sql="SELECT p.item_name as item_name,p.formulation,t.batch_no,t.expiry_date as expiry_date_str,t.expiry_date, + DATEDIFF(t.expiry_date,curdate()) as expiry_month_pending, (t.total_unit-t.total_sale_unit-total_lost_unit-t.total_return_unit) AS c_qty, - t.id,t.mrp,t.selling_unit_rate,p.id AS item_code,t.packing,if(t.stock_date>'2025-09-21',1,0) as new_stock + t.id,t.mrp,t.selling_unit_rate,p.id AS item_code,t.packing FROM med_product_master p JOIN purchase_invoice_item t ON p.id=t.item_code and (t.total_unit-t.total_sale_unit-t.total_lost_unit-t.total_return_unit)>0 and t.remove_item=0 and t.item_return=0 - and (LAST_DAY(expiry_date)>date_add(sysdate(),interval -15 day) or p.exp_date_applicable=0) - where (p.item_name like '" . $q . "%' "; + and (expiry_date>date_add(sysdate(),interval -1 month) or p.exp_date_applicable=0) + where (p.item_name like '".$q."%' or p.genericname like '".$q."%'"; - if (strlen($q) > 5) { - $sql = $sql . " or p.item_name SOUNDS LIKE '" . $q . "' or p.genericname like '%" . $q . "%'"; + if(strlen($q)>5) + { + $sql=$sql. " or p.item_name SOUNDS LIKE '".$q."'"; } - $sql = $sql . ") order by p.item_name,t.id limit 100"; - + $sql=$sql.") order by p.item_name,id limit 100"; + $query = $this->db->query($sql); + + if($query->num_rows() > 0){ + foreach ($query->result_array() as $row){ + $msg_desc=''; + $no_exp_month=Round($row['expiry_month_pending']/30,0); - if ($query->num_rows() > 0) { - foreach ($query->result_array() as $row) { - $msg_desc = ''; - $no_exp_month = Round($row['expiry_month_pending'] / 30, 2); - - if ($no_exp_month <= 4 && $no_exp_month >= 2) { - $msg_desc .= ' Expire Within : ' . htmlentities(stripslashes($no_exp_month)) . ' Month '; - } elseif ($no_exp_month == 1) { - $msg_desc .= ' Expired : ' . htmlentities(stripslashes($no_exp_month)) . ' Month '; - } elseif ($no_exp_month < 1) { - $msg_desc .= ' Expired : ' . htmlentities(stripslashes($no_exp_month)) . ' Month '; - } - - - $new_row['label'] = htmlentities(stripslashes($row['item_name'] . ' ' . $row['formulation'])) . ' |B:' . htmlentities(stripslashes($row['batch_no'])) . ' |Pak:' . htmlentities(stripslashes($row['packing'])) . ' |Rs.' . htmlentities(stripslashes($row['mrp'])) . ' |Qty:' . htmlentities(stripslashes($row['c_qty'])); - $new_row['value'] = htmlentities(stripslashes($row['item_name'])); - $new_row['expiry_alert'] = htmlentities(stripslashes($no_exp_month)); - $new_row['desc'] = $msg_desc; - $new_row['l_item_code'] = htmlentities(stripslashes($row['item_code'])); - $new_row['l_ss_no'] = htmlentities(stripslashes($row['id'])); - $new_row['l_Batch'] = htmlentities(stripslashes($row['batch_no'])); - $new_row['l_Expiry'] = htmlentities(stripslashes($row['expiry_date_str'])); - $new_row['l_mrp'] = htmlentities(stripslashes($row['mrp'])); - $new_row['l_unit_rate'] = htmlentities(stripslashes($row['selling_unit_rate'])); - $new_row['l_c_qty'] = htmlentities(stripslashes($row['c_qty'])); - $new_row['l_packing'] = htmlentities(stripslashes($row['packing'])); - $new_row['l_new_stock'] = htmlentities(stripslashes($row['new_stock'])); - $new_row['sql'] = $sql; - $row_set[] = $new_row; //build an array + if($no_exp_month<=4 && $no_exp_month>=2){ + $msg_desc.=' Expire Within : '.htmlentities(stripslashes($no_exp_month)).' Month '; + }elseif($no_exp_month<2){ + $msg_desc.=' Expired : '.htmlentities(stripslashes($no_exp_month)).' Month '; } - echo json_encode($row_set); //format the array into json data - } else { + + + $new_row['label']=htmlentities(stripslashes($row['item_name'].' '.$row['formulation'])).' |B:'.htmlentities(stripslashes($row['batch_no'])). ' |Pak:'.htmlentities(stripslashes($row['packing'])).' |Rs.'.htmlentities(stripslashes($row['mrp'])).' |Qty:'.htmlentities(stripslashes($row['c_qty'])); + $new_row['value']=htmlentities(stripslashes($row['item_name'])); + $new_row['expiry_alert']=htmlentities(stripslashes($no_exp_month)); + $new_row['desc']=$msg_desc; + $new_row['l_item_code']=htmlentities(stripslashes($row['item_code'])); + $new_row['l_ss_no']=htmlentities(stripslashes($row['id'])); + $new_row['l_Batch']=htmlentities(stripslashes($row['batch_no'])); + $new_row['l_Expiry']=htmlentities(stripslashes($row['expiry_date_str'])); + $new_row['l_mrp']=htmlentities(stripslashes($row['mrp'])); + $new_row['l_unit_rate']=htmlentities(stripslashes($row['selling_unit_rate'])); + $new_row['l_c_qty']=htmlentities(stripslashes($row['c_qty'])); + $new_row['l_packing']=htmlentities(stripslashes($row['packing'])); + //$new_row['sql']=$sql; + $row_set[] = $new_row; //build an array + } + echo json_encode($row_set); //format the array into json data + }else{ //$new_row['sql']=$sql; //$row_set[] = $new_row; echo json_encode($row_set); } } } - - public function get_drug_master() - { - - if (isset($_GET['term'])) { + + public function get_drug_master(){ + + if (isset($_GET['term'])){ $q = strtolower($_GET['term']); - $sql = "select * from purchase_invoice_item p + $sql="select * from purchase_invoice_item p where p.id in (select max(id) from purchase_invoice_item t - where t.Item_name like '" . $q . "%' group by t.Item_name ) + where t.Item_name like '".$q."%' group by t.Item_name ) order by p.Item_name "; - - $sql = "SELECT m.* ,p.id as ss_no,m.packing as p_packing,p.mrp,p.purchase_price,p.discount, + + $sql="SELECT m.* ,p.id as ss_no,m.packing as p_packing,p.mrp,p.purchase_price,p.discount, p.batch_no,date_format(expiry_date,'%m') as str_expiry_month , date_format(expiry_date,'%y') as str_expiry_year , m.batch_applicable,m.exp_date_applicable, @@ -2268,225 +2254,230 @@ class Medical extends MY_Controller FROM med_product_master m LEFT JOIN (SELECT * from purchase_invoice_item WHERE id in (select max(id) from purchase_invoice_item - WHERE Item_name LIKE '" . $q . "%' + WHERE Item_name LIKE '".$q."%' group BY item_code ) ) as p ON m.id=p.item_code - WHERE m.is_continue=1 and m.Item_name LIKE '" . $q . "%' + WHERE m.is_continue=1 and m.Item_name LIKE '".$q."%' order BY m.item_name "; - $sql = $sql . " limit 20"; + $sql=$sql." limit 20"; $query = $this->db->query($sql); + + if($query->num_rows() > 0){ + foreach ($query->result_array() as $row){ + $new_row['label']=htmlentities(stripslashes($row['item_name'])).' | '.htmlentities(stripslashes($row['p_packing'])).' | '.htmlentities(stripslashes($row['mrp'])); + $new_row['value']=htmlentities(stripslashes($row['item_name'])); + $new_row['l_item_code']=htmlentities(stripslashes($row['id'])); + $new_row['l_mrp']=htmlentities(stripslashes($row['mrp'])); + + $new_row['l_packing']=htmlentities(stripslashes($row['packing'])); + $new_row['l_CGST_per']=htmlentities(stripslashes($row['p_CGST_per'])); + $new_row['l_SGST_per']=htmlentities(stripslashes($row['p_SGST_per'])); + $new_row['l_HSNCODE']=htmlentities(stripslashes($row['HSNCODE'])); - if ($query->num_rows() > 0) { - foreach ($query->result_array() as $row) { - $new_row['label'] = htmlentities(stripslashes($row['item_name'])) . ' | ' . htmlentities(stripslashes($row['p_packing'])) . ' | ' . htmlentities(stripslashes($row['mrp'])); - $new_row['value'] = htmlentities(stripslashes($row['item_name'])); - $new_row['l_item_code'] = htmlentities(stripslashes($row['id'])); - $new_row['l_mrp'] = htmlentities(stripslashes($row['mrp'])); + $new_row['l_batch_no']=htmlentities(stripslashes($row['batch_no'])); + + $new_row['l_purchase_price']=htmlentities(stripslashes($row['purchase_price'])); + + $new_row['l_package']=htmlentities(stripslashes($row['p_packing'])); + $new_row['l_disc_price']=htmlentities(stripslashes($row['discount'])); - $new_row['l_packing'] = htmlentities(stripslashes($row['packing'])); - $new_row['l_CGST_per'] = htmlentities(stripslashes($row['p_CGST_per'])); - $new_row['l_SGST_per'] = htmlentities(stripslashes($row['p_SGST_per'])); - $new_row['l_HSNCODE'] = htmlentities(stripslashes($row['HSNCODE'])); + $new_row['l_rack_no']=htmlentities(stripslashes($row['p_rack_no'])); + $new_row['l_shelf_no']=htmlentities(stripslashes($row['p_shelf_no'])); + $new_row['l_cold_storage']=htmlentities(stripslashes($row['p_cold_storage'])); - $new_row['l_batch_no'] = htmlentities(stripslashes($row['batch_no'])); + $new_row['batch_applicable']=htmlentities(stripslashes($row['batch_applicable'])); + $new_row['exp_date_applicable']=htmlentities(stripslashes($row['exp_date_applicable'])); - $new_row['l_purchase_price'] = htmlentities(stripslashes($row['purchase_price'])); - - $new_row['l_package'] = htmlentities(stripslashes($row['p_packing'])); - $new_row['l_disc_price'] = htmlentities(stripslashes($row['discount'])); - - $new_row['l_rack_no'] = htmlentities(stripslashes($row['p_rack_no'])); - $new_row['l_shelf_no'] = htmlentities(stripslashes($row['p_shelf_no'])); - $new_row['l_cold_storage'] = htmlentities(stripslashes($row['p_cold_storage'])); - - $new_row['batch_applicable'] = htmlentities(stripslashes($row['batch_applicable'])); - $new_row['exp_date_applicable'] = htmlentities(stripslashes($row['exp_date_applicable'])); - - $new_row['datepicker_doe_month'] = htmlentities(stripslashes($row['str_expiry_month'])); - $new_row['datepicker_doe_year'] = htmlentities(stripslashes($row['str_expiry_year'])); - - $row_set[] = $new_row; //build an array - } - echo json_encode($row_set); //format the array into json data - } else { + $new_row['datepicker_doe_month']=htmlentities(stripslashes($row['str_expiry_month'])); + $new_row['datepicker_doe_year']=htmlentities(stripslashes($row['str_expiry_year'])); + + $row_set[] = $new_row; //build an array + } + echo json_encode($row_set); //format the array into json data + }else{ $row_set[] = array(); echo json_encode($row_set); } } } - - public function get_formulation_desc() - { - - if (isset($_GET['term'])) { + + public function get_formulation_desc(){ + + if (isset($_GET['term'])){ $q = strtolower($_GET['term']); - $sql = "select * from drugs_formulation where formulation_desc like '" . $q . "%'"; + $sql="select * from drugs_formulation where formulation_desc like '".$q."%'"; $query = $this->db->query($sql); - if ($query->num_rows() > 0) { - foreach ($query->result_array() as $row) { - $new_row['label'] = htmlentities(stripslashes($row['formulation_desc'])); - $new_row['value'] = htmlentities(stripslashes($row['formulation_desc'])); - $row_set[] = $new_row; //build an array - } - echo json_encode($row_set); //format the array into json data + if($query->num_rows() > 0){ + foreach ($query->result_array() as $row){ + $new_row['label']=htmlentities(stripslashes($row['formulation_desc'])); + $new_row['value']=htmlentities(stripslashes($row['formulation_desc'])); + $row_set[] = $new_row; //build an array + } + echo json_encode($row_set); //format the array into json data } } } - + public function go_final() { $this->load->model('Medical_M'); + + $inv_id=$this->input->post('inv_id'); + $doc_id=$this->input->post('doc_id'); + $doc_name=$this->input->post('doc_name'); + $remark_ipd=$this->input->post('input_remark_ipd'); + $patient_code=$this->input->post('patient_code'); + $custmer_Name=$this->input->post('custmer_Name'); + $ipd_credit=$this->input->post('ipd_credit'); - $inv_id = $this->input->post('inv_id'); - $doc_id = $this->input->post('doc_id'); - $doc_name = $this->input->post('doc_name'); - $remark_ipd = $this->input->post('input_remark_ipd'); - $patient_code = $this->input->post('patient_code'); - $custmer_Name = $this->input->post('custmer_Name'); - $ipd_credit = $this->input->post('ipd_credit'); + $org_credit=$this->input->post('org_credit'); + $inv_date=$this->input->post('inv_date'); - $org_credit = $this->input->post('org_credit'); - $inv_date = $this->input->post('inv_date'); - - $sql = "select * from patient_master where p_code='" . $patient_code . "' "; + $sql="select * from patient_master where p_code='".$patient_code."' "; $query = $this->db->query($sql); - $person_info = $query->result(); + $person_info= $query->result(); - $sql = "select * from doctor_master where id='" . $doc_id . "' "; + $sql="select * from doctor_master where id='".$doc_id."' "; $query = $this->db->query($sql); - $doc_info = $query->result(); - - $sql = "select * from invoice_med_master where id=" . $inv_id; + $doc_info= $query->result(); + + $sql="select * from invoice_med_master where id=".$inv_id; $query = $this->db->query($sql); - $data['invoice_master'] = $query->result(); + $data['invoice_master']= $query->result(); - if ($this->ion_auth->in_group('InvoiceDateChanged') || $this->ion_auth->in_group('admin')) { - $inv_date = str_to_MysqlDate($inv_date); - } else { - $inv_date = $data['invoice_master'][0]->inv_date; + if($this->ion_auth->in_group('InvoiceDateChanged') || $this->ion_auth->in_group('admin')) + { + $inv_date=str_to_MysqlDate($inv_date); + }else{ + $inv_date=$data['invoice_master'][0]->inv_date; + } + + if(count($person_info)>0) + { + $patient_id=$person_info[0]->id; + $patient_code_u=$patient_code; + $custmer_Name=$person_info[0]->p_fname; + }else{ + $patient_id=0; + $patient_code_u=''; + } + + $refername=$doc_name; + + if(count($doc_info)>0) + { + $refername=$doc_info[0]->p_fname; } - if (count($person_info) > 0) { - $patient_id = $person_info[0]->id; - $patient_code_u = $patient_code; - $custmer_Name = $person_info[0]->p_fname; - } else { - $patient_id = 0; - $patient_code_u = ''; - } + $data = array( + 'patient_id' => $patient_id, + 'patient_code' => $patient_code_u, + 'doc_id' => $doc_id, + 'doc_name' => $refername, + 'inv_name' => $custmer_Name, + 'remark_ipd'=>$remark_ipd, + 'ipd_credit'=>$ipd_credit, + 'case_credit'=>$org_credit, + 'inv_date' => $inv_date + ); - $refername = $doc_name; - - if (count($doc_info) > 0) { - $refername = $doc_info[0]->p_fname; - } - - $data = array( - 'patient_id' => $patient_id, - 'patient_code' => $patient_code_u, - 'doc_id' => $doc_id, - 'doc_name' => $refername, - 'inv_name' => $custmer_Name, - 'remark_ipd' => $remark_ipd, - 'ipd_credit' => $ipd_credit, - 'case_credit' => $org_credit, - 'inv_date' => $inv_date - ); - - $inser_id = $this->Medical_M->update_in_upv_item($data, $inv_id); + $inser_id=$this->Medical_M->update_in_upv_item($data,$inv_id); $this->Medical_M->update_invoice_group($inv_id); $this->Medical_M->update_invoice_final($inv_id); - } + } + public function getDrugTable() { + + $requestData= $_REQUEST; - $requestData = $_REQUEST; - - $columns = array( - // datatable column index => database column name - 0 => 'item_id', + $columns = array( + // datatable column index => database column name + 0 =>'item_id', 1 => 'itemname', 2 => 'formulation', - 3 => 'genericname', - 5 => 'company_name_idx', - 4 => 'mrp' - ); + 3=> 'genericname', + 5=> 'company_name_idx', + 4=> 'mrp' + ); // getting total number records without any search $sql_f_all = "select * "; + + $sql_count="Select count(*) as no_rec "; - $sql_count = "Select count(*) as no_rec "; - - $sql_from = " from drug_temp "; - - $total_sql = $sql_count . $sql_from; + $sql_from=" from drug_temp "; + $total_sql=$sql_count.$sql_from; + $query = $this->db->query($total_sql); - $data['total_rec'] = $query->result(); - $totalData = $data['total_rec'][0]->no_rec; + $data['total_rec']= $query->result(); + $totalData=$data['total_rec'][0]->no_rec; $totalFiltered = $totalData; // when there is no search parameter then total number rows = total number filtered rows. - $sql_where = " WHERE 1 = 1"; - - $sql_where_flag = 0; + $sql_where=" WHERE 1 = 1"; + $sql_where_flag=0; + // getting records as per search parameters - if (!empty($requestData['columns'][0]['search']['value'])) { //item_id - $sql_where .= " AND item_id LIKE '" . $requestData['columns'][0]['search']['value'] . "%' "; - $sql_where_flag = 1; + if( !empty($requestData['columns'][0]['search']['value']) ){ //item_id + $sql_where.=" AND item_id LIKE '".$requestData['columns'][0]['search']['value']."%' "; + $sql_where_flag=1; } - - if (!empty($requestData['columns'][1]['search']['value'])) { //itemname - $sql_where .= " AND itemname LIKE '%" . $requestData['columns'][1]['search']['value'] . "%' "; - $sql_where_flag = 1; + + if( !empty($requestData['columns'][1]['search']['value']) ){ //itemname + $sql_where.=" AND itemname LIKE '%".$requestData['columns'][1]['search']['value']."%' "; + $sql_where_flag=1; } - - if (!empty($requestData['columns'][2]['search']['value'])) { //dosage - $sql_where .= " AND formulation LIKE '%" . $requestData['columns'][2]['search']['value'] . "%' "; - $sql_where_flag = 1; + + if( !empty($requestData['columns'][2]['search']['value']) ){ //dosage + $sql_where.=" AND formulation LIKE '%".$requestData['columns'][2]['search']['value']."%' "; + $sql_where_flag=1; } - - if (!empty($requestData['columns'][3]['search']['value'])) { //formulation - $sql_where .= " AND genericname LIKE '%" . $requestData['columns'][3]['search']['value'] . "%' "; - $sql_where_flag = 1; + + if( !empty($requestData['columns'][3]['search']['value']) ){ //formulation + $sql_where.=" AND genericname LIKE '%".$requestData['columns'][3]['search']['value']."%' "; + $sql_where_flag=1; } - - if (!empty($requestData['columns'][4]['search']['value'])) { //therapeutic - $sql_where .= " AND company_name_idx LIKE '%" . $requestData['columns'][4]['search']['value'] . "%' "; - $sql_where_flag = 1; + + if( !empty($requestData['columns'][4]['search']['value']) ){ //therapeutic + $sql_where.=" AND company_name_idx LIKE '%".$requestData['columns'][4]['search']['value']."%' "; + $sql_where_flag=1; } - - $total_filer_sql = $sql_count . $sql_from . $sql_where; - + + $total_filer_sql=$sql_count.$sql_from.$sql_where; + $query = $this->db->query($total_filer_sql); - $data['total_rec_filter'] = $query->result(); // when there is a search parameter then we have to modify total number filtered rows as per search result. - $totalFiltered = $data['total_rec_filter'][0]->no_rec; - - - $sql_order = " ORDER BY " . $columns[$requestData['order'][0]['column']] . " " . $requestData['order'][0]['dir'] . " LIMIT " . $requestData['start'] . " ," . $requestData['length'] . " "; // adding length - - $Result_sql = $sql_f_all . $sql_from . $sql_where . $sql_order; + $data['total_rec_filter']= $query->result();// when there is a search parameter then we have to modify total number filtered rows as per search result. + $totalFiltered=$data['total_rec_filter'][0]->no_rec; + + $sql_order=" ORDER BY ". $columns[$requestData['order'][0]['column']]." ".$requestData['order'][0]['dir']." LIMIT ".$requestData['start']." ,".$requestData['length']." "; // adding length + + $Result_sql=$sql_f_all.$sql_from.$sql_where.$sql_order; + $query = $this->db->query($Result_sql); - $rdata = $query->result_array(); + $rdata= $query->result_array(); $output = array( - "draw" => intval($requestData['draw']), // for every request/draw by clientside , they send a number as a parameter, when they recieve a response/data they first check the draw number, so we are sending same number in draw. - "recordsTotal" => intval($totalData), // total number of records - "recordsFiltered" => intval($totalFiltered), // total number of records after searching, if there is no searching then totalFiltered = totalData - "data" => array(), - "sql" => $Result_sql - ); + "draw" => intval( $requestData['draw'] ), // for every request/draw by clientside , they send a number as a parameter, when they recieve a response/data they first check the draw number, so we are sending same number in draw. + "recordsTotal" => intval( $totalData ), // total number of records + "recordsFiltered" => intval( $totalFiltered ), // total number of records after searching, if there is no searching then totalFiltered = totalData + "data" => array(), + "sql" => $Result_sql + ); - foreach ($rdata as $aRow) { + foreach($rdata as $aRow) + { $row = array(); - - foreach ($columns as $col) { + + foreach($columns as $col) + { $row[] = $aRow[$col]; } @@ -2495,24 +2486,24 @@ class Medical extends MY_Controller echo json_encode($output); // send data as json format } - + public function getInvoiceTable() { //Single Store Remove Store ID feild - $requestData = $_REQUEST; + $requestData= $_REQUEST; - $columns = array( - // datatable column index => database column name - 0 => 'inv_med_code', + $columns = array( + // datatable column index => database column name + 0 => 'inv_med_code', 1 => 'inv_name', - 2 => 'patient_code', - 3 => 'IPD_CODE', - 4 => 'inv_date_str', - 5 => 'net_amount', - 6 => 'payment_received', - 7 => 'payment_balance', - 8 => 'id', + 2=> 'patient_code', + 3=> 'IPD_CODE', + 4=> 'inv_date_str', + 5=> 'net_amount', + 6=> 'payment_received', + 7=> 'payment_balance', + 8=> 'id', ); // getting total number records without any search @@ -2522,85 +2513,89 @@ class Medical extends MY_Controller if(m.case_id>0,Concat(o.case_id_code,'
'),'') as ORG_CODE , m.inv_date,Date_Format(m.inv_date,'%d-%m-%Y') as inv_date_str, m.net_amount,m.id,m.payment_received,m.payment_balance "; + + $sql_count="Select count(*) as no_rec "; - $sql_count = "Select count(*) as no_rec "; - - $sql_from = " from (invoice_med_master m left join ipd_master i on m.ipd_id=i.id ) + $sql_from=" from (invoice_med_master m left join ipd_master i on m.ipd_id=i.id ) left join organization_case_master o on m.case_id=o.id left join inv_med_group g on i.id=g.ipd_id AND g.med_group_id=m.med_group_id"; //$total_sql=$sql_count.$sql_from; - $total_sql = "Select count(*) as no_rec from invoice_med_master"; - + $total_sql="Select count(*) as no_rec from invoice_med_master"; + $query = $this->db->query($total_sql); - $data['total_rec'] = $query->result(); - $totalData = $data['total_rec'][0]->no_rec; + $data['total_rec']= $query->result(); + $totalData=$data['total_rec'][0]->no_rec; $totalFiltered = $totalData; // when there is no search parameter then total number rows = total number filtered rows. - if ($this->ion_auth->in_group('MedicalStoreAdmin')) { - $sql_where = " WHERE sale_return=0 "; - } else { - $sql_where = " WHERE sale_return=0 and inv_date >= date_add(sysdate(),interval -50 day) "; + if($this->ion_auth->in_group('MedicalStoreAdmin')) + { + $sql_where=" WHERE sale_return=0 "; + }else{ + $sql_where=" WHERE sale_return=0 and inv_date >= date_add(sysdate(),interval -50 day) "; } - - $sql_where_flag = 0; - + + $sql_where_flag=0; + // getting records as per search parameters - if (!empty($requestData['columns'][0]['search']['value'])) { //inv_med_code - $sql_where .= " AND inv_med_code LIKE '%" . $requestData['columns'][0]['search']['value'] . "' "; - $sql_where_flag = 1; + if( !empty($requestData['columns'][0]['search']['value']) ){ //inv_med_code + $sql_where.=" AND inv_med_code LIKE '%".$requestData['columns'][0]['search']['value']."' "; + $sql_where_flag=1; } - if (!empty($requestData['columns'][1]['search']['value'])) { //inv_name - $stext = $requestData['columns'][1]['search']['value']; - if (!is_numeric($stext) && strlen($stext) > 3) { - $sql_where .= " AND inv_name LIKE '%" . $requestData['columns'][1]['search']['value'] . "%' "; + if( !empty($requestData['columns'][1]['search']['value']) ){ //inv_name + $stext=$requestData['columns'][1]['search']['value']; + if(!is_numeric($stext) && strlen($stext)>3) + { + $sql_where.=" AND inv_name LIKE '%".$requestData['columns'][1]['search']['value']."%' "; } - $sql_where_flag = 1; + $sql_where_flag=1; } - if (!empty($requestData['columns'][2]['search']['value'])) { //patient_code - $stext = $requestData['columns'][2]['search']['value']; - $sql_where .= " AND (patient_code LIKE '%" . $stext . "' )"; - $sql_where_flag = 1; + if( !empty($requestData['columns'][2]['search']['value']) ){ //patient_code + $stext=$requestData['columns'][2]['search']['value']; + $sql_where.=" AND (patient_code LIKE '%".$stext."' )"; + $sql_where_flag=1; } - if (!empty($requestData['columns'][3]['search']['value'])) { //patient_code - $stext = $requestData['columns'][3]['search']['value']; - $sql_where .= " AND (m.ipd_code LIKE '%" . $stext . "' AND m.ipd_id>0 ) "; - $sql_where_flag = 1; + if( !empty($requestData['columns'][3]['search']['value']) ){ //patient_code + $stext=$requestData['columns'][3]['search']['value']; + $sql_where.=" AND (m.ipd_code LIKE '%".$stext."' AND m.ipd_id>0 ) "; + $sql_where_flag=1; } - - - $total_filer_sql = $sql_count . $sql_from . $sql_where; - + + + $total_filer_sql=$sql_count.$sql_from.$sql_where; + $query = $this->db->query($total_filer_sql); - $data['total_rec_filter'] = $query->result(); // when there is a search parameter then we have to modify total number filtered rows as per search result. - $totalFiltered = $data['total_rec_filter'][0]->no_rec; - - $sql_order = " ORDER BY id desc," . $columns[$requestData['order'][0]['column']] . " " . $requestData['order'][0]['dir'] . " LIMIT " . $requestData['start'] . " ," . $requestData['length'] . " "; // adding length - - $Result_sql = $sql_f_all . $sql_from . $sql_where . $sql_order; + $data['total_rec_filter']= $query->result();// when there is a search parameter then we have to modify total number filtered rows as per search result. + $totalFiltered=$data['total_rec_filter'][0]->no_rec; + $sql_order=" ORDER BY id desc,". $columns[$requestData['order'][0]['column']]." ".$requestData['order'][0]['dir']." LIMIT ".$requestData['start']." ,".$requestData['length']." "; // adding length + + $Result_sql=$sql_f_all.$sql_from.$sql_where.$sql_order; + $query = $this->db->query($Result_sql); - $rdata = $query->result_array(); + $rdata= $query->result_array(); //$totalFiltered=count($rdata); $output = array( - "draw" => intval($requestData['draw']), // for every request/draw by clientside , they send a number as a parameter, when they recieve a response/data they first check the draw number, so we are sending same number in draw. - "recordsTotal" => intval($totalData), // total number of records - "recordsFiltered" => intval($totalFiltered), // total number of records after searching, if there is no searching then totalFiltered = totalData - "data" => array(), - "sql" => $Result_sql - ); + "draw" => intval( $requestData['draw'] ), // for every request/draw by clientside , they send a number as a parameter, when they recieve a response/data they first check the draw number, so we are sending same number in draw. + "recordsTotal" => intval( $totalData ), // total number of records + "recordsFiltered" => intval( $totalFiltered ), // total number of records after searching, if there is no searching then totalFiltered = totalData + "data" => array(), + "sql" => $Result_sql + ); - foreach ($rdata as $aRow) { + foreach($rdata as $aRow) + { $row = array(); - - foreach ($columns as $col) { + + foreach($columns as $col) + { $row[] = $aRow[$col]; } @@ -2610,27 +2605,27 @@ class Medical extends MY_Controller echo json_encode($output); // send data as json format } - + public function getReturnInvoiceTable() { //Single Store Remove Store ID feild - $requestData = $_REQUEST; + $requestData= $_REQUEST; - $columns = array( - // datatable column index => database column name - 0 => 'inv_med_code', + $columns = array( + // datatable column index => database column name + 0 => 'inv_med_code', 1 => 'inv_name', 2 => 'Code', - 3 => 'inv_date_str', - 4 => 'net_amount', - 5 => 'payment_received', - 6 => 'payment_balance', - 7 => 'id', - 8 => 'ipd_status', - 9 => 'org_status', - 10 => 'ipd_credit_type', - 11 => 'org_credit_type' + 3=> 'inv_date_str', + 4=> 'net_amount', + 5=> 'payment_received', + 6=> 'payment_balance', + 7=> 'id', + 8=> 'ipd_status', + 9=> 'org_status', + 10=> 'ipd_credit_type', + 11=> 'org_credit_type' ); // getting total number records without any search @@ -2642,77 +2637,81 @@ class Medical extends MY_Controller m.doc_name,m.net_amount,m.payment_received,m.payment_balance,m.id,i.ipd_status, o.status as org_status, m.ipd_credit as ipd_credit_type,m.case_credit as org_credit_type "; + + $sql_count="Select count(*) as no_rec "; - $sql_count = "Select count(*) as no_rec "; - - $sql_from = " from (invoice_med_master m left join ipd_master i on m.ipd_id=i.id ) + $sql_from=" from (invoice_med_master m left join ipd_master i on m.ipd_id=i.id ) left join organization_case_master o on m.case_id=o.id "; - $total_sql = $sql_count . $sql_from; - + $total_sql=$sql_count.$sql_from; + $query = $this->db->query($total_sql); - $data['total_rec'] = $query->result(); - $totalData = $data['total_rec'][0]->no_rec; + $data['total_rec']= $query->result(); + $totalData=$data['total_rec'][0]->no_rec; $totalFiltered = $totalData; // when there is no search parameter then total number rows = total number filtered rows. - if ($this->ion_auth->in_group('MedicalStoreAdmin')) { - $sql_where = " WHERE sale_return=1 "; - } else { - $sql_where = " WHERE sale_return=1 and inv_date >= date_add(sysdate(),interval -50 day) "; + if($this->ion_auth->in_group('MedicalStoreAdmin')) + { + $sql_where=" WHERE sale_return=1 "; + }else{ + $sql_where=" WHERE sale_return=1 and inv_date >= date_add(sysdate(),interval -50 day) "; } + - - $sql_where_flag = 0; - + $sql_where_flag=0; + // getting records as per search parameters - if (!empty($requestData['columns'][0]['search']['value'])) { //inv_med_code - $sql_where .= " AND inv_med_code LIKE '%" . $requestData['columns'][0]['search']['value'] . "' "; - $sql_where_flag = 1; + if( !empty($requestData['columns'][0]['search']['value']) ){ //inv_med_code + $sql_where.=" AND inv_med_code LIKE '%".$requestData['columns'][0]['search']['value']."' "; + $sql_where_flag=1; } - if (!empty($requestData['columns'][1]['search']['value'])) { //inv_name - $stext = $requestData['columns'][1]['search']['value']; - if (is_numeric($stext) && strlen($stext) > 3) { - $sql_where .= " AND inv_phone_number LIKE '" . $stext . "%' "; - } else { - $sql_where .= " AND inv_name LIKE '%" . $requestData['columns'][1]['search']['value'] . "%' "; + if( !empty($requestData['columns'][1]['search']['value']) ){ //inv_name + $stext=$requestData['columns'][1]['search']['value']; + if(is_numeric($stext) && strlen($stext)>3) + { + $sql_where.=" AND inv_phone_number LIKE '".$stext."%' "; + }else{ + $sql_where.=" AND inv_name LIKE '%".$requestData['columns'][1]['search']['value']."%' "; } - $sql_where_flag = 1; + $sql_where_flag=1; } - if (!empty($requestData['columns'][2]['search']['value'])) { //patient_code - $sql_where .= " AND (patient_code LIKE '%" . $requestData['columns'][2]['search']['value'] . "' OR - m.ipd_code LIKE '%" . $requestData['columns'][2]['search']['value'] . "' OR - o.case_id_code LIKE '%" . $requestData['columns'][2]['search']['value'] . "' )"; - $sql_where_flag = 1; + if( !empty($requestData['columns'][2]['search']['value']) ){ //patient_code + $sql_where.=" AND (patient_code LIKE '%".$requestData['columns'][2]['search']['value']."' OR + m.ipd_code LIKE '%".$requestData['columns'][2]['search']['value']."' OR + o.case_id_code LIKE '%".$requestData['columns'][2]['search']['value']."' )"; + $sql_where_flag=1; } - - $total_filer_sql = $sql_count . $sql_from . $sql_where; - + + $total_filer_sql=$sql_count.$sql_from.$sql_where; + $query = $this->db->query($total_filer_sql); - $data['total_rec_filter'] = $query->result(); // when there is a search parameter then we have to modify total number filtered rows as per search result. - $totalFiltered = $data['total_rec_filter'][0]->no_rec; - - $sql_order = " ORDER BY id desc," . $columns[$requestData['order'][0]['column']] . " " . $requestData['order'][0]['dir'] . " LIMIT " . $requestData['start'] . " ," . $requestData['length'] . " "; // adding length - - $Result_sql = $sql_f_all . $sql_from . $sql_where . $sql_order; + $data['total_rec_filter']= $query->result();// when there is a search parameter then we have to modify total number filtered rows as per search result. + $totalFiltered=$data['total_rec_filter'][0]->no_rec; + $sql_order=" ORDER BY id desc,". $columns[$requestData['order'][0]['column']]." ".$requestData['order'][0]['dir']." LIMIT ".$requestData['start']." ,".$requestData['length']." "; // adding length + + $Result_sql=$sql_f_all.$sql_from.$sql_where.$sql_order; + $query = $this->db->query($Result_sql); - $rdata = $query->result_array(); + $rdata= $query->result_array(); $output = array( - "draw" => intval($requestData['draw']), // for every request/draw by clientside , they send a number as a parameter, when they recieve a response/data they first check the draw number, so we are sending same number in draw. - "recordsTotal" => intval($totalData), // total number of records - "recordsFiltered" => intval($totalFiltered), // total number of records after searching, if there is no searching then totalFiltered = totalData - "data" => array(), - "sql" => $Result_sql - ); + "draw" => intval( $requestData['draw'] ), // for every request/draw by clientside , they send a number as a parameter, when they recieve a response/data they first check the draw number, so we are sending same number in draw. + "recordsTotal" => intval( $totalData ), // total number of records + "recordsFiltered" => intval( $totalFiltered ), // total number of records after searching, if there is no searching then totalFiltered = totalData + "data" => array(), + "sql" => $Result_sql + ); - foreach ($rdata as $aRow) { + foreach($rdata as $aRow) + { $row = array(); - - foreach ($columns as $col) { + + foreach($columns as $col) + { $row[] = $aRow[$col]; } @@ -2722,17 +2721,17 @@ class Medical extends MY_Controller echo json_encode($output); // send data as json format } - - + + public function getStockDrugTable() { + + $requestData= $_REQUEST; - $requestData = $_REQUEST; - - $columns = array( - // datatable column index => database column name - 0 => 'ss_no', - 1 => 'item_code', + $columns = array( + // datatable column index => database column name + 0 =>'ss_no', + 1 =>'item_code', 2 => 'item_name', 3 => 'formulation', 4 => 'rack_no', @@ -2742,83 +2741,85 @@ class Medical extends MY_Controller 8 => 'expiry_date', 9 => 'mrp', 10 => 'update_stock_qty' - ); + ); // getting total number records without any search $sql_f_all = "select * "; + + $sql_count="Select count(*) as no_rec "; - $sql_count = "Select count(*) as no_rec "; - - $sql_from = " from stock_addition "; - - $total_sql = $sql_count . $sql_from; + $sql_from=" from stock_addition "; + $total_sql=$sql_count.$sql_from; + $query = $this->db->query($total_sql); - $data['total_rec'] = $query->result(); - $totalData = $data['total_rec'][0]->no_rec; + $data['total_rec']= $query->result(); + $totalData=$data['total_rec'][0]->no_rec; $totalFiltered = $totalData; // when there is no search parameter then total number rows = total number filtered rows. - $sql_where = " WHERE 1 = 1 "; - - $sql_where_flag = 0; + $sql_where=" WHERE 1 = 1 "; + $sql_where_flag=0; + // getting records as per search parameters - if (!empty($requestData['columns'][0]['search']['value'])) { //item_id - $sql_where .= " AND item_code LIKE '" . $requestData['columns'][0]['search']['value'] . "%' "; - $sql_where_flag = 1; + if( !empty($requestData['columns'][0]['search']['value']) ){ //item_id + $sql_where.=" AND item_code LIKE '".$requestData['columns'][0]['search']['value']."%' "; + $sql_where_flag=1; + } + + if( !empty($requestData['columns'][1]['search']['value']) ){ //itemname + $sql_where.=" AND item_name LIKE '%".$requestData['columns'][1]['search']['value']."%' "; + $sql_where_flag=1; + } + + if( !empty($requestData['columns'][2]['search']['value']) ){ //dosage + $sql_where.=" AND formulation LIKE '%".$requestData['columns'][2]['search']['value']."%' "; + $sql_where_flag=1; + } + + if( !empty($requestData['columns'][3]['search']['value']) ){ //dosage + $sql_where.=" AND rack_no LIKE '%".$requestData['columns'][3]['search']['value']."%' "; + $sql_where_flag=1; + } + + if( !empty($requestData['columns'][4]['search']['value']) ){ //dosage + $sql_where.=" AND shelf_no LIKE '%".$requestData['columns'][4]['search']['value']."%' "; + $sql_where_flag=1; } - if (!empty($requestData['columns'][1]['search']['value'])) { //itemname - $sql_where .= " AND item_name LIKE '%" . $requestData['columns'][1]['search']['value'] . "%' "; - $sql_where_flag = 1; + if( !empty($requestData['columns'][5]['search']['value']) ){ //dosage + $sql_where.=" AND batch_no LIKE '%".$requestData['columns'][5]['search']['value']."%' "; + $sql_where_flag=1; } - if (!empty($requestData['columns'][2]['search']['value'])) { //dosage - $sql_where .= " AND formulation LIKE '%" . $requestData['columns'][2]['search']['value'] . "%' "; - $sql_where_flag = 1; - } - - if (!empty($requestData['columns'][3]['search']['value'])) { //dosage - $sql_where .= " AND rack_no LIKE '%" . $requestData['columns'][3]['search']['value'] . "%' "; - $sql_where_flag = 1; - } - - if (!empty($requestData['columns'][4]['search']['value'])) { //dosage - $sql_where .= " AND shelf_no LIKE '%" . $requestData['columns'][4]['search']['value'] . "%' "; - $sql_where_flag = 1; - } - - if (!empty($requestData['columns'][5]['search']['value'])) { //dosage - $sql_where .= " AND batch_no LIKE '%" . $requestData['columns'][5]['search']['value'] . "%' "; - $sql_where_flag = 1; - } - - $total_filer_sql = $sql_count . $sql_from . $sql_where; - + $total_filer_sql=$sql_count.$sql_from.$sql_where; + $query = $this->db->query($total_filer_sql); - $data['total_rec_filter'] = $query->result(); // when there is a search parameter then we have to modify total number filtered rows as per search result. - $totalFiltered = $data['total_rec_filter'][0]->no_rec; - - $sql_order = " ORDER BY " . $columns[$requestData['order'][0]['column']] . " " . $requestData['order'][0]['dir'] . " LIMIT " . $requestData['start'] . " ," . $requestData['length'] . " "; // adding length - - $Result_sql = $sql_f_all . $sql_from . $sql_where . $sql_order; + $data['total_rec_filter']= $query->result();// when there is a search parameter then we have to modify total number filtered rows as per search result. + $totalFiltered=$data['total_rec_filter'][0]->no_rec; + $sql_order=" ORDER BY ". $columns[$requestData['order'][0]['column']]." ".$requestData['order'][0]['dir']." LIMIT ".$requestData['start']." ,".$requestData['length']." "; // adding length + + $Result_sql=$sql_f_all.$sql_from.$sql_where.$sql_order; + $query = $this->db->query($Result_sql); - $rdata = $query->result_array(); + $rdata= $query->result_array(); $output = array( - "draw" => intval($requestData['draw']), // for every request/draw by clientside , they send a number as a parameter, when they recieve a response/data they first check the draw number, so we are sending same number in draw. - "recordsTotal" => intval($totalData), // total number of records - "recordsFiltered" => intval($totalFiltered), // total number of records after searching, if there is no searching then totalFiltered = totalData - "data" => array(), - "sql" => $Result_sql - ); + "draw" => intval( $requestData['draw'] ), // for every request/draw by clientside , they send a number as a parameter, when they recieve a response/data they first check the draw number, so we are sending same number in draw. + "recordsTotal" => intval( $totalData ), // total number of records + "recordsFiltered" => intval( $totalFiltered ), // total number of records after searching, if there is no searching then totalFiltered = totalData + "data" => array(), + "sql" => $Result_sql + ); - foreach ($rdata as $aRow) { + foreach($rdata as $aRow) + { $row = array(); - - foreach ($columns as $col) { + + foreach($columns as $col) + { $row[] = $aRow[$col]; } @@ -2828,249 +2829,256 @@ class Medical extends MY_Controller echo json_encode($output); // send data as json format } - + public function confirm_payment() { - if (!$this->input->is_ajax_request()) { - exit('no valid req.'); - } - + if (!$this->input->is_ajax_request()) { exit('no valid req.'); } + $this->load->model('Medical_M'); - $invoice_id = $this->input->post('med_invoice_id'); - $input_amount_paid = $this->input->post('input_amount_paid'); - - $sql = "select * from invoice_med_master where id='" . $invoice_id . "'"; + $invoice_id=$this->input->post('med_invoice_id'); + $input_amount_paid=$this->input->post('input_amount_paid'); + + $sql="select * from invoice_med_master where id='".$invoice_id."'"; $query = $this->db->query($sql); - $inv_master = $query->result(); + $inv_master= $query->result(); $user = $this->ion_auth->user()->row(); $user_id = $user->id; - $user_name = $user->first_name . '' . $user->last_name; + $user_name = $user->first_name.''. $user->last_name; - $showcontent1 = '
+ $showcontent1='
- Payment Method by : '; + Payment Method by : '; - $showcontent2 = '
'; + $showcontent2='
'; - $pay_remark = ''; - - if ($inv_master[0]->patient_id > 0) { - $Customerof_type = 1; - } else { - $Customerof_type = 3; + $pay_remark=''; + + if($inv_master[0]->patient_id>0) + { + $Customerof_type=1; + }else{ + $Customerof_type=3; } - if ($this->input->post('mode') == 1) { - $paydata = array( - 'payment_mode' => '1', - 'Customerof_type' => $Customerof_type, - 'Customerof_id' => $inv_master[0]->patient_id, - 'Customerof_code' => $inv_master[0]->patient_code, - 'Medical_invoice_id' => $inv_master[0]->id, - 'Medical_invoice_code' => $inv_master[0]->inv_med_code, - 'credit_debit' => '0', - 'amount' => $input_amount_paid, - 'payment_date' => date('Y-m-d H:i:s'), - 'remark' => $pay_remark, - 'update_by' => $user_name . '[' . $user_id . ']', - 'update_by_id' => $user_id + if($this->input->post('mode')==1) + { + $paydata = array( + 'payment_mode'=> '1', + 'Customerof_type'=>$Customerof_type, + 'Customerof_id'=>$inv_master[0]->patient_id, + 'Customerof_code'=>$inv_master[0]->patient_code, + 'Medical_invoice_id'=>$inv_master[0]->id, + 'Medical_invoice_code'=>$inv_master[0]->inv_med_code, + 'credit_debit'=>'0', + 'amount'=>$input_amount_paid, + 'payment_date'=>date('Y-m-d H:i:s'), + 'remark'=>$pay_remark, + 'update_by'=>$user_name.'['.$user_id.']', + 'update_by_id'=>$user_id ); - $insert_id = $this->Medical_M->insert_payment($paydata); + $insert_id=$this->Medical_M->insert_payment($paydata); - $data = array( - - 'payment_mode' => '1', - 'payment_status' => '1', - 'invoice_status' => '1', - 'payment_id' => $insert_id, - 'payment_mode_desc' => 'Cash', - 'confirm_invoice' => date('Y-m-d H:i:s'), - 'prepared_by' => $user_name . '[' . $user_id . ']' + $data = array( + + 'payment_mode'=> '1', + 'payment_status'=>'1', + 'invoice_status'=>'1', + 'payment_id'=>$insert_id, + 'payment_mode_desc'=>'Cash', + 'confirm_invoice'=>date('Y-m-d H:i:s'), + 'prepared_by'=>$user_name.'['.$user_id.']' ); - $this->Medical_M->update_in_upv_item($data, $invoice_id); + $this->Medical_M->update_in_upv_item( $data,$invoice_id); + + $status='CASH'; + $showcontent=$showcontent1.$status.$showcontent2; + + $rvar=array( + 'update' =>1, + 'showcontent'=>$showcontent + ); - $status = 'CASH'; - $showcontent = $showcontent1 . $status . $showcontent2; - - $rvar = array( - 'update' => 1, - 'showcontent' => $showcontent - ); - - $encode_data = json_encode($rvar); - echo $encode_data; + $encode_data = json_encode($rvar); + echo $encode_data; } - - if ($this->input->post('mode') == 2) { + + if($this->input->post('mode')==2) + { $FormRules = array( - array( - 'field' => 'input_card_tran', + array( + 'field' => 'input_card_tran', 'label' => 'Card Transcation ID', - 'rules' => 'required|min_length[3]|max_length[15]' + 'rules' => 'required|min_length[3]|max_length[15]' ) - ); - + ); + $this->form_validation->set_rules($FormRules); - - if ($this->form_validation->run() == TRUE) { - $paydata = array( - 'payment_mode' => '2', - 'Customerof_type' => $Customerof_type, - 'Customerof_id' => $inv_master[0]->patient_id, - 'Customerof_code' => $inv_master[0]->patient_code, - 'Medical_invoice_id' => $inv_master[0]->id, - 'Medical_invoice_code' => $inv_master[0]->inv_med_code, - 'credit_debit' => '0', - 'amount' => $input_amount_paid, - 'payment_date' => date('Y-m-d H:i:s'), - 'remark' => $pay_remark, - 'update_by' => $user_name . '[' . $user_id . ']', - 'update_by_id' => $user_id, - 'pay_bank_id' => $this->input->post('cbo_pay_type'), - 'card_tran_id' => $this->input->post('input_card_tran') + + if ($this->form_validation->run() == TRUE) + { + $paydata = array( + 'payment_mode'=> '2', + 'Customerof_type'=>$Customerof_type, + 'Customerof_id'=>$inv_master[0]->patient_id, + 'Customerof_code'=>$inv_master[0]->patient_code, + 'Medical_invoice_id'=>$inv_master[0]->id, + 'Medical_invoice_code'=>$inv_master[0]->inv_med_code, + 'credit_debit'=>'0', + 'amount'=>$input_amount_paid, + 'payment_date'=>date('Y-m-d H:i:s'), + 'remark'=>$pay_remark, + 'update_by'=>$user_name.'['.$user_id.']', + 'update_by_id'=>$user_id, + 'pay_bank_id'=>$this->input->post('cbo_pay_type'), + 'card_tran_id'=>$this->input->post('input_card_tran') ); + + $insert_id=$this->Medical_M->insert_payment($paydata); - $insert_id = $this->Medical_M->insert_payment($paydata); - - $data = array( - 'payment_mode' => '2', - 'payment_status' => '1', - 'invoice_status' => '1', - 'payment_mode_desc' => 'Bank Card', - 'confirm_invoice' => date('Y-m-d H:i:s'), - 'payment_id' => $insert_id, - 'card_tran_id' => $this->input->post('input_card_tran'), - 'prepared_by' => $user_name . '[' . $user_id . ']', - 'prepared_by_id' => $user_id - ); - - $this->Medical_M->update_in_upv_item($data, $invoice_id); - - $status = 'Bank Card'; - $showcontent = $showcontent1 . $status . $showcontent2; - - $rvar = array( - 'update' => 1, - 'showcontent' => $showcontent + $data = array( + 'payment_mode'=> '2', + 'payment_status'=>'1', + 'invoice_status'=>'1', + 'payment_mode_desc'=>'Bank Card', + 'confirm_invoice'=>date('Y-m-d H:i:s'), + 'payment_id'=>$insert_id, + 'card_tran_id'=>$this->input->post('input_card_tran'), + 'prepared_by'=>$user_name.'['.$user_id.']', + 'prepared_by_id'=>$user_id ); + + $this->Medical_M->update_in_upv_item( $data,$invoice_id); + + $status='Bank Card'; + $showcontent=$showcontent1.$status.$showcontent2; + + $rvar=array( + 'update' =>1, + 'showcontent'=>$showcontent + ); $encode_data = json_encode($rvar); - echo $encode_data; - } else { - $send_error = validation_errors(); - $rvar = array( - 'update' => 0, - 'error_text' => $send_error - ); - $encode_data = json_encode($rvar); - echo $encode_data; + echo $encode_data; + } + else{ + $send_error=validation_errors(); + $rvar=array( + 'update' =>0, + 'error_text'=>$send_error + ); + $encode_data = json_encode($rvar); + echo $encode_data; } } - - if ($this->input->post('mode') == 3) { - $data = array( - - 'payment_mode' => '3', - 'payment_status' => '1', - 'invoice_status' => '1', - 'confirm_invoice' => date('d/m/Y H:m:s'), - 'payment_mode_desc' => 'IPD Credit', - 'ipd_id' => $this->input->post('ipd_id'), - 'prepared_by' => $user_name . '[' . $user_id . ']' + + if($this->input->post('mode')==3) + { + $data = array( + + 'payment_mode'=> '3', + 'payment_status'=>'1', + 'invoice_status'=>'1', + 'confirm_invoice'=>date('d/m/Y H:m:s'), + 'payment_mode_desc'=>'IPD Credit', + 'ipd_id'=>$this->input->post('ipd_id'), + 'prepared_by'=>$user_name.'['.$user_id.']' ); - - $this->Medical_M->update_in_upv_item($data, $invoice_id); - - $status = 'IPD Credit'; - $showcontent = $showcontent1 . $status . $showcontent2; - - $rvar = array( - 'update' => 1, - 'showcontent' => $showcontent - ); - - $encode_data = json_encode($rvar); - echo $encode_data; + + $this->Medical_M->update_in_upv_item( $data,$invoice_id); + + $status='IPD Credit'; + $showcontent=$showcontent1.$status.$showcontent2; + + $rvar=array( + 'update' =>1, + 'showcontent'=>$showcontent + ); + + $encode_data = json_encode($rvar); + echo $encode_data; } - - if ($this->input->post('mode') == 4) { - $data = array( - 'payment_mode' => '4', - 'payment_status' => '1', - 'invoice_status' => '1', - 'confirm_invoice' => date('d/m/Y H:m:s'), - 'payment_mode_desc' => 'Org Credit', - 'case_id' => $this->input->post('ipd_id'), - 'prepared_by' => $user_name . '[' . $user_id . ']' + + if($this->input->post('mode')==4) + { + $data = array( + 'payment_mode'=> '4', + 'payment_status'=>'1', + 'invoice_status'=>'1', + 'confirm_invoice'=>date('d/m/Y H:m:s'), + 'payment_mode_desc'=>'Org Credit', + 'case_id'=>$this->input->post('ipd_id'), + 'prepared_by'=>$user_name.'['.$user_id.']' ); - - $this->Medical_M->update_in_upv_item($data, $invoice_id); - - $status = 'Org Credit'; - $showcontent = $showcontent1 . $status . $showcontent2; - - $rvar = array( - 'update' => 1, - 'showcontent' => $showcontent - ); - - $encode_data = json_encode($rvar); - echo $encode_data; + + $this->Medical_M->update_in_upv_item( $data,$invoice_id); + + $status='Org Credit'; + $showcontent=$showcontent1.$status.$showcontent2; + + $rvar=array( + 'update' =>1, + 'showcontent'=>$showcontent + ); + + $encode_data = json_encode($rvar); + echo $encode_data; } - - if ($this->input->post('mode') == 5) { - if ($input_amount_paid < 0) { - $input_amount_paid = $input_amount_paid * -1; + + if($this->input->post('mode')==5) + { + if($input_amount_paid<0) + { + $input_amount_paid=$input_amount_paid*-1; } - - $paydata = array( - 'payment_mode' => '1', - 'Customerof_type' => $Customerof_type, - 'Customerof_id' => $inv_master[0]->patient_id, - 'Customerof_code' => $inv_master[0]->patient_code, - 'Medical_invoice_id' => $inv_master[0]->id, - 'Medical_invoice_code' => $inv_master[0]->inv_med_code, - 'credit_debit' => '1', - 'amount' => $input_amount_paid, - 'payment_date' => date('Y-m-d H:i:s'), - 'remark' => $pay_remark, - 'update_by' => $user_name . '[' . $user_id . ']', - 'update_by_id' => $user_id + + $paydata = array( + 'payment_mode'=> '1', + 'Customerof_type'=>$Customerof_type, + 'Customerof_id'=>$inv_master[0]->patient_id, + 'Customerof_code'=>$inv_master[0]->patient_code, + 'Medical_invoice_id'=>$inv_master[0]->id, + 'Medical_invoice_code'=>$inv_master[0]->inv_med_code, + 'credit_debit'=>'1', + 'amount'=>$input_amount_paid, + 'payment_date'=>date('Y-m-d H:i:s'), + 'remark'=>$pay_remark, + 'update_by'=>$user_name.'['.$user_id.']', + 'update_by_id'=>$user_id ); - $insert_id = $this->Medical_M->insert_payment($paydata); + $insert_id=$this->Medical_M->insert_payment($paydata); - $data = array( - - 'payment_mode' => '1', - 'payment_status' => '1', - 'invoice_status' => '1', - 'payment_id' => $insert_id, - 'payment_mode_desc' => 'Cash Return', - 'confirm_invoice' => date('Y-m-d H:i:s'), - 'prepared_by' => $user_name . '[' . $user_id . ']' + $data = array( + + 'payment_mode'=> '1', + 'payment_status'=>'1', + 'invoice_status'=>'1', + 'payment_id'=>$insert_id, + 'payment_mode_desc'=>'Cash Return', + 'confirm_invoice'=>date('Y-m-d H:i:s'), + 'prepared_by'=>$user_name.'['.$user_id.']' ); - $this->Medical_M->update_in_upv_item($data, $invoice_id); + $this->Medical_M->update_in_upv_item( $data,$invoice_id); + + $status='CASH'; + $showcontent=$showcontent1.$status.$showcontent2; + + $rvar=array( + 'update' =>1, + 'showcontent'=>$showcontent + ); - $status = 'CASH'; - $showcontent = $showcontent1 . $status . $showcontent2; - - $rvar = array( - 'update' => 1, - 'showcontent' => $showcontent - ); - - $encode_data = json_encode($rvar); - echo $encode_data; + $encode_data = json_encode($rvar); + echo $encode_data; } $this->Medical_M->update_invoice_final($invoice_id); @@ -3078,106 +3086,113 @@ class Medical extends MY_Controller public function Adjust_Payment() { - if (!$this->input->is_ajax_request()) { - exit('no valid req.'); - } - + if (!$this->input->is_ajax_request()) { exit('no valid req.'); } + $this->load->model('Medical_M'); - $invoice_id = $this->input->post('med_invoice_id'); - $input_amount_paid = $this->input->post('input_amount_paid'); + $invoice_id=$this->input->post('med_invoice_id'); + $input_amount_paid=$this->input->post('input_amount_paid'); - $sql = "select * from invoice_med_master where id='" . $invoice_id . "'"; + $sql="select * from invoice_med_master where id='".$invoice_id."'"; $query = $this->db->query($sql); - $inv_master = $query->result(); + $inv_master= $query->result(); - if (count($inv_master) > 0) { - if ($inv_master[0]->ipd_id == 0) { + if(count($inv_master)>0) + { + if($inv_master[0]->ipd_id==0){ + + $discount=$inv_master[0]->discount_amount; + $discount=$discount+$input_amount_paid; + + $log=$inv_master[0]->log; - $discount = $inv_master[0]->discount_amount; - $discount = $discount + $input_amount_paid; + $update_str="Adjust Balance Amt:".$input_amount_paid; - $log = $inv_master[0]->log; - - $update_str = "Adjust Balance Amt:" . $input_amount_paid; - - $log = $log . PHP_EOL . PHP_EOL . $update_str; - - $dataupdate = array( + $log=$log.PHP_EOL.PHP_EOL.$update_str; + + $dataupdate = array( 'discount_amount' => $discount, 'log' => $log, ); - + $this->load->model('Medical_M'); - $this->Medical_M->update_in_upv_item($dataupdate, $invoice_id); - + $this->Medical_M->update_in_upv_item($dataupdate,$invoice_id); + $this->Medical_M->update_invoice_final($invoice_id); } + } - } + - public function invoice_print($inv_id, $print_format = 0) + } + + public function invoice_print($inv_id,$print_format=0) { $this->load->model('Medical_M'); $this->Medical_M->update_invoice_final($inv_id); - - $sql = "select *,(discount_amount+item_discount_amount) as inv_disc_total,(CGST_Tamount+SGST_Tamount) as TGST from invoice_med_master where id=" . $inv_id; + + $sql="select *,(discount_amount+item_discount_amount) as inv_disc_total,(CGST_Tamount+SGST_Tamount) as TGST from invoice_med_master where id=".$inv_id; $query = $this->db->query($sql); - $data['invoice_master'] = $query->result(); - - $sql = "select *,(disc_amount+disc_whole) as d_amt,(CGST+SGST) as gst,(CGST_per+SGST_per) as gst_per from inv_med_item - where inv_med_id=" . $inv_id; + $data['invoice_master']= $query->result(); + + $sql="select *,(disc_amount+disc_whole) as d_amt,(CGST+SGST) as gst,(CGST_per+SGST_per) as gst_per from inv_med_item + where inv_med_id=".$inv_id; $query = $this->db->query($sql); - $data['inv_items'] = $query->result(); - - $sql = "select * from ipd_master where id=" . $data['invoice_master'][0]->ipd_id; + $data['inv_items']= $query->result(); + + $sql="select * from ipd_master where id=".$data['invoice_master'][0]->ipd_id; + $query = $this->db->query($sql); + $data['ipd_master']= $query->result(); + + $sql="select * from organization_case_master where id=".$data['invoice_master'][0]->case_id; $query = $this->db->query($sql); - $data['ipd_master'] = $query->result(); - - $sql = "select * from organization_case_master where id=" . $data['invoice_master'][0]->case_id; + $data['orgcase']= $query->result(); + + $sql="select sum(if(credit_debit>0,amount*-1,amount)) as paid_amount from payment_history_medical where Medical_invoice_id=".$inv_id; $query = $this->db->query($sql); - $data['orgcase'] = $query->result(); - - $sql = "select sum(if(credit_debit>0,amount*-1,amount)) as paid_amount from payment_history_medical where Medical_invoice_id=" . $inv_id; - $query = $this->db->query($sql); - $data['payment_history_medical'] = $query->result(); - - $sql = "select *,if(credit_debit>0,amount*-1,amount) as paid_amount, + $data['payment_history_medical']= $query->result(); + + $sql="select *,if(credit_debit>0,amount*-1,amount) as paid_amount, (case payment_mode when 1 then 'Cash' when 2 then 'Bank Card' when 3 then 'Return Cash ' when 4 then 'Bank Return' when 5 then 'Cash Return' else 'Other' end) as Payment_type_str - from payment_history_medical where Medical_invoice_id=" . $inv_id; + from payment_history_medical where Medical_invoice_id=".$inv_id; $query = $this->db->query($sql); - $data['payment_history'] = $query->result(); - - if ($print_format == 0) { - $this->load->view('Medical/Medical_invoice_print_2', $data); - } else { - $this->load->view('Medical/Medical_invoice_print', $data); + $data['payment_history']= $query->result(); + + if($print_format==0) + { + $this->load->view('Medical/Medical_invoice_print_2',$data); + }else{ + $this->load->view('Medical/Medical_invoice_print',$data); } + } - - - public function invoice_print_all($ipd_id, $cash = 0) + + + public function invoice_print_all($ipd_id,$cash=0) { //$cash 0 for Cash Only,1 for Credit only,2 Package Credit only,3 for All $this->load->model('Medical_M'); - - $cash_where = " "; - - if ($cash == 0) { - $cash_where .= " and ipd_credit=0 "; - $med_type = 1; - } elseif ($cash == 1) { - $cash_where .= " and ipd_credit=1 and ipd_credit_type=1 "; - $med_type = 2; - } elseif ($cash == 2) { - $cash_where .= " and ipd_credit=1 and ipd_credit_type=0 "; - $med_type = 3; + + $cash_where=" "; + + if($cash==0) + { + $cash_where.=" and ipd_credit=0 "; + $med_type=1; + }elseif($cash==1) + { + $cash_where.=" and ipd_credit=1 and ipd_credit_type=1 "; + $med_type=2; + }elseif($cash==2) + { + $cash_where.=" and ipd_credit=1 and ipd_credit_type=0 "; + $med_type=3; } - $this->Medical_M->update_invoice_group_gst($ipd_id, $med_type); + $this->Medical_M->update_invoice_group_gst($ipd_id,$med_type); - - $sql = "select i.inv_med_id,i.id,i.item_Name,i.formulation, + + $sql="select i.inv_med_id,i.id,i.item_Name,i.formulation, i.batch_no,Date_Format(i.expiry,'%m-%Y')as expiry, i.price,i.qty,sum(i.amount) as amount,i.HSNCODE, m.inv_med_code,m.id as m_id, @@ -3188,11 +3203,11 @@ class Medical extends MY_Controller (i.CGST_per+i.SGST_per) as gst_per from inv_med_item i join invoice_med_master m on i.inv_med_id=m.id - where m.group_invoice_id>0 and m.ipd_id=" . $ipd_id . $cash_where . " group by i.inv_med_id,i.id WITH ROLLUP"; + where m.group_invoice_id>0 and m.ipd_id=".$ipd_id.$cash_where." group by i.inv_med_id,i.id WITH ROLLUP"; $query = $this->db->query($sql); - $data['inv_items'] = $query->result(); - - $sql = "select sum(CGST_Tamount) as CGST_Tamount, + $data['inv_items']= $query->result(); + + $sql="select sum(CGST_Tamount) as CGST_Tamount, sum(SGST_Tamount) as SGST_Tamount, sum(TaxableAmount) as TaxableAmount, sum(net_amount) as net_amount, @@ -3200,113 +3215,119 @@ class Medical extends MY_Controller sum(payment_balance) as payment_balance, sum(discount_amount+item_discount_amount) as inv_disc_total, (CGST_Tamount+SGST_Tamount) as TGST from invoice_med_master - where group_invoice_id>0 and ipd_id=" . $ipd_id . $cash_where . " group by ipd_id"; + where group_invoice_id>0 and ipd_id=".$ipd_id.$cash_where." group by ipd_id"; $query = $this->db->query($sql); - $data['invoice_master'] = $query->result(); - - $sql = "select m.p_id,p.p_fname,m.ipd_code,p.p_code, m.doc_name, + $data['invoice_master']= $query->result(); + + $sql="select m.p_id,p.p_fname,m.ipd_code,p.p_code, m.doc_name, m.org_id from v_ipd_list m join patient_master p on m.p_id=p.id - where m.id=" . $ipd_id; + where m.id=".$ipd_id; + $query = $this->db->query($sql); + $data['ipd_master']= $query->result(); + + $sql="select * from organization_case_master where id='".$data['ipd_master'][0]->org_id."'"; $query = $this->db->query($sql); - $data['ipd_master'] = $query->result(); - - $sql = "select * from organization_case_master where id='" . $data['ipd_master'][0]->org_id . "'"; - $query = $this->db->query($sql); - $data['orgcase'] = $query->result(); - - $sql = "select sum(if(p.credit_debit>0,p.amount*-1,p.amount)) as paid_amount + $data['orgcase']= $query->result(); + + $sql="select sum(if(p.credit_debit>0,p.amount*-1,p.amount)) as paid_amount from payment_history_medical p join inv_med_group m on p.group_id=m.med_group_id - where m.ipd_id=" . $ipd_id . " and m.med_type=" . $med_type; + where m.ipd_id=".$ipd_id." and m.med_type=".$med_type; $query = $this->db->query($sql); - $data['payment_Total'] = $query->result(); - - $sql = "select p.*,if(p.credit_debit>0,p.amount*-1,p.amount) as paid_amount, + $data['payment_Total']= $query->result(); + + $sql="select p.*,if(p.credit_debit>0,p.amount*-1,p.amount) as paid_amount, (case p.payment_mode when 1 then 'Cash' when 2 then 'Bank Card' when 3 then 'Return Cash ' when 4 then 'Bank Return' when 5 then 'Cash Return' else 'Other' end) as Payment_type_str from payment_history_medical p join inv_med_group m on p.group_id=m.med_group_id - where m.ipd_id=" . $ipd_id . " and m.med_type=" . $med_type; + where m.ipd_id=".$ipd_id." and m.med_type=".$med_type; $query = $this->db->query($sql); - $data['payment_history'] = $query->result(); - - $sql = "select * from inv_med_group - where ipd_id='" . $ipd_id . "' and med_type='" . $med_type . "'"; + $data['payment_history']= $query->result(); + + $sql="select * from inv_med_group + where ipd_id='".$ipd_id."' and med_type='".$med_type."'"; $query = $this->db->query($sql); - $data['inv_med_group'] = $query->result(); + $data['inv_med_group']= $query->result(); - if ($cash == 0) { - if ($data['inv_med_group'][0]->bill_final == 1) { - $this->load->view('Medical/Medical_invoice_print_all', $data); - } else { - $this->load->view('Medical/Medical_invoice_print_all_provisional', $data); + if($cash==0) + { + if($data['inv_med_group'][0]->bill_final==1) + { + $this->load->view('Medical/Medical_invoice_print_all',$data); + }else{ + $this->load->view('Medical/Medical_invoice_print_all_provisional',$data); } - } else { - $this->load->view('Medical/Medical_invoice_print_all', $data); + }else{ + $this->load->view('Medical/Medical_invoice_print_all',$data); } + } - - + + public function final_invoice($inv_id) { $this->load->model('Medical_M'); - - /* $sql="select * from invoice_med_master where id=".$inv_id; + + $sql="select * from invoice_med_master where id=".$inv_id; $query = $this->db->query($sql); - $data['invoiceMaster']= $query->result(); */ - + $data['invoiceMaster']= $query->result(); + //$this->Medical_M->update_invoice_group($inv_id); //$this->Medical_M->opd_reset( $inv_id); $this->Medical_M->update_invoice_final($inv_id); - - $sql = "select *,(discount_amount+item_discount_amount) as inv_disc_total,(CGST_Tamount+SGST_Tamount) as TGST ,date_add(ifnull(confirm_invoice,inv_insert_datetime) ,interval 240 minute) as bill_open_date, - if( date_add(ifnull(confirm_invoice,inv_insert_datetime) ,interval 48 hour)>sysdate(),0,1) as bill_opd_close - from invoice_med_master where id=" . $inv_id; + + $sql="select *,(discount_amount+item_discount_amount) as inv_disc_total,(CGST_Tamount+SGST_Tamount) as TGST ,date_add(inv_date,interval 24 hour) as bill_open_date + from invoice_med_master where id=".$inv_id; $query = $this->db->query($sql); - $data['invoiceMaster'] = $query->result(); + $data['invoiceMaster']= $query->result(); - $sql = "select * from inv_med_item where inv_med_id=" . $inv_id; + $sql="select * from inv_med_item where inv_med_id=".$inv_id; $query = $this->db->query($sql); - $data['inv_items'] = $query->result(); - - $sql = "select *,if(gender=1,'Male','FeMale') as xgender, + $data['inv_items']= $query->result(); + + $sql="select *,if(gender=1,'Male','FeMale') as xgender, GET_AGE_1(dob,age,age_in_month,estimate_dob) AS age - from patient_master where id='" . $data['invoiceMaster'][0]->patient_id . "' "; + from patient_master where id='".$data['invoiceMaster'][0]->patient_id."' "; $query = $this->db->query($sql); - $data['person_info'] = $query->result(); - - $sql = "select * from ipd_master where ipd_status=0 and id=" . $data['invoiceMaster'][0]->ipd_id; - $query = $this->db->query($sql); - $data['ipd_master'] = $query->result(); - - if ($data['invoiceMaster'][0]->case_id > 0) { - $sql = "select * from organization_case_master where id=" . $data['invoiceMaster'][0]->case_id; + $data['person_info']= $query->result(); + + $sql="select * from ipd_master where ipd_status=0 and id=".$data['invoiceMaster'][0]->ipd_id; + $query = $this->db->query($sql); + $data['ipd_master']= $query->result(); + + if($data['invoiceMaster'][0]->case_id > 0) + { + $sql="select * from organization_case_master where id=".$data['invoiceMaster'][0]->case_id; $query = $this->db->query($sql); - $data['OCaseMaster'] = $query->result(); + $data['OCaseMaster']= $query->result(); } - $sql = "select sum(if(credit_debit>0,amount*-1,amount)) as paid_amount from payment_history_medical where Medical_invoice_id=" . $inv_id; + $sql="select sum(if(credit_debit>0,amount*-1,amount)) as paid_amount from payment_history_medical where Medical_invoice_id=".$inv_id; $query = $this->db->query($sql); - $data['payment_history_medical'] = $query->result(); + $data['payment_history_medical']= $query->result(); - $sql = "select s.id,s.pay_type,m.bank_name + $sql="select s.id,s.pay_type,m.bank_name From medical_bank m join medical_bank_payment_source s on m.id=s.bank_id"; $query = $this->db->query($sql); - $data['bank_data'] = $query->result(); + $data['bank_data']= $query->result(); - $sql = "select p.*,if(p.credit_debit=0,p.amount,p.amount*-1) as paid_amount, + $sql="select p.*,if(p.credit_debit=0,p.amount,p.amount*-1) as paid_amount, Concat((case p.payment_mode when 1 then 'Cash' when 2 then 'Bank Card' else 'Other' end),if(p.credit_debit=0,'',' Return')) as Payment_type_str from payment_history_medical p where Medical_invoice_id=$inv_id"; - $query = $this->db->query($sql); - $data['payment_history'] = $query->result(); - - if (count($data['invoiceMaster']) > 0) { - if ($data['invoiceMaster'][0]->ipd_id > 0) { - redirect('Medical/list_med_inv/' . $data['invoiceMaster'][0]->ipd_id); - } else if ($data['invoiceMaster'][0]->case_id > 0 && $data['invoiceMaster'][0]->case_credit > 0) { - redirect('Medical/list_med_orginv/' . $data['invoiceMaster'][0]->case_id); - } else { - $this->load->view('Medical/Medical_Final_Invoice', $data); + $query = $this->db->query($sql); + $data['payment_history']= $query->result(); + + if(count($data['invoiceMaster'])>0) + { + if($data['invoiceMaster'][0]->ipd_id>0) + { + redirect('Medical/list_med_inv/'.$data['invoiceMaster'][0]->ipd_id); + }else if($data['invoiceMaster'][0]->case_id>0 && $data['invoiceMaster'][0]->case_credit>0) + { + redirect('Medical/list_med_orginv/'.$data['invoiceMaster'][0]->case_id); + }else{ + $this->load->view('Medical/Medical_Final_Invoice',$data); } } } @@ -3314,260 +3335,275 @@ class Medical extends MY_Controller public function final_return_invoice($inv_id) { $this->load->model('Medical_M'); - - $sql = "select *,(discount_amount+item_discount_amount) as inv_disc_total,(CGST_Tamount+SGST_Tamount) as TGST from invoice_med_master where id=" . $inv_id; + + $sql="select *,(discount_amount+item_discount_amount) as inv_disc_total,(CGST_Tamount+SGST_Tamount) as TGST from invoice_med_master where id=".$inv_id; $query = $this->db->query($sql); - $data['invoiceMaster'] = $query->result(); + $data['invoiceMaster']= $query->result(); - $sql = "select *,ifnull(DATEDIFF(expiry,CURDATE()),1000) AS no_day from inv_med_item where inv_med_id=" . $inv_id; + $sql="select *,ifnull(DATEDIFF(expiry,CURDATE()),1000) AS no_day from inv_med_item where inv_med_id=".$inv_id; $query = $this->db->query($sql); - $data['inv_items'] = $query->result(); - - $sql = "select *,if(gender=1,'Male','FeMale') as xgender, + $data['inv_items']= $query->result(); + + $sql="select *,if(gender=1,'Male','FeMale') as xgender, GET_AGE_1(dob,age,age_in_month,estimate_dob) AS age - from patient_master where id='" . $data['invoiceMaster'][0]->patient_id . "' "; + from patient_master where id='".$data['invoiceMaster'][0]->patient_id."' "; $query = $this->db->query($sql); - $data['person_info'] = $query->result(); - - $sql = "select sum(if(credit_debit>0,amount*-1,amount)) as paid_amount from payment_history_medical where Medical_invoice_id=" . $inv_id; + $data['person_info']= $query->result(); + + $sql="select sum(if(credit_debit>0,amount*-1,amount)) as paid_amount from payment_history_medical where Medical_invoice_id=".$inv_id; $query = $this->db->query($sql); - $data['payment_history_medical'] = $query->result(); + $data['payment_history_medical']= $query->result(); - $sql = "select p.*,if(p.credit_debit=0,p.amount,p.amount*-1) as paid_amount, + $sql="select p.*,if(p.credit_debit=0,p.amount,p.amount*-1) as paid_amount, Concat((case p.payment_mode when 1 then 'Cash' when 2 then 'Bank Card' else 'Other' end),if(p.credit_debit=0,'',' Return')) as Payment_type_str from payment_history_medical p where p.Customerof_type in (1,3) and Medical_invoice_id=$inv_id"; - $query = $this->db->query($sql); - $data['payment_history'] = $query->result(); - - if (count($data['invoiceMaster']) > 0) { - $this->load->view('Medical/Medical_Final_return_Invoice', $data); - } else { + $query = $this->db->query($sql); + $data['payment_history']= $query->result(); + + if(count($data['invoiceMaster'])>0) + { + $this->load->view('Medical/Medical_Final_return_Invoice',$data); + }else{ echo 'Error In Inv. No.'; } } - - public function add_item($type, $req = 0) + + public function add_item($type,$req=0) { $this->load->model('Medical_M'); - - $inser_id = 1; - $Error_Show = ''; - $exist = 0; - $input_id = 0; - - $store_stock_id = $this->input->post('l_ssno'); + + $inser_id=1; + $Error_Show=''; + $exist=0; + $input_id=0; + + $store_stock_id=$this->input->post('l_ssno'); $user = $this->ion_auth->user()->row(); $user_id = $user->id; - $user_name_info = $user->first_name . '' . $user->last_name . '[' . $user_id . ']' . date('d-m-Y H:i:s'); - - if ($type == 1) { - $inv_id = $this->input->post('inv_id'); - $qty = $this->input->post('qty'); - $disc = $this->input->post('disc'); - $product_unit_rate = $this->input->post('product_unit_rate'); - - $sql = "SELECT p.item_name as item_name,t.batch_no,t.expiry_date, + $user_name_info = $user->first_name.''. $user->last_name .'['.$user_id.']'.date('d-m-Y H:i:s'); + + if($type==1) + { + $inv_id=$this->input->post('inv_id'); + $qty=$this->input->post('qty'); + $disc=$this->input->post('disc'); + $product_unit_rate=$this->input->post('product_unit_rate'); + + $sql="SELECT p.item_name as item_name,t.batch_no,t.expiry_date, (t.total_unit-t.total_sale_unit) AS S_qty, t.mrp,t.selling_unit_rate,p.id AS master_product_id, t.id as purchase_item_id,p.formulation, t.HSNCODE,t.CGST_per,t.SGST_per,t.packing FROM med_product_master p JOIN purchase_invoice_item t ON p.id=t.item_code - where t.id= " . $store_stock_id; + where t.id= ".$store_stock_id; $query = $this->db->query($sql); - $data['itemlist'] = $query->result(); + $data['itemlist']= $query->result(); - $sql = "select * from inv_med_item where inv_med_id=" . $inv_id . " - and store_stock_id=" . $store_stock_id; + $sql="select * from inv_med_item where inv_med_id=".$inv_id." + and store_stock_id=".$store_stock_id; $query = $this->db->query($sql); - $itemExist = $query->result(); - - $CGST = $data['itemlist'][0]->CGST_per; - $SGST = $data['itemlist'][0]->SGST_per; - + $itemExist= $query->result(); + + $CGST=$data['itemlist'][0]->CGST_per; + $SGST=$data['itemlist'][0]->SGST_per; + //$item_rate=$data['itemlist'][0]->unit_rate; - $item_rate = $product_unit_rate; + $item_rate=$product_unit_rate; - $amount_value = $qty * $item_rate; + $amount_value=$qty*$item_rate; + + $disc_amount=$amount_value*$disc/100; + + $Tamount_value=$amount_value-$disc_amount; - $disc_amount = $amount_value * $disc / 100; - - $Tamount_value = $amount_value - $disc_amount; - - $HSNCODE = $data['itemlist'][0]->HSNCODE; - - $stock_qty = $data['itemlist'][0]->S_qty; - - if ($qty > $stock_qty) { - $inser_id = 0; - $Error_Show = 'Stock Qty. is less than Required Qty : Current Qty :' . $stock_qty; - } elseif ($stock_qty == 0) { - $stock_qty = 0; - $inser_id = 0; - $Error_Show = 'Stock is Empty'; + $HSNCODE=$data['itemlist'][0]->HSNCODE; + + $stock_qty=$data['itemlist'][0]->S_qty; + + if($qty>$stock_qty) + { + $inser_id=0; + $Error_Show='Stock Qty. is less than Required Qty : Current Qty :'.$stock_qty; + }elseif($stock_qty==0){ + $stock_qty=0; + $inser_id=0; + $Error_Show='Stock is Empty'; } - - if ($inser_id > 0) { - $data['insert_inv_med_item'] = array( - 'inv_med_id' => $inv_id, - 'item_code' => $data['itemlist'][0]->master_product_id, - 'item_Name' => $data['itemlist'][0]->item_name, - 'formulation' => $data['itemlist'][0]->formulation, - 'qty' => $qty, - 'batch_no' => $data['itemlist'][0]->batch_no, - 'expiry' => $data['itemlist'][0]->expiry_date, - 'price' => $item_rate, - 'price2' => $item_rate, - 'mrp' => $data['itemlist'][0]->mrp, - 'disc_per' => $disc, - 'disc_amount' => $disc_amount, - 'amount' => $amount_value, - 'tamount' => $Tamount_value, - 'CGST_per' => $CGST, - 'SGST_per' => $SGST, - 'HSNCODE' => $HSNCODE, - 'store_stock_id' => $data['itemlist'][0]->purchase_item_id, - 'update_by_id' => $user_id, - 'update_by_remark' => $user_name_info, - 'packing' => $data['itemlist'][0]->packing, + + if($inser_id>0) + { + $data['insert_inv_med_item'] = array( + 'inv_med_id' => $inv_id, + 'item_code' => $data['itemlist'][0]->master_product_id, + 'item_Name' => $data['itemlist'][0]->item_name, + 'formulation' => $data['itemlist'][0]->formulation, + 'qty' => $qty, + 'batch_no' => $data['itemlist'][0]->batch_no, + 'expiry' => $data['itemlist'][0]->expiry_date, + 'price' => $item_rate, + 'price2' => $item_rate, + 'mrp' => $data['itemlist'][0]->mrp, + 'disc_per' => $disc, + 'disc_amount' => $disc_amount, + 'amount' => $amount_value, + 'tamount' => $Tamount_value, + 'CGST_per'=> $CGST, + 'SGST_per'=> $SGST, + 'HSNCODE'=> $HSNCODE, + 'store_stock_id'=>$data['itemlist'][0]->purchase_item_id, + 'update_by_id'=>$user_id, + 'update_by_remark'=>$user_name_info, + 'packing'=>$data['itemlist'][0]->packing, ); - if (count($itemExist) > 0) { - $Error_Show = 'Please Check Also Same Item List'; - $exist = count($itemExist); - $input_id = $itemExist[0]->id; - $input_id = 0; + if(count($itemExist)>0) + { + $Error_Show='Please Check Also Same Item List'; + $exist=count($itemExist); + $input_id=$itemExist[0]->id; + $input_id=0; } - $inser_id = $this->Medical_M->add_invoiceitem($data['insert_inv_med_item']); + $inser_id=$this->Medical_M->add_invoiceitem( $data['insert_inv_med_item']); } - } else if ($type == 2) { - $update_qty = $this->input->post('u_qty'); - $itemid = $this->input->post('itemid'); + } + else if($type==2) + { + $update_qty=$this->input->post('u_qty'); + $itemid=$this->input->post('itemid'); - $sql = "select * from inv_med_item where id=" . $itemid; + $sql="select * from inv_med_item where id=".$itemid; $query = $this->db->query($sql); - $data['inv_med_item'] = $query->result(); + $data['inv_med_item']= $query->result(); + + $CGST=$data['inv_med_item'][0]->CGST_per; + $SGST=$data['inv_med_item'][0]->SGST_per; + $disc=$data['inv_med_item'][0]->disc_per; + + $inv_id=$data['inv_med_item'][0]->inv_med_id; - $CGST = $data['inv_med_item'][0]->CGST_per; - $SGST = $data['inv_med_item'][0]->SGST_per; - $disc = $data['inv_med_item'][0]->disc_per; - - $inv_id = $data['inv_med_item'][0]->inv_med_id; - - $store_stock_id = $data['inv_med_item'][0]->store_stock_id; - - $sql = "SELECT p.item_name,t.batch_no,t.expiry_date, + $store_stock_id=$data['inv_med_item'][0]->store_stock_id; + + $sql="SELECT p.item_name,t.batch_no,t.expiry_date, (t.total_unit-t.total_sale_unit) AS S_qty, t.mrp,t.selling_unit_rate,p.id AS master_product_id, t.id as purchase_item_id,p.formulation, t.HSNCODE,t.CGST_per,t.SGST_per,t.packing FROM med_product_master p JOIN purchase_invoice_item t ON p.id=t.item_code - where t.id= " . $store_stock_id; - + where t.id= ".$store_stock_id; + $query = $this->db->query($sql); - $item_master = $query->result(); - - $stock_qty = 0; - - $old_qty = $data['inv_med_item'][0]->qty; - $diff_qty = $update_qty - $old_qty; - - if ($diff_qty > 0) { - if (count($item_master) > 0) { - $stock_qty = $item_master[0]->S_qty; - if ($diff_qty > $stock_qty) { - $inser_id = 0; - $Error_Show = 'Stock Qty. is less than Required Qty : Current Qty :' . $stock_qty; + $item_master= $query->result(); + + $stock_qty=0; + + $old_qty=$data['inv_med_item'][0]->qty; + $diff_qty=$update_qty-$old_qty; + + if($diff_qty>0) + { + if(count($item_master)>0) + { + $stock_qty=$item_master[0]->S_qty; + if($diff_qty>$stock_qty) + { + $inser_id=0; + $Error_Show='Stock Qty. is less than Required Qty : Current Qty :'.$stock_qty; } - } else { - $stock_qty = 0; - $inser_id = 0; - $Error_Show = 'Stock is Empty'; + }else{ + $stock_qty=0; + $inser_id=0; + $Error_Show='Stock is Empty'; } } + + if($inser_id>0) + { + $item_rate=$data['inv_med_item'][0]->price; + $amount_value=$update_qty*$item_rate; + + $disc_amount=$amount_value*$disc/100; + + $Tamount_value=$amount_value-$disc_amount; - if ($inser_id > 0) { - $item_rate = $data['inv_med_item'][0]->price; - $amount_value = $update_qty * $item_rate; - - $disc_amount = $amount_value * $disc / 100; - - $Tamount_value = $amount_value - $disc_amount; - - $data['update_inv_med_item'] = array( + $data['update_inv_med_item'] = array( 'qty' => $update_qty, 'disc_amount' => $disc_amount, 'amount' => $amount_value, 'tamount' => $Tamount_value, - 'store_stock_id' => $store_stock_id, - 'packing' => $data['inv_med_item'][0]->packing, + 'store_stock_id'=>$store_stock_id, + 'packing'=>$data['inv_med_item'][0]->packing, 'inv_med_id' => $inv_id, ); - $this->Medical_M->update_invoiceitem($data['update_inv_med_item'], $itemid); - $inser_id = $itemid; + $this->Medical_M->update_invoiceitem($data['update_inv_med_item'],$itemid); + $inser_id=$itemid; + } - + $this->Medical_M->update_invoice_group($inv_id); $this->Medical_M->update_invoice_final($inv_id); - } else { - $inv_id = $this->input->post('inv_id'); - $itemid = $this->input->post('itemid'); + + }else{ + $inv_id=$this->input->post('inv_id'); + $itemid=$this->input->post('itemid'); - $sql = "select * from inv_med_item where id=" . $itemid; + $sql="select * from inv_med_item where id=".$itemid; $query = $this->db->query($sql); - $inv_items = $query->row_array(); - - $this->Medical_M->delete_invoiceitem($itemid, $inv_items); + $inv_items= $query->row_array(); + + $this->Medical_M->delete_invoiceitem($itemid,$inv_items); + } - $content = ''; - - if ($inser_id > 0) { + $content=''; + + if($inser_id>0) + { $this->Medical_M->update_invoice_final($inv_id); - - $sql = "SELECT i.*,ifnull(DATEDIFF(expiry,CURDATE()),1000) AS no_day, + + $sql="SELECT i.*,ifnull(DATEDIFF(expiry,CURDATE()),1000) AS no_day, SUM(p.total_unit-p.total_sale_unit-total_return_unit-total_lost_unit)/p.packing AS cur_qty FROM (inv_med_item i JOIN purchase_invoice_item p ON i.item_code=p.item_code AND p.remove_item=0 ) - where inv_med_id=" . $inv_id . " GROUP BY i.id"; + where inv_med_id=".$inv_id." GROUP BY i.id"; $query = $this->db->query($sql); - $data['inv_items'] = $query->result(); + $data['inv_items']= $query->result(); - $sql = "select item_code - from inv_med_item where inv_med_id=" . $inv_id . " Group by item_code Having count(id)>1"; + $sql="select item_code + from inv_med_item where inv_med_id=".$inv_id." Group by item_code Having count(id)>1"; $query = $this->db->query($sql); - $data['inv_items_multiple'] = $query->result(); + $data['inv_items_multiple']= $query->result(); + + $sql="select sum(amount) as Gtotal,sum(tamount) as tamt,sum(CGST) as TCGST,sum(SGST) as TSGST, + sum(disc_amount) as t_dis_amt from inv_med_item where inv_med_id=".$inv_id; + $query = $this->db->query($sql); + $data['invoiceGtotal']= $query->result(); - $sql = "select sum(amount) as Gtotal,sum(tamount) as tamt,sum(CGST) as TCGST,sum(SGST) as TSGST, - sum(disc_amount) as t_dis_amt from inv_med_item where inv_med_id=" . $inv_id; + $sql="select * from invoice_med_master where id=".$inv_id; $query = $this->db->query($sql); - $data['invoiceGtotal'] = $query->result(); - - $sql = "select * from invoice_med_master where id=" . $inv_id; - $query = $this->db->query($sql); - $data['invoiceMaster'] = $query->result(); + $data['invoiceMaster']= $query->result(); $user = $this->ion_auth->user()->row(); $data['user_id'] = $user->id; - $data['sale_return'] = $data['invoiceMaster'][0]->sale_return; - - $content = $this->load->view('Medical/Med_Item_List', $data, true); + $data['sale_return']=$data['invoiceMaster'][0]->sale_return; + + $content=$this->load->view('Medical/Med_Item_List',$data,true); //$content=''; - } - - $rvar = array( - 'exist' => $exist, - 'insertid' => $inser_id, - 'content' => $content, - 'error' => $Error_Show, - 'input_id' => $input_id, - 'csrf_dst_name_value' => $this->security->get_csrf_hash() + } + + $rvar=array( + 'exist' =>$exist, + 'insertid' =>$inser_id, + 'content'=>$content, + 'error'=>$Error_Show, + 'input_id'=>$input_id, + 'csrf_dst_name_value'=>$this->security->get_csrf_hash() ); $encode_data = json_encode($rvar); echo $encode_data; @@ -3575,52 +3611,52 @@ class Medical extends MY_Controller function show_items($inv_id) { - $this->load->model('Medical_M'); - - //$this->Medical_M->update_invoice_final($inv_id); - - $sql = "SELECT i.*,ifnull(DATEDIFF(expiry,CURDATE()),1000) AS no_day, + $this->load->model('Medical_M'); + + //$this->Medical_M->update_invoice_final($inv_id); + + $sql="SELECT i.*,ifnull(DATEDIFF(expiry,CURDATE()),1000) AS no_day, SUM(p.total_unit-p.total_sale_unit-total_return_unit-total_lost_unit)/p.packing AS cur_qty FROM (inv_med_item i JOIN purchase_invoice_item p ON i.item_code=p.item_code AND p.remove_item=0 ) - where inv_med_id=" . $inv_id . " GROUP BY i.id"; - $query = $this->db->query($sql); - $data['inv_items'] = $query->result(); + where inv_med_id=".$inv_id." GROUP BY i.id"; + $query = $this->db->query($sql); + $data['inv_items']= $query->result(); - $sql = "select item_code - from inv_med_item where inv_med_id=" . $inv_id . " Group by item_code Having count(id)>1"; - $sql = "select item_code + $sql="select item_code + from inv_med_item where inv_med_id=".$inv_id." Group by item_code Having count(id)>1"; + $sql="select item_code from inv_med_item where 1<>1"; - $query = $this->db->query($sql); - $data['inv_items_multiple'] = $query->result(); + $query = $this->db->query($sql); + $data['inv_items_multiple']= $query->result(); + + $sql="select sum(amount) as Gtotal,sum(tamount) as tamt,sum(CGST) as TCGST,sum(SGST) as TSGST, + sum(disc_amount) as t_dis_amt from inv_med_item where inv_med_id=".$inv_id; + $query = $this->db->query($sql); + $data['invoiceGtotal']= $query->result(); - $sql = "select sum(amount) as Gtotal,sum(tamount) as tamt,sum(CGST) as TCGST,sum(SGST) as TSGST, - sum(disc_amount) as t_dis_amt from inv_med_item where inv_med_id=" . $inv_id; - $query = $this->db->query($sql); - $data['invoiceGtotal'] = $query->result(); + $sql="select * from invoice_med_master where id=".$inv_id; + $query = $this->db->query($sql); + $data['invoiceMaster']= $query->result(); - $sql = "select * from invoice_med_master where id=" . $inv_id; - $query = $this->db->query($sql); - $data['invoiceMaster'] = $query->result(); + $user = $this->ion_auth->user()->row(); + $data['user_id'] = $user->id; - $user = $this->ion_auth->user()->row(); - $data['user_id'] = $user->id; + $data['sale_return']=$data['invoiceMaster'][0]->sale_return; + + $content=$this->load->view('Medical/Med_Item_List',$data,true); - $data['sale_return'] = $data['invoiceMaster'][0]->sale_return; - - $content = $this->load->view('Medical/Med_Item_List', $data, true); - - //$content="hello"; - echo $content; + //$content="hello"; + echo $content; } - - + + public function list_org_ipd() { $sql = "select *,(paid_amount-(charge_amount+med_amount)) as balance from v_ipd_list where ipd_status=0 "; - $query = $this->db->query($sql); - $data['data'] = $query->result(); + $query = $this->db->query($sql); + $data['data']= $query->result(); $sql = "SELECT CONCAT('IPD : ',i.ipd_code,' /Name :',p.p_fname,' / Admit Dt: ',date_format(i.register_date,'%d-%m-%Y'), ' /Balance :',m.payment_balance) AS show_content @@ -3628,10 +3664,10 @@ class Medical extends MY_Controller JOIN patient_master p ON i.p_id=p.id WHERE i.ipd_status=0 AND m.med_type=1 AND m.net_amount>0 AND payment_balance>=50000 "; - $query = $this->db->query($sql); - $data['high_balance'] = $query->result(); + $query = $this->db->query($sql); + $data['high_balance']= $query->result(); - $this->load->view('Medical/Medical_ipd_org_list', $data); + $this->load->view('Medical/Medical_ipd_org_list',$data); } public function list_high_balance() @@ -3641,214 +3677,225 @@ class Medical extends MY_Controller JOIN patient_master p ON i.p_id=p.id WHERE i.ipd_status=0 AND m.med_type=1 AND m.net_amount>0 AND payment_balance>=50000 "; - $query = $this->db->query($sql); - $data['high_balance'] = $query->result(); + $query = $this->db->query($sql); + $data['high_balance']= $query->result(); + + $this->load->view('Medical/Report/Med_high_pending',$data); + - $this->load->view('Medical/Report/Med_high_pending', $data); } - - + + public function list_org() { - $sql = "select p.p_fname,p.p_code,p.p_relative,p.p_rname,o.insurance_company_name,o.case_id_code,o.id as org_id,o.p_id , + $sql = "select p.p_fname,p.p_code,p.p_relative,p.p_rname,o.insurance_company_name,o.case_id_code,o.id as org_id,o.p_id , o.date_registration,Date_Format(o.date_registration,'%d-%m-%Y') as str_register_date,o.insurance_id from organization_case_master o join patient_master p on o.p_id=p.id and o.insurance_id >1 and o.`status`=0 and o.case_type=0 "; - $query = $this->db->query($sql); - $data['organization_case_master'] = $query->result(); + $query = $this->db->query($sql); + $data['organization_case_master']= $query->result(); - $this->load->view('Medical/Medical_org_list', $data); + $this->load->view('Medical/Medical_org_list',$data); } - + public function list_med_inv($ipd_id) { - - $sql = "select *,if(ipd_credit=0,'CASH','CREDIT') as credit, + + $sql="select *,if(ipd_credit=0,'CASH','CREDIT') as credit, if(ipd_credit=1 and ipd_credit_type=0,'Yes','No') as Package - from invoice_med_master where ipd_id = " . $ipd_id . " Order by inv_date,id"; + from invoice_med_master where ipd_id = ".$ipd_id." Order by inv_date,id"; $query = $this->db->query($sql); - $data['inv_master'] = $query->result(); + $data['inv_master']= $query->result(); $this->load->model('Medical_M'); //$this->Medical_M->update_invoice_group_gst($ipd_id,1); - - $sql = "select sum(if(ipd_credit=0,net_amount,0)) as cash_netAmount, + + $sql="select sum(if(ipd_credit=0,net_amount,0)) as cash_netAmount, sum(if(ipd_credit=1 and ipd_credit_type=1,net_amount,0)) as IPDCrAmount , sum(if(ipd_credit=1 and ipd_credit_type=0,net_amount,0)) as PackageCrAmount, sum(payment_balance) as t_payment_balance ,sum(net_amount) as t_net_amount - from invoice_med_master where ipd_id = " . $ipd_id; + from invoice_med_master where ipd_id = ".$ipd_id; $query = $this->db->query($sql); - $data['inv_master_total'] = $query->result(); - - $sql = "select * from ipd_master where id = " . $ipd_id; + $data['inv_master_total']= $query->result(); + + $sql="select * from ipd_master where id = ".$ipd_id; $query = $this->db->query($sql); - $data['ipd_master'] = $query->result(); - - $sql = "select *,if(gender=1,'Male','Female') as xgender, - GET_AGE_1(dob,age,age_in_month,estimate_dob) AS age from patient_master where id='" . $data['ipd_master'][0]->p_id . "' "; + $data['ipd_master']= $query->result(); + + $sql="select *,if(gender=1,'Male','Female') as xgender, + GET_AGE_1(dob,age,age_in_month,estimate_dob) AS age from patient_master where id='".$data['ipd_master'][0]->p_id."' "; $query = $this->db->query($sql); - $data['person_info'] = $query->result(); - - $sql = "select * from v_ipd_list where id=" . $ipd_id; + $data['person_info']= $query->result(); + + $sql="select * from v_ipd_list where id=".$ipd_id; $query = $this->db->query($sql); - $data['ipd_list'] = $query->result(); - - $sql = "select * from inv_med_group where med_type=1 and ipd_id=" . $ipd_id; + $data['ipd_list']= $query->result(); + + $sql="select * from inv_med_group where med_type=1 and ipd_id=".$ipd_id; $query = $this->db->query($sql); - $data['med_group_list'] = $query->result(); - - $sql = "select b.ipd_id,b.bed_id,b.TDate,m.room_name,m.bed_no + $data['med_group_list']= $query->result(); + + $sql="select b.ipd_id,b.bed_id,b.TDate,m.room_name,m.bed_no from ipd_bed_assign b left join hc_bed_master m on b.bed_id=m.id - where b.ipd_id=" . $ipd_id . " order by TDate desc"; + where b.ipd_id=".$ipd_id." order by TDate desc"; $query = $this->db->query($sql); - $data['bed_list'] = $query->result(); + $data['bed_list']= $query->result(); - if ($data['ipd_master'][0]->case_id > 0) { - $sql = "select * from organization_case_master where id='" . $data['ipd_master'][0]->case_id . "'"; + if($data['ipd_master'][0]->case_id>0) + { + $sql="select * from organization_case_master where id='".$data['ipd_master'][0]->case_id."'"; $query = $this->db->query($sql); - $data['orgcase'] = $query->result(); + $data['orgcase']= $query->result(); - $ins_comp_id = $data['orgcase'][0]->insurance_id; - $inc_card_id = $data['orgcase'][0]->insurance_card_id; + $ins_comp_id=$data['orgcase'][0]->insurance_id; + $inc_card_id=$data['orgcase'][0]->insurance_card_id; - $sql = "select * from hc_insurance_card where id='" . $inc_card_id . "'"; + $sql="select * from hc_insurance_card where id='".$inc_card_id."'"; $query = $this->db->query($sql); - $data['hc_insurance_card'] = $query->result(); + $data['hc_insurance_card']= $query->result(); - $sql = "select * from hc_insurance where id='" . $ins_comp_id . "'"; + $sql="select * from hc_insurance where id='".$ins_comp_id."'"; $query = $this->db->query($sql); - $data['insurance'] = $query->result(); + $data['insurance']= $query->result(); } - if (count($data['med_group_list']) > 0) { - if ($data['med_group_list'][0]->discount_group_2 <> 0) { + if(count($data['med_group_list'])>0) + { + if($data['med_group_list'][0]->discount_group_2<>0) + { exit('Please Contact to Medical Store Admin '); } } - - $this->load->view('Medical/Medical_invoice_list', $data); + + $this->load->view('Medical/Medical_invoice_list',$data); } - + public function list_med_orginv($org_id) { - - $sql = "select *,if(case_credit=0,'CASH','CREDIT') as credit - from invoice_med_master where case_id = " . $org_id . " order by inv_date,id"; + + $sql="select *,if(case_credit=0,'CASH','CREDIT') as credit + from invoice_med_master where case_id = ".$org_id." order by inv_date,id"; $query = $this->db->query($sql); - $data['inv_master'] = $query->result(); - - $sql = "select * from organization_case_master where id = " . $org_id; + $data['inv_master']= $query->result(); + + $sql="select * from organization_case_master where id = ".$org_id; $query = $this->db->query($sql); - $data['orgcase_master'] = $query->result(); - - $sql = "select *,if(gender=1,'Male','Female') as xgender, - GET_AGE_1(dob,age,age_in_month,estimate_dob) AS age from patient_master where id='" . $data['orgcase_master'][0]->p_id . "' "; + $data['orgcase_master']= $query->result(); + + $sql="select *,if(gender=1,'Male','Female') as xgender, + GET_AGE_1(dob,age,age_in_month,estimate_dob) AS age from patient_master where id='".$data['orgcase_master'][0]->p_id."' "; $query = $this->db->query($sql); - $data['person_info'] = $query->result(); + $data['person_info']= $query->result(); - $this->load->view('Medical/Medical_org_invoicelist', $data); + $this->load->view('Medical/Medical_org_invoicelist',$data); } - + public function update_discount() { - $invoice_id = $this->input->post('med_invoice_id'); - + $invoice_id=$this->input->post('med_invoice_id'); + $user = $this->ion_auth->user()->row(); $user_id = $user->id; - $user_name = $user->first_name . '' . $user->last_name; - - $dataupdate = array( - 'discount_amount' => $this->input->post('input_dis_amt'), - 'discount_remark' => $this->input->post('input_dis_desc'), - 'discount_by' => $user_name . '[' . $user_id . ']' - ); + $user_name = $user->first_name.''. $user->last_name; + $dataupdate = array( + 'discount_amount' => $this->input->post('input_dis_amt'), + 'discount_remark' => $this->input->post('input_dis_desc'), + 'discount_by'=>$user_name.'['.$user_id.']' + ); + $this->load->model('Medical_M'); - $this->Medical_M->update_in_upv_item($dataupdate, $invoice_id); - + $this->Medical_M->update_in_upv_item($dataupdate,$invoice_id); + $this->Medical_M->update_invoice_final($invoice_id); + } - + public function BillFinal($group_id) { - + $user = $this->ion_auth->user()->row(); $user_id = $user->id; - $user_name = $user->first_name . '' . $user->last_name; - - $dataupdate = array( - 'bill_final' => '1', - 'bill_final_by' => $user_name . '[' . $user_id . ']' - ); + $user_name = $user->first_name.''. $user->last_name; + $dataupdate = array( + 'bill_final' => '1', + 'bill_final_by'=>$user_name.'['.$user_id.']' + ); + $this->load->model('Medical_M'); - $this->Medical_M->update_group_invoice($dataupdate, $group_id); - - $rvar = array( - 'update' => 1, - ); + $this->Medical_M->update_group_invoice($dataupdate,$group_id); + + $rvar=array( + 'update' =>1, + ); $encode_data = json_encode($rvar); echo $encode_data; + } - + public function InvBillFinal($invoice_id) { $user = $this->ion_auth->user()->row(); $user_id = $user->id; - $user_name = $user->first_name . '' . $user->last_name; - - $dataupdate = array( - 'bill_final' => '1', - 'bill_final_by' => $user_name . '[' . $user_id . ']' - ); + $user_name = $user->first_name.''. $user->last_name; + $dataupdate = array( + 'bill_final' => '1', + 'bill_final_by'=>$user_name.'['.$user_id.']' + ); + $this->load->model('Medical_M'); - $this->Medical_M->update_in_upv_item($dataupdate, $invoice_id); - - $rvar = array( - 'update' => 1, - ); + $this->Medical_M->update_in_upv_item($dataupdate,$invoice_id); + + $rvar=array( + 'update' =>1, + ); $encode_data = json_encode($rvar); echo $encode_data; + } - - + + public function search() { - $sdata = $this->input->post('txtsearch'); - + $sdata=$this->input->post('txtsearch'); + $sdata = preg_replace('/[^A-Za-z0-9 _.@\-]/', '', trim($sdata)); - if (strlen($sdata) == 0) { - $sql = "SELECT p.*,GET_AGE_1(dob,age,age_in_month,estimate_dob) AS age , + if(strlen($sdata)==0) + { + $sql = "SELECT p.*,GET_AGE_1(dob,age,age_in_month,estimate_dob) AS age , Max(o.apointment_date) as Last_OPD , date_format(if(Max(o.apointment_date) IS NULL,p.insert_date,Max(o.apointment_date)),'%d-%m-%Y') AS Last_Visit FROM patient_master p left join opd_master o on p.id=o.p_id group BY p.id order BY if(Max(o.apointment_date) IS NULL,p.insert_date,Max(o.apointment_date)) DESC LIMIT 100"; - } else { + }else{ - $sdate_array = explode(" ", $sdata); - $search_string = " 1=1 "; + $sdate_array=explode(" ",$sdata); + $search_string=" 1=1 " ; - foreach ($sdate_array as $row_data) { - if (is_numeric($row_data)) { - $search_string .= " and (p.p_code like '%$row_data' + foreach($sdate_array as $row_data) + { + if(is_numeric($row_data)) + { + $search_string.=" and (p.p_code like '%$row_data' or p.mphone1 = '$row_data' or p.udai='$row_data' )"; - } elseif (ctype_alpha($row_data)) { - $search_string .= " and (p.p_fname like '%$row_data%' + }elseif(ctype_alpha($row_data)){ + $search_string.=" and (p.p_fname like '%$row_data%' or p.email1 = '$row_data' - or SUBSTRING_INDEX(p.p_fname,' ',1) sounds like '" . $row_data . "')"; - } else { - $search_string .= " and (p.p_code like '$row_data' + or SUBSTRING_INDEX(p.p_fname,' ',1) sounds like '".$row_data."')"; + }else{ + $search_string.=" and (p.p_code like '$row_data' or p.email1 = '$row_data' )"; } - } + } - $sql = "SELECT p.*,GET_AGE_1(dob,age,age_in_month,estimate_dob) AS age , + $sql = "SELECT p.*,GET_AGE_1(dob,age,age_in_month,estimate_dob) AS age , Max(o.apointment_date) as Last_OPD , date_format(if(Max(o.apointment_date) IS NULL,p.insert_date,Max(o.apointment_date)),'%d-%m-%Y') AS Last_Visit FROM patient_master p left join opd_master o on p.id=o.p_id @@ -3859,510 +3906,532 @@ class Medical extends MY_Controller $query = $this->db->query($sql); - $data['data'] = $query->result(); + $data['data']= $query->result(); - $this->load->view('Medical/Patient_Search_Result', $data); + $this->load->view('Medical/Patient_Search_Result',$data); } - + public function Update_Invoice_ipd_credit_type() { - $ipd_credit_type = $this->input->post('ipd_credit_type'); + $ipd_credit_type= $this->input->post('ipd_credit_type'); $inv_med_id = $this->input->post('inv_med_id'); - + $user = $this->ion_auth->user()->row(); $user_id = $user->id; - $user_name = $user->first_name . '' . $user->last_name . '[' . $user_id . ']T:' . date('d-m-Y'); + $user_name = $user->first_name.''. $user->last_name.'['.$user_id.']T:'.date('d-m-Y'); - if ($inv_med_id == '1') { - $ipd_credit_type_update = 'Include by : ' . $user_name; - } else { - $ipd_credit_type_update = 'Packeage by ' . $user_name; + if($inv_med_id=='1') + { + $ipd_credit_type_update='Include by : '.$user_name; + }else{ + $ipd_credit_type_update='Packeage by '.$user_name; } - $dataupdate = array( + $dataupdate = array( 'ipd_credit_type' => $ipd_credit_type, - 'ipd_credit_type_update' => $ipd_credit_type_update, + 'ipd_credit_type_update'=>$ipd_credit_type_update, ); - + $this->load->model('Medical_M'); - $this->Medical_M->update_in_upv_item($dataupdate, $inv_med_id); + $this->Medical_M->update_in_upv_item($dataupdate,$inv_med_id); } - - - + + + public function Med_Inv_Group($inv_med_id) { - if (!$this->input->is_ajax_request()) { - exit('no valid req.'); - } - - $sql = "select * from invoice_med_master where id=" . $inv_med_id; + if (!$this->input->is_ajax_request()) { exit('no valid req.'); } + + $sql = "select * from invoice_med_master where id=".$inv_med_id; $query = $this->db->query($sql); - $invoice_med_master = $query->result(); - + $invoice_med_master= $query->result(); + $user = $this->ion_auth->user()->row(); $user_id = $user->id; - $user_name = $user->first_name . '' . $user->last_name; - - $old_remark = $invoice_med_master[0]->update_history; - - $new_remark = 'Group By : ' . $user_name . '[' . $user_id . ']' . ' Date:' . date('d-m-Y h:i:s') . PHP_EOL; - - $new_remark .= $old_remark; - - $dataupdate = array( - 'med_group_id' => 1, - 'update_history' => $new_remark - ); - + $user_name = $user->first_name.''. $user->last_name; + + $old_remark=$invoice_med_master[0]->update_history; + + $new_remark='Group By : '.$user_name.'['.$user_id.']'.' Date:'.date('d-m-Y h:i:s').PHP_EOL; + + $new_remark.= $old_remark; + + $dataupdate = array( + 'med_group_id' => 1, + 'update_history' => $new_remark + ); + $this->load->model('Medical_M'); - $this->Medical_M->update_in_upv_item($dataupdate, $inv_med_id); + $this->Medical_M->update_in_upv_item($dataupdate,$inv_med_id); //$this->Medical_M->update_invoice_group($inv_med_id); - - $rvar = array( - 'update' => 1, - ); + + $rvar=array( + 'update' =>1, + ); $encode_data = json_encode($rvar); echo $encode_data; + } public function Update_Group_Discount($med_group_id) { - $input_discount = $this->input->post('input_discount'); - $Ipd_ID = $this->input->post('ipd_id'); - + $input_discount= $this->input->post('input_discount'); + $Ipd_ID= $this->input->post('ipd_id'); + $user = $this->ion_auth->user()->row(); $user_id = $user->id; - $user_name = $user->first_name . '' . $user->last_name; - - $dataupdate = array( - 'discount_group' => $input_discount, - 'discount_by_group' => $user_name . '[' . $user_id . ']' . ' Date:' . date('d-m-Y h:i:s') - ); + $user_name = $user->first_name.''. $user->last_name; + + $dataupdate = array( + 'discount_group' => $input_discount, + 'discount_by_group' => $user_name.'['.$user_id.']'.' Date:'.date('d-m-Y h:i:s') + ); $this->load->model('Medical_M'); - $this->Medical_M->update_group_invoice($dataupdate, $med_group_id); + $this->Medical_M->update_group_invoice($dataupdate,$med_group_id); //$this->Medical_M->update_invoice_group_gst($Ipd_ID); - - $rvar = array( - 'update' => 1, - ); + + $rvar=array( + 'update' =>1, + ); $encode_data = json_encode($rvar); echo $encode_data; } public function edit_invoice_edit($inv_id) - { - $sql = "select *,if(ipd_credit>0,'Credit to IPD','CASH') as credit_status, + { + $sql="select *,if(ipd_credit>0,'Credit to IPD','CASH') as credit_status, if(case_credit>0,'Credit to Org','CASH') as credit_org_status from invoice_med_master where id=$inv_id"; $query = $this->db->query($sql); - $data['invoiceMaster'] = $query->result(); + $data['invoiceMaster']= $query->result(); - $sql = "select sum(amount) as Gtotal,sum(tamount) as tamt,sum(CGST) as TCGST,sum(SGST) as TSGST,sum(disc_amount) as t_dis_amt from inv_med_item where inv_med_id=" . $inv_id; + $sql="select sum(amount) as Gtotal,sum(tamount) as tamt,sum(CGST) as TCGST,sum(SGST) as TSGST,sum(disc_amount) as t_dis_amt from inv_med_item where inv_med_id=".$inv_id; $query = $this->db->query($sql); - $data['invoiceGtotal'] = $query->result(); + $data['invoiceGtotal']= $query->result(); - $sql = "select * from doctor_master where active=1"; + $sql="select * from doctor_master where active=1"; $query = $this->db->query($sql); - $data['doclist'] = $query->result(); + $data['doclist']= $query->result(); - $sql = "select *, - GET_AGE_1(dob,age,age_in_month,estimate_dob) AS age from patient_master where id='" . $data['invoiceMaster'][0]->patient_id . "' "; + $sql="select *, + GET_AGE_1(dob,age,age_in_month,estimate_dob) AS age from patient_master where id='".$data['invoiceMaster'][0]->patient_id."' "; $query = $this->db->query($sql); - $data['person_info'] = $query->result(); - - $data['org_Name'] = ""; - $ipd_id = $data['invoiceMaster'][0]->ipd_id; - - if ($ipd_id > 0) { - $sql = "select * from ipd_master where id=" . $ipd_id; + $data['person_info']= $query->result(); + + $data['org_Name']=""; + $ipd_id=$data['invoiceMaster'][0]->ipd_id; + + if($ipd_id>0) + { + $sql="select * from ipd_master where id=".$ipd_id; $query = $this->db->query($sql); - $ipd_master = $query->result(); + $ipd_master= $query->result(); - $sql = "select * from v_ipd_list m join patient_master p on m.p_id=p.id - where m.id=" . $ipd_id; + $sql="select * from v_ipd_list m join patient_master p on m.p_id=p.id + where m.id=".$ipd_id; $query = $this->db->query($sql); - $data['ipd_list'] = $query->result(); + $data['ipd_list']= $query->result(); - $data['ipd_master'] = $ipd_master; - - if (count($ipd_master) > 0) { - $p_ipd_id = $ipd_master[0]->id; - $p_ipd_code = $ipd_master[0]->ipd_code; - - if ($ipd_master[0]->case_id > 0) { - $sql = "select * from organization_case_master where id=" . $ipd_master[0]->case_id; + $data['ipd_master']=$ipd_master; + + if(count($ipd_master)>0) + { + $p_ipd_id=$ipd_master[0]->id; + $p_ipd_code=$ipd_master[0]->ipd_code; + + if($ipd_master[0]->case_id>0) + { + $sql="select * from organization_case_master where id=".$ipd_master[0]->case_id; $query = $this->db->query($sql); - $org_master = $query->result(); - - if (count($org_master) > 0) { - $data['org_Name'] = $org_master[0]->insurance_company_name; + $org_master= $query->result(); + + if(count($org_master)>0) + { + $data['org_Name']=$org_master[0]->insurance_company_name; } + } } } - - if ($data['invoiceMaster'][0]->case_id > 0) { - $sql = "select * from organization_case_master where id=" . $data['invoiceMaster'][0]->case_id; + + if($data['invoiceMaster'][0]->case_id > 0) + { + $sql="select * from organization_case_master where id=".$data['invoiceMaster'][0]->case_id; $query = $this->db->query($sql); - $data['OCaseMaster'] = $query->result(); + $data['OCaseMaster']= $query->result(); } - + $user = $this->ion_auth->user()->row(); $data['user_id'] = $user->id; - - $this->load->view('Medical/invoice_master_edit', $data); + + $this->load->view('Medical/invoice_master_edit',$data); + } - - public function LockIPD($inv_med_id, $lock = 1) + + public function LockIPD($inv_med_id,$lock=1) { - if (!$this->input->is_ajax_request()) { - exit('no valid req.'); - } - - $sql = "select * from ipd_master where id=" . $inv_med_id; + if (!$this->input->is_ajax_request()) { exit('no valid req.'); } + + $sql = "select * from ipd_master where id=".$inv_med_id; $query = $this->db->query($sql); - $ipd_master = $query->result(); - + $ipd_master= $query->result(); + $user = $this->ion_auth->user()->row(); $user_id = $user->id; - $user_name = $user->first_name . '' . $user->last_name; - - $old_remark = $ipd_master[0]->lock_remark; - - if ($lock == 1) { - $new_remark = 'Locked By : ' . $user_name . '[' . $user_id . ']' . ' Date:' . date('d-m-Y h:i:s') . PHP_EOL; - } else { - $new_remark = 'Unlocked By : ' . $user_name . '[' . $user_id . ']' . ' Date:' . date('d-m-Y h:i:s') . PHP_EOL; + $user_name = $user->first_name.''. $user->last_name; + + $old_remark=$ipd_master[0]->lock_remark; + + if($lock==1) + { + $new_remark='Locked By : '.$user_name.'['.$user_id.']'.' Date:'.date('d-m-Y h:i:s').PHP_EOL; + + }else{ + $new_remark='Unlocked By : '.$user_name.'['.$user_id.']'.' Date:'.date('d-m-Y h:i:s').PHP_EOL; } - - $new_remark .= $old_remark; - - $dataupdate = array( - 'lock_medical' => $lock, - 'lock_remark' => $new_remark - ); - + + $new_remark.= $old_remark; + + $dataupdate = array( + 'lock_medical' => $lock, + 'lock_remark' => $new_remark + ); + $this->load->model('Ipd_M'); - $this->Ipd_M->update($dataupdate, $inv_med_id); - - $rvar = array( - 'update' => 1, - ); - + $this->Ipd_M->update($dataupdate,$inv_med_id); + + $rvar=array( + 'update' =>1, + ); + $encode_data = json_encode($rvar); echo $encode_data; + + } public function load_model_box($ipd_id) { $this->load->model('Medical_M'); - $this->Medical_M->update_invoice_group_gst($ipd_id, 1); - - $sql = "select *,if(ipd_status=0,DATEDIFF(sysdate(),register_date), + $this->Medical_M->update_invoice_group_gst($ipd_id,1); + + $sql="select *,if(ipd_status=0,DATEDIFF(sysdate(),register_date), DATEDIFF(discharge_date,register_date)) as no_days, if(case_type=1,'MLC','Non MLC') as case_type_s, Date_format(register_date,'%d-%m-%Y') as str_register_date from ipd_master - where id='" . $ipd_id . "' "; - $query = $this->db->query($sql); - $data['ipd_info'] = $query->result(); + where id='".$ipd_id."' "; + $query = $this->db->query($sql); + $data['ipd_info']= $query->result(); - $sql = "select *,if(gender=1,'Male','Female') as xgender, + $sql="select *,if(gender=1,'Male','Female') as xgender, GET_AGE_1(dob,age,age_in_month,estimate_dob) AS age - from patient_master where id='" . $data['ipd_info'][0]->p_id . "' "; - $query = $this->db->query($sql); - $data['person_info'] = $query->result(); + from patient_master where id='".$data['ipd_info'][0]->p_id."' "; + $query = $this->db->query($sql); + $data['person_info']= $query->result(); - $sql = "select * from inv_med_group where med_type=1 and ipd_id=" . $ipd_id; + $sql="select * from inv_med_group where med_type=1 and ipd_id=".$ipd_id; $query = $this->db->query($sql); - $data['med_group_list'] = $query->result(); - - $sql = "select p.*,if(p.credit_debit=0,p.amount,p.amount*-1) as paid_amount, + $data['med_group_list']= $query->result(); + + $sql="select p.*,if(p.credit_debit=0,p.amount,p.amount*-1) as paid_amount, Date_Format(payment_date,'%d-%m-%Y') as str_payment_date, Concat((case p.payment_mode when 1 then 'Cash' when 2 then 'Bank Card' else 'Other' end),if(p.credit_debit=0,'',' Return')) as Payment_type_str from payment_history_medical p join inv_med_group m on p.group_id=m.med_group_id - where m.ipd_id=" . $ipd_id . " and m.med_type=1"; + where m.ipd_id=".$ipd_id." and m.med_type=1"; $query = $this->db->query($sql); - $data['payment_history'] = $query->result(); - - $sql = "select * from inv_med_group where med_type=1 and ipd_id=" . $ipd_id; + $data['payment_history']= $query->result(); + + $sql="select * from inv_med_group where med_type=1 and ipd_id=".$ipd_id; $query = $this->db->query($sql); - $data['inv_med_group'] = $query->result(); - - $sql = "select s.id,s.pay_type,m.bank_name + $data['inv_med_group']= $query->result(); + + $sql="select s.id,s.pay_type,m.bank_name From medical_bank m join medical_bank_payment_source s on m.id=s.bank_id"; $query = $this->db->query($sql); - $data['bank_data'] = $query->result(); + $data['bank_data']= $query->result(); + + $phone_number_list=array($data['person_info'][0]->mphone1,$data['ipd_info'][0]->P_mobile1,$data['ipd_info'][0]->P_mobile2); - $phone_number_list = array($data['person_info'][0]->mphone1, $data['ipd_info'][0]->P_mobile1, $data['ipd_info'][0]->P_mobile2); - - $data['phone_number_list'] = array_unique($phone_number_list); - - $this->load->view('Medical/Med_Model_Payment', $data); + $data['phone_number_list']=array_unique($phone_number_list); + + $this->load->view('Medical/Med_Model_Payment',$data); } - - public function payment_receipt($ipd_id, $cash = 0) + + public function payment_receipt($ipd_id,$cash=0) { - $cash_where = " "; - - if ($cash == 0) { - $cash_where .= " and ipd_credit=0 "; - $med_type = 1; - } elseif ($cash == 1) { - $cash_where .= " and ipd_credit=1 and ipd_credit_type=1 "; - $med_type = 2; - } elseif ($cash == 2) { - $cash_where .= " and ipd_credit=1 and ipd_credit_type=0 "; - $med_type = 3; + $cash_where=" "; + + if($cash==0) + { + $cash_where.=" and ipd_credit=0 "; + $med_type=1; + }elseif($cash==1) + { + $cash_where.=" and ipd_credit=1 and ipd_credit_type=1 "; + $med_type=2; + }elseif($cash==2) + { + $cash_where.=" and ipd_credit=1 and ipd_credit_type=0 "; + $med_type=3; } - - $sql = "select m.p_id,p.p_fname,m.ipd_code,p.p_code, m.doc_name,m.mphone1,m.P_mobile1,m.P_mobile2,m.add1,m.add2, + + $sql="select m.p_id,p.p_fname,m.ipd_code,p.p_code, m.doc_name,m.mphone1,m.P_mobile1,m.P_mobile2,m.add1,m.add2, m.city,m.district,m.state, m.org_id from v_ipd_list m join patient_master p on m.p_id=p.id - where m.id=" . $ipd_id; + where m.id=".$ipd_id; + $query = $this->db->query($sql); + $data['ipd_master']= $query->result(); + + $sql="select * from organization_case_master where id='".$data['ipd_master'][0]->org_id."'"; $query = $this->db->query($sql); - $data['ipd_master'] = $query->result(); - - $sql = "select * from organization_case_master where id='" . $data['ipd_master'][0]->org_id . "'"; + $data['orgcase']= $query->result(); + + $sql="select * from inv_med_group + where ipd_id='".$ipd_id."' and med_type=".$med_type; $query = $this->db->query($sql); - $data['orgcase'] = $query->result(); + $data['inv_med_group']= $query->result(); - $sql = "select * from inv_med_group - where ipd_id='" . $ipd_id . "' and med_type=" . $med_type; - $query = $this->db->query($sql); - $data['inv_med_group'] = $query->result(); - - $sql = "select p.*,if(p.credit_debit>0,p.amount*-1,p.amount) as paid_amount, + $sql="select p.*,if(p.credit_debit>0,p.amount*-1,p.amount) as paid_amount, Date_Format(payment_date,'%d-%m-%Y') as str_payment_date, (case p.payment_mode when 1 then 'Cash' when 2 then 'Bank Card' when 3 then 'Return Cash ' when 4 then 'Bank Return' when 5 then 'Cash Return' else 'Other' end) as Payment_type_str from payment_history_medical p join inv_med_group m on p.group_id=m.med_group_id - where m.ipd_id=" . $ipd_id . " and m.med_type=" . $med_type; + where m.ipd_id=".$ipd_id." and m.med_type=".$med_type; $query = $this->db->query($sql); - $data['payment_history'] = $query->result(); - + $data['payment_history']= $query->result(); + //$this->load->view('Medical/Med_Payment_Receipt',$data); //load mPDF library - $this->load->library('m_pdf'); - $this->m_pdf->pdf->SetWatermarkText(M_store); - $this->m_pdf->pdf->showWatermarkText = true; + $this->load->library('m_pdf'); + $this->m_pdf->pdf->SetWatermarkText(M_store); + $this->m_pdf->pdf->showWatermarkText = true; + + $file_name='Report-payment_receipt-'.$ipd_id."-".date('Ymdhis').".pdf"; + $filepath=$file_name; + $content=$this->load->view('Medical/Med_Payment_Receipt',$data,TRUE); + $this->m_pdf->pdf->WriteHTML($content); + $this->m_pdf->pdf->Output($filepath,"I"); - $file_name = 'Report-payment_receipt-' . $ipd_id . "-" . date('Ymdhis') . ".pdf"; - $filepath = $file_name; - $content = $this->load->view('Medical/Med_Payment_Receipt', $data, TRUE); - $this->m_pdf->pdf->WriteHTML($content); - $this->m_pdf->pdf->Output($filepath, "I"); } - public function payment_receipt_sms($ipd_id, $cash = 0) + public function payment_receipt_sms($ipd_id,$cash=0) { - $inv_phone_number = $this->input->post('phone_number'); + $inv_phone_number=$this->input->post('phone_number'); - $cash_where = " "; - - if ($cash == 0) { - $cash_where .= " and ipd_credit=0 "; - $med_type = 1; - } elseif ($cash == 1) { - $cash_where .= " and ipd_credit=1 and ipd_credit_type=1 "; - $med_type = 2; - } elseif ($cash == 2) { - $cash_where .= " and ipd_credit=1 and ipd_credit_type=0 "; - $med_type = 3; + $cash_where=" "; + + if($cash==0) + { + $cash_where.=" and ipd_credit=0 "; + $med_type=1; + }elseif($cash==1) + { + $cash_where.=" and ipd_credit=1 and ipd_credit_type=1 "; + $med_type=2; + }elseif($cash==2) + { + $cash_where.=" and ipd_credit=1 and ipd_credit_type=0 "; + $med_type=3; } - - $sql = "select m.p_id,p.p_fname,m.ipd_code,p.p_code, m.doc_name, + + $sql="select m.p_id,p.p_fname,m.ipd_code,p.p_code, m.doc_name, m.org_id,m.P_mobile1,m.P_mobile2 from v_ipd_list m join patient_master p on m.p_id=p.id - where m.id=" . $ipd_id; + where m.id=".$ipd_id; + $query = $this->db->query($sql); + $ipd_master= $query->result(); + + $sql="select * from inv_med_group + where ipd_id='".$ipd_id."' and med_type=".$med_type; $query = $this->db->query($sql); - $ipd_master = $query->result(); - - $sql = "select * from inv_med_group - where ipd_id='" . $ipd_id . "' and med_type=" . $med_type; + $inv_med_group= $query->result(); + + $sql="select * from invoice_med_master + where ipd_id='".$ipd_id."' and ipd_credit=0 order by id desc limit 1"; $query = $this->db->query($sql); - $inv_med_group = $query->result(); + $inv_med_master= $query->result(); - $sql = "select * from invoice_med_master - where ipd_id='" . $ipd_id . "' and ipd_credit=0 order by id desc limit 1"; - $query = $this->db->query($sql); - $inv_med_master = $query->result(); - - $sql = "select p.*,if(p.credit_debit>0,p.amount*-1,p.amount) as paid_amount, + $sql="select p.*,if(p.credit_debit>0,p.amount*-1,p.amount) as paid_amount, Date_Format(payment_date,'%d-%m-%Y') as str_payment_date, (case p.payment_mode when 1 then 'Cash' when 2 then 'Bank Card' when 3 then 'Return Cash ' when 4 then 'Bank Return' when 5 then 'Cash Return' else 'Other' end) as Payment_type_str from payment_history_medical p join inv_med_group m on p.group_id=m.med_group_id - where m.ipd_id=" . $ipd_id . " and m.med_type=" . $med_type . " order by id desc limit 1"; + where m.ipd_id=".$ipd_id." and m.med_type=".$med_type." order by id desc limit 1"; $query = $this->db->query($sql); - $payment_history_last = $query->result(); + $payment_history_last= $query->result(); - $Last_Inv_Amt = 0; - $Last_pay_Amt = 0; + $Last_Inv_Amt=0; + $Last_pay_Amt=0; - if (count($inv_med_master) > 0) { - $Last_Inv_Amt = $inv_med_master[0]->net_amount; + if(count($inv_med_master)>0) + { + $Last_Inv_Amt=$inv_med_master[0]->net_amount; } - if (count($payment_history_last) > 0) { - $Last_pay_Amt = $payment_history_last[0]->paid_amount; + if(count($payment_history_last)>0) + { + $Last_pay_Amt=$payment_history_last[0]->paid_amount; } + + $SMS_SEND= M_store_short." STORE BILL STATUS%nIPD No.: ".$ipd_master[0]->ipd_code."%nPName: ".Trim($ipd_master[0]->p_fname)."%nTot. Med Amt.: ".Round($inv_med_group[0]->net_amount,0)."%nLast Inv. Amt.: ".Round($Last_Inv_Amt,0)."%nTot. Paid Amt.: ".Round($inv_med_group[0]->payment_received)."%nLast Paid Amt.: ".Round($Last_pay_Amt,0)."%nBal. Amt.: ".Round($inv_med_group[0]->payment_balance,0)."%nFrom: DevSoftTech HMS"; - $SMS_SEND = M_store_short . " STORE BILL STATUS%nIPD No.: " . $ipd_master[0]->ipd_code . "%nPName: " . Trim($ipd_master[0]->p_fname) . "%nTot. Med Amt.: " . Round($inv_med_group[0]->net_amount, 0) . "%nLast Inv. Amt.: " . Round($Last_Inv_Amt, 0) . "%nTot. Paid Amt.: " . Round($inv_med_group[0]->payment_received) . "%nLast Paid Amt.: " . Round($Last_pay_Amt, 0) . "%nBal. Amt.: " . Round($inv_med_group[0]->payment_balance, 0) . "%nFrom: DevSoftTech HMS"; - - + //$inv_phone_number="9720958717"; $this->load->model('SMS_M'); - $data = array( - 'to_number' => $inv_phone_number, - 'message' => $SMS_SEND + $data=array( + 'to_number'=>$inv_phone_number, + 'message'=>$SMS_SEND ); - $insert_id = $this->SMS_M->insert_sms_outbox($data); + $insert_id=$this->SMS_M->insert_sms_outbox($data); - - $rvar = array( - 'update' => $insert_id, - 'msg_text' => "Message Send" + + $rvar=array( + 'update' =>$insert_id, + 'msg_text'=>"Message Send" ); $encode_data = json_encode($rvar); echo $encode_data; + } public function group_confirm_payment() { - if (!$this->input->is_ajax_request()) { - exit('no valid req.'); - } - + if (!$this->input->is_ajax_request()) { exit('no valid req.'); } + $this->load->model('Ipd_M'); $this->load->model('Medical_M'); - - $ipd_id = $this->input->post('ipd_id'); - $amount = $this->input->post('amount'); - $Med_Group_id = $this->input->post('Med_Group_id'); - - $sql = "select * from ipd_master where id=" . $ipd_id; + + $ipd_id=$this->input->post('ipd_id'); + $amount=$this->input->post('amount'); + $Med_Group_id=$this->input->post('Med_Group_id'); + + $sql="select * from ipd_master where id=".$ipd_id; $query = $this->db->query($sql); - $ipd_master = $query->result(); + $ipd_master= $query->result(); $user = $this->ion_auth->user()->row(); $user_id = $user->id; - $user_name = $user->first_name . '' . $user->last_name; + $user_name = $user->first_name.''. $user->last_name; + + $pay_remark=$this->input->post('cash_remark'); + $cr_dr=$this->input->post('cr_dr'); - $pay_remark = $this->input->post('cash_remark'); - $cr_dr = $this->input->post('cr_dr'); - - - $pay_datetime = str_to_MysqlDate($this->input->post('date_payment')) . ' ' . date('H:i:s'); - - if ($this->input->post('mode') == 1) { - $paydata = array( - 'payment_mode' => '1', - 'Customerof_type' => '2', - 'Customerof_id' => $ipd_master[0]->p_id, - 'group_id' => $Med_Group_id, - 'ipd_id' => $ipd_id, - 'med_type' => 0, - 'credit_debit' => $cr_dr, - 'amount' => $amount, - 'payment_date' => $pay_datetime, - 'remark' => $pay_remark, - 'update_by' => $user_name . '[' . $user_id . ']', - 'update_by_id' => $user_id + + $pay_datetime=str_to_MysqlDate($this->input->post('date_payment')).' '.date('H:i:s'); + + if($this->input->post('mode')==1) + { + $paydata = array( + 'payment_mode'=> '1', + 'Customerof_type'=>'2', + 'Customerof_id'=>$ipd_master[0]->p_id, + 'group_id'=>$Med_Group_id, + 'ipd_id'=>$ipd_id, + 'med_type'=>0, + 'credit_debit'=>$cr_dr, + 'amount'=>$amount, + 'payment_date'=>$pay_datetime, + 'remark'=>$pay_remark, + 'update_by'=>$user_name.'['.$user_id.']', + 'update_by_id'=>$user_id ); - $insert_id = $this->Medical_M->insert_payment($paydata); + $insert_id=$this->Medical_M->insert_payment($paydata); - - $rvar = array( - 'update' => 1, - 'ipd_id' => $ipd_id, - 'payid' => $insert_id, - 'pay_date' => $pay_datetime - ); + + $rvar=array( + 'update' =>1, + 'ipd_id'=> $ipd_id, + 'payid' => $insert_id, + 'pay_date' =>$pay_datetime + ); $encode_data = json_encode($rvar); echo $encode_data; } - - if ($this->input->post('mode') == 2) { - + + if($this->input->post('mode')==2) + { + $FormRules = array( - array( - 'field' => 'input_card_tran', + array( + 'field' => 'input_card_tran', 'label' => 'Card Transcation ID', - 'rules' => 'required|min_length[1]|max_length[15]' - ) - ); - + 'rules' => 'required|min_length[1]|max_length[15]' + ) + ); + $this->form_validation->set_rules($FormRules); + + if ($this->form_validation->run() == TRUE) + { + - if ($this->form_validation->run() == TRUE) { - - - $paydata = array( - 'payment_mode' => '2', - 'Customerof_type' => '2', - 'Customerof_id' => $ipd_master[0]->p_id, - 'group_id' => $Med_Group_id, - 'ipd_id' => $ipd_id, - 'med_type' => 0, - 'credit_debit' => $cr_dr, - 'amount' => $amount, - 'payment_date' => $pay_datetime, - 'remark' => $pay_remark, - 'update_by' => $user_name . '[' . $user_id . ']', - 'update_by_id' => $user_id, - 'pay_bank_id' => $this->input->post('cbo_pay_type'), - 'card_tran_id' => $this->input->post('input_card_tran'), - + $paydata = array( + 'payment_mode'=> '2', + 'Customerof_type'=>'2', + 'Customerof_id'=>$ipd_master[0]->p_id, + 'group_id'=>$Med_Group_id, + 'ipd_id'=>$ipd_id, + 'med_type'=>0, + 'credit_debit'=>$cr_dr, + 'amount'=>$amount, + 'payment_date'=>$pay_datetime, + 'remark'=>$pay_remark, + 'update_by'=>$user_name.'['.$user_id.']', + 'update_by_id'=>$user_id, + 'pay_bank_id'=>$this->input->post('cbo_pay_type'), + 'card_tran_id'=>$this->input->post('input_card_tran'), + ); - - $insert_id = $this->Medical_M->insert_payment($paydata); + + $insert_id=$this->Medical_M->insert_payment($paydata); $this->Medical_M->update_invoice_group_gst($ipd_id); - - $rvar = array( - 'update' => 1, - 'ipd_id' => $ipd_id, - 'payid' => $insert_id, - 'pay_date' => $pay_datetime - ); - $encode_data = json_encode($rvar); - echo $encode_data; - } else { - $send_error = validation_errors(); - $rvar = array( - 'update' => 0, - 'error_text' => $send_error + + $rvar=array( + 'update' =>1, + 'ipd_id'=> $ipd_id, + 'payid' => $insert_id, + 'pay_date' =>$pay_datetime ); $encode_data = json_encode($rvar); echo $encode_data; } + else{ + $send_error=validation_errors(); + $rvar=array( + 'update' =>0, + 'error_text'=>$send_error + ); + $encode_data = json_encode($rvar); + echo $encode_data; + } } - - - if ($this->input->post('mode') == 5) { + + + if($this->input->post('mode')==5) + { $FormRules = array( + array( + 'field' => 'input_person_name', + 'label' => 'Name on Chq.', + 'rules' => 'required|min_length[1]|max_length[30]' + ), array( - 'field' => 'input_person_name', - 'label' => 'Name on Chq.', - 'rules' => 'required|min_length[1]|max_length[30]' - ), - array( - 'field' => 'input_bank_tran', + 'field' => 'input_bank_tran', 'label' => 'Chq. Number', - 'rules' => 'required|min_length[1]|max_length[15]' - ) + 'rules' => 'required|min_length[1]|max_length[15]' + ) /*, array( 'field' => 'input_card_digit', @@ -4375,735 +4444,760 @@ class Medical extends MY_Controller 'rules' => 'required|min_length[1]|max_length[50]' ), */ - ); - + ); + $this->form_validation->set_rules($FormRules); - - if ($this->form_validation->run() == TRUE) { - $pay_remark = 'Chq Payment'; - - $paydata = array( - 'payment_mode' => '2', - 'payof_type' => '4', - 'payof_id' => $ipd_master[0]->id, - 'payof_code' => $ipd_master[0]->ipd_code, - 'credit_debit' => $cr_dr, + + if ($this->form_validation->run() == TRUE) + { + $pay_remark='Chq Payment'; + + $paydata = array( + 'payment_mode'=> '2', + 'payof_type'=>'4', + 'payof_id'=>$ipd_master[0]->id, + 'payof_code'=>$ipd_master[0]->ipd_code, + 'credit_debit'=>$cr_dr, 'amount' => $amount, - 'payment_date' => $pay_datetime, - 'remark' => $pay_remark, - 'update_by' => $user_name . '[' . $user_id . ']', - 'card_bank' => $this->input->post('input_bank_hospital'), - 'cust_card' => $this->input->post('input_bank_name'), - 'card_remark' => $this->input->post('input_person_name'), - 'card_tran_id' => $this->input->post('input_bank_tran'), - 'update_by_id' => $user_id + 'payment_date'=>$pay_datetime, + 'remark'=>$pay_remark, + 'update_by'=>$user_name.'['.$user_id.']', + 'card_bank'=>$this->input->post('input_bank_hospital'), + 'cust_card'=>$this->input->post('input_bank_name'), + 'card_remark'=>$this->input->post('input_person_name'), + 'card_tran_id'=>$this->input->post('input_bank_tran'), + 'update_by_id'=>$user_id ); + + $insert_id=$this->Payment_M->insert($paydata); - $insert_id = $this->Payment_M->insert($paydata); - - $data = array( - 'payment_mode' => '2', - 'payment_mode_desc' => 'Bank Chq.-Draft', - 'payment_id' => $insert_id, - 'pay_date' => $pay_datetime, - 'enter_pay_date' => date('Y-m-d H:i:s'), - 'ipd_id' => $ipd_id, - 'amount' => $amount, - 'card_bank' => $this->input->post('input_bank_hospital'), - 'card_remark' => $this->input->post('input_card_digit'), - 'cust_card' => $this->input->post('input_bank_name'), - 'card_tran_id' => $this->input->post('input_bank_tran'), - 'prepared_by' => $user_name . '[' . $user_id . ']', - 'prepared_by_id' => $user_id + $data = array( + 'payment_mode'=> '2', + 'payment_mode_desc'=>'Bank Chq.-Draft', + 'payment_id'=>$insert_id, + 'pay_date'=>$pay_datetime, + 'enter_pay_date' => date('Y-m-d H:i:s'), + 'ipd_id' => $ipd_id, + 'amount' => $amount, + 'card_bank'=>$this->input->post('input_bank_hospital'), + 'card_remark'=>$this->input->post('input_card_digit'), + 'cust_card'=>$this->input->post('input_bank_name'), + 'card_tran_id'=>$this->input->post('input_bank_tran'), + 'prepared_by'=>$user_name.'['.$user_id.']', + 'prepared_by_id'=>$user_id ); - - $insert_ipdpay_id = $this->Ipd_M->insert_payment_ipd($data); - - $status = 'Bank Card'; - - - $rvar = array( - 'update' => 1, - 'ipd_id' => $ipd_id, - 'payid' => $insert_ipdpay_id + + $insert_ipdpay_id=$this->Ipd_M->insert_payment_ipd( $data); + + $status='Bank Card'; + + + $rvar=array( + 'update' =>1, + 'ipd_id'=> $ipd_id, + 'payid' => $insert_ipdpay_id ); - + $encode_data = json_encode($rvar); - echo $encode_data; - } else { - $send_error = validation_errors(); - $rvar = array( - 'update' => 0, - 'error_text' => $send_error - ); - $encode_data = json_encode($rvar); - echo $encode_data; + echo $encode_data; + } + else{ + $send_error=validation_errors(); + $rvar=array( + 'update' =>0, + 'error_text'=>$send_error + ); + $encode_data = json_encode($rvar); + echo $encode_data; } } } - - public function group_cash_print($ipd_id, $payid) + + public function group_cash_print($ipd_id,$payid) { - $sql = "select *,date_format(payment_date,'%d-%m-%Y') as pay_date, + $sql="select *,date_format(payment_date,'%d-%m-%Y') as pay_date, (case payment_mode when 1 then 'CASH' when 2 then 'Bank' Else 'Other' End) as payment_mode_desc - from payment_history_medical where id=" . $payid; + from payment_history_medical where id=".$payid; $query = $this->db->query($sql); - $data['med_payment'] = $query->result(); - - $sql = "select * from ipd_master where id =" . $ipd_id; + $data['med_payment']= $query->result(); + + $sql="select * from ipd_master where id =".$ipd_id; $query = $this->db->query($sql); - $data['ipd_master'] = $query->result(); - - $pno = $data['ipd_master'][0]->p_id; - - $sql = "select *,if(gender=1,'Male','Female') as xgender, + $data['ipd_master']= $query->result(); + + $pno=$data['ipd_master'][0]->p_id; + + $sql="select *,if(gender=1,'Male','Female') as xgender, GET_AGE_1(dob,age,age_in_month,estimate_dob) AS age - from patient_master where id='" . $pno . "' "; + from patient_master where id='".$pno."' "; - $query = $this->db->query($sql); - $data['person_info'] = $query->result(); - - $this->load->view('Medical/Med_Payment_receipt', $data); + $query = $this->db->query($sql); + $data['person_info']= $query->result(); + + $this->load->view('Medical/Med_Payment_receipt',$data); + } - public function Invoice_Item_Return($inv_type_id, $inv_type = 0) + public function Invoice_Item_Return($inv_type_id,$inv_type=0) { - $data['inv_type_id'] = $inv_type_id; - $data['inv_type'] = $inv_type; + $data['inv_type_id']=$inv_type_id; + $data['inv_type']=$inv_type; - $p_id = 0; - - if ($inv_type == 0) { - $sql = "select * from ipd_master where id='" . $inv_type_id . "' "; + $p_id=0; + + if($inv_type==0) + { + $sql="select * from ipd_master where id='".$inv_type_id."' "; $query = $this->db->query($sql); - $data['ipd_master'] = $query->result(); - - $sql_items = "select m.id as inv_id,m.inv_med_code,date_format(inv_date,'%d-%m-%Y') as str_inv_date,m.ipd_id,m.patient_id,m.group_invoice_id,m.case_id, + $data['ipd_master']= $query->result(); + + $sql_items="select m.id as inv_id,m.inv_med_code,date_format(inv_date,'%d-%m-%Y') as str_inv_date,m.ipd_id,m.patient_id,m.group_invoice_id,m.case_id, t.id as item_id,t.item_Name,t.qty,t.batch_no,t.expiry,t.store_stock_id as ss_no,t.item_code,t.mrp,t.price, t.amount,t.disc_amount,t.tamount,r.r_qty,r.id as return_id from (invoice_med_master m join inv_med_item t on m.id=t.inv_med_id ) left join inv_med_item_return r on t.id=r.inv_item_id and return_status=0 - where m.ipd_id=" . $inv_type_id . " order by t.item_Name,t.batch_no"; - - $p_id = $data['ipd_master'][0]->p_id; - } elseif ($inv_type == 1) { - $sql = "select * from organization_case_master where id='" . $inv_type_id . "' "; + where m.ipd_id=".$inv_type_id. " order by t.item_Name,t.batch_no"; + + $p_id=$data['ipd_master'][0]->p_id; + + }elseif($inv_type==1){ + $sql="select * from organization_case_master where id='".$inv_type_id."' "; $query = $this->db->query($sql); - $data['org_master'] = $query->result(); - - $sql_items = "select m.id as inv_id,m.inv_med_code,date_format(inv_date,'%d-%m-%Y') as str_inv_date,m.ipd_id,m.patient_id,m.group_invoice_id,m.case_id, + $data['org_master']= $query->result(); + + $sql_items="select m.id as inv_id,m.inv_med_code,date_format(inv_date,'%d-%m-%Y') as str_inv_date,m.ipd_id,m.patient_id,m.group_invoice_id,m.case_id, t.id as item_id,t.item_Name,t.qty,t.batch_no,t.expiry,t.store_stock_id as ss_no,t.item_code,t.mrp,t.price, t.amount,t.disc_amount,t.tamount,r.r_qty,r.id as return_id from (invoice_med_master m join inv_med_item t on m.id=t.inv_med_id ) left join inv_med_item_return r on t.id=r.inv_item_id and return_status=0 - where m.case_id=" . $inv_type_id . " order by t.item_Name,t.batch_no"; - - $p_id = $data['org_master'][0]->p_id; - } else { - $sql = "select * from invoice_med_master where id='" . $inv_type_id . "' "; + where m.case_id=".$inv_type_id. " order by t.item_Name,t.batch_no"; + + $p_id=$data['org_master'][0]->p_id; + }else{ + $sql="select * from invoice_med_master where id='".$inv_type_id."' "; $query = $this->db->query($sql); - $data['invoice_med_master'] = $query->result(); - - $sql_items = "select m.id as inv_id,m.inv_med_code,date_format(inv_date,'%d-%m-%Y') as str_inv_date,m.ipd_id,m.patient_id,m.group_invoice_id,m.case_id, + $data['invoice_med_master']= $query->result(); + + $sql_items="select m.id as inv_id,m.inv_med_code,date_format(inv_date,'%d-%m-%Y') as str_inv_date,m.ipd_id,m.patient_id,m.group_invoice_id,m.case_id, t.id as item_id,t.item_Name,t.qty,t.batch_no,t.expiry,t.store_stock_id as ss_no,t.item_code,t.mrp,t.price, t.amount,t.disc_amount,t.tamount,r.r_qty,r.id as return_id from (invoice_med_master m join inv_med_item t on m.id=t.inv_med_id ) left join inv_med_item_return r on t.id=r.inv_item_id and return_status=0 - where m.id=" . $inv_type_id . " order by t.item_Name,t.batch_no"; - - $p_id = $data['invoice_med_master'][0]->patient_id; + where m.id=".$inv_type_id. " order by t.item_Name,t.batch_no"; + + $p_id=$data['invoice_med_master'][0]->patient_id; } - - $sql = "select * from patient_master_exten - where id='" . $p_id . "' "; + + $sql="select * from patient_master_exten + where id='".$p_id."' "; $query = $this->db->query($sql); - $data['person_info'] = $query->result(); - + $data['person_info']= $query->result(); + $query = $this->db->query($sql_items); - $data['inv_items'] = $query->result(); + $data['inv_items']= $query->result(); - $this->load->view('Medical/Medical_Invoice_Return', $data); + $this->load->view('Medical/Medical_Invoice_Return',$data); } - public function Invoice_Item_Return_new($inv_type_id, $inv_type = 0) + public function Invoice_Item_Return_new($inv_type_id,$inv_type=0) { - $data['inv_type_id'] = $inv_type_id; - $data['inv_type'] = $inv_type; + $data['inv_type_id']=$inv_type_id; + $data['inv_type']=$inv_type; - $p_id = 0; - - $sql = "select * from ipd_master where id='" . $inv_type_id . "' "; + $p_id=0; + + $sql="select * from ipd_master where id='".$inv_type_id."' "; $query = $this->db->query($sql); - $data['ipd_master'] = $query->result(); - - $p_id = $data['ipd_master'][0]->p_id; + $data['ipd_master']= $query->result(); + + $p_id=$data['ipd_master'][0]->p_id; - $sql = "select * from patient_master_exten - where id='" . $p_id . "' "; + $sql="select * from patient_master_exten + where id='".$p_id."' "; $query = $this->db->query($sql); - $data['person_info'] = $query->result(); - - $this->load->view('Medical/IPD_return_medicine', $data); + $data['person_info']= $query->result(); + + $this->load->view('Medical/IPD_return_medicine',$data); } - public function IPD_Item_Return_temp($inv_type_id, $inv_type = 0) + public function IPD_Item_Return_temp($inv_type_id,$inv_type=0) { - $data['inv_type_id'] = $inv_type_id; - $data['inv_type'] = $inv_type; + $data['inv_type_id']=$inv_type_id; + $data['inv_type']=$inv_type; - if ($inv_type == 0) { - - $sql_items = "select m.id as inv_id,m.inv_med_code,date_format(inv_date,'%d-%m-%Y') as str_inv_date,m.ipd_id,m.patient_id,m.group_invoice_id,m.case_id, + if($inv_type==0) + { + + $sql_items="select m.id as inv_id,m.inv_med_code,date_format(inv_date,'%d-%m-%Y') as str_inv_date,m.ipd_id,m.patient_id,m.group_invoice_id,m.case_id, t.id as item_id,t.item_Name,t.qty,t.batch_no,t.expiry,t.store_stock_id as ss_no,t.item_code,t.mrp,t.price, t.amount,t.disc_amount,t.tamount,r.r_qty,r.id as return_id from (invoice_med_master m join inv_med_item t on m.id=t.inv_med_id ) join inv_med_item_return r on t.id=r.inv_item_id and return_status=0 - where m.ipd_id=" . $inv_type_id . " order by r.id desc"; - } elseif ($inv_type == 1) { - - $sql_items = "select m.id as inv_id,m.inv_med_code,date_format(inv_date,'%d-%m-%Y') as str_inv_date,m.ipd_id,m.patient_id,m.group_invoice_id,m.case_id, + where m.ipd_id=".$inv_type_id. " order by r.id desc"; + + + }elseif($inv_type==1){ + + $sql_items="select m.id as inv_id,m.inv_med_code,date_format(inv_date,'%d-%m-%Y') as str_inv_date,m.ipd_id,m.patient_id,m.group_invoice_id,m.case_id, t.id as item_id,t.item_Name,t.qty,t.batch_no,t.expiry,t.store_stock_id as ss_no,t.item_code,t.mrp,t.price, t.amount,t.disc_amount,t.tamount,r.r_qty,r.id as return_id from (invoice_med_master m join inv_med_item t on m.id=t.inv_med_id ) join inv_med_item_return r on t.id=r.inv_item_id and return_status=0 - where m.case_id=" . $inv_type_id . " order by r.id desc"; - } else { - - $sql_items = "select m.id as inv_id,m.inv_med_code,date_format(inv_date,'%d-%m-%Y') as str_inv_date,m.ipd_id,m.patient_id,m.group_invoice_id,m.case_id, + where m.case_id=".$inv_type_id. " order by r.id desc"; + + }else{ + + $sql_items="select m.id as inv_id,m.inv_med_code,date_format(inv_date,'%d-%m-%Y') as str_inv_date,m.ipd_id,m.patient_id,m.group_invoice_id,m.case_id, t.id as item_id,t.item_Name,t.qty,t.batch_no,t.expiry,t.store_stock_id as ss_no,t.item_code,t.mrp,t.price, t.amount,t.disc_amount,t.tamount,r.r_qty,r.id as return_id from (invoice_med_master m join inv_med_item t on m.id=t.inv_med_id ) join inv_med_item_return r on t.id=r.inv_item_id and return_status=0 - where l m.id=" . $inv_type_id . " order by r.id desc"; + where l m.id=".$inv_type_id. " order by r.id desc"; + } - + $query = $this->db->query($sql_items); - $data['inv_items'] = $query->result(); + $data['inv_items']= $query->result(); - $this->load->view('Medical/Medical_Invoice_Return_list', $data); + $this->load->view('Medical/Medical_Invoice_Return_list',$data); } public function IPD_Item_list($inv_type_id) { - $data['inv_type_id'] = $inv_type_id; + $data['inv_type_id']=$inv_type_id; - if (isset($_GET['term'])) { + if (isset($_GET['term'])){ $q = strtolower($_GET['term']); - $sql = "select m.id as inv_id,m.inv_med_code,date_format(inv_date,'%d-%m-%Y') as str_inv_date,m.ipd_id,m.patient_id,m.group_invoice_id,m.case_id, + $sql="select m.id as inv_id,m.inv_med_code,date_format(inv_date,'%d-%m-%Y') as str_inv_date,m.ipd_id,m.patient_id,m.group_invoice_id,m.case_id, t.id as item_id,t.item_Name,t.qty,t.batch_no,t.expiry,t.store_stock_id as ss_no,t.item_code,t.mrp,t.price, t.amount,t.disc_amount,t.tamount,r.r_qty,r.id as return_id from (invoice_med_master m join inv_med_item t on m.id=t.inv_med_id ) left join inv_med_item_return r on t.id=r.inv_item_id and return_status=0 - where r.id is null and m.ipd_id=" . $inv_type_id . " "; - - if (strlen($q) > 0) { - $sql .= " and t.item_name LIKE '" . $q . "%'"; - } else { - $sql .= " and 1<>1 "; + where r.id is null and m.ipd_id=".$inv_type_id. " "; + + if(strlen($q)>0) + { + $sql.=" and t.item_name LIKE '".$q."%'"; + }else{ + $sql.=" and 1<>1 "; } - $sql .= " order by t.item_name,t.id"; - + $sql.=" order by t.item_name,t.id"; + $query = $this->db->query($sql); - if ($query->num_rows() > 0) { - foreach ($query->result_array() as $row) { - $new_row['label'] = htmlentities(stripslashes($row['item_Name'])) . ' |B:' . htmlentities(stripslashes($row['batch_no'])) . ' |Rs.' . htmlentities(stripslashes($row['mrp'])) . ' |Qty:' . htmlentities(stripslashes($row['qty'])); - $new_row['value'] = htmlentities(stripslashes($row['item_Name'])); - $new_row['l_item_code'] = htmlentities(stripslashes($row['item_id'])); - $new_row['l_Batch'] = htmlentities(stripslashes($row['batch_no'])); - $new_row['l_mrp'] = htmlentities(stripslashes($row['mrp'])); - $new_row['l_price'] = htmlentities(stripslashes($row['price'])); - $new_row['l_qty'] = htmlentities(stripslashes($row['qty'])); - $new_row['sql'] = $sql; - $row_set[] = $new_row; //build an array + if($query->num_rows() > 0){ + foreach ($query->result_array() as $row){ + $new_row['label']=htmlentities(stripslashes($row['item_Name'])).' |B:'.htmlentities(stripslashes($row['batch_no'])). ' |Rs.'.htmlentities(stripslashes($row['mrp'])).' |Qty:'.htmlentities(stripslashes($row['qty'])); + $new_row['value']=htmlentities(stripslashes($row['item_Name'])); + $new_row['l_item_code']=htmlentities(stripslashes($row['item_id'])); + $new_row['l_Batch']=htmlentities(stripslashes($row['batch_no'])); + $new_row['l_mrp']=htmlentities(stripslashes($row['mrp'])); + $new_row['l_price']=htmlentities(stripslashes($row['price'])); + $new_row['l_qty']=htmlentities(stripslashes($row['qty'])); + $new_row['sql']=$sql; + $row_set[] = $new_row; //build an array } echo json_encode($row_set); //format the array into json data - } else { - $new_row['sql'] = $sql; + }else{ + $new_row['sql']=$sql; $row_set[] = $new_row; echo json_encode($row_set); } } + } - + public function Med_Return_invoice_search($r_inv_id) { - $data['r_inv_id'] = $r_inv_id; - $this->load->view('Medical/Med_Return_Invoice_search', $data); + $data['r_inv_id']=$r_inv_id; + $this->load->view('Medical/Med_Return_Invoice_search',$data); } public function Invoice_Item_old() { - $search_text = trim($this->input->post('search_text')); - $search_type = $this->input->post('search_type'); + $search_text=trim($this->input->post('search_text')); + $search_type=$this->input->post('search_type'); - if ($search_type == 1) { - $sql = "SELECT m.id AS inv_id,m.inv_med_code,m.inv_date,m.inv_name,m.inv_phone_number, + if($search_type==1){ + $sql="SELECT m.id AS inv_id,m.inv_med_code,m.inv_date,m.inv_name,m.inv_phone_number, i.*,date_format(i.expiry,'%m-%Y') as exp_date,(i.disc_amount+disc_whole) as t_discount FROM (invoice_med_master m JOIN inv_med_item i ON m.id=i.inv_med_id AND m.sale_return=0) Where m.inv_date >=date_add(curdate(),interval -5 month) and m.inv_phone_number='$search_text' and m.ipd_id=0 and m.case_id=0 "; $query = $this->db->query($sql); - $data['med_inv_item_list'] = $query->result(); + $data['med_inv_item_list']= $query->result(); } - if ($search_type == 2) { - $sql = "SELECT count(id) as no_rec,group_concat(id) as p_id_list - From patient_master where p_code like '" . $search_text . "' "; + if($search_type==2){ + $sql="SELECT count(id) as no_rec,group_concat(id) as p_id_list + From patient_master where p_code like '".$search_text."' "; $query = $this->db->query($sql); - $patient_master = $query->result(); + $patient_master= $query->result(); - $search_id_list = "0"; - if ($patient_master[0]->no_rec) { - $search_id_list = $patient_master[0]->p_id_list; + $search_id_list="0"; + if($patient_master[0]->no_rec) + { + $search_id_list=$patient_master[0]->p_id_list; } - - $sql = "SELECT m.id AS inv_id,m.inv_med_code,m.inv_date,m.inv_name,m.inv_phone_number, + + $sql="SELECT m.id AS inv_id,m.inv_med_code,m.inv_date,m.inv_name,m.inv_phone_number, i.*,date_format(i.expiry,'%m-%Y') as exp_date,(i.disc_amount+disc_whole) as t_discount FROM (invoice_med_master m JOIN inv_med_item i ON m.id=i.inv_med_id AND m.sale_return=0) Where m.inv_date >=date_add(curdate(),interval -5 month) and m.patient_id in ($search_id_list) and m.ipd_id=0 and m.case_id=0"; $query = $this->db->query($sql); - $data['med_inv_item_list'] = $query->result(); + $data['med_inv_item_list']= $query->result(); } - if ($search_type == 3) { - $sql = "SELECT m.id AS inv_id,m.inv_med_code,m.inv_date,m.inv_name,m.inv_phone_number, + if($search_type==3){ + $sql="SELECT m.id AS inv_id,m.inv_med_code,m.inv_date,m.inv_name,m.inv_phone_number, i.*,date_format(i.expiry,'%m-%Y') as exp_date,(i.disc_amount+disc_whole) as t_discount FROM (invoice_med_master m JOIN inv_med_item i ON m.id=i.inv_med_id AND m.sale_return=0) - Where m.inv_date >=date_add(curdate(),interval -12 month) and m.inv_med_code like '%" . $search_text . "' and m.ipd_id=0 and m.case_id=0"; + Where m.inv_date >=date_add(curdate(),interval -12 month) and m.inv_med_code like '%".$search_text."' and m.ipd_id=0 and m.case_id=0"; $query = $this->db->query($sql); - $data['med_inv_item_list'] = $query->result(); + $data['med_inv_item_list']= $query->result(); } - if ($search_type == 4) { - $sql = "SELECT m.id AS inv_id,m.inv_med_code,m.inv_date,m.inv_name,m.inv_phone_number, + if($search_type==4){ + $sql="SELECT m.id AS inv_id,m.inv_med_code,m.inv_date,m.inv_name,m.inv_phone_number, i.*,date_format(i.expiry,'%m-%Y') as exp_date,(i.disc_amount+disc_whole) as t_discount FROM (invoice_med_master m JOIN inv_med_item i ON m.id=i.inv_med_id AND m.sale_return=0) - Where m.inv_date >=date_add(curdate(),interval -5 month) and i.item_Name like '" . $search_text . "%' "; + Where m.inv_date >=date_add(curdate(),interval -5 month) and i.item_Name like '".$search_text."%' "; $query = $this->db->query($sql); - $data['med_inv_item_list'] = $query->result(); + $data['med_inv_item_list']= $query->result(); } - $this->load->view('Medical/Med_Item_old_list', $data); + $this->load->view('Medical/Med_Item_old_list',$data); } public function Invoice_old($inv_id) { - $sql = "Select * from invoice_med_master where id=$inv_id "; + $sql="Select * from invoice_med_master where id=$inv_id"; $query = $this->db->query($sql); - $invoice_med_master = $query->result(); + $invoice_med_master= $query->result(); - $phone_no = ''; - $p_id = 0; - $ipd_id = 0; + $phone_no=''; + $p_id=0; + $ipd_id=0; - if (count($invoice_med_master) > 0) { - $phone_no = $invoice_med_master[0]->inv_phone_number; - $p_id = $invoice_med_master[0]->patient_id; - $ipd_id = $invoice_med_master[0]->ipd_id; + if(count($invoice_med_master)>0) + { + $phone_no=$invoice_med_master[0]->inv_phone_number; + $p_id=$invoice_med_master[0]->patient_id; + $ipd_id=$invoice_med_master[0]->ipd_id; } - if ($ipd_id > 0) { - $sql = "SELECT m.id AS inv_id,m.inv_med_code,m.inv_date,m.inv_name,m.inv_phone_number, + if($ipd_id>0){ + $sql="SELECT m.id AS inv_id,m.inv_med_code,m.inv_date,m.inv_name,m.inv_phone_number, i.*,date_format(i.expiry,'%m-%Y') as exp_date,(i.disc_amount+disc_whole) as t_discount, m.net_amount FROM (invoice_med_master m JOIN inv_med_item i ON m.id=i.inv_med_id AND m.sale_return=0) Where m.id<>$inv_id and m.ipd_id=$ipd_id and m.case_id=0 order by m.id desc"; - } else if ($p_id > 0) { - $sql = "SELECT m.id AS inv_id,m.inv_med_code,m.inv_date,m.inv_name,m.inv_phone_number, + }else if($p_id>0) + { + $sql="SELECT m.id AS inv_id,m.inv_med_code,m.inv_date,m.inv_name,m.inv_phone_number, i.*,date_format(i.expiry,'%m-%Y') as exp_date,(i.disc_amount+disc_whole) as t_discount, m.net_amount FROM (invoice_med_master m JOIN inv_med_item i ON m.id=i.inv_med_id AND m.sale_return=0) - Where m.patient_id='$p_id' and m.id<>$inv_id and m.ipd_id=0 and m.case_id=0 - and m.inv_date>date_add(sysdate(),interval -6 month) - order by m.id desc"; - } else if ($phone_no != '') { - $sql = "SELECT m.id AS inv_id,m.inv_med_code,m.inv_date,m.inv_name,m.inv_phone_number, + Where m.patient_id='$p_id' and m.id<>$inv_id and m.ipd_id=0 and m.case_id=0 order by m.id desc"; + }else if($phone_no!=''){ + $sql="SELECT m.id AS inv_id,m.inv_med_code,m.inv_date,m.inv_name,m.inv_phone_number, i.*,date_format(i.expiry,'%m-%Y') as exp_date,(i.disc_amount+disc_whole) as t_discount, m.net_amount FROM (invoice_med_master m JOIN inv_med_item i ON m.id=i.inv_med_id AND m.sale_return=0) - Where m.inv_phone_number='$phone_no' and m.id<>$inv_id and m.ipd_id=0 and m.case_id=0 - and m.inv_date>date_add(sysdate(),interval -6 month) - order by m.id desc"; - } else { - $sql = "SELECT m.id AS inv_id,m.inv_med_code,m.inv_date,m.inv_name,m.inv_phone_number, + Where m.inv_phone_number='$phone_no' and m.id<>$inv_id and m.ipd_id=0 and m.case_id=0 order by m.id desc"; + }else{ + $sql="SELECT m.id AS inv_id,m.inv_med_code,m.inv_date,m.inv_name,m.inv_phone_number, i.*,date_format(i.expiry,'%m-%Y') as exp_date,(i.disc_amount+disc_whole) as t_discount, m.net_amount FROM (invoice_med_master m JOIN inv_med_item i ON m.id=i.inv_med_id AND m.sale_return=0) - Where 1<>1 and m.inv_date>date_add(sysdate(),interval -6 month)"; + Where 1<>1 "; } - + $query = $this->db->query($sql); - $data['med_inv_item_list'] = $query->result(); + $data['med_inv_item_list']= $query->result(); - $this->load->view('Medical/Med_old_invoice_list', $data); + $this->load->view('Medical/Med_old_invoice_list',$data); } public function add_remove_item() { $this->load->model('Medical_M'); - $inv_id = $this->input->post('inv_id'); - $item_id = $this->input->post('itemid'); - $rqty = $this->input->post('rqty'); + $inv_id=$this->input->post('inv_id'); + $item_id=$this->input->post('itemid'); + $rqty=$this->input->post('rqty'); - $this->Medical_M->opd_reset($inv_id); + $this->Medical_M->opd_reset( $inv_id); $this->Medical_M->update_invoice_final($inv_id); $user = $this->ion_auth->user()->row(); - $user_update_info = $user->first_name . '' . $user->last_name . '[' . $user->id . ']' . date('d-m-Y H:i:s'); + $user_update_info = $user->first_name.''. $user->last_name.'['.$user->id.']'.date('d-m-Y H:i:s'); - $sql = "select * from inv_med_item where id='" . $item_id . "' "; - $query = $this->db->query($sql); - $inv_med_item_result = $query->result_array(); + $sql="select * from inv_med_item where id='".$item_id."' "; + $query = $this->db->query($sql); + $inv_med_item_result= $query->result_array(); - $update = 0; - $msg_box = ""; + $update=0; + $msg_box=""; - if (count($inv_med_item_result) > 0) { - $inv_med_item = $inv_med_item_result[0]; + if(count($inv_med_item_result)>0) + { + $inv_med_item=$inv_med_item_result[0]; - $CGST = $inv_med_item['CGST_per']; - $SGST = $inv_med_item['SGST_per']; + $CGST=$inv_med_item['CGST_per']; + $SGST=$inv_med_item['SGST_per']; - $item_rate = $inv_med_item['price2']; - $amount_value = $rqty * $item_rate * -1; + $item_rate=$inv_med_item['price2']; + $amount_value=$rqty*$item_rate*-1; - $disc_total = $inv_med_item['disc_amount'] + $inv_med_item['disc_whole']; - $amount = $inv_med_item['amount']; - $twdisc_amount = $inv_med_item['twdisc_amount']; + $disc_total=$inv_med_item['disc_amount']+$inv_med_item['disc_whole']; + $amount=$inv_med_item['amount']; + $twdisc_amount=$inv_med_item['twdisc_amount']; - $margin = $amount - $twdisc_amount; - $desc_per = $margin * 100 / $amount; + $margin=$amount-$twdisc_amount; + $desc_per=$margin*100/$amount; - $disc_amount = $amount_value * $desc_per / 100; - $Tamount_value = $amount_value - $disc_amount; + $disc_amount=$amount_value*$desc_per/100; + $Tamount_value=$amount_value-$disc_amount; unset($inv_med_item['id']); - $inv_med_item['inv_med_id'] = $inv_id; + $inv_med_item['inv_med_id'] =$inv_id; //Old Qty Sale - $old_qty = $inv_med_item['qty']; - $inv_med_item['qty'] = $rqty; + $old_qty=$inv_med_item['qty']; + $inv_med_item['qty'] =$rqty; - $inv_med_item['return_item_id'] = $item_id; - $inv_med_item['sale_return'] = 1; + $inv_med_item['return_item_id']=$item_id; + $inv_med_item['sale_return']=1; $inv_med_item['amount'] = $amount_value; $inv_med_item['tamount'] = $Tamount_value; - $inv_med_item['disc_amount'] = $disc_amount; - $inv_med_item['disc_per'] = $desc_per; + $inv_med_item['disc_amount']=$disc_amount; + $inv_med_item['disc_per']=$desc_per; - $inv_med_item['disc_whole'] = '0'; - $inv_med_item['twdisc_amount'] = $Tamount_value; + $inv_med_item['disc_whole']='0'; + $inv_med_item['twdisc_amount']=$Tamount_value; - $inv_med_item['update_by_remark'] = $user_update_info; - $inv_med_item['update_by_id'] = $user->id; + $inv_med_item['update_by_remark']=$user_update_info; + $inv_med_item['update_by_id']=$user->id; - $sql = "select * from inv_med_item + $sql="select * from inv_med_item where sale_return=1 and inv_med_id='$inv_id' and return_item_id='$item_id' "; $query = $this->db->query($sql); - $inv_med_item_return = $query->result(); - - $sql = "select sum(qty) as t_r_qty from inv_med_item + $inv_med_item_return= $query->result(); + + $sql="select sum(qty) as t_r_qty from inv_med_item where sale_return=1 and return_item_id='$item_id' "; $query = $this->db->query($sql); - $med_item_return_total = $query->result(); + $med_item_return_total= $query->result(); - $tot_qty = 0; + $tot_qty=0; - if (count($med_item_return_total) > 0) { - $tot_return = $med_item_return_total[0]->t_r_qty; - $tot_qty = $old_qty - $tot_return; + if(count($med_item_return_total)>0) + { + $tot_return=$med_item_return_total[0]->t_r_qty; + $tot_qty=$old_qty-$tot_return; } - if ($tot_qty >= $rqty) { - if (count($inv_med_item_return) == 0) { - $update = $this->Medical_M->add_invoiceitem($inv_med_item); - $msg_box = "Added Return list"; - } else { - $update = $inv_med_item_return[0]->id; - - $this->Medical_M->update_invoiceitem($inv_med_item, $update); - $msg_box = "Update Return "; + if($tot_qty>=$rqty) + { + if(count($inv_med_item_return)==0) + { + $update=$this->Medical_M->add_invoiceitem( $inv_med_item); + $msg_box="Added Return list"; + }else{ + $update=$inv_med_item_return[0]->id; + + $this->Medical_M->update_invoiceitem( $inv_med_item,$update); + $msg_box="Update Return "; } - } else { - $update = 0; - $msg_box = "Item Already Returned"; + }else{ + $update=0; + $msg_box="Item Already Returned"; } - } else { - $update = 0; - $msg_box = "No item found"; + + }else{ + $update=0; + $msg_box="No item found"; } - + $this->Medical_M->update_invoice_final($inv_id); - - $sql = "SELECT i.*,ifnull(DATEDIFF(expiry,CURDATE()),1000) AS no_day, + + $sql="SELECT i.*,ifnull(DATEDIFF(expiry,CURDATE()),1000) AS no_day, SUM(p.total_unit-p.total_sale_unit-total_return_unit-total_lost_unit)/p.packing AS cur_qty FROM (inv_med_item i JOIN purchase_invoice_item p ON i.item_code=p.item_code AND p.remove_item=0 ) - where inv_med_id=" . $inv_id . " GROUP BY i.id"; + where inv_med_id=".$inv_id." GROUP BY i.id"; $query = $this->db->query($sql); - $data['inv_items'] = $query->result(); + $data['inv_items']= $query->result(); - $sql = "select item_code - from inv_med_item where inv_med_id=" . $inv_id . " Group by item_code Having count(id)>1"; - $query = $this->db->query($sql); - $data['inv_items_multiple'] = $query->result(); - - $sql = "Select sum(amount) as Gtotal,sum(tamount) as tamt, + $sql="select item_code + from inv_med_item where inv_med_id=".$inv_id." Group by item_code Having count(id)>1"; + $query = $this->db->query($sql); + $data['inv_items_multiple']= $query->result(); + + $sql="Select sum(amount) as Gtotal,sum(tamount) as tamt, sum(CGST) as TCGST,sum(SGST) as TSGST,sum(disc_amount) as t_dis_amt - from inv_med_item where inv_med_id=" . $inv_id; + from inv_med_item where inv_med_id=".$inv_id; $query = $this->db->query($sql); - $data['invoiceGtotal'] = $query->result(); + $data['invoiceGtotal']= $query->result(); $user = $this->ion_auth->user()->row(); $data['user_id'] = $user->id; - $sql = "select * from invoice_med_master where id=" . $inv_id; + $sql="select * from invoice_med_master where id=".$inv_id; $query = $this->db->query($sql); - $data['invoiceMaster'] = $query->result(); + $data['invoiceMaster']= $query->result(); - $data['sale_return'] = $data['invoiceMaster'][0]->sale_return; + $data['sale_return']=$data['invoiceMaster'][0]->sale_return; + + $content=$this->load->view('Medical/Med_Item_List',$data,true); - $content = $this->load->view('Medical/Med_Item_List', $data, true); - - $rvar = array( - 'update' => $update, - 'msg_text' => $msg_box, - 'content' => $content - ); + $rvar=array( + 'update' =>$update, + 'msg_text'=>$msg_box, + 'content'=>$content + ); $encode_data = json_encode($rvar); echo $encode_data; + } public function Update_Return() { $this->load->model('Medical_M'); - $r_qty = $this->input->post('u_qty'); - $item_id = $this->input->post('itemid'); + $r_qty=$this->input->post('u_qty'); + $item_id=$this->input->post('itemid'); - $sql = "select * from inv_med_item where id='" . $item_id . "' "; - $query = $this->db->query($sql); - $inv_med_item_result = $query->result_array(); + $sql="select * from inv_med_item where id='".$item_id."' "; + $query = $this->db->query($sql); + $inv_med_item_result= $query->result_array(); - $user = $this->ion_auth->user()->row(); - $user_update_info = $user->first_name . '' . $user->last_name . '[' . $user->id . ']' . date('d-m-Y H:i:s'); + $user = $this->ion_auth->user()->row(); + $user_update_info = $user->first_name.''. $user->last_name.'['.$user->id.']'.date('d-m-Y H:i:s'); - $update = 0; - $msg_box = ""; + $update=0; + $msg_box=""; - if (count($inv_med_item_result) > 0) { - $inv_med_item = $inv_med_item_result[0]; + if(count($inv_med_item_result)>0) + { + $inv_med_item=$inv_med_item_result[0]; - $CGST = $inv_med_item['CGST_per']; - $SGST = $inv_med_item['SGST_per']; + $CGST=$inv_med_item['CGST_per']; + $SGST=$inv_med_item['SGST_per']; - $item_rate = $inv_med_item['price']; - $amount_value = $r_qty * $item_rate; + $item_rate=$inv_med_item['price']; + $amount_value=$r_qty*$item_rate; - $disc = $inv_med_item['disc_per']; - $disc_amount = $amount_value * $disc / 100; + $disc=$inv_med_item['disc_per']; + $disc_amount=$amount_value*$disc/100; - $Tamount_value = $amount_value - $disc_amount; + $Tamount_value=$amount_value-$disc_amount; $inv_med_item['inv_item_id'] = $inv_med_item['id']; unset($inv_med_item['id']); - $inv_med_item['r_qty'] = $r_qty; + $inv_med_item['r_qty'] =$r_qty; $inv_med_item['amount'] = $amount_value; $inv_med_item['tamount'] = $Tamount_value; - $inv_med_item['update_remark'] = $user_update_info; + $inv_med_item['update_remark']=$user_update_info; - $sql = "select * from inv_med_item_return where return_status=0 and inv_item_id='" . $item_id . "' "; + $sql="select * from inv_med_item_return where return_status=0 and inv_item_id='".$item_id."' "; $query = $this->db->query($sql); - $inv_med_item_return = $query->result_array(); + $inv_med_item_return= $query->result_array(); - if (count($inv_med_item_return) == 0) { - $update = $this->Medical_M->insert_inv_med_item_return_add($inv_med_item); - $msg_box = "Added in Pending Return list"; - } else { - $update = 1; + if(count($inv_med_item_return)==0) + { + $update=$this->Medical_M->insert_inv_med_item_return_add( $inv_med_item); + $msg_box="Added in Pending Return list"; + }else{ + $update=1; $this->Medical_M->delete_return_item($item_id); - $update = $this->Medical_M->insert_inv_med_item_return_add($inv_med_item); - $msg_box = "Alerady in Pending Return list, Now Update Again "; + $update=$this->Medical_M->insert_inv_med_item_return_add($inv_med_item); + $msg_box="Alerady in Pending Return list, Now Update Again "; } - } else { - $update = 0; - $msg_box = "No item found"; - } - $rvar = array( - 'update' => $update, - 'msg_text' => $msg_box - ); + }else{ + $update=0; + $msg_box="No item found"; + } + + $rvar=array( + 'update' =>$update, + 'msg_text'=>$msg_box + ); $encode_data = json_encode($rvar); echo $encode_data; } - + public function undo_Return() { $this->load->model('Medical_M'); - $item_id = $this->input->post('itemid'); + $item_id=$this->input->post('itemid'); - $update = 1; - $msg_box = ""; + $update=1; + $msg_box=""; $this->Medical_M->delete_return_item($item_id); - $rvar = array( - 'update' => $update, - 'msg_text' => $msg_box - ); + $rvar=array( + 'update' =>$update, + 'msg_text'=>$msg_box + ); $encode_data = json_encode($rvar); echo $encode_data; } - public function pre_reurn_item_list($inv_type_id, $inv_type = 0) + public function pre_reurn_item_list($inv_type_id,$inv_type=0) { - $data['inv_type_id'] = $inv_type_id; - $data['inv_type'] = $inv_type; + $data['inv_type_id']=$inv_type_id; + $data['inv_type']=$inv_type; - $p_id = 0; - - if ($inv_type == 0) { - $sql = "select * from ipd_master where id='" . $inv_type_id . "' "; + $p_id=0; + + if($inv_type==0) + { + $sql="select * from ipd_master where id='".$inv_type_id."' "; $query = $this->db->query($sql); - $data['ipd_master'] = $query->result(); - - $sql_items = "select m.id as inv_id,m.inv_med_code,date_format(inv_date,'%d-%m-%Y') as str_inv_date,m.ipd_id,m.patient_id,m.group_invoice_id,m.case_id, + $data['ipd_master']= $query->result(); + + $sql_items="select m.id as inv_id,m.inv_med_code,date_format(inv_date,'%d-%m-%Y') as str_inv_date,m.ipd_id,m.patient_id,m.group_invoice_id,m.case_id, t.id as item_id,t.item_Name,t.qty,t.batch_no,t.expiry,t.store_stock_id as ss_no,t.item_code,t.mrp,t.price, t.amount,t.disc_amount,t.tamount,t.r_qty,t.id as return_id from (invoice_med_master m join inv_med_item_return t on m.id=t.inv_med_id and t.return_status=0) - where m.ipd_id=" . $inv_type_id . " order by t.item_Name,t.batch_no"; - - $p_id = $data['ipd_master'][0]->p_id; - } elseif ($inv_type == 1) { - $sql = "select * from organization_case_master where id='" . $inv_type_id . "' "; + where m.ipd_id=".$inv_type_id. " order by t.item_Name,t.batch_no"; + + $p_id=$data['ipd_master'][0]->p_id; + + }elseif($inv_type==1){ + $sql="select * from organization_case_master where id='".$inv_type_id."' "; $query = $this->db->query($sql); - $data['org_master'] = $query->result(); - - $sql_items = "select m.id as inv_id,m.inv_med_code,date_format(inv_date,'%d-%m-%Y') as str_inv_date,m.ipd_id,m.patient_id,m.group_invoice_id,m.case_id, + $data['org_master']= $query->result(); + + $sql_items="select m.id as inv_id,m.inv_med_code,date_format(inv_date,'%d-%m-%Y') as str_inv_date,m.ipd_id,m.patient_id,m.group_invoice_id,m.case_id, t.id as item_id,t.item_Name,t.qty,t.batch_no,t.expiry,t.store_stock_id as ss_no,t.item_code,t.mrp,t.price, t.amount,t.disc_amount,t.tamount,t.r_qty,t.id as return_id from (invoice_med_master m join inv_med_item_return t on m.id=t.inv_med_id and t.return_status=0) - where m.case_id=" . $inv_type_id . " order by t.item_Name,t.batch_no"; - - $p_id = $data['org_master'][0]->p_id; - } else { - $sql = "select * from invoice_med_master where id='" . $inv_type_id . "' "; + where m.case_id=".$inv_type_id. " order by t.item_Name,t.batch_no"; + + $p_id=$data['org_master'][0]->p_id; + }else{ + $sql="select * from invoice_med_master where id='".$inv_type_id."' "; $query = $this->db->query($sql); - $data['invoice_med_master'] = $query->result(); - - $sql_items = "select m.id as inv_id,m.inv_med_code,date_format(inv_date,'%d-%m-%Y') as str_inv_date,m.ipd_id,m.patient_id,m.group_invoice_id,m.case_id, + $data['invoice_med_master']= $query->result(); + + $sql_items="select m.id as inv_id,m.inv_med_code,date_format(inv_date,'%d-%m-%Y') as str_inv_date,m.ipd_id,m.patient_id,m.group_invoice_id,m.case_id, t.id as item_id,t.item_Name,t.qty,t.batch_no,t.expiry,t.store_stock_id as ss_no,t.item_code,t.mrp,t.price, t.amount,t.disc_amount,t.tamount,t.r_qty,t.id as return_id from (invoice_med_master m join inv_med_item_return t on m.id=t.inv_med_id and t.return_status=0) - where m.id=" . $inv_type_id . " order by t.item_Name,t.batch_no"; - - $p_id = $data['invoice_med_master'][0]->patient_id; + where m.id=".$inv_type_id. " order by t.item_Name,t.batch_no"; + + $p_id=$data['invoice_med_master'][0]->patient_id; } - - $sql = "select * from patient_master_exten - where id='" . $p_id . "' "; + + $sql="select * from patient_master_exten + where id='".$p_id."' "; $query = $this->db->query($sql); - $data['person_info'] = $query->result(); - + $data['person_info']= $query->result(); + $query = $this->db->query($sql_items); - $data['inv_items'] = $query->result(); + $data['inv_items']= $query->result(); - $this->load->view('Medical/Medical_Invoice_Return_pre', $data); + $this->load->view('Medical/Medical_Invoice_Return_pre',$data); } - public function Med_Return_final($inv_type_id, $inv_type = 0) + public function Med_Return_final($inv_type_id,$inv_type=0) { $this->load->model('Medical_M'); - $data['inv_type_id'] = $inv_type_id; - $data['inv_type'] = $inv_type; + $data['inv_type_id']=$inv_type_id; + $data['inv_type']=$inv_type; - $p_id = 0; - - if ($inv_type == 0) { - $sql = "select * from ipd_master where id='" . $inv_type_id . "' "; + $p_id=0; + + if($inv_type==0) + { + $sql="select * from ipd_master where id='".$inv_type_id."' "; $query = $this->db->query($sql); - $data['ipd_master'] = $query->result(); - - $sql_items = "select m.id as inv_id,m.inv_med_code,date_format(inv_date,'%d-%m-%Y') as str_inv_date,m.ipd_id,m.patient_id,m.group_invoice_id,m.case_id, + $data['ipd_master']= $query->result(); + + $sql_items="select m.id as inv_id,m.inv_med_code,date_format(inv_date,'%d-%m-%Y') as str_inv_date,m.ipd_id,m.patient_id,m.group_invoice_id,m.case_id, t.id as ritem_id,t.inv_item_id,t.item_Name,t.qty,t.batch_no,t.expiry,t.store_stock_id as ss_no,t.item_code,t.mrp,t.price, t.amount,t.disc_per,t.disc_amount,t.tamount,t.r_qty,t.id as return_id from (invoice_med_master m join inv_med_item_return t on m.id=t.inv_med_id and t.return_status=0) - where m.ipd_id=" . $inv_type_id . " order by t.item_Name,t.batch_no"; - - $p_id = $data['ipd_master'][0]->p_id; - } elseif ($inv_type == 1) { - $sql = "select * from organization_case_master where id='" . $inv_type_id . "' "; + where m.ipd_id=".$inv_type_id. " order by t.item_Name,t.batch_no"; + + $p_id=$data['ipd_master'][0]->p_id; + + }elseif($inv_type==1){ + $sql="select * from organization_case_master where id='".$inv_type_id."' "; $query = $this->db->query($sql); - $data['org_master'] = $query->result(); - - $sql_items = "select m.id as inv_id,m.inv_med_code,date_format(inv_date,'%d-%m-%Y') as str_inv_date,m.ipd_id,m.patient_id,m.group_invoice_id,m.case_id, + $data['org_master']= $query->result(); + + $sql_items="select m.id as inv_id,m.inv_med_code,date_format(inv_date,'%d-%m-%Y') as str_inv_date,m.ipd_id,m.patient_id,m.group_invoice_id,m.case_id, t.id as ritem_id,t.inv_item_id,t.item_Name,t.qty,t.batch_no,t.expiry,t.store_stock_id as ss_no,t.item_code,t.mrp,t.price, t.amount,t.disc_per,t.disc_amount,t.tamount,t.r_qty,t.id as return_id from (invoice_med_master m join inv_med_item_return t on m.id=t.inv_med_id and t.return_status=0) - where m.case_id=" . $inv_type_id . " order by t.item_Name,t.batch_no"; - - $p_id = $data['org_master'][0]->p_id; - } else { - $sql = "select * from invoice_med_master where id='" . $inv_type_id . "' "; + where m.case_id=".$inv_type_id. " order by t.item_Name,t.batch_no"; + + $p_id=$data['org_master'][0]->p_id; + }else{ + $sql="select * from invoice_med_master where id='".$inv_type_id."' "; $query = $this->db->query($sql); - $data['invoice_med_master'] = $query->result(); - - $sql_items = "select m.id as inv_id,m.inv_med_code,date_format(inv_date,'%d-%m-%Y') as str_inv_date,m.ipd_id,m.patient_id,m.group_invoice_id,m.case_id, + $data['invoice_med_master']= $query->result(); + + $sql_items="select m.id as inv_id,m.inv_med_code,date_format(inv_date,'%d-%m-%Y') as str_inv_date,m.ipd_id,m.patient_id,m.group_invoice_id,m.case_id, t.id as ritem_id,t.inv_item_id,t.item_Name,t.qty,t.batch_no,t.expiry,t.store_stock_id as ss_no,t.item_code,t.mrp,t.price, t.amount,t.disc_per,t.disc_amount,t.tamount,t.r_qty,t.id as return_id from (invoice_med_master m join inv_med_item_return t on m.id=t.inv_med_id and t.return_status=0) - where m.id=" . $inv_type_id . " order by t.item_Name,t.batch_no"; - - $p_id = $data['invoice_med_master'][0]->patient_id; + where m.id=".$inv_type_id. " order by t.item_Name,t.batch_no"; + + $p_id=$data['invoice_med_master'][0]->patient_id; } - - $sql = "select * from patient_master_exten - where id='" . $p_id . "' "; + + $sql="select * from patient_master_exten + where id='".$p_id."' "; $query = $this->db->query($sql); - $data['person_info'] = $query->result(); - + $data['person_info']= $query->result(); + $query = $this->db->query($sql_items); - $data['inv_items'] = $query->result(); + $data['inv_items']= $query->result(); - foreach ($data['inv_items'] as $row) { - $store_stock_id = $row->ss_no; + foreach($data['inv_items'] as $row) + { + $store_stock_id=$row->ss_no; - $ritem_id = $row->ritem_id; + $ritem_id=$row->ritem_id; - $itemid = $row->inv_item_id; + $itemid=$row->inv_item_id; - $item_rate = $row->price; + $item_rate=$row->price; + + $current_qty=$row->qty-$row->r_qty; - $current_qty = $row->qty - $row->r_qty; + $inv_id=$row->inv_id; + + $amount_value=$current_qty*$item_rate; - $inv_id = $row->inv_id; + $disc_per=$row->disc_per; + + $disc_amount=$amount_value*$disc_per/100; + + $Tamount_value=$amount_value-$disc_amount; - $amount_value = $current_qty * $item_rate; - - $disc_per = $row->disc_per; - - $disc_amount = $amount_value * $disc_per / 100; - - $Tamount_value = $amount_value - $disc_amount; - - $data['update_inv_med_item'] = array( + $data['update_inv_med_item'] = array( 'qty' => $current_qty, 'disc_amount' => $disc_amount, 'amount' => $amount_value, @@ -5112,100 +5206,102 @@ class Medical extends MY_Controller 'inv_med_id' => $inv_id, ); - $update_return_item = array( + $update_return_item = array( 'return_status' => '1', ); - $this->Medical_M->update_return_item($update_return_item, $ritem_id); - - $this->Medical_M->update_invoiceitem($data['update_inv_med_item'], $itemid); + $this->Medical_M->update_return_item($update_return_item,$ritem_id); + $this->Medical_M->update_invoiceitem($data['update_inv_med_item'],$itemid); + $this->Medical_M->update_invoice_final($inv_id); } - redirect('/Medical/pre_reurn_item_list/' . $inv_type_id . '/' . $inv_type = 0); + redirect('/Medical/pre_reurn_item_list/'.$inv_type_id.'/'.$inv_type=0); } - public function Med_Return_print($inv_type_id, $inv_type = 0) + public function Med_Return_print($inv_type_id,$inv_type=0) { $this->load->model('Medical_M'); - $data['inv_type_id'] = $inv_type_id; - $data['inv_type'] = $inv_type; + $data['inv_type_id']=$inv_type_id; + $data['inv_type']=$inv_type; - $p_id = 0; - - if ($inv_type == 0) { - $sql = "select * from v_ipd_list where id='" . $inv_type_id . "' "; + $p_id=0; + + if($inv_type==0) + { + $sql="select * from v_ipd_list where id='".$inv_type_id."' "; $query = $this->db->query($sql); - $data['ipd_master'] = $query->result(); - - $sql_items = "select m.id as inv_id,m.inv_med_code,date_format(inv_date,'%d-%m-%Y') as str_inv_date, + $data['ipd_master']= $query->result(); + + $sql_items="select m.id as inv_id,m.inv_med_code,date_format(inv_date,'%d-%m-%Y') as str_inv_date, date_format(return_date_time,'%d-%m-%Y') as str_ret_date,m.ipd_id,m.patient_id,m.group_invoice_id,m.case_id, t.id as ritem_id,t.inv_item_id,t.item_Name,t.qty,t.batch_no,t.expiry,t.store_stock_id as ss_no,t.item_code,t.mrp,t.price, t.update_remark,t.return_date_time, t.amount,t.disc_per,t.disc_amount,t.tamount,t.r_qty,t.id as return_id from (invoice_med_master m join inv_med_item_return t on m.id=t.inv_med_id and t.return_status=1) - where m.ipd_id=" . $inv_type_id . " order by t.return_date_time,t.item_Name,t.batch_no"; - - $p_id = $data['ipd_master'][0]->p_id; - } elseif ($inv_type == 1) { - $sql = "select * from organization_case_master where id='" . $inv_type_id . "' "; + where m.ipd_id=".$inv_type_id. " order by t.return_date_time,t.item_Name,t.batch_no"; + + $p_id=$data['ipd_master'][0]->p_id; + + }elseif($inv_type==1){ + $sql="select * from organization_case_master where id='".$inv_type_id."' "; $query = $this->db->query($sql); - $data['org_master'] = $query->result(); - - $sql_items = "select m.id as inv_id,m.inv_med_code,date_format(inv_date,'%d-%m-%Y') as str_inv_date, + $data['org_master']= $query->result(); + + $sql_items="select m.id as inv_id,m.inv_med_code,date_format(inv_date,'%d-%m-%Y') as str_inv_date, date_format(return_date_time,'%d-%m-%Y') as str_ret_date,m.ipd_id,m.patient_id,m.group_invoice_id,m.case_id, t.id as ritem_id,t.inv_item_id,t.item_Name,t.qty,t.batch_no,t.expiry,t.store_stock_id as ss_no,t.item_code,t.mrp,t.price,t.update_remark,t.return_date_time, t.amount,t.disc_per,t.disc_amount,t.tamount,t.r_qty,t.id as return_id from (invoice_med_master m join inv_med_item_return t on m.id=t.inv_med_id and t.return_status=1) - where m.case_id=" . $inv_type_id . " order by t.return_date_time,t.item_Name,t.batch_no"; - - $p_id = $data['org_master'][0]->p_id; - } else { - $sql = "select * from invoice_med_master where id='" . $inv_type_id . "' "; + where m.case_id=".$inv_type_id. " order by t.return_date_time,t.item_Name,t.batch_no"; + + $p_id=$data['org_master'][0]->p_id; + }else{ + $sql="select * from invoice_med_master where id='".$inv_type_id."' "; $query = $this->db->query($sql); - $data['invoice_med_master'] = $query->result(); - - $sql_items = "select m.id as inv_id,m.inv_med_code,date_format(inv_date,'%d-%m-%Y') as str_inv_date, + $data['invoice_med_master']= $query->result(); + + $sql_items="select m.id as inv_id,m.inv_med_code,date_format(inv_date,'%d-%m-%Y') as str_inv_date, date_format(return_date_time,'%d-%m-%Y') as str_ret_date,m.ipd_id,m.patient_id,m.group_invoice_id,m.case_id, t.id as ritem_id,t.inv_item_id,t.item_Name,t.qty,t.batch_no,t.expiry,t.store_stock_id as ss_no,t.item_code,t.mrp,t.price,t.update_remark,t.return_date_time, t.amount,t.disc_per,t.disc_amount,t.tamount,t.r_qty,t.id as return_id from (invoice_med_master m join inv_med_item_return t on m.id=t.inv_med_id and t.return_status=1) - where m.id=" . $inv_type_id . " order by t.return_date_time,t.item_Name,t.batch_no"; - - $p_id = $data['invoice_med_master'][0]->patient_id; + where m.id=".$inv_type_id. " order by t.return_date_time,t.item_Name,t.batch_no"; + + $p_id=$data['invoice_med_master'][0]->patient_id; } - - $sql = "select * from patient_master_exten - where id='" . $p_id . "' "; + + $sql="select * from patient_master_exten + where id='".$p_id."' "; $query = $this->db->query($sql); - $data['person_info'] = $query->result(); - + $data['person_info']= $query->result(); + $query = $this->db->query($sql_items); - $data['inv_items'] = $query->result(); + $data['inv_items']= $query->result(); //load mPDF library - $this->load->library('m_pdf'); + $this->load->library('m_pdf'); - $this->m_pdf->pdf->SetWatermarkText(M_store); - $this->m_pdf->pdf->showWatermarkText = false; + $this->m_pdf->pdf->SetWatermarkText(M_store); + $this->m_pdf->pdf->showWatermarkText = false; - $file_name = 'Medical_Return_' . date('Ymdhis') . ".pdf"; + $file_name='Medical_Return_'.date('Ymdhis').".pdf"; - $filepath = $file_name; + $filepath=$file_name; - $content = $this->load->view('Medical/Print/Medical_return_medicine', $data, TRUE); + $content=$this->load->view('Medical/Print/Medical_return_medicine',$data,TRUE); //echo $content; - //generate the PDF from the given html - $this->m_pdf->pdf->WriteHTML($content); - - //download it. - $this->m_pdf->pdf->Output($filepath, "I"); + //generate the PDF from the given html + $this->m_pdf->pdf->WriteHTML($content); + //download it. + $this->m_pdf->pdf->Output($filepath,"I"); + //$this->load->view('Medical/Medical_Invoice_Return_print',$data); } @@ -5213,18 +5309,22 @@ class Medical extends MY_Controller //Medical Notification public function get_medical_bill_pending_higher() { - $sql = "SELECT COUNT(i.id) AS No_IPD + $sql="SELECT COUNT(i.id) AS No_IPD FROM inv_med_group m JOIN ipd_master i ON m.ipd_id=i.id WHERE i.ipd_status=0 AND m.med_type=1 AND m.net_amount>0 AND payment_balance>=50000"; $query = $this->db->query($sql); - $ipd_pending_balance = $query->result(); + $ipd_pending_balance= $query->result(); - $No_IPD = $ipd_pending_balance[0]->No_IPD; - if ($No_IPD > 0) { - echo 'High Bal. :' . $No_IPD; - } else { + $No_IPD=$ipd_pending_balance[0]->No_IPD; + if($No_IPD>0) + { + echo 'High Bal. :'.$No_IPD; + }else{ echo ''; } } -} + + + +} \ No newline at end of file diff --git a/old_code_ci3/controllers/Medical1.php b/old_code_ci3/controllers/Medical1.php new file mode 100644 index 0000000..5a5a6d5 --- /dev/null +++ b/old_code_ci3/controllers/Medical1.php @@ -0,0 +1,4820 @@ +load->view('Medical/Dashboard'); + } + + public function select_store($store_id) + { + $sql="select * from store_master where store_id=".$store_id; + $query = $this->db->query($sql); + $data['store_master']= $query->result(); + + $this->load->view('Medical/Store_Dashboard',$data); + } + + public function main_store() + { + $this->load->view('Medical/Stock/main_store_dashboard'); + } + + + public function DrugList() + { + $this->load->view('Medical/Drug_Details'); + + //$sql="select item_id,itemname,dosage from drug_temp_25072017"; + //$query = $this->db->query($sql); + //$data['drug_data']= $query->result(); + + //$this->load->view('Medical/Drug_Details_all',$data); + } + + public function Purchase() + { + $this->load->view('Medical/Purchase/supplier_list'); + } + + public function PurchaseMasterEdit($inv_id) + { + $sql="select * from med_supplier order by name_supplier"; + $query = $this->db->query($sql); + $data['supplier_data']= $query->result(); + + $sql="select p.*,s.name_supplier from purchase_invoice p join med_supplier s on p.sid=s.sid where p.id=".$inv_id; + $query = $this->db->query($sql); + $data['inv_master_data']= $query->result(); + + $sql="select * from purchase_invoice_item where purchase_id='".$inv_id."' "; + $query = $this->db->query($sql); + $data['purchase_item']= $query->result(); + + $this->load->view('Medical/Purchase/purchase_invoice_master_edit',$data); + + } + + public function UpdatePurchase() + { + $rec_id=$this->input->post('hid_purchaseid'); + $sid=$this->input->post('input_supplier'); + $invoice_code=$this->input->post('input_invoicecode'); + $d_invoice=$this->input->post('datepicker_invoice'); + + $Udata = array( + 'sid'=> $sid, + 'date_of_invoice'=> str_to_MysqlDate($d_invoice), + 'Invoice_no'=> $invoice_code + ); + + $this->load->model('Medical_M'); + + $update_id=$this->Medical_M->update_purchase($Udata,$rec_id); + + $rvar=array( + 'insertid' =>1, + 'show_text'=>'Data Update' + ); + + $encode_data = json_encode($rvar); + echo $encode_data; + + } + + public function UpdatePurchaseInvoiceStatus($purchase_inv_id,$inv_status) + { + $user = $this->ion_auth->user()->row(); + $user_id = $user->id; + $user_name_info = $user->first_name.''. $user->last_name .'['.$user_id.']'.date('d-m-Y H:i:s'); + + $Udata = array( + 'inv_status'=> $inv_status, + 'inv_status_update_by'=> $user_name_info, + ); + + $this->load->model('Medical_M'); + + $update_id=$this->Medical_M->update_purchase($Udata,$purchase_inv_id); + + redirect('Medical/PurchaseMasterEdit/'.$purchase_inv_id); + + } + + public function PurchaseNew() + { + $sql="select * from med_supplier order by name_supplier"; + $query = $this->db->query($sql); + $data['supplier_data']= $query->result(); + + $this->load->view('Medical/Purchase/new_purchase_invoice',$data); + } + + public function SupplierList() + { + $sql="select * from med_supplier"; + $query = $this->db->query($sql); + $data['supplier_data']= $query->result(); + + $this->load->view('Medical/Purchase/supplier_master',$data); + } + + public function PurchaseInvoice() + { + $sdata=$this->input->post('txtsearch'); + + $sdata = preg_replace('/[^A-Za-z0-9_ \-]/', '', $sdata); + + if(trim($sdata)=='') + { + $sql="select p.id,p.Invoice_no,p.date_of_invoice, + date_format(p.date_of_invoice,'%d-%m-%Y') as str_date_of_invoice,p.sid,s.name_supplier, + s.short_name,s.gst_no, + p.T_Net_Amount as tamount + from (purchase_invoice p join med_supplier s on p.sid=s.sid) + + group by p.id + order by p.id desc limit 50"; + }else{ + + $numric_condition=""; + + if(is_numeric($sdata)) + { + $numric_condition=" OR p.Invoice_no=".$sdata ; + } + + $sql="select p.id,p.Invoice_no,p.date_of_invoice, + date_format(p.date_of_invoice,'%d-%m-%Y') as str_date_of_invoice, + p.sid,s.name_supplier,s.short_name,s.gst_no, + p.T_Net_Amount as tamount + from (purchase_invoice p join med_supplier s on p.sid=s.sid) + where (p.Invoice_no LIKE '%".$sdata."' ".$numric_condition." ) + group by p.id order by p.id desc limit 50"; + } + + $query = $this->db->query($sql); + $data['purchase_list']= $query->result(); + + $this->load->view('Medical/Purchase/purchase_supp_list',$data); + } + + public function PurchaseInvoiceEdit($inv_id) + { + $sql="select p.id,p.Invoice_no,p.date_of_invoice,date_format(p.date_of_invoice,'%d/%m/%Y') as str_date_of_invoice, + p.sid,s.name_supplier,s.short_name,s.gst_no,p.inv_status + from purchase_invoice p join med_supplier s on p.sid=s.sid + where p.id=".$inv_id; + $query = $this->db->query($sql); + $data['purchase_invoice']= $query->result(); + + $sql="select * from purchase_invoice_item where purchase_id=".$inv_id; + $query = $this->db->query($sql); + $data['purchase_invoice_item']= $query->result(); + + $this->load->view('Medical/Purchase/purchase_Invoice_Edit',$data); + } + + public function purchase_invoice_delete($inv_id) + { + + $sql="select * from purchase_invoice_item where purchase_id=$inv_id"; + $query = $this->db->query($sql); + $purchase_invoice_item= $query->result(); + + if (count($purchase_invoice_item)>0){ + $rvar=array( + 'is_delete' =>0, + 'show_text'=>"Invoice has Items, Empty the item list", + ); + }else{ + $this->load->model('Medical_M'); + $is_delete=$this->Medical_M->delete_purchase($inv_id); + $rvar=array( + 'is_delete' =>1, + 'show_text'=>"Invoice has been deleted", + ); + } + + + $encode_data = json_encode($rvar); + echo $encode_data; + + } + + public function SupplierListSub() + { + $sql="select * from med_supplier order by name_supplier"; + $query = $this->db->query($sql); + $data['supplier_data']= $query->result(); + + $this->load->view('Medical/Purchase/supplier_master_sub',$data); + } + + public function SupplierEdit($sid=0) + { + $sql="select * from med_supplier where sid=".$sid; + $query = $this->db->query($sql); + $data['supplier_data']= $query->result(); + + $this->load->view('Medical/Purchase/supplier_Edit',$data); + } + + public function CreatePurchase() + { + if (!$this->input->is_ajax_request()) { exit('no valid req.'); } + + $FormRules = array( + array( + 'field' => 'input_invoicecode', + 'label' => 'Invoice No', + 'rules' => 'required|min_length[3]|max_length[30]' + ) + ); + + $this->form_validation->set_rules($FormRules); + + if ($this->form_validation->run() == TRUE) + { + $sid=$this->input->post('input_supplier'); + $invoice_code=$this->input->post('input_invoicecode'); + $d_invoice=$this->input->post('datepicker_invoice'); + + $where=" where sid=$sid"; + + if(is_numeric($invoice_code)) + $where.=" and Invoice_no=".$invoice_code ; + else + $where.=" and Invoice_no='".$invoice_code."'"; + + $sql="select count(*) as no_rec from purchase_invoice ".$where; + $query = $this->db->query($sql); + $chk_rec= $query->result(); + + if($chk_rec[0]->no_rec==0) + { + $Udata = array( + 'sid'=> $sid, + 'date_of_invoice'=> str_to_MysqlDate($d_invoice), + 'Invoice_no'=> $invoice_code + ); + + $this->load->model('Medical_M'); + + $inser_id=$this->Medical_M->insert_purchase($Udata); + $send_msg="Added Successfully"; + + if($inser_id>0) + { + $show_text=Show_Alert('success','Success',$send_msg); + }else{ + $show_text=Show_Alert('danger','Error',$send_msg); + } + }else{ + $show_text=Show_Alert('danger','Error',' Record Already Exist'); + $inser_id=0; + } + + $rvar=array( + 'insertid' =>$inser_id, + 'show_text'=>$show_text + ); + + $encode_data = json_encode($rvar); + echo $encode_data; + + } + else{ + $send_msg=validation_errors(); + $rvar=array( + 'insertid' =>0, + 'show_text'=>Show_Alert('danger','Error',$send_msg) + ); + $encode_data = json_encode($rvar); + echo $encode_data; + } + } + + + public function SupplierUpdate($sid=0) + { + if (!$this->input->is_ajax_request()) { exit('no valid req.'); } + + $FormRules = array( + array( + 'field' => 'input_name_supplier', + 'label' => 'Supplier Name', + 'rules' => 'required|min_length[3]|max_length[30]' + ), + array( + 'field' => 'input_short_name', + 'label' => 'Short Name', + 'rules' => 'required|min_length[1]|max_length[30]' + ), + array( + 'field' => 'input_gst_no', + 'label' => 'GST No.', + 'rules' => 'required|min_length[5]|max_length[15]' + ), + array( + 'field' => 'input_state', + 'label' => 'State', + 'rules' => 'required|min_length[1]|max_length[20]' + ) + ); + + $this->form_validation->set_rules($FormRules); + + if ($this->form_validation->run() == TRUE) + { + $sid=$this->input->post('hid_sid'); + $name_supplier=$this->input->post('input_name_supplier'); + $short_name=$this->input->post('input_short_name'); + $contact_no=$this->input->post('input_contact_no'); + $gst_no=$this->input->post('input_gst_no'); + $city=$this->input->post('input_city'); + $state=$this->input->post('input_state'); + + $Udata = array( + 'name_supplier'=> $name_supplier, + 'short_name'=> $short_name, + 'contact_no'=> $contact_no, + 'gst_no'=> $gst_no, + 'city'=> $city, + 'state'=> $state + ); + + $this->load->model('Medical_M'); + + if($sid>0) + { + $inser_id=$this->Medical_M->update_supplier($Udata,$sid); + $send_msg="Saved Successfully"; + }else{ + $inser_id=$this->Medical_M->insert_supplier($Udata); + $send_msg="Added Successfully"; + } + + if($inser_id>0) + { + $show_text=Show_Alert('success','Success',$send_msg); + }else{ + $show_text=Show_Alert('danger','Error',$send_msg); + } + + $rvar=array( + 'insertid' =>$inser_id, + 'show_text'=>$show_text + ); + + $encode_data = json_encode($rvar); + echo $encode_data; + + } + else{ + $send_msg=validation_errors(); + $rvar=array( + 'insertid' =>0, + 'show_text'=>Show_Alert('danger','Error',$send_msg) + ); + $encode_data = json_encode($rvar); + echo $encode_data; + } + + } + + public function StockDrugList() + { + $this->load->view('Medical/Medical_stock_drug'); + } + + public function add_stock() + { + if (!$this->input->is_ajax_request()) { exit('no valid req.'); } + + $FormRules = array( + array( + 'field' => 'input_product_code', + 'label' => 'Product Code', + 'rules' => 'required|min_length[3]|max_length[30]' + ), + array( + 'field' => 'input_product_name', + 'label' => 'Product Name', + 'rules' => 'required|min_length[3]|max_length[100]' + ), + array( + 'field' => 'input_product_mrp', + 'label' => 'Product MRP', + 'rules' => 'required|min_length[1]|max_length[10]' + ), + array( + 'field' => 'input_selling_price', + 'label' => 'Selling Price', + 'rules' => 'required|min_length[1]|max_length[10]' + ), + array( + 'field' => 'input_qty', + 'label' => 'Product Qty', + 'rules' => 'required|min_length[1]|max_length[10]' + ), + array( + 'field' => 'input_package', + 'label' => 'Package', + 'rules' => 'required|min_length[1]|max_length[10]' + ), + array( + 'field' => 'input_HSNCODE', + 'label' => 'HSNCODE', + 'rules' => 'required|min_length[1]|max_length[10]' + ), + array( + 'field' => 'input_CGST', + 'label' => 'CGST', + 'rules' => 'required|min_length[1]|max_length[10]' + ), + array( + 'field' => 'input_SGST', + 'label' => 'SGST', + 'rules' => 'required|min_length[1]|max_length[10]' + ) + ); + + $this->form_validation->set_rules($FormRules); + + if ($this->form_validation->run() == TRUE) + { + $item_code=$this->input->post('input_product_code'); + + if($item_code=='IC0000000') + { + $item_code='MC'.date('ymdhis'); + } + + $selling_price=$this->input->post('input_selling_price'); + + $package=$this->input->post('input_package'); + $qty=$this->input->post('input_qty'); + $total_unit=$package*$qty; + $unit_rate=$selling_price/$qty; + + $datepicker_doe_month=$this->input->post('datepicker_doe_month'); + $datepicker_doe_year=$this->input->post('datepicker_doe_year'); + + $datepicker_doe="20".$datepicker_doe_year."-".$datepicker_doe_month."-01"; + + $this->load->model('Medical_M'); + $data = array( + 'item_code' => $item_code, + 'item_name' => $this->input->post('input_product_name'), + 'rack_no' => $this->input->post('input_rack_no'), + 'shelf_no' => $this->input->post('input_shelf_no'), + 'cold_storage' => $this->input->post('input_storage'), + 'batch_no' => $this->input->post('input_batch_code'), + 'qty' => $this->input->post('input_qty'), + 'packing' => $this->input->post('input_package'), + 'expiry_date' => $datepicker_doe, + 'mrp' => $this->input->post('input_product_mrp'), + 'purchase_price' => $this->input->post('input_purchase_price'), + 'selling_price' => $this->input->post('input_selling_price'), + 'total_unit' => $total_unit, + 'unit_rate' => $unit_rate, + 'margin' => $this->input->post('input_margin'), + 'formulation' => $this->input->post('input_formulation'), + 'stock_date' => str_to_MysqlDate($this->input->post('datepicker_stock')), + 'min_qty' => $this->input->post('input_minqty'), + 'HSNCODE' => $this->input->post('input_HSNCODE'), + 'CGST' => $this->input->post('input_CGST'), + 'SGST' => $this->input->post('input_SGST'), + 'IGST' => $this->input->post('input_IGST'), + 'dosage' => $this->input->post('input_dosage'), + 'supplier_id' => $this->input->post('input_supplier') + ); + + $data_drug = array( + 'item_id' => $item_code, + 'itemname' => $this->input->post('input_product_name'), + 'mrp' => $this->input->post('input_product_mrp'), + 'formulation' => $this->input->post('input_formulation'), + 'HSNCODE' => $this->input->post('input_HSNCODE'), + 'CGST' => $this->input->post('input_CGST'), + 'SGST' => $this->input->post('input_SGST'), + 'IGST' => $this->input->post('input_IGST'), + 'dosage' => $this->input->post('input_dosage') + ); + $show_text=''; + + $sql="select * from drug_temp where item_id='".$item_code."'"; + $query = $this->db->query($sql); + $drug_item= $query->result(); + + if(count($drug_item)>0) + { + $inser_id=$this->Medical_M->update_drug($data_drug,$item_code); + }else{ + $inser_id=$this->Medical_M->insert_drug_add($data_drug); + } + + if($inser_id>0) + { + $inser_id=0; + $inser_id=$this->Medical_M->insert_stock_add($data); + if($inser_id>0) + { + $send_msg="Added"; + }else{ + $send_msg="Error : Add in Stock Table"; + } + }else{ + $send_msg="Error : Addition data in Master Drug Table"; + } + + if($inser_id>0) + { + $show_text=Show_Alert('success','Success',$send_msg); + }else{ + $show_text=Show_Alert('danger','Error',$send_msg); + } + + $rvar=array( + 'insertid' =>$inser_id, + 'product_code' => $item_code, + 'show_text'=>$show_text + ); + + $encode_data = json_encode($rvar); + echo $encode_data; + + } + else + { + $send_msg=validation_errors(); + $rvar=array( + 'insertid' =>0, + 'show_text'=>Show_Alert('danger','Error',$send_msg) + ); + $encode_data = json_encode($rvar); + echo $encode_data; + } + } + + public function update_master() + { + if (!$this->input->is_ajax_request()) { exit('no valid req.'); } + + $FormRules = array( + array( + 'field' => 'input_product_code', + 'label' => 'Product Code', + 'rules' => 'required|min_length[3]|max_length[30]' + ), + array( + 'field' => 'input_product_name', + 'label' => 'Product Name', + 'rules' => 'required|min_length[3]|max_length[100]' + ), + array( + 'field' => 'input_product_mrp', + 'label' => 'Product MRP', + 'rules' => 'required|min_length[1]|max_length[10]' + ), + array( + 'field' => 'input_selling_price', + 'label' => 'Selling Price', + 'rules' => 'required|min_length[1]|max_length[10]' + ), + array( + 'field' => 'input_HSNCODE', + 'label' => 'HSNCODE', + 'rules' => 'required|min_length[1]|max_length[10]' + ), + array( + 'field' => 'input_CGST', + 'label' => 'CGST', + 'rules' => 'required|min_length[1]|max_length[10]' + ), + array( + 'field' => 'input_SGST', + 'label' => 'SGST', + 'rules' => 'required|min_length[1]|max_length[10]' + ) + ); + + $this->form_validation->set_rules($FormRules); + + if ($this->form_validation->run() == TRUE) + { + $item_code=$this->input->post('input_product_code'); + + $this->load->model('Medical_M'); + + $data_drug = array( + 'item_id' => $item_code, + 'itemname' => $this->input->post('input_product_name'), + 'mrp' => $this->input->post('input_product_mrp'), + 'formulation' => $this->input->post('input_formulation'), + 'HSNCODE' => $this->input->post('input_HSNCODE'), + 'CGST' => $this->input->post('input_CGST'), + 'SGST' => $this->input->post('input_SGST'), + 'IGST' => $this->input->post('input_IGST'), + 'dosage' => $this->input->post('input_dosage') + ); + $show_text=''; + + $sql="select * from drug_temp where item_id='".$item_code."'"; + $query = $this->db->query($sql); + $drug_item= $query->result(); + + if(count($drug_item)>0) + { + $inser_id=$this->Medical_M->update_drug($data_drug,$item_code); + }else{ + $inser_id=$this->Medical_M->insert_drug_add($data_drug); + } + + if($inser_id>0) + { + $inser_id=0; + $inser_id=$this->Medical_M->insert_stock_add($data); + if($inser_id>0) + { + $send_msg="Update"; + }else{ + $send_msg="Error : Edit in Drug Master"; + } + }else{ + $send_msg="Error : Addition data in Master Drug Table"; + } + + if($inser_id>0) + { + $show_text=Show_Alert('success','Success',$send_msg); + }else{ + $show_text=Show_Alert('danger','Error',$send_msg); + } + + $rvar=array( + 'insertid' =>$inser_id, + 'product_code' => $item_code, + 'show_text'=>$show_text + ); + + $encode_data = json_encode($rvar); + echo $encode_data; + + } + else + { + $send_msg=validation_errors(); + $rvar=array( + 'insertid' =>0, + 'show_text'=>Show_Alert('danger','Error',$send_msg) + ); + $encode_data = json_encode($rvar); + echo $encode_data; + } + } + + public function update_stock($ss_no) + { + if (!$this->input->is_ajax_request()) { exit('no valid req.'); } + + $FormRules = array( + array( + 'field' => 'input_product_code', + 'label' => 'Product Code', + 'rules' => 'required|min_length[3]|max_length[30]' + ), + array( + 'field' => 'input_product_name', + 'label' => 'Product Name', + 'rules' => 'required|min_length[3]|max_length[100]' + ) + , + array( + 'field' => 'input_product_mrp', + 'label' => 'Product MRP', + 'rules' => 'required|min_length[1]|max_length[10]' + ), + array( + 'field' => 'input_selling_price', + 'label' => 'Selling Price', + 'rules' => 'required|min_length[1]|max_length[10]' + ), + array( + 'field' => 'input_qty', + 'label' => 'Product Qty', + 'rules' => 'required|min_length[1]|max_length[10]' + ), + array( + 'field' => 'input_package', + 'label' => 'Package', + 'rules' => 'required|min_length[1]|max_length[10]' + ), + array( + 'field' => 'input_HSNCODE', + 'label' => 'HSNCODE', + 'rules' => 'required|min_length[1]|max_length[10]' + ), + array( + 'field' => 'input_CGST', + 'label' => 'CGST', + 'rules' => 'required|min_length[1]|max_length[10]' + ), + array( + 'field' => 'input_SGST', + 'label' => 'SGST', + 'rules' => 'required|min_length[1]|max_length[10]' + ) + ); + + $this->form_validation->set_rules($FormRules); + + if ($this->form_validation->run() == TRUE) + { + $item_code=$this->input->post('input_product_code'); + + $selling_price=$this->input->post('input_selling_price'); + + $package=$this->input->post('input_package'); + $qty=$this->input->post('input_qty'); + $total_unit=$package*$qty; + $unit_rate=$selling_price/$qty; + + $datepicker_doe_month=$this->input->post('datepicker_doe_month'); + $datepicker_doe_year=$this->input->post('datepicker_doe_year'); + + $datepicker_doe="20".$datepicker_doe_year."-".$datepicker_doe_month."-01"; + + $this->load->model('Medical_M'); + $data = array( + 'item_code' => $item_code, + 'item_name' => $this->input->post('input_product_name'), + 'rack_no' => $this->input->post('input_rack_no'), + 'shelf_no' => $this->input->post('input_shelf_no'), + 'cold_storage' => $this->input->post('input_storage'), + 'batch_no' => $this->input->post('input_batch_code'), + 'qty' => $this->input->post('input_qty'), + 'packing' => $this->input->post('input_package'), + 'expiry_date' => $datepicker_doe, + 'mrp' => $this->input->post('input_product_mrp'), + 'purchase_price' => $this->input->post('input_purchase_price'), + 'selling_price' => $this->input->post('input_selling_price'), + 'total_unit' => $total_unit, + 'unit_rate' => $unit_rate, + 'margin' => $this->input->post('input_margin'), + 'formulation' => $this->input->post('input_formulation'), + 'stock_date' => str_to_MysqlDate($this->input->post('datepicker_stock')), + 'min_qty' => $this->input->post('input_minqty'), + 'HSNCODE' => $this->input->post('input_HSNCODE'), + 'CGST' => $this->input->post('input_CGST'), + 'SGST' => $this->input->post('input_SGST'), + 'IGST' => $this->input->post('input_IGST'), + 'supplier_id' => $this->input->post('input_supplier') + ); + + $show_text=''; + + $is_update_stock=0; + + $is_update_stock=$this->Medical_M->update_stock_upd($data,$ss_no); + + if($is_update_stock>0) + { + $send_msg="Updated"; + }else{ + $send_msg="Error : Update in Stock Table"; + } + + if($is_update_stock>0) + { + $show_text=Show_Alert('success','Updated',$send_msg); + }else{ + $show_text=Show_Alert('danger','Error',$send_msg); + } + + $rvar=array( + 'is_update_stock' =>$is_update_stock, + 'product_code' => $item_code, + 'show_text'=>$show_text + ); + + $encode_data = json_encode($rvar); + echo $encode_data; + + } + else + { + $send_msg=validation_errors(); + $rvar=array( + 'is_update_stock' =>0, + 'show_text'=>Show_Alert('danger','Error',$send_msg) + ); + $encode_data = json_encode($rvar); + echo $encode_data; + } + } + + public function purchase_update_stock($inv_id,$return_stock=0) + { + if (!$this->input->is_ajax_request()) { exit('no valid req.'); } + + $sql="select * from purchase_invoice where id=".$inv_id; + $query = $this->db->query($sql); + $purchase_invoice= $query->result(); + + $user = $this->ion_auth->user()->row(); + $user_id = $user->id; + $user_name_info = $user->first_name.''. $user->last_name .'['.$user_id.']'.date('d-m-Y H:i:s'); + + $FormRules = array( + array( + 'field' => 'input_product_code', + 'label' => 'Not Found in Database', + 'rules' => 'required|min_length[1]|max_length[30]' + ), + array( + 'field' => 'input_drug_hid', + 'label' => 'Product Name', + 'rules' => 'required|min_length[3]|max_length[100]' + ), + array( + 'field' => 'input_product_mrp', + 'label' => 'Product MRP', + 'rules' => 'required|min_length[1]|max_length[10]' + ), + array( + 'field' => 'input_selling_price', + 'label' => 'Selling Price', + 'rules' => 'required|min_length[1]|max_length[10]' + ), + array( + 'field' => 'input_Qty', + 'label' => 'Product Qty', + 'rules' => 'required|min_length[1]|max_length[10]' + ), + array( + 'field' => 'input_package', + 'label' => 'Package', + 'rules' => 'required|min_length[1]|max_length[10]' + ), + array( + 'field' => 'input_HSNCODE', + 'label' => 'HSNCODE', + 'rules' => 'required|min_length[1]|max_length[10]' + ), + array( + 'field' => 'input_CGST', + 'label' => 'CGST', + 'rules' => 'required|min_length[1]|max_length[10]' + ), + array( + 'field' => 'input_SGST', + 'label' => 'SGST', + 'rules' => 'required|min_length[1]|max_length[10]' + ), + array( + 'field' => 'input_purchase_price', + 'label' => 'Purchase Price', + 'rules' => 'required|min_length[1]|max_length[10]' + ) + ); + + $this->form_validation->set_rules($FormRules); + + if ($this->form_validation->run() == TRUE) + { + $item_code=$this->input->post('input_product_code'); + $item_id=$this->input->post('invoice_item_id'); + + $datepicker_doe_month=$this->input->post('datepicker_doe_month'); + $datepicker_doe_year=$this->input->post('datepicker_doe_year'); + + $datepicker_doe="20".$datepicker_doe_year."-".$datepicker_doe_month."-01"; + + $this->load->model('Medical_M'); + + $Pdata = array( + 'purchase_id' => $inv_id, + 'item_code' => $item_code, + 'item_name' => $this->input->post('input_drug_hid'), + 'packing' => $this->input->post('input_package'), + 'batch_no' => $this->input->post('input_batch_code'), + 'purchase_price' => $this->input->post('input_purchase_price'), + 'expiry_date' => $datepicker_doe, + 'mrp' => $this->input->post('input_product_mrp'), + + 'qty' => $this->input->post('input_Qty'), + 'qty_free' => $this->input->post('input_Qty_Free'), + + 'discount' => $this->input->post('input_disc_price'), + + 'CGST_per' => $this->input->post('input_CGST'), + 'SGST_per' => $this->input->post('input_SGST'), + + 'HSNCODE' => $this->input->post('input_HSNCODE'), + + 'cold_storage' => $this->input->post('input_storage'), + 'shelf_no' => $this->input->post('input_shelf_no'), + 'rack_no' => $this->input->post('input_rack_no'), + 'stock_date' => $purchase_invoice[0]->date_of_invoice, + + 'selling_price' => $this->input->post('input_selling_price'), + + 'sch_disc_amt' => $this->input->post('input_sch_amount'), + 'sch_disc_per' => $this->input->post('input_sch_disc'), + + 'insert_by' => $user_name_info, + + 'item_return' => $return_stock + ); + + $show_text=''; + + $is_update_stock=0; + + $send_msg=""; + + if($item_id<1) + { + $is_update_stock=$this->Medical_M->insert_purchase_item($Pdata); + $send_msg="Added"; + }else{ + $sql="select * from purchase_invoice_item where id='$item_id' "; + $query = $this->db->query($sql); + $drug_item= $query->result(); + + if(count($drug_item)>0){ + $tot_sale_qty=$drug_item[0]->total_sale_unit; + + $qty = $this->input->post('input_Qty'); + $qty_free= $this->input->post('input_Qty_Free'); + + $packing=$this->input->post('input_package'); + + $tot_qty=($qty+$qty_free)*$packing; + + if($tot_sale_qty<=$tot_qty) + { + $is_update_stock=$this->Medical_M->update_purchase_item($Pdata,$item_id); + if($is_update_stock>0) + { + $send_msg="Updated"; + }else{ + $send_msg="Error : Update in Stock Table"; + } + }else{ + $send_msg="Error : Update Qty is Less then saled Qty :".$tot_qty." / Saled :".$tot_sale_qty; + + //Update While Qty in Minus + + $is_update_stock=$this->Medical_M->update_purchase_item($Pdata,$item_id); + if($is_update_stock>0) + { + $send_msg="Updated : But Error : Update Qty is Less then saled Qty :".$tot_qty." / Saled :".$tot_sale_qty; + }else{ + $send_msg="Error : Update in Stock Table"; + } + + } + + }else{ + $send_msg="Error : Record Not Found in Stock Table"; + } + } + + $rvar=array( + 'is_update_stock' =>$is_update_stock, + 'product_code' => $item_code, + 'show_text'=>$send_msg + ); + + $encode_data = json_encode($rvar); + echo $encode_data; + + } + else + { + $send_msg=validation_errors(); + $rvar=array( + 'is_update_stock' =>0, + 'show_text'=>$send_msg + ); + $encode_data = json_encode($rvar); + echo $encode_data; + } + } + + function purchase_invoice_item_edit($inv_id,$inv_item_id) + { + $sql="select *, + date_format(expiry_date,'%m') as str_expiry_month , + date_format(expiry_date,'%y') as str_expiry_year + from purchase_invoice_item where id=".$inv_item_id." and purchase_id=".$inv_id; + $query = $this->db->query($sql); + $purchase_invoice_item= $query->result(); + + if(count($purchase_invoice_item)>0) + { + $rvar=array( + 'is_update_stock'=>'1', + 'item_id' =>$purchase_invoice_item[0]->id, + 'product_code' =>$purchase_invoice_item[0]->item_code, + 'product_mrp' => $purchase_invoice_item[0]->mrp, + 'selling_price'=>$purchase_invoice_item[0]->selling_price, + 'batch_code'=>$purchase_invoice_item[0]->batch_no, + 'disc_price'=>$purchase_invoice_item[0]->discount, + 'qty'=>$purchase_invoice_item[0]->qty, + 'qty_free'=>$purchase_invoice_item[0]->qty_free, + 'package'=>$purchase_invoice_item[0]->packing, + 'purchase_price'=>$purchase_invoice_item[0]->purchase_price, + 'datepicker_doe_month'=>$purchase_invoice_item[0]->str_expiry_month, + 'datepicker_doe_year'=>$purchase_invoice_item[0]->str_expiry_year, + 'drug'=>$purchase_invoice_item[0]->Item_name, + + 'sch_disc_amt'=>$purchase_invoice_item[0]->sch_disc_amt, + 'sch_disc_per'=>$purchase_invoice_item[0]->sch_disc_per, + + 'HSNCODE'=>$purchase_invoice_item[0]->HSNCODE, + 'CGST_per'=>$purchase_invoice_item[0]->CGST_per, + 'SGST_per'=>$purchase_invoice_item[0]->SGST_per, + + 'cold_storage'=>$purchase_invoice_item[0]->cold_storage, + 'shelf_no'=>$purchase_invoice_item[0]->shelf_no, + 'rack_no'=>$purchase_invoice_item[0]->rack_no, + + ); + }else{ + $rvar=array( + 'is_update_stock'=>'0', + 'show_text'=>$sql + ); + } + + $encode_data = json_encode($rvar); + echo $encode_data; + + } + + public function purchase_invoice_item_list($inv_id) + { + $sql="select *,date_format(expiry_date,'%m/%y') as exp_date_str from purchase_invoice_item where purchase_id='".$inv_id."' "; + $query = $this->db->query($sql); + $data['purchase_item']= $query->result(); + + $sql="select * from purchase_invoice where id='".$inv_id."' "; + $query = $this->db->query($sql); + $data['purchase_invoice']= $query->result(); + + $this->load->view('Medical/Purchase/purchase_invoice_item',$data); + + } + + public function purchase_invoice_item_list_old($item_code) + { + $sql="SELECT s.name_supplier, date_format(p.date_of_invoice,'%d-%m-%Y') as date_of_invoice_str, + i.Item_name,i.packing,i.purchase_price,i.qty,i.qty_free,i.mrp + FROM (purchase_invoice p JOIN purchase_invoice_item i ON p.id=i.purchase_id) + JOIN med_supplier s ON p.sid=s.sid + WHERE i.item_code=$item_code ORDER BY i.id DESC LIMIT 5 "; + $query = $this->db->query($sql); + $data['purchase_item_old']= $query->result(); + + $this->load->view('Medical/Purchase/purchase_item_old',$data); + + } + + public function purchase_invoice_item_delete($inv_id,$inv_item_del) + { + $this->load->model('Medical_M'); + + $sql="select * from purchase_invoice_item where id='$inv_item_del' "; + $query = $this->db->query($sql); + $drug_item= $query->result(); + + if(count($drug_item)>0){ + $sale_qty=$drug_item[0]->total_sale_unit; + + if($sale_qty>0) + { + $rvar=array( + 'is_update_stock' =>0, + 'show_text'=>'Sold some Quantity of this Item', + ); + + }else{ + $is_update_stock=$this->Medical_M->delete_purchase_item($inv_id,$inv_item_del); + $rvar=array( + 'is_update_stock' =>1, + 'show_text'=>'Removed Successfully', + ); + } + } + + $encode_data = json_encode($rvar); + echo $encode_data; + } + + public function AddDrugStock($drug_item_code) + { + $sql="select * from drug_temp where item_id='".$drug_item_code."' "; + $query = $this->db->query($sql); + $data['drug_item']= $query->result(); + + $sql="select * from stock_addition where item_code='".$drug_item_code."' "; + $query = $this->db->query($sql); + $data['drug_stock_item']= $query->result(); + + $sql="select * from med_supplier "; + $query = $this->db->query($sql); + $data['med_supplier']= $query->result(); + + $this->load->view('Medical/Drug_Stock_Add',$data); + } + + public function UpdateDrugStock($ss_no) + { + $sql="select * from stock_addition where ss_no='".$ss_no."' "; + $query = $this->db->query($sql); + $data['stock_item']= $query->result(); + + $sql="select * from med_supplier "; + $query = $this->db->query($sql); + $data['med_supplier']= $query->result(); + + $this->load->view('Medical/Stock_Update',$data); + } + + public function load_stock_data($item_code) + { + $sql="select * from stock_addition where item_code='".$item_code."' "; + $query = $this->db->query($sql); + $data['drug_stock_item']= $query->result(); + + echo ' + + + + + + + + + + + + + + '; + + $srno=0; + + foreach($data['drug_stock_item'] as $row) + { + $srno=$srno+1; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + } + + echo ''; + + echo ' + + + + + + + + + + + + +
Item CodeItem NameFormulationStorage/Shelf/Rack No.Batch No.Qty /Sale QtyExpiryMRPRate/Unit
'.$row->item_code.''.$row->item_name.''.$row->formulation.''.$row->cold_storage.'/'.$row->shelf_no.'/'.$row->rack_no.''.$row->batch_no.''.$row->total_unit.'/'.$row->total_sale_unit.''.$row->expiry_date.''.$row->mrp.''.$row->unit_rate.'
Item CodeItem NameFormulationStorage/Shelf/Rack No.Batch No.Qty /Sale QtyExpiryMRPRate/Unit
'; + } + + public function Invoice_counter() + { + $sql="select * from invoice_med_master"; + $query = $this->db->query($sql); + $data['invoiceMaster']= $query->result(); + + $sql="select * from inv_med_item"; + $query = $this->db->query($sql); + $data['inv_items']= $query->result(); + + $sql="select sum(amount) as Gtotal from inv_med_item"; + $query = $this->db->query($sql); + $data['invoiceGtotal']= $query->result(); + + $sql="select * from doctor_master where active=1"; + $query = $this->db->query($sql); + $data['doclist']= $query->result(); + + if($data['invoiceMaster'][0]->case_id > 0) + { + $sql="select * from organization_case_master where id=".$data['invoiceMaster'][0]->case_id; + $query = $this->db->query($sql); + $data['OCaseMaster']= $query->result(); + } + + $user = $this->ion_auth->user()->row(); + $data['user_id'] = $user->id; + + $this->load->view('Medical/Medical_Invoice_V',$data); + + } + + public function Invoice_Med_Draft() + { + $this->load->view('Medical/Draft_Med_Invoice'); + } + + public function Invoice_Med_Return() + { + $this->load->view('Medical/Draft_Med_Return_Invoice'); + } + + public function Invoice_med_show($inv_id) + { + $sql="select *,if(ipd_credit>0,'Credit to IPD','CASH') as credit_status, + if(case_credit>0,'Credit to Org','CASH') as credit_org_status from invoice_med_master + where id=$inv_id"; + $query = $this->db->query($sql); + $data['invoiceMaster']= $query->result(); + + $patient_id=$data['invoiceMaster'][0]->patient_id; + $inv_phone_number=$data['invoiceMaster'][0]->inv_phone_number; + + if($patient_id==0) + { + + } + + $sql="select *,ifnull(DATEDIFF(expiry,CURDATE()),-1000) AS no_day from inv_med_item where inv_med_id=".$inv_id; + $query = $this->db->query($sql); + $data['inv_items']= $query->result(); + + $sql="select sum(amount) as Gtotal,sum(tamount) as tamt,sum(CGST) as TCGST,sum(SGST) as TSGST,sum(disc_amount) as t_dis_amt from inv_med_item where inv_med_id=".$inv_id; + $query = $this->db->query($sql); + $data['invoiceGtotal']= $query->result(); + + $sql="select * from doctor_master where active=1"; + $query = $this->db->query($sql); + $data['doclist']= $query->result(); + + $sql="select *, + GET_AGE_1(dob,age,age_in_month,estimate_dob) AS age from patient_master where id='".$data['invoiceMaster'][0]->patient_id."' "; + $query = $this->db->query($sql); + $data['person_info']= $query->result(); + + $data['org_Name']=""; + $ipd_id=$data['invoiceMaster'][0]->ipd_id; + + if($ipd_id>0) + { + $sql="select * from ipd_master where id=".$ipd_id; + $query = $this->db->query($sql); + $ipd_master= $query->result(); + + $sql="select * from v_ipd_list m join patient_master p on m.p_id=p.id + where m.id=".$ipd_id; + $query = $this->db->query($sql); + $data['ipd_list']= $query->result(); + + $data['ipd_master']=$ipd_master; + + if(count($ipd_master)>0) + { + $p_ipd_id=$ipd_master[0]->id; + $p_ipd_code=$ipd_master[0]->ipd_code; + + if($ipd_master[0]->case_id>0) + { + $sql="select * from organization_case_master where id=".$ipd_master[0]->case_id; + $query = $this->db->query($sql); + $org_master= $query->result(); + + if(count($org_master)>0) + { + $data['org_Name']=$org_master[0]->insurance_company_name; + } + } + } + } + + if($data['invoiceMaster'][0]->case_id > 0) + { + $sql="select * from organization_case_master where id=".$data['invoiceMaster'][0]->case_id; + $query = $this->db->query($sql); + $data['OCaseMaster']= $query->result(); + } + + + + $user = $this->ion_auth->user()->row(); + $data['user_id'] = $user->id; + + $data['sale_return']=$data['invoiceMaster'][0]->sale_return; + + $data['content']=$this->load->view('Medical/Med_Item_List',$data,true); + + if($data['invoiceMaster'][0]->sale_return==0) + { + $this->load->view('Medical/Medical_Invoice_V',$data); + }else{ + $this->load->view('Medical/Medical_Invoice_Return_V',$data); + } + + } + + //New Invoice Edit + public function Invoice_med_datasheet($inv_id) + { + $sql="select *,if(ipd_credit>0,'Credit to IPD','CASH') as credit_status, + if(case_credit>0,'Credit to Org','CASH') as credit_org_status from invoice_med_master + where id=$inv_id"; + $query = $this->db->query($sql); + $data['invoiceMaster']= $query->result(); + + $sql="select *,ifnull(DATEDIFF(expiry,CURDATE()),-1000) AS no_day from inv_med_item where inv_med_id=".$inv_id; + $query = $this->db->query($sql); + $data['inv_items']= $query->result(); + + $sql="select sum(amount) as Gtotal,sum(tamount) as tamt,sum(CGST) as TCGST,sum(SGST) as TSGST,sum(disc_amount) as t_dis_amt from inv_med_item where inv_med_id=".$inv_id; + $query = $this->db->query($sql); + $data['invoiceGtotal']= $query->result(); + + $sql="select * from doctor_master where active=1"; + $query = $this->db->query($sql); + $data['doclist']= $query->result(); + + $sql="select *, + GET_AGE_1(dob,age,age_in_month,estimate_dob) AS age from patient_master where id='".$data['invoiceMaster'][0]->patient_id."' "; + $query = $this->db->query($sql); + $data['person_info']= $query->result(); + + $data['org_Name']=""; + $ipd_id=$data['invoiceMaster'][0]->ipd_id; + + if($ipd_id>0) + { + $sql="select * from ipd_master where id=".$ipd_id; + $query = $this->db->query($sql); + $ipd_master= $query->result(); + + $sql="select * from v_ipd_list m join patient_master p on m.p_id=p.id + where m.id=".$ipd_id; + $query = $this->db->query($sql); + $data['ipd_list']= $query->result(); + + $data['ipd_master']=$ipd_master; + + if(count($ipd_master)>0) + { + $p_ipd_id=$ipd_master[0]->id; + $p_ipd_code=$ipd_master[0]->ipd_code; + + if($ipd_master[0]->case_id>0) + { + $sql="select * from organization_case_master where id=".$ipd_master[0]->case_id; + $query = $this->db->query($sql); + $org_master= $query->result(); + + if(count($org_master)>0) + { + $data['org_Name']=$org_master[0]->insurance_company_name; + } + } + } + } + + if($data['invoiceMaster'][0]->case_id > 0) + { + $sql="select * from organization_case_master where id=".$data['invoiceMaster'][0]->case_id; + $query = $this->db->query($sql); + $data['OCaseMaster']= $query->result(); + } + + $user = $this->ion_auth->user()->row(); + $data['user_id'] = $user->id; + + $data['sale_return']=$data['invoiceMaster'][0]->sale_return; + + $data['content']=$this->load->view('Medical/Med_Item_List',$data,true); + + if($data['invoiceMaster'][0]->sale_return==0) + { + $this->load->view('Medical/Medical_Invoice_V',$data); + }else{ + $this->load->view('Medical/Medical_Invoice_Return_V',$data); + } + + + } + + + // Update Medical Invoice Master + + public function update_uhid() + { + $this->load->model('Medical_M'); + + $user = $this->ion_auth->user()->row(); + $data['user_id'] = $user->id; + + $inv_id=$this->input->post('med_invoice_id'); + $pid=$this->input->post('pid'); + + $sql="select * from invoice_med_master where id=".$inv_id; + $query = $this->db->query($sql); + $invoice_master= $query->result(); + + $sql="select * from patient_master_exten where id='".$pid."' "; + $query = $this->db->query($sql); + $person_info= $query->result(); + + if(count($person_info)>0) + { + $patient_id=$person_info[0]->id; + $patient_code_u=$person_info[0]->p_code; + $custmer_Name=$person_info[0]->p_fname; + + $data = array( + 'customer_type'=>1, + 'patient_id' => $patient_id, + 'patient_code' => $patient_code_u, + 'inv_name' => $custmer_Name, + 'ipd_credit'=>0, + 'case_credit'=>0, + 'case_credit'=>0, + ); + + $inser_id=$this->Medical_M->update_in_upv_item($data,$inv_id); + $this->Medical_M->update_invoice_group($inv_id); + $this->Medical_M->update_invoice_final($inv_id); + $status= 1; + $remark="Done"; + + }else{ + $status=0; + $remark="Not Done"; + } + + $rvar=array( + 'status' =>$status, + 'remark'=>$remark + ); + + $encode_data = json_encode($rvar); + echo $encode_data; + } + + public function update_ipd() + { + $this->load->model('Medical_M'); + + $user = $this->ion_auth->user()->row(); + $data['user_id'] = $user->id; + + $inv_id=$this->input->post('med_invoice_id'); + $ipd_id=$this->input->post('ipd_id'); + + $sql="select * from invoice_med_master where id=".$inv_id; + $query = $this->db->query($sql); + $invoice_master= $query->result(); + + $sql="select * from ipd_master where id=".$ipd_id; + $query = $this->db->query($sql); + $ipd_master= $query->result(); + + $pid=$ipd_master[0]->p_id; + + $sql="select * from patient_master_exten where id='".$pid."' "; + $query = $this->db->query($sql); + $person_info= $query->result(); + + if(count($person_info)>0) + { + $patient_id=$person_info[0]->id; + $patient_code_u=$person_info[0]->p_code; + $custmer_Name=$person_info[0]->p_fname; + + $ipd_id=$ipd_master[0]->id; + $ipd_code=$ipd_master[0]->ipd_code; + + $data = array( + 'customer_type'=>1, + 'patient_id' => $patient_id, + 'patient_code' => $patient_code_u, + 'inv_name' => $custmer_Name, + 'ipd_credit'=>0, + 'case_credit'=>0, + 'ipd_id'=> $ipd_id, + 'ipd_code'=>$ipd_code, + ); + + $inser_id=$this->Medical_M->update_in_upv_item($data,$inv_id); + $this->Medical_M->update_invoice_group($inv_id); + $this->Medical_M->update_invoice_final($inv_id); + $status= 1; + $remark="Done"; + + }else{ + $status=0; + $remark="Not Done"; + } + + $rvar=array( + 'status' =>$status, + 'remark'=>$remark + ); + $encode_data = json_encode($rvar); + echo $encode_data; + } + + public function update_org() + { + $this->load->model('Medical_M'); + + $user = $this->ion_auth->user()->row(); + $data['user_id'] = $user->id; + + $inv_id=$this->input->post('med_invoice_id'); + $org_id=$this->input->post('org_id'); + + $sql="select * from invoice_med_master where id=".$inv_id; + $query = $this->db->query($sql); + $invoice_master= $query->result(); + + $sql="select * from organization_case_master where case_type=0 and id=".$org_id; + $query = $this->db->query($sql); + $org_master= $query->result(); + + $pid=$org_master[0]->p_id; + + $sql="select * from patient_master_exten where id='".$pid."' "; + $query = $this->db->query($sql); + $person_info= $query->result(); + + if(count($person_info)>0) + { + $patient_id=$person_info[0]->id; + $patient_code_u=$person_info[0]->p_code; + $custmer_Name=$person_info[0]->p_fname; + + $org_id=$org_master[0]->id; + $org_code=$org_master[0]->case_id_code; + + $data = array( + 'customer_type'=>1, + 'patient_id' => $patient_id, + 'patient_code' => $patient_code_u, + 'inv_name' => $custmer_Name, + 'ipd_credit'=>0, + 'case_credit'=>1, + 'ipd_id'=> 0, + 'ipd_code'=>'', + 'case_id'=>$org_id, + ); + + $inser_id=$this->Medical_M->update_in_upv_item($data,$inv_id); + $this->Medical_M->update_invoice_group($inv_id); + $this->Medical_M->update_invoice_final($inv_id); + $status= 1; + $remark="Done"; + + }else{ + $status=0; + $remark="Not Done"; + } + + $rvar=array( + 'status' =>$status, + 'remark'=>$remark + ); + $encode_data = json_encode($rvar); + echo $encode_data; + } + + public function update_invdate() + { + $this->load->model('Medical_M'); + + $inv_id=$this->input->post('med_invoice_id'); + $inv_date=$this->input->post('inv_date'); + + $sql="select * from invoice_med_master where id=".$inv_id; + $query = $this->db->query($sql); + $invoice_master= $query->result(); + + $inv_date=str_to_MysqlDate($inv_date); + + $data = array( + 'inv_date' => $inv_date, + ); + + $inser_id=$this->Medical_M->update_in_upv_item($data,$inv_id); + + $status= 1; + $remark="Done"; + + $rvar=array( + 'status' =>$status, + 'remark'=>$remark + ); + $encode_data = json_encode($rvar); + echo $encode_data; + } + + public function update_name_phone() + { + $this->load->model('Medical_M'); + + $inv_id=$this->input->post('med_invoice_id'); + $pid=$this->input->post('pid'); + $customer_type=$this->input->post('customer_type'); + $P_Name=$this->input->post('P_Name'); + $P_Phone=$this->input->post('P_Phone'); + + $doc_id=$this->input->post('doc_id'); + $doc_name=$this->input->post('doc_name'); + + $refername=$doc_name; + + $sql="select * from doctor_master where id='".$doc_id."' "; + $query = $this->db->query($sql); + $doc_info= $query->result(); + + if(count($doc_info)>0) + { + $refername=$doc_info[0]->p_fname; + } + + + $data = array( + 'customer_type'=>$customer_type, + 'patient_id' => '0', + 'patient_code' => '', + 'inv_name' => $P_Name, + 'inv_phone_number' => $P_Phone, + 'ipd_credit'=>0, + 'case_credit'=>0, + 'ipd_id'=> 0, + 'ipd_code'=>'', + 'case_id'=>'0', + 'doc_id' => $doc_id, + 'doc_name' => $refername, + ); + + $inser_id=$this->Medical_M->update_in_upv_item($data,$inv_id); + + $status= 1; + $remark="Done"; + + $rvar=array( + 'status' =>$status, + 'remark'=>$remark + ); + $encode_data = json_encode($rvar); + echo $encode_data; + } + + public function update_doctor() + { + $this->load->model('Medical_M'); + + $inv_id=$this->input->post('med_invoice_id'); + + $doc_id=$this->input->post('doc_id'); + $doc_name=$this->input->post('doc_name'); + + $refername=$doc_name; + + $sql="select * from doctor_master where id='".$doc_id."' "; + $query = $this->db->query($sql); + $doc_info= $query->result(); + + if(count($doc_info)>0) + { + $refername=$doc_info[0]->p_fname; + } + + $data = array( + 'doc_id' => $doc_id, + 'doc_name' => $refername, + ); + + $inser_id=$this->Medical_M->update_in_upv_item($data,$inv_id); + + $status= 1; + $remark="Done"; + + $rvar=array( + 'status' =>$status, + 'remark'=>$remark + ); + $encode_data = json_encode($rvar); + echo $encode_data; + } + + + public function update_cr_status_ipd() + { + $this->load->model('Medical_M'); + + $inv_id=$this->input->post('med_invoice_id'); + $credit_ipd=$this->input->post('credit_ipd'); + + $sql="select * from invoice_med_master where id=".$inv_id; + $query = $this->db->query($sql); + $invoice_master= $query->result(); + + $ipd_id=$invoice_master[0]->ipd_id; + + $data = array( + 'ipd_credit' => $credit_ipd, + ); + + $inser_id=$this->Medical_M->update_in_upv_item($data,$inv_id); + + $status= 1; + $remark="Done"; + + $this->Medical_M->update_invoice_group_gst($ipd_id,'1'); + $this->Medical_M->update_invoice_group_gst($ipd_id,'2'); + $this->Medical_M->update_invoice_group_gst($ipd_id,'3'); + + $rvar=array( + 'status' =>$status, + 'remark'=>$remark + ); + $encode_data = json_encode($rvar); + echo $encode_data; + } + + // End Update Medical Invoice Master + + public function search_customer($sale=0) + { + $data['sale']=$sale; + $this->load->view('Medical/Search_Patient',$data); + } + + public function Invoice_counter_new($pno,$ipd_id,$case_id) + { + + $select_doc=0; + $p_fname=''; + $p_pcode=''; + $p_pid=$pno; + $p_ipd_id=$ipd_id; + $p_ipd_code=''; + $customer_type=0; + + $select_doc=0; + $data['org_Name']=""; + $data['content']=""; + + if($pno>0) + { + $sql="select *,if(gender=1,'Male','Female') as xgender, + GET_AGE_1(dob,age,age_in_month,estimate_dob) AS age from patient_master where id='".$pno."' "; + $query = $this->db->query($sql); + $person_info= $query->result(); + + $sql="select doc_id from opd_master where p_id='".$pno."' order by opd_id desc limit 1"; + $query = $this->db->query($sql); + $data['opd_master']= $query->result(); + + $p_fname=$person_info[0]->p_fname; + $p_pcode=$person_info[0]->p_code; + + if(count($data['opd_master'])>0) + { + $select_doc=$data['opd_master'][0]->doc_id; + }else{ + $select_doc=0; + } + + $customer_type=1; + } + + if($ipd_id>0) + { + $sql="select * from ipd_master where id=".$ipd_id; + $query = $this->db->query($sql); + $data['ipd_master']= $query->result(); + + $sql="select * from v_ipd_list m join patient_master p on m.p_id=p.id + where m.id=".$ipd_id; + $query = $this->db->query($sql); + $data['ipd_list']= $query->result(); + + $p_ipd_code=$data['ipd_master'][0]->ipd_code; + + if($data['ipd_master'][0]->case_id>0) + { + $sql="select * from organization_case_master where id=".$data['ipd_master'][0]->case_id; + $query = $this->db->query($sql); + $org_master= $query->result(); + + if(count($org_master)>0) + { + $data['org_Name']=$org_master[0]->insurance_company_name; + } + } + } + + $this->load->model('Medical_M'); + + $data['invoice_med_master'] = array( + 'patient_id' => $p_pid, + 'ipd_id' => $p_ipd_id, + 'ipd_code' => $p_ipd_code, + 'case_id' => $case_id, + 'inv_date' => str_to_MysqlDate(date('d/m/Y')), + 'inv_name' => $p_fname, + 'patient_code' => $p_pcode, + 'doc_id' => $select_doc, + 'sale_return'=>0, + 'case_credit'=>0, + 'customer_type'=>$customer_type, + ); + + if($case_id>0) + { + $data['invoice_med_master']['case_credit']=1; + } + + $inser_id=$this->Medical_M->add_invoice( $data['invoice_med_master']); + + if($inser_id) + { + $sql="select *,if(ipd_credit>0,'Credit to IPD','CASH') as credit_status from invoice_med_master where id=".$inser_id; + $query = $this->db->query($sql); + $data['invoiceMaster']= $query->result(); + + $sql="select *,ifnull(DATEDIFF(expiry,CURDATE()),-1000) AS no_day from inv_med_item where inv_med_id=".$inser_id; + $query = $this->db->query($sql); + $data['inv_items']= $query->result(); + + $sql="select sum(amount) as Gtotal,sum(tamount) as tamt,sum(CGST) as TCGST,sum(SGST) as TSGST,sum(disc_amount) as t_dis_amt from inv_med_item where inv_med_id=".$inser_id; + $query = $this->db->query($sql); + $data['invoiceGtotal']= $query->result(); + + $sql="select * from doctor_master where active=1"; + $query = $this->db->query($sql); + $data['doclist']= $query->result(); + + $sql="select * from organization_case_master where id=".$case_id; + $query = $this->db->query($sql); + $data['OCaseMaster']= $query->result(); + + $data['sale_return']=$data['invoiceMaster'][0]->sale_return; + + $data['content']=$this->load->view('Medical/Med_Item_List',$data,true); + + $this->load->view('Medical/Medical_Invoice_V',$data); + } + } + + public function Invoice_Return_new($pno) + { + + $select_doc=0; + $p_fname=''; + $p_pcode=''; + $p_pid=$pno; + $inv_phone_number=''; + + $data['content']=''; + + if($pno>0) + { + $sql="select *,if(gender=1,'Male','Female') as xgender, + GET_AGE_1(dob,age,age_in_month,estimate_dob) AS age from patient_master where id='".$pno."' "; + $query = $this->db->query($sql); + $person_info= $query->result(); + + $p_fname=$person_info[0]->p_fname; + $p_pcode=$person_info[0]->p_code; + $inv_phone_number=$person_info[0]->mphone1; + + $select_doc=0; + } + + $this->load->model('Medical_M'); + + $data['invoice_med_master'] = array( + 'patient_id' => $p_pid, + 'inv_date' => str_to_MysqlDate(date('d/m/Y')), + 'inv_name' => $p_fname, + 'patient_code' => $p_pcode, + 'doc_id' => $select_doc, + 'inv_phone_number'=>$inv_phone_number, + 'sale_return'=>1 + ); + + $inser_id=$this->Medical_M->add_invoice( $data['invoice_med_master']); + + if($inser_id) + { + $sql="select *,if(ipd_credit>0,'Credit to IPD','CASH') as credit_status from invoice_med_master where id=".$inser_id; + $query = $this->db->query($sql); + $data['invoiceMaster']= $query->result(); + + $sql="select *,ifnull(DATEDIFF(expiry,CURDATE()),-1000) AS no_day from inv_med_item where inv_med_id=".$inser_id; + $query = $this->db->query($sql); + $data['inv_items']= $query->result(); + + $sql="select sum(amount) as Gtotal,sum(tamount) as tamt,sum(CGST) as TCGST,sum(SGST) as TSGST,sum(disc_amount) as t_dis_amt from inv_med_item where inv_med_id=".$inser_id; + $query = $this->db->query($sql); + $data['invoiceGtotal']= $query->result(); + + $data['sale_return']=$data['invoiceMaster'][0]->sale_return; + + $data['content']=$this->load->view('Medical/Med_Item_List',$data,true); + + $this->load->view('Medical/Medical_Invoice_Return_V',$data); + } + } + + public function item_stock_list($item_code) + { + $sql="SELECT p.item_name,t.batch_no,t.expiry_date as expiry_date_str,t.expiry_date, + (t.total_unit-t.total_sale_unit) AS c_qty, + t.id,t.mrp,t.selling_unit_rate,p.id AS item_code + FROM med_product_master p + JOIN purchase_invoice_item t ON p.id=t.item_code + where (t.total_unit-t.total_sale_unit)>0 + and (expiry_date>date_add(sysdate(),interval 1 month) or p.exp_date_applicable=0) + and p.id =$item_code"; + + $query = $this->db->query($sql); + $data['Item_list']=$query->result_array() ; + + $this->load->view('Medical/sale_item_list_for_add',$data); + } + + public function get_drug(){ + if (isset($_GET['term'])){ + $q = strtolower($_GET['term']); + + $sql="SELECT p.item_name,t.batch_no,t.expiry_date as expiry_date_str,t.expiry_date, + (t.total_unit-t.total_sale_unit-total_lost_unit) AS c_qty, + t.id,t.mrp,t.selling_unit_rate,p.id AS item_code,p.packing + FROM med_product_master p + JOIN purchase_invoice_item t ON p.id=t.item_code and (t.total_unit-t.total_sale_unit-t.total_lost_unit)>0 + and (expiry_date>date_add(sysdate(),interval 1 day) or p.exp_date_applicable=0) + and remove_item=0 + where (p.item_name like '".$q."%' "; + + if(strlen($q)>5) + { + $sql=$sql. " or p.item_name SOUNDS LIKE '".$q."'"; + } + + $sql=$sql.") order by id desc limit 100"; + + $query = $this->db->query($sql); + + if($query->num_rows() > 0){ + foreach ($query->result_array() as $row){ + $new_row['label']=htmlentities(stripslashes($row['item_name'])).' |B:'.htmlentities(stripslashes($row['batch_no'])). ' |Pak:'.htmlentities(stripslashes($row['packing'])).' |Rs.'.htmlentities(stripslashes($row['mrp'])).' |Qty:'.htmlentities(stripslashes($row['c_qty'])); + $new_row['value']=htmlentities(stripslashes($row['item_name'])); + $new_row['l_item_code']=htmlentities(stripslashes($row['item_code'])); + $new_row['l_ss_no']=htmlentities(stripslashes($row['id'])); + $new_row['l_Batch']=htmlentities(stripslashes($row['batch_no'])); + $new_row['l_Expiry']=htmlentities(stripslashes($row['expiry_date_str'])); + $new_row['l_mrp']=htmlentities(stripslashes($row['mrp'])); + $new_row['l_unit_rate']=htmlentities(stripslashes($row['selling_unit_rate'])); + $new_row['l_c_qty']=htmlentities(stripslashes($row['c_qty'])); + $new_row['l_packing']=htmlentities(stripslashes($row['packing'])); + $new_row['sql']=$sql; + $row_set[] = $new_row; //build an array + } + echo json_encode($row_set); //format the array into json data + }else{ + $new_row['sql']=$sql; + $row_set[] = $new_row; + echo json_encode($row_set); + } + } + } + + public function get_drug_master(){ + + if (isset($_GET['term'])){ + $q = strtolower($_GET['term']); + + $sql="select * from purchase_invoice_item p + where p.id in (select max(id) from purchase_invoice_item t + where t.Item_name like '".$q."%' group by t.Item_name ) + order by p.Item_name "; + + $sql="SELECT m.* ,p.id as ss_no,m.packing as p_packing,p.mrp,p.purchase_price,p.discount, + p.batch_no,date_format(expiry_date,'%m') as str_expiry_month , + date_format(expiry_date,'%y') as str_expiry_year , + m.batch_applicable,m.exp_date_applicable, + if(p.id is null,m.CGST_per,p.CGST_per) as p_CGST_per, + if(p.id is null,m.SGST_per,p.SGST_per) as p_SGST_per, + if(p.id is null,m.rack_no,p.rack_no) as p_rack_no, + if(p.id is null,m.shelf_no,p.shelf_no) as p_shelf_no, + if(p.id is null,m.cold_storage,p.cold_storage) as p_cold_storage + + FROM med_product_master m + LEFT JOIN (SELECT * from purchase_invoice_item + WHERE id in (select max(id) from purchase_invoice_item + WHERE Item_name LIKE '".$q."%' + group BY item_code ) ) as p ON m.id=p.item_code + WHERE m.Item_name LIKE '".$q."%' + order BY m.item_name "; + + $sql=$sql." limit 20"; + + $query = $this->db->query($sql); + + if($query->num_rows() > 0){ + foreach ($query->result_array() as $row){ + $new_row['label']=htmlentities(stripslashes($row['item_name'])).' | '.htmlentities(stripslashes($row['p_packing'])).' | '.htmlentities(stripslashes($row['mrp'])); + $new_row['value']=htmlentities(stripslashes($row['item_name'])); + $new_row['l_item_code']=htmlentities(stripslashes($row['id'])); + $new_row['l_mrp']=htmlentities(stripslashes($row['mrp'])); + + $new_row['l_packing']=htmlentities(stripslashes($row['packing'])); + $new_row['l_CGST_per']=htmlentities(stripslashes($row['p_CGST_per'])); + $new_row['l_SGST_per']=htmlentities(stripslashes($row['p_SGST_per'])); + $new_row['l_HSNCODE']=htmlentities(stripslashes($row['HSNCODE'])); + + $new_row['l_batch_no']=htmlentities(stripslashes($row['batch_no'])); + + $new_row['l_purchase_price']=htmlentities(stripslashes($row['purchase_price'])); + + $new_row['l_package']=htmlentities(stripslashes($row['p_packing'])); + $new_row['l_disc_price']=htmlentities(stripslashes($row['discount'])); + + $new_row['l_rack_no']=htmlentities(stripslashes($row['p_rack_no'])); + $new_row['l_shelf_no']=htmlentities(stripslashes($row['p_shelf_no'])); + $new_row['l_cold_storage']=htmlentities(stripslashes($row['p_cold_storage'])); + + $new_row['batch_applicable']=htmlentities(stripslashes($row['batch_applicable'])); + $new_row['exp_date_applicable']=htmlentities(stripslashes($row['exp_date_applicable'])); + + $new_row['datepicker_doe_month']=htmlentities(stripslashes($row['str_expiry_month'])); + $new_row['datepicker_doe_year']=htmlentities(stripslashes($row['str_expiry_year'])); + + $row_set[] = $new_row; //build an array + } + echo json_encode($row_set); //format the array into json data + }else{ + $row_set[] = array(); + echo json_encode($row_set); + } + } + } + + public function get_formulation_desc(){ + + if (isset($_GET['term'])){ + $q = strtolower($_GET['term']); + + $sql="select * from drugs_formulation where formulation_desc like '".$q."%'"; + $query = $this->db->query($sql); + + if($query->num_rows() > 0){ + foreach ($query->result_array() as $row){ + $new_row['label']=htmlentities(stripslashes($row['formulation_desc'])); + $new_row['value']=htmlentities(stripslashes($row['formulation_desc'])); + $row_set[] = $new_row; //build an array + } + echo json_encode($row_set); //format the array into json data + } + } + } + + public function go_final() + { + $this->load->model('Medical_M'); + + $inv_id=$this->input->post('inv_id'); + $doc_id=$this->input->post('doc_id'); + $doc_name=$this->input->post('doc_name'); + $remark_ipd=$this->input->post('input_remark_ipd'); + $patient_code=$this->input->post('patient_code'); + $custmer_Name=$this->input->post('custmer_Name'); + $ipd_credit=$this->input->post('ipd_credit'); + + $org_credit=$this->input->post('org_credit'); + $inv_date=$this->input->post('inv_date'); + + $sql="select * from patient_master where p_code='".$patient_code."' "; + $query = $this->db->query($sql); + $person_info= $query->result(); + + $sql="select * from doctor_master where id='".$doc_id."' "; + $query = $this->db->query($sql); + $doc_info= $query->result(); + + $sql="select * from invoice_med_master where id=".$inv_id; + $query = $this->db->query($sql); + $data['invoice_master']= $query->result(); + + if($this->ion_auth->in_group('InvoiceDateChanged') || $this->ion_auth->in_group('admin')) + { + $inv_date=str_to_MysqlDate($inv_date); + }else{ + $inv_date=$data['invoice_master'][0]->inv_date; + } + + if(count($person_info)>0) + { + $patient_id=$person_info[0]->id; + $patient_code_u=$patient_code; + $custmer_Name=$person_info[0]->p_fname; + }else{ + $patient_id=0; + $patient_code_u=''; + } + + $refername=$doc_name; + + if(count($doc_info)>0) + { + $refername=$doc_info[0]->p_fname; + } + + $data = array( + 'patient_id' => $patient_id, + 'patient_code' => $patient_code_u, + 'doc_id' => $doc_id, + 'doc_name' => $refername, + 'inv_name' => $custmer_Name, + 'remark_ipd'=>$remark_ipd, + 'ipd_credit'=>$ipd_credit, + 'case_credit'=>$org_credit, + 'inv_date' => $inv_date + ); + + $inser_id=$this->Medical_M->update_in_upv_item($data,$inv_id); + $this->Medical_M->update_invoice_group($inv_id); + $this->Medical_M->update_invoice_final($inv_id); + + } + + public function getDrugTable() + { + + $requestData= $_REQUEST; + + $columns = array( + // datatable column index => database column name + 0 =>'item_id', + 1 => 'itemname', + 2 => 'formulation', + 3=> 'genericname', + 5=> 'company_name_idx', + 4=> 'mrp' + ); + + // getting total number records without any search + $sql_f_all = "select * "; + + $sql_count="Select count(*) as no_rec "; + + $sql_from=" from drug_temp "; + + $total_sql=$sql_count.$sql_from; + + $query = $this->db->query($total_sql); + $data['total_rec']= $query->result(); + $totalData=$data['total_rec'][0]->no_rec; + + $totalFiltered = $totalData; // when there is no search parameter then total number rows = total number filtered rows. + + $sql_where=" WHERE 1 = 1"; + + $sql_where_flag=0; + + // getting records as per search parameters + if( !empty($requestData['columns'][0]['search']['value']) ){ //item_id + $sql_where.=" AND item_id LIKE '".$requestData['columns'][0]['search']['value']."%' "; + $sql_where_flag=1; + } + + if( !empty($requestData['columns'][1]['search']['value']) ){ //itemname + $sql_where.=" AND itemname LIKE '%".$requestData['columns'][1]['search']['value']."%' "; + $sql_where_flag=1; + } + + if( !empty($requestData['columns'][2]['search']['value']) ){ //dosage + $sql_where.=" AND formulation LIKE '%".$requestData['columns'][2]['search']['value']."%' "; + $sql_where_flag=1; + } + + if( !empty($requestData['columns'][3]['search']['value']) ){ //formulation + $sql_where.=" AND genericname LIKE '%".$requestData['columns'][3]['search']['value']."%' "; + $sql_where_flag=1; + } + + if( !empty($requestData['columns'][4]['search']['value']) ){ //therapeutic + $sql_where.=" AND company_name_idx LIKE '%".$requestData['columns'][4]['search']['value']."%' "; + $sql_where_flag=1; + } + + $total_filer_sql=$sql_count.$sql_from.$sql_where; + + $query = $this->db->query($total_filer_sql); + $data['total_rec_filter']= $query->result();// when there is a search parameter then we have to modify total number filtered rows as per search result. + $totalFiltered=$data['total_rec_filter'][0]->no_rec; + + + $sql_order=" ORDER BY ". $columns[$requestData['order'][0]['column']]." ".$requestData['order'][0]['dir']." LIMIT ".$requestData['start']." ,".$requestData['length']." "; // adding length + + $Result_sql=$sql_f_all.$sql_from.$sql_where.$sql_order; + + $query = $this->db->query($Result_sql); + $rdata= $query->result_array(); + + $output = array( + "draw" => intval( $requestData['draw'] ), // for every request/draw by clientside , they send a number as a parameter, when they recieve a response/data they first check the draw number, so we are sending same number in draw. + "recordsTotal" => intval( $totalData ), // total number of records + "recordsFiltered" => intval( $totalFiltered ), // total number of records after searching, if there is no searching then totalFiltered = totalData + "data" => array(), + "sql" => $Result_sql + ); + + foreach($rdata as $aRow) + { + $row = array(); + + foreach($columns as $col) + { + $row[] = $aRow[$col]; + } + + $output['data'][] = $row; + } + + echo json_encode($output); // send data as json format + } + + public function getInvoiceTable() + { + //Single Store Remove Store ID feild + + $requestData= $_REQUEST; + + $columns = array( + // datatable column index => database column name + 0 => 'inv_med_code', + 1 => 'inv_name', + 2 => 'Code', + 3=> 'inv_date_str', + 4=> 'net_amount', + 5=> 'payment_received', + 6=> 'payment_balance', + 7=> 'id', + 8=> 'ipd_status', + 9=> 'org_status', + 10=> 'ipd_credit_type', + 11=> 'org_credit_type' + ); + + // getting total number records without any search + $sql_f_all = "select m.inv_med_code,m.inv_name, + Concat(if(m.patient_code<>'',Concat(m.patient_code,'
'),''), + if(m.ipd_code<>'',Concat('',m.ipd_code,'
'),''), + if(m.case_id>0,Concat(o.case_id_code,'
'),'')) as Code , + m.inv_date,Date_Format(m.inv_date,'%d-%m-%Y') as inv_date_str, + m.doc_name,m.net_amount,m.payment_received,m.payment_balance,m.id,i.ipd_status, + o.status as org_status, + m.ipd_credit as ipd_credit_type,m.case_credit as org_credit_type "; + + $sql_count="Select count(*) as no_rec "; + + $sql_from=" from (invoice_med_master m left join ipd_master i on m.ipd_id=i.id ) + left join organization_case_master o on m.case_id=o.id "; + + $total_sql=$sql_count.$sql_from; + + $query = $this->db->query($total_sql); + $data['total_rec']= $query->result(); + $totalData=$data['total_rec'][0]->no_rec; + + $totalFiltered = $totalData; // when there is no search parameter then total number rows = total number filtered rows. + + if($this->ion_auth->in_group('MedicalStoreAdmin')) + { + $sql_where=" WHERE sale_return=0 "; + }else{ + $sql_where=" WHERE sale_return=0 and inv_date >= date_add(sysdate(),interval -50 day) "; + } + + + $sql_where_flag=0; + + // getting records as per search parameters + if( !empty($requestData['columns'][0]['search']['value']) ){ //inv_med_code + $sql_where.=" AND inv_med_code LIKE '%".$requestData['columns'][0]['search']['value']."' "; + $sql_where_flag=1; + } + + if( !empty($requestData['columns'][1]['search']['value']) ){ //inv_name + $stext=$requestData['columns'][1]['search']['value']; + if(is_numeric($stext) && strlen($stext)>3) + { + $sql_where.=" AND inv_phone_number LIKE '".$stext."%' "; + }else{ + $sql_where.=" AND inv_name LIKE '%".$requestData['columns'][1]['search']['value']."%' "; + } + $sql_where_flag=1; + } + + if( !empty($requestData['columns'][2]['search']['value']) ){ //patient_code + $sql_where.=" AND (patient_code LIKE '%".$requestData['columns'][2]['search']['value']."' OR + m.ipd_code LIKE '%".$requestData['columns'][2]['search']['value']."' OR + o.case_id_code LIKE '%".$requestData['columns'][2]['search']['value']."' )"; + $sql_where_flag=1; + } + + $total_filer_sql=$sql_count.$sql_from.$sql_where; + + $query = $this->db->query($total_filer_sql); + $data['total_rec_filter']= $query->result();// when there is a search parameter then we have to modify total number filtered rows as per search result. + $totalFiltered=$data['total_rec_filter'][0]->no_rec; + + $sql_order=" ORDER BY id desc,". $columns[$requestData['order'][0]['column']]." ".$requestData['order'][0]['dir']." LIMIT ".$requestData['start']." ,".$requestData['length']." "; // adding length + + $Result_sql=$sql_f_all.$sql_from.$sql_where.$sql_order; + + $query = $this->db->query($Result_sql); + $rdata= $query->result_array(); + + $output = array( + "draw" => intval( $requestData['draw'] ), // for every request/draw by clientside , they send a number as a parameter, when they recieve a response/data they first check the draw number, so we are sending same number in draw. + "recordsTotal" => intval( $totalData ), // total number of records + "recordsFiltered" => intval( $totalFiltered ), // total number of records after searching, if there is no searching then totalFiltered = totalData + "data" => array(), + "sql" => $Result_sql + ); + + foreach($rdata as $aRow) + { + $row = array(); + + foreach($columns as $col) + { + $row[] = $aRow[$col]; + } + + $output['data'][] = $row; + } + + echo json_encode($output); // send data as json format + + } + + public function getReturnInvoiceTable() + { + //Single Store Remove Store ID feild + + $requestData= $_REQUEST; + + $columns = array( + // datatable column index => database column name + 0 => 'inv_med_code', + 1 => 'inv_name', + 2 => 'Code', + 3=> 'inv_date_str', + 4=> 'net_amount', + 5=> 'payment_received', + 6=> 'payment_balance', + 7=> 'id', + 8=> 'ipd_status', + 9=> 'org_status', + 10=> 'ipd_credit_type', + 11=> 'org_credit_type' + ); + + // getting total number records without any search + $sql_f_all = "select m.inv_med_code,m.inv_name, + Concat(if(m.patient_code<>'',Concat(m.patient_code,'
'),''), + if(m.ipd_code<>'',Concat('',m.ipd_code,'
'),''), + if(m.case_id>0,Concat(o.case_id_code,'
'),'')) as Code , + m.inv_date,Date_Format(m.inv_date,'%d-%m-%Y') as inv_date_str, + m.doc_name,m.net_amount,m.payment_received,m.payment_balance,m.id,i.ipd_status, + o.status as org_status, + m.ipd_credit as ipd_credit_type,m.case_credit as org_credit_type "; + + $sql_count="Select count(*) as no_rec "; + + $sql_from=" from (invoice_med_master m left join ipd_master i on m.ipd_id=i.id ) + left join organization_case_master o on m.case_id=o.id "; + + $total_sql=$sql_count.$sql_from; + + $query = $this->db->query($total_sql); + $data['total_rec']= $query->result(); + $totalData=$data['total_rec'][0]->no_rec; + + $totalFiltered = $totalData; // when there is no search parameter then total number rows = total number filtered rows. + + if($this->ion_auth->in_group('MedicalStoreAdmin')) + { + $sql_where=" WHERE sale_return=1 "; + }else{ + $sql_where=" WHERE sale_return=1 and inv_date >= date_add(sysdate(),interval -50 day) "; + } + + + $sql_where_flag=0; + + // getting records as per search parameters + if( !empty($requestData['columns'][0]['search']['value']) ){ //inv_med_code + $sql_where.=" AND inv_med_code LIKE '%".$requestData['columns'][0]['search']['value']."' "; + $sql_where_flag=1; + } + + if( !empty($requestData['columns'][1]['search']['value']) ){ //inv_name + $stext=$requestData['columns'][1]['search']['value']; + if(is_numeric($stext) && strlen($stext)>3) + { + $sql_where.=" AND inv_phone_number LIKE '".$stext."%' "; + }else{ + $sql_where.=" AND inv_name LIKE '%".$requestData['columns'][1]['search']['value']."%' "; + } + $sql_where_flag=1; + } + + if( !empty($requestData['columns'][2]['search']['value']) ){ //patient_code + $sql_where.=" AND (patient_code LIKE '%".$requestData['columns'][2]['search']['value']."' OR + m.ipd_code LIKE '%".$requestData['columns'][2]['search']['value']."' OR + o.case_id_code LIKE '%".$requestData['columns'][2]['search']['value']."' )"; + $sql_where_flag=1; + } + + $total_filer_sql=$sql_count.$sql_from.$sql_where; + + $query = $this->db->query($total_filer_sql); + $data['total_rec_filter']= $query->result();// when there is a search parameter then we have to modify total number filtered rows as per search result. + $totalFiltered=$data['total_rec_filter'][0]->no_rec; + + $sql_order=" ORDER BY id desc,". $columns[$requestData['order'][0]['column']]." ".$requestData['order'][0]['dir']." LIMIT ".$requestData['start']." ,".$requestData['length']." "; // adding length + + $Result_sql=$sql_f_all.$sql_from.$sql_where.$sql_order; + + $query = $this->db->query($Result_sql); + $rdata= $query->result_array(); + + $output = array( + "draw" => intval( $requestData['draw'] ), // for every request/draw by clientside , they send a number as a parameter, when they recieve a response/data they first check the draw number, so we are sending same number in draw. + "recordsTotal" => intval( $totalData ), // total number of records + "recordsFiltered" => intval( $totalFiltered ), // total number of records after searching, if there is no searching then totalFiltered = totalData + "data" => array(), + "sql" => $Result_sql + ); + + foreach($rdata as $aRow) + { + $row = array(); + + foreach($columns as $col) + { + $row[] = $aRow[$col]; + } + + $output['data'][] = $row; + } + + echo json_encode($output); // send data as json format + + } + + + public function getStockDrugTable() + { + + $requestData= $_REQUEST; + + $columns = array( + // datatable column index => database column name + 0 =>'ss_no', + 1 =>'item_code', + 2 => 'item_name', + 3 => 'formulation', + 4 => 'rack_no', + 5 => 'shelf_no', + 6 => 'batch_no', + 7 => 'total_unit', + 8 => 'expiry_date', + 9 => 'mrp', + 10 => 'update_stock_qty' + ); + + // getting total number records without any search + $sql_f_all = "select * "; + + $sql_count="Select count(*) as no_rec "; + + $sql_from=" from stock_addition "; + + $total_sql=$sql_count.$sql_from; + + $query = $this->db->query($total_sql); + $data['total_rec']= $query->result(); + $totalData=$data['total_rec'][0]->no_rec; + + $totalFiltered = $totalData; // when there is no search parameter then total number rows = total number filtered rows. + + $sql_where=" WHERE 1 = 1 "; + + $sql_where_flag=0; + + // getting records as per search parameters + if( !empty($requestData['columns'][0]['search']['value']) ){ //item_id + $sql_where.=" AND item_code LIKE '".$requestData['columns'][0]['search']['value']."%' "; + $sql_where_flag=1; + } + + if( !empty($requestData['columns'][1]['search']['value']) ){ //itemname + $sql_where.=" AND item_name LIKE '%".$requestData['columns'][1]['search']['value']."%' "; + $sql_where_flag=1; + } + + if( !empty($requestData['columns'][2]['search']['value']) ){ //dosage + $sql_where.=" AND formulation LIKE '%".$requestData['columns'][2]['search']['value']."%' "; + $sql_where_flag=1; + } + + if( !empty($requestData['columns'][3]['search']['value']) ){ //dosage + $sql_where.=" AND rack_no LIKE '%".$requestData['columns'][3]['search']['value']."%' "; + $sql_where_flag=1; + } + + if( !empty($requestData['columns'][4]['search']['value']) ){ //dosage + $sql_where.=" AND shelf_no LIKE '%".$requestData['columns'][4]['search']['value']."%' "; + $sql_where_flag=1; + } + + if( !empty($requestData['columns'][5]['search']['value']) ){ //dosage + $sql_where.=" AND batch_no LIKE '%".$requestData['columns'][5]['search']['value']."%' "; + $sql_where_flag=1; + } + + $total_filer_sql=$sql_count.$sql_from.$sql_where; + + $query = $this->db->query($total_filer_sql); + $data['total_rec_filter']= $query->result();// when there is a search parameter then we have to modify total number filtered rows as per search result. + $totalFiltered=$data['total_rec_filter'][0]->no_rec; + + $sql_order=" ORDER BY ". $columns[$requestData['order'][0]['column']]." ".$requestData['order'][0]['dir']." LIMIT ".$requestData['start']." ,".$requestData['length']." "; // adding length + + $Result_sql=$sql_f_all.$sql_from.$sql_where.$sql_order; + + $query = $this->db->query($Result_sql); + $rdata= $query->result_array(); + + $output = array( + "draw" => intval( $requestData['draw'] ), // for every request/draw by clientside , they send a number as a parameter, when they recieve a response/data they first check the draw number, so we are sending same number in draw. + "recordsTotal" => intval( $totalData ), // total number of records + "recordsFiltered" => intval( $totalFiltered ), // total number of records after searching, if there is no searching then totalFiltered = totalData + "data" => array(), + "sql" => $Result_sql + ); + + foreach($rdata as $aRow) + { + $row = array(); + + foreach($columns as $col) + { + $row[] = $aRow[$col]; + } + + $output['data'][] = $row; + } + + echo json_encode($output); // send data as json format + + } + + public function confirm_payment() + { + if (!$this->input->is_ajax_request()) { exit('no valid req.'); } + + $this->load->model('Medical_M'); + + $invoice_id=$this->input->post('med_invoice_id'); + $input_amount_paid=$this->input->post('input_amount_paid'); + + $sql="select * from invoice_med_master where id='".$invoice_id."'"; + $query = $this->db->query($sql); + $inv_master= $query->result(); + + $user = $this->ion_auth->user()->row(); + $user_id = $user->id; + $user_name = $user->first_name.''. $user->last_name; + + $showcontent1='
+
+ Print +
+
+ Payment Method by : '; + + $showcontent2='
'; + + $pay_remark=''; + + if($inv_master[0]->patient_id>0) + { + $Customerof_type=1; + }else{ + $Customerof_type=3; + } + + if($this->input->post('mode')==1) + { + $paydata = array( + 'payment_mode'=> '1', + 'Customerof_type'=>$Customerof_type, + 'Customerof_id'=>$inv_master[0]->patient_id, + 'Customerof_code'=>$inv_master[0]->patient_code, + 'Medical_invoice_id'=>$inv_master[0]->id, + 'Medical_invoice_code'=>$inv_master[0]->inv_med_code, + 'credit_debit'=>'0', + 'amount'=>$input_amount_paid, + 'payment_date'=>date('Y-m-d H:i:s'), + 'remark'=>$pay_remark, + 'update_by'=>$user_name.'['.$user_id.']', + 'update_by_id'=>$user_id + ); + + $insert_id=$this->Medical_M->insert_payment($paydata); + + $data = array( + + 'payment_mode'=> '1', + 'payment_status'=>'1', + 'invoice_status'=>'1', + 'payment_id'=>$insert_id, + 'payment_mode_desc'=>'Cash', + 'confirm_invoice'=>date('Y-m-d H:i:s'), + 'prepared_by'=>$user_name.'['.$user_id.']' + ); + + $this->Medical_M->update_in_upv_item( $data,$invoice_id); + + $status='CASH'; + $showcontent=$showcontent1.$status.$showcontent2; + + $rvar=array( + 'update' =>1, + 'showcontent'=>$showcontent + ); + + $encode_data = json_encode($rvar); + echo $encode_data; + } + + if($this->input->post('mode')==2) + { + $FormRules = array( + array( + 'field' => 'input_card_mac', + 'label' => 'Card Bank Name', + 'rules' => 'required|min_length[1]|max_length[30]' + ), + array( + 'field' => 'input_card_digit', + 'label' => 'Card Last 4 Digit ', + 'rules' => 'required|min_length[4]' + ), + array( + 'field' => 'input_card_bank', + 'label' => 'Bank Name ', + 'rules' => 'required|min_length[1]|max_length[50]' + ), + array( + 'field' => 'input_card_tran', + 'label' => 'Card Transcation ID', + 'rules' => 'required|min_length[3]|max_length[15]' + ) + ); + + $this->form_validation->set_rules($FormRules); + + if ($this->form_validation->run() == TRUE) + { + $paydata = array( + 'payment_mode'=> '2', + 'Customerof_type'=>$Customerof_type, + 'Customerof_id'=>$inv_master[0]->patient_id, + 'Customerof_code'=>$inv_master[0]->patient_code, + 'Medical_invoice_id'=>$inv_master[0]->id, + 'Medical_invoice_code'=>$inv_master[0]->inv_med_code, + 'credit_debit'=>'0', + 'amount'=>$input_amount_paid, + 'payment_date'=>date('Y-m-d H:i:s'), + 'remark'=>$pay_remark, + 'update_by'=>$user_name.'['.$user_id.']', + 'update_by_id'=>$user_id, + 'card_bank'=>$this->input->post('input_card_mac'), + 'cust_card'=>$this->input->post('input_card_bank'), + 'card_remark'=>$this->input->post('input_card_digit'), + 'card_tran_id'=>$this->input->post('input_card_tran') + ); + + $insert_id=$this->Medical_M->insert_payment($paydata); + + $data = array( + 'payment_mode'=> '2', + 'payment_status'=>'1', + 'invoice_status'=>'1', + 'payment_mode_desc'=>'Bank Card', + 'confirm_invoice'=>date('Y-m-d H:i:s'), + 'payment_id'=>$insert_id, + 'card_bank'=>$this->input->post('input_card_mac'), + 'card_remark'=>$this->input->post('input_card_digit'), + 'cust_card'=>$this->input->post('input_card_bank'), + 'card_tran_id'=>$this->input->post('input_card_tran'), + 'prepared_by'=>$user_name.'['.$user_id.']', + 'prepared_by_id'=>$user_id + ); + + $this->Medical_M->update_in_upv_item( $data,$invoice_id); + + $status='Bank Card'; + $showcontent=$showcontent1.$status.$showcontent2; + + $rvar=array( + 'update' =>1, + 'showcontent'=>$showcontent + ); + $encode_data = json_encode($rvar); + echo $encode_data; + } + else{ + $send_error=validation_errors(); + $rvar=array( + 'update' =>0, + 'error_text'=>$send_error + ); + $encode_data = json_encode($rvar); + echo $encode_data; + } + } + + if($this->input->post('mode')==3) + { + $data = array( + + 'payment_mode'=> '3', + 'payment_status'=>'1', + 'invoice_status'=>'1', + 'confirm_invoice'=>date('d/m/Y H:m:s'), + 'payment_mode_desc'=>'IPD Credit', + 'ipd_id'=>$this->input->post('ipd_id'), + 'prepared_by'=>$user_name.'['.$user_id.']' + ); + + $this->Medical_M->update_in_upv_item( $data,$invoice_id); + + $status='IPD Credit'; + $showcontent=$showcontent1.$status.$showcontent2; + + $rvar=array( + 'update' =>1, + 'showcontent'=>$showcontent + ); + + $encode_data = json_encode($rvar); + echo $encode_data; + } + + if($this->input->post('mode')==4) + { + $data = array( + 'payment_mode'=> '4', + 'payment_status'=>'1', + 'invoice_status'=>'1', + 'confirm_invoice'=>date('d/m/Y H:m:s'), + 'payment_mode_desc'=>'Org Credit', + 'case_id'=>$this->input->post('ipd_id'), + 'prepared_by'=>$user_name.'['.$user_id.']' + ); + + $this->Medical_M->update_in_upv_item( $data,$invoice_id); + + $status='Org Credit'; + $showcontent=$showcontent1.$status.$showcontent2; + + $rvar=array( + 'update' =>1, + 'showcontent'=>$showcontent + ); + + $encode_data = json_encode($rvar); + echo $encode_data; + } + + if($this->input->post('mode')==5) + { + if($input_amount_paid<0) + { + $input_amount_paid=$input_amount_paid*-1; + } + + $paydata = array( + 'payment_mode'=> '1', + 'Customerof_type'=>$Customerof_type, + 'Customerof_id'=>$inv_master[0]->patient_id, + 'Customerof_code'=>$inv_master[0]->patient_code, + 'Medical_invoice_id'=>$inv_master[0]->id, + 'Medical_invoice_code'=>$inv_master[0]->inv_med_code, + 'credit_debit'=>'1', + 'amount'=>$input_amount_paid, + 'payment_date'=>date('Y-m-d H:i:s'), + 'remark'=>$pay_remark, + 'update_by'=>$user_name.'['.$user_id.']', + 'update_by_id'=>$user_id + ); + + $insert_id=$this->Medical_M->insert_payment($paydata); + + $data = array( + + 'payment_mode'=> '1', + 'payment_status'=>'1', + 'invoice_status'=>'1', + 'payment_id'=>$insert_id, + 'payment_mode_desc'=>'Cash Return', + 'confirm_invoice'=>date('Y-m-d H:i:s'), + 'prepared_by'=>$user_name.'['.$user_id.']' + ); + + $this->Medical_M->update_in_upv_item( $data,$invoice_id); + + $status='CASH'; + $showcontent=$showcontent1.$status.$showcontent2; + + $rvar=array( + 'update' =>1, + 'showcontent'=>$showcontent + ); + + $encode_data = json_encode($rvar); + echo $encode_data; + } + } + + public function invoice_print($inv_id,$print_format=0) + { + $this->load->model('Medical_M'); + $this->Medical_M->update_invoice_final($inv_id); + + $sql="select *,(discount_amount+item_discount_amount) as inv_disc_total,(CGST_Tamount+SGST_Tamount) as TGST from invoice_med_master where id=".$inv_id; + $query = $this->db->query($sql); + $data['invoice_master']= $query->result(); + + $sql="select *,(disc_amount+disc_whole) as d_amt,(CGST+SGST) as gst,(CGST_per+SGST_per) as gst_per from inv_med_item + where inv_med_id=".$inv_id; + $query = $this->db->query($sql); + $data['inv_items']= $query->result(); + + $sql="select * from ipd_master where id=".$data['invoice_master'][0]->ipd_id; + $query = $this->db->query($sql); + $data['ipd_master']= $query->result(); + + $sql="select * from organization_case_master where id=".$data['invoice_master'][0]->case_id; + $query = $this->db->query($sql); + $data['orgcase']= $query->result(); + + $sql="select sum(if(credit_debit>0,amount*-1,amount)) as paid_amount from payment_history_medical where Medical_invoice_id=".$inv_id; + $query = $this->db->query($sql); + $data['payment_history_medical']= $query->result(); + + $sql="select *,if(credit_debit>0,amount*-1,amount) as paid_amount, + (case payment_mode when 1 then 'Cash' when 2 then 'Bank Card' when 3 then 'Return Cash ' when 4 then 'Bank Return' when 5 then 'Cash Return' else 'Other' end) as Payment_type_str + from payment_history_medical where Medical_invoice_id=".$inv_id; + $query = $this->db->query($sql); + $data['payment_history']= $query->result(); + + if($print_format==0) + { + $this->load->view('Medical/Medical_invoice_print_2',$data); + }else{ + $this->load->view('Medical/Medical_invoice_print',$data); + } + + } + + + public function invoice_print_all($ipd_id,$cash=0) + { + //$cash 0 for Cash Only,1 for Credit only,2 Package Credit only,3 for All + $this->load->model('Medical_M'); + + $cash_where=" "; + + if($cash==0) + { + $cash_where.=" and ipd_credit=0 "; + $med_type=1; + }elseif($cash==1) + { + $cash_where.=" and ipd_credit=1 and ipd_credit_type=1 "; + $med_type=2; + }elseif($cash==2) + { + $cash_where.=" and ipd_credit=1 and ipd_credit_type=0 "; + $med_type=3; + } + + $this->Medical_M->update_invoice_group_gst($ipd_id,$med_type); + + + $sql="select i.inv_med_id,i.id,i.item_Name,i.formulation, + i.batch_no,Date_Format(i.expiry,'%m-%Y')as expiry, + i.price,i.qty,sum(i.amount) as amount,i.HSNCODE, + m.inv_med_code,m.id as m_id, + date_format(m.inv_date,'%d-%m-%Y') as str_inv_date, + sum(twdisc_amount) as twdisc_amount, + sum(i.disc_amount+i.disc_whole) as d_amt, + sum(i.CGST+i.SGST) as gst, + (i.CGST_per+i.SGST_per) as gst_per + from inv_med_item i join invoice_med_master m + on i.inv_med_id=m.id + where m.group_invoice_id>0 and m.ipd_id=".$ipd_id.$cash_where." group by i.inv_med_id,i.id WITH ROLLUP"; + $query = $this->db->query($sql); + $data['inv_items']= $query->result(); + + $sql="select sum(CGST_Tamount) as CGST_Tamount, + sum(SGST_Tamount) as SGST_Tamount, + sum(TaxableAmount) as TaxableAmount, + sum(net_amount) as net_amount, + sum(payment_received) as payment_received, + sum(payment_balance) as payment_balance, + sum(discount_amount+item_discount_amount) as inv_disc_total, + (CGST_Tamount+SGST_Tamount) as TGST from invoice_med_master + where group_invoice_id>0 and ipd_id=".$ipd_id.$cash_where." group by ipd_id"; + $query = $this->db->query($sql); + $data['invoice_master']= $query->result(); + + $sql="select m.p_id,p.p_fname,m.ipd_code,p.p_code, m.doc_name, + m.org_id from v_ipd_list m join patient_master p on m.p_id=p.id + where m.id=".$ipd_id; + $query = $this->db->query($sql); + $data['ipd_master']= $query->result(); + + $sql="select * from organization_case_master where id='".$data['ipd_master'][0]->org_id."'"; + $query = $this->db->query($sql); + $data['orgcase']= $query->result(); + + $sql="select sum(if(p.credit_debit>0,p.amount*-1,p.amount)) as paid_amount + from payment_history_medical p join inv_med_group m + on p.group_id=m.med_group_id + where m.ipd_id=".$ipd_id." and m.med_type=".$med_type; + $query = $this->db->query($sql); + $data['payment_Total']= $query->result(); + + $sql="select p.*,if(p.credit_debit>0,p.amount*-1,p.amount) as paid_amount, + (case p.payment_mode when 1 then 'Cash' when 2 then 'Bank Card' when 3 then 'Return Cash ' when 4 then 'Bank Return' when 5 then 'Cash Return' else 'Other' end) as Payment_type_str + from payment_history_medical p join inv_med_group m + on p.group_id=m.med_group_id + where m.ipd_id=".$ipd_id." and m.med_type=".$med_type; + $query = $this->db->query($sql); + $data['payment_history']= $query->result(); + + $sql="select * from inv_med_group + where ipd_id='".$ipd_id."' and med_type='".$med_type."'"; + $query = $this->db->query($sql); + $data['inv_med_group']= $query->result(); + + if($cash==0) + { + if($data['inv_med_group'][0]->bill_final==1) + { + $this->load->view('Medical/Medical_invoice_print_all',$data); + }else{ + $this->load->view('Medical/Medical_invoice_print_all_provisional',$data); + } + }else{ + $this->load->view('Medical/Medical_invoice_print_all',$data); + } + + } + + + public function final_invoice($inv_id) + { + $this->load->model('Medical_M'); + + $this->Medical_M->update_invoice_group($inv_id); + $this->Medical_M->update_invoice_final($inv_id); + + $sql="select *,(discount_amount+item_discount_amount) as inv_disc_total,(CGST_Tamount+SGST_Tamount) as TGST from invoice_med_master where id=".$inv_id; + $query = $this->db->query($sql); + $data['invoiceMaster']= $query->result(); + + $sql="select * from inv_med_item where inv_med_id=".$inv_id; + $query = $this->db->query($sql); + $data['inv_items']= $query->result(); + + $sql="select *,if(gender=1,'Male','FeMale') as xgender, + GET_AGE_1(dob,age,age_in_month,estimate_dob) AS age + from patient_master where id='".$data['invoiceMaster'][0]->patient_id."' "; + $query = $this->db->query($sql); + $data['person_info']= $query->result(); + + $sql="select * from ipd_master where ipd_status=0 and id=".$data['invoiceMaster'][0]->ipd_id; + $query = $this->db->query($sql); + $data['ipd_master']= $query->result(); + + if($data['invoiceMaster'][0]->case_id > 0) + { + $sql="select * from organization_case_master where id=".$data['invoiceMaster'][0]->case_id; + $query = $this->db->query($sql); + $data['OCaseMaster']= $query->result(); + } + + $sql="select sum(if(credit_debit>0,amount*-1,amount)) as paid_amount from payment_history_medical where Medical_invoice_id=".$inv_id; + $query = $this->db->query($sql); + $data['payment_history_medical']= $query->result(); + + if(count($data['invoiceMaster'])>0) + { + if($data['invoiceMaster'][0]->ipd_id>0) + { + redirect('Medical/list_med_inv/'.$data['invoiceMaster'][0]->ipd_id); + }else if($data['invoiceMaster'][0]->case_id>0 && $data['invoiceMaster'][0]->case_credit>0) + { + redirect('Medical/list_med_orginv/'.$data['invoiceMaster'][0]->case_id); + }else{ + $this->load->view('Medical/Medical_Final_Invoice',$data); + } + } + } + + public function final_return_invoice($inv_id) + { + $this->load->model('Medical_M'); + + $sql="select *,(discount_amount+item_discount_amount) as inv_disc_total,(CGST_Tamount+SGST_Tamount) as TGST from invoice_med_master where id=".$inv_id; + $query = $this->db->query($sql); + $data['invoiceMaster']= $query->result(); + + $sql="select * from inv_med_item where inv_med_id=".$inv_id; + $query = $this->db->query($sql); + $data['inv_items']= $query->result(); + + $sql="select *,if(gender=1,'Male','FeMale') as xgender, + GET_AGE_1(dob,age,age_in_month,estimate_dob) AS age + from patient_master where id='".$data['invoiceMaster'][0]->patient_id."' "; + $query = $this->db->query($sql); + $data['person_info']= $query->result(); + + $sql="select sum(if(credit_debit>0,amount*-1,amount)) as paid_amount from payment_history_medical where Medical_invoice_id=".$inv_id; + $query = $this->db->query($sql); + $data['payment_history_medical']= $query->result(); + + if(count($data['invoiceMaster'])>0) + { + $this->load->view('Medical/Medical_Final_return_Invoice',$data); + }else{ + echo 'Error In Inv. No.'; + } + } + + public function add_item($type,$req=0) + { + $this->load->model('Medical_M'); + + $inser_id=1; + $Error_Show=''; + + $store_stock_id=$this->input->post('l_ssno'); + + $user = $this->ion_auth->user()->row(); + $user_id = $user->id; + $user_name_info = $user->first_name.''. $user->last_name .'['.$user_id.']'.date('d-m-Y H:i:s'); + + if($type==1) + { + $inv_id=$this->input->post('inv_id'); + $qty=$this->input->post('qty'); + $disc=$this->input->post('disc'); + $product_unit_rate=$this->input->post('product_unit_rate'); + + $sql="SELECT p.item_name,t.batch_no,t.expiry_date, + (t.total_unit-t.total_sale_unit) AS S_qty, + t.mrp,t.selling_unit_rate,p.id AS master_product_id, + t.id as purchase_item_id,p.formulation, + p.HSNCODE,p.CGST_per,p.SGST_per,t.packing + FROM med_product_master p + JOIN purchase_invoice_item t ON p.id=t.item_code + where t.id= ".$store_stock_id; + $query = $this->db->query($sql); + $data['itemlist']= $query->result(); + + $sql="select *,ifnull(DATEDIFF(expiry,CURDATE()),-1000) AS no_day from inv_med_item where inv_med_id=".$inv_id." and store_stock_id=".$store_stock_id; + $query = $this->db->query($sql); + $itemExist= $query->result(); + + $CGST=$data['itemlist'][0]->CGST_per; + $SGST=$data['itemlist'][0]->SGST_per; + + //$item_rate=$data['itemlist'][0]->unit_rate; + $item_rate=$product_unit_rate; + + $amount_value=$qty*$item_rate; + + $disc_amount=$amount_value*$disc/100; + + $Tamount_value=$amount_value-$disc_amount; + + $HSNCODE=$data['itemlist'][0]->HSNCODE; + + $stock_qty=$data['itemlist'][0]->S_qty; + + if($qty>$stock_qty) + { + $inser_id=0; + $Error_Show='Stock Qty. is less than Required Qty : Current Qty :'.$stock_qty; + }elseif($stock_qty==0){ + $stock_qty=0; + $inser_id=0; + $Error_Show='Stock is Empty'; + } + + if($inser_id>0) + { + $data['insert_inv_med_item'] = array( + 'inv_med_id' => $inv_id, + 'item_code' => $data['itemlist'][0]->master_product_id, + 'item_Name' => $data['itemlist'][0]->item_name, + 'formulation' => $data['itemlist'][0]->formulation, + 'qty' => $qty, + 'batch_no' => $data['itemlist'][0]->batch_no, + 'expiry' => $data['itemlist'][0]->expiry_date, + 'price' => $item_rate, + 'price2' => $item_rate, + 'mrp' => $data['itemlist'][0]->mrp, + 'disc_per' => $disc, + 'disc_amount' => $disc_amount, + 'amount' => $amount_value, + 'tamount' => $Tamount_value, + 'CGST_per'=> $CGST, + 'SGST_per'=> $SGST, + 'HSNCODE'=> $HSNCODE, + 'store_stock_id'=>$data['itemlist'][0]->purchase_item_id, + 'update_by_id'=>$user_id, + 'update_by_remark'=>$user_name_info, + 'packing'=>$data['itemlist'][0]->packing, + ); + + if(count($itemExist)>0) + { + $inser_id=0; + $Error_Show='Already in Item List'; + }else{ + $inser_id=$this->Medical_M->add_invoiceitem( $data['insert_inv_med_item']); + + } + } + } + else if($type==2) + { + $update_qty=$this->input->post('u_qty'); + $itemid=$this->input->post('itemid'); + + $sql="select * from inv_med_item where id=".$itemid; + $query = $this->db->query($sql); + $data['inv_med_item']= $query->result(); + + $CGST=$data['inv_med_item'][0]->CGST_per; + $SGST=$data['inv_med_item'][0]->SGST_per; + $disc=$data['inv_med_item'][0]->disc_per; + + $inv_id=$data['inv_med_item'][0]->inv_med_id; + + $store_stock_id=$data['inv_med_item'][0]->store_stock_id; + + $sql="SELECT p.item_name,t.batch_no,t.expiry_date, + (t.total_unit-t.total_sale_unit) AS S_qty, + t.mrp,t.selling_unit_rate,p.id AS master_product_id, + t.id as purchase_item_id,p.formulation, + p.HSNCODE,p.CGST_per,p.SGST_per,t.packing + FROM med_product_master p + JOIN purchase_invoice_item t ON p.id=t.item_code + where t.id= ".$store_stock_id; + + $query = $this->db->query($sql); + $item_master= $query->result(); + + $stock_qty=0; + + $old_qty=$data['inv_med_item'][0]->qty; + $diff_qty=$update_qty-$old_qty; + + if($diff_qty>0) + { + if(count($item_master)>0) + { + $stock_qty=$item_master[0]->S_qty; + if($diff_qty>$stock_qty) + { + $inser_id=0; + $Error_Show='Stock Qty. is less than Required Qty : Current Qty :'.$stock_qty; + } + }else{ + $stock_qty=0; + $inser_id=0; + $Error_Show='Stock is Empty'; + } + } + + if($inser_id>0) + { + $item_rate=$data['inv_med_item'][0]->price; + $amount_value=$update_qty*$item_rate; + + $disc_amount=$amount_value*$disc/100; + + $Tamount_value=$amount_value-$disc_amount; + + $data['update_inv_med_item'] = array( + 'qty' => $update_qty, + 'disc_amount' => $disc_amount, + 'amount' => $amount_value, + 'tamount' => $Tamount_value, + 'store_stock_id'=>$store_stock_id, + 'packing'=>$data['inv_med_item'][0]->packing, + ); + + $this->Medical_M->update_invoiceitem($data['update_inv_med_item'],$itemid); + $inser_id=$itemid; + + } + + $this->Medical_M->update_invoice_group($inv_id); + $this->Medical_M->update_invoice_final($inv_id); + + }else{ + $inv_id=$this->input->post('inv_id'); + $itemid=$this->input->post('itemid'); + + $sql="select *,ifnull(DATEDIFF(expiry,CURDATE()),-1000) AS no_day from inv_med_item where id=".$itemid; + $query = $this->db->query($sql); + $inv_items= $query->row_array(); + + $this->Medical_M->delete_invoiceitem($itemid,$inv_items); + + } + + $content=''; + + if($inser_id>0) + { + $this->Medical_M->update_invoice_final($inv_id); + + $sql="select *,ifnull(DATEDIFF(expiry,CURDATE()),-1000) AS no_day + from inv_med_item where inv_med_id=".$inv_id; + $query = $this->db->query($sql); + $data['inv_items']= $query->result(); + + $sql="select sum(amount) as Gtotal,sum(tamount) as tamt,sum(CGST) as TCGST,sum(SGST) as TSGST, + sum(disc_amount) as t_dis_amt from inv_med_item where inv_med_id=".$inv_id; + $query = $this->db->query($sql); + $data['invoiceGtotal']= $query->result(); + + $sql="select * from invoice_med_master where id=".$inv_id; + $query = $this->db->query($sql); + $data['invoiceMaster']= $query->result(); + + + $user = $this->ion_auth->user()->row(); + $data['user_id'] = $user->id; + + $data['sale_return']=$data['invoiceMaster'][0]->sale_return; + + $content=$this->load->view('Medical/Med_Item_List',$data,true); + } + + + $rvar=array( + 'insertid' =>$inser_id, + 'content'=>$content, + 'error'=>$Error_Show, + 'csrf_dst_name_value'=>$this->security->get_csrf_hash() + ); + $encode_data = json_encode($rvar); + echo $encode_data; + } + + + + public function list_org_ipd() + { + $sql = "select *,(paid_amount-(charge_amount+med_amount)) as balance + from v_ipd_list where ipd_status=0 "; + $query = $this->db->query($sql); + $data['data']= $query->result(); + + $this->load->view('Medical/Medical_ipd_org_list',$data); + } + + + public function list_org() + { + $sql = "select p.p_fname,p.p_code,p.p_relative,p.p_rname,o.insurance_company_name,o.case_id_code,o.id as org_id,o.p_id , + o.date_registration,Date_Format(o.date_registration,'%d-%m-%Y') as str_register_date,o.insurance_id + from organization_case_master o join patient_master p on o.p_id=p.id + and o.insurance_id >1 and o.`status`=0 and o.case_type=0 "; + $query = $this->db->query($sql); + $data['organization_case_master']= $query->result(); + + + $this->load->view('Medical/Medical_org_list',$data); + } + + public function list_med_inv($ipd_id) + { + $sql="select *,if(ipd_credit=0,'CASH','CREDIT') as credit, + if(ipd_credit=1 and ipd_credit_type=0,'Yes','No') as Package + from invoice_med_master where ipd_id = ".$ipd_id." Order by inv_date,id"; + $query = $this->db->query($sql); + $data['inv_master']= $query->result(); + + $sql="select sum(if(ipd_credit=0,net_amount,0)) as cash_netAmount, + sum(if(ipd_credit=1 and ipd_credit_type=1,net_amount,0)) as IPDCrAmount , + sum(if(ipd_credit=1 and ipd_credit_type=0,net_amount,0)) as PackageCrAmount, + sum(payment_balance) as t_payment_balance ,sum(net_amount) as t_net_amount + from invoice_med_master where ipd_id = ".$ipd_id; + $query = $this->db->query($sql); + $data['inv_master_total']= $query->result(); + + $sql="select * from ipd_master where id = ".$ipd_id; + $query = $this->db->query($sql); + $data['ipd_master']= $query->result(); + + $sql="select *,if(gender=1,'Male','Female') as xgender, + GET_AGE_1(dob,age,age_in_month,estimate_dob) AS age from patient_master where id='".$data['ipd_master'][0]->p_id."' "; + $query = $this->db->query($sql); + $data['person_info']= $query->result(); + + $sql="select * from v_ipd_list where id=".$ipd_id; + $query = $this->db->query($sql); + $data['ipd_list']= $query->result(); + + $sql="select * from inv_med_group where med_type=1 and ipd_id=".$ipd_id; + $query = $this->db->query($sql); + $data['med_group_list']= $query->result(); + + $sql="select b.ipd_id,b.bed_id,b.TDate,m.room_name,m.bed_no + from ipd_bed_assign b left join hc_bed_master m on b.bed_id=m.id + where b.ipd_id=".$ipd_id." order by TDate desc"; + $query = $this->db->query($sql); + $data['bed_list']= $query->result(); + + if($data['ipd_master'][0]->case_id>0) + { + $sql="select * from organization_case_master where id='".$data['ipd_master'][0]->case_id."'"; + $query = $this->db->query($sql); + $data['orgcase']= $query->result(); + + $ins_comp_id=$data['orgcase'][0]->insurance_id; + $inc_card_id=$data['orgcase'][0]->insurance_card_id; + + $sql="select * from hc_insurance_card where id='".$inc_card_id."'"; + $query = $this->db->query($sql); + $data['hc_insurance_card']= $query->result(); + + $sql="select * from hc_insurance where id='".$ins_comp_id."'"; + $query = $this->db->query($sql); + $data['insurance']= $query->result(); + } + + $this->load->view('Medical/Medical_invoice_list',$data); + } + + public function list_med_orginv($org_id) + { + + $sql="select *,if(case_credit=0,'CASH','CREDIT') as credit + from invoice_med_master where case_id = ".$org_id." order by inv_date,id"; + $query = $this->db->query($sql); + $data['inv_master']= $query->result(); + + $sql="select * from organization_case_master where id = ".$org_id; + $query = $this->db->query($sql); + $data['orgcase_master']= $query->result(); + + $sql="select *,if(gender=1,'Male','Female') as xgender, + GET_AGE_1(dob,age,age_in_month,estimate_dob) AS age from patient_master where id='".$data['orgcase_master'][0]->p_id."' "; + $query = $this->db->query($sql); + $data['person_info']= $query->result(); + + $this->load->view('Medical/Medical_org_invoicelist',$data); + } + + public function update_discount() + { + $invoice_id=$this->input->post('med_invoice_id'); + + $user = $this->ion_auth->user()->row(); + $user_id = $user->id; + $user_name = $user->first_name.''. $user->last_name; + + $dataupdate = array( + 'discount_amount' => $this->input->post('input_dis_amt'), + 'discount_remark' => $this->input->post('input_dis_desc'), + 'discount_by'=>$user_name.'['.$user_id.']' + ); + + $this->load->model('Medical_M'); + $this->Medical_M->update_in_upv_item($dataupdate,$invoice_id); + + $this->Medical_M->update_invoice_final($invoice_id); + + } + + public function BillFinal($group_id) + { + + $user = $this->ion_auth->user()->row(); + $user_id = $user->id; + $user_name = $user->first_name.''. $user->last_name; + + $dataupdate = array( + 'bill_final' => '1', + 'bill_final_by'=>$user_name.'['.$user_id.']' + ); + + $this->load->model('Medical_M'); + $this->Medical_M->update_group_invoice($dataupdate,$group_id); + + $rvar=array( + 'update' =>1, + ); + $encode_data = json_encode($rvar); + echo $encode_data; + + } + + public function InvBillFinal($invoice_id) + { + $user = $this->ion_auth->user()->row(); + $user_id = $user->id; + $user_name = $user->first_name.''. $user->last_name; + + $dataupdate = array( + 'bill_final' => '1', + 'bill_final_by'=>$user_name.'['.$user_id.']' + ); + + $this->load->model('Medical_M'); + $this->Medical_M->update_in_upv_item($dataupdate,$invoice_id); + + $rvar=array( + 'update' =>1, + ); + $encode_data = json_encode($rvar); + echo $encode_data; + + } + + + public function search() + { + $sdata=$this->input->post('txtsearch'); + + $sdata = preg_replace('/[^A-Za-z0-9 _.@\-]/', '', trim($sdata)); + + if(strlen($sdata)==0) + { + $sql = "SELECT p.*,GET_AGE_1(dob,age,age_in_month,estimate_dob) AS age , + Max(o.apointment_date) as Last_OPD , + date_format(if(Max(o.apointment_date) IS NULL,p.insert_date,Max(o.apointment_date)),'%d-%m-%Y') AS Last_Visit + FROM patient_master p left join opd_master o on p.id=o.p_id + group BY p.id + order BY if(Max(o.apointment_date) IS NULL,p.insert_date,Max(o.apointment_date)) DESC + LIMIT 100"; + }else{ + + $sdate_array=explode(" ",$sdata); + $search_string=" 1=1 " ; + + foreach($sdate_array as $row_data) + { + if(is_numeric($row_data)) + { + $search_string.=" and (p.p_code like '%$row_data' + or p.mphone1 = '$row_data' + or p.udai='$row_data' )"; + }elseif(ctype_alpha($row_data)){ + $search_string.=" and (p.p_fname like '%$row_data%' + or p.email1 = '$row_data' + or SUBSTRING_INDEX(p.p_fname,' ',1) sounds like '".$row_data."')"; + }else{ + $search_string.=" and (p.p_code like '$row_data' + or p.email1 = '$row_data' )"; + } + } + + $sql = "SELECT p.*,GET_AGE_1(dob,age,age_in_month,estimate_dob) AS age , + Max(o.apointment_date) as Last_OPD , + date_format(if(Max(o.apointment_date) IS NULL,p.insert_date,Max(o.apointment_date)),'%d-%m-%Y') AS Last_Visit + FROM patient_master p left join opd_master o on p.id=o.p_id + WHERE $search_string + group BY p.id + order BY if(Max(o.apointment_date) IS NULL,p.insert_date,Max(o.apointment_date)) DESC "; + } + + + $query = $this->db->query($sql); + $data['data']= $query->result(); + + $this->load->view('Medical/Patient_Search_Result',$data); + } + + public function Update_Invoice_ipd_credit_type() + { + $ipd_credit_type= $this->input->post('ipd_credit_type'); + $inv_med_id = $this->input->post('inv_med_id'); + + $user = $this->ion_auth->user()->row(); + $user_id = $user->id; + $user_name = $user->first_name.''. $user->last_name.'['.$user_id.']T:'.date('d-m-Y'); + + if($inv_med_id=='1') + { + $ipd_credit_type_update='Include by : '.$user_name; + }else{ + $ipd_credit_type_update='Packeage by '.$user_name; + } + + $dataupdate = array( + 'ipd_credit_type' => $ipd_credit_type, + 'ipd_credit_type_update'=>$ipd_credit_type_update, + ); + + $this->load->model('Medical_M'); + $this->Medical_M->update_in_upv_item($dataupdate,$inv_med_id); + } + + + + public function Med_Inv_Group($inv_med_id) + { + if (!$this->input->is_ajax_request()) { exit('no valid req.'); } + + $sql = "select * from invoice_med_master where id=".$inv_med_id; + $query = $this->db->query($sql); + $invoice_med_master= $query->result(); + + $user = $this->ion_auth->user()->row(); + $user_id = $user->id; + $user_name = $user->first_name.''. $user->last_name; + + $old_remark=$invoice_med_master[0]->update_history; + + $new_remark='Group By : '.$user_name.'['.$user_id.']'.' Date:'.date('d-m-Y h:i:s').PHP_EOL; + + $new_remark.= $old_remark; + + $dataupdate = array( + 'med_group_id' => 1, + 'update_history' => $new_remark + ); + + $this->load->model('Medical_M'); + $this->Medical_M->update_in_upv_item($dataupdate,$inv_med_id); + $this->Medical_M->update_invoice_group($inv_med_id); + + $rvar=array( + 'update' =>1, + ); + $encode_data = json_encode($rvar); + echo $encode_data; + + } + + public function Update_Group_Discount($med_group_id) + { + $input_discount= $this->input->post('input_discount'); + $Ipd_ID= $this->input->post('ipd_id'); + + $user = $this->ion_auth->user()->row(); + $user_id = $user->id; + $user_name = $user->first_name.''. $user->last_name; + + $dataupdate = array( + 'discount_group' => $input_discount, + 'discount_by_group' => $user_name.'['.$user_id.']'.' Date:'.date('d-m-Y h:i:s') + ); + + $this->load->model('Medical_M'); + $this->Medical_M->update_group_invoice($dataupdate,$med_group_id); + $this->Medical_M->update_invoice_group_gst($Ipd_ID); + + $rvar=array( + 'update' =>1, + ); + + $encode_data = json_encode($rvar); + echo $encode_data; + } + + public function edit_invoice_edit($inv_id) + { + $sql="select *,if(ipd_credit>0,'Credit to IPD','CASH') as credit_status, + if(case_credit>0,'Credit to Org','CASH') as credit_org_status from invoice_med_master + where id=$inv_id"; + $query = $this->db->query($sql); + $data['invoiceMaster']= $query->result(); + + $sql="select sum(amount) as Gtotal,sum(tamount) as tamt,sum(CGST) as TCGST,sum(SGST) as TSGST,sum(disc_amount) as t_dis_amt from inv_med_item where inv_med_id=".$inv_id; + $query = $this->db->query($sql); + $data['invoiceGtotal']= $query->result(); + + $sql="select * from doctor_master where active=1"; + $query = $this->db->query($sql); + $data['doclist']= $query->result(); + + $sql="select *, + GET_AGE_1(dob,age,age_in_month,estimate_dob) AS age from patient_master where id='".$data['invoiceMaster'][0]->patient_id."' "; + $query = $this->db->query($sql); + $data['person_info']= $query->result(); + + $data['org_Name']=""; + $ipd_id=$data['invoiceMaster'][0]->ipd_id; + + if($ipd_id>0) + { + $sql="select * from ipd_master where id=".$ipd_id; + $query = $this->db->query($sql); + $ipd_master= $query->result(); + + $sql="select * from v_ipd_list m join patient_master p on m.p_id=p.id + where m.id=".$ipd_id; + $query = $this->db->query($sql); + $data['ipd_list']= $query->result(); + + $data['ipd_master']=$ipd_master; + + if(count($ipd_master)>0) + { + $p_ipd_id=$ipd_master[0]->id; + $p_ipd_code=$ipd_master[0]->ipd_code; + + if($ipd_master[0]->case_id>0) + { + $sql="select * from organization_case_master where id=".$ipd_master[0]->case_id; + $query = $this->db->query($sql); + $org_master= $query->result(); + + if(count($org_master)>0) + { + $data['org_Name']=$org_master[0]->insurance_company_name; + } + + } + } + } + + if($data['invoiceMaster'][0]->case_id > 0) + { + $sql="select * from organization_case_master where id=".$data['invoiceMaster'][0]->case_id; + $query = $this->db->query($sql); + $data['OCaseMaster']= $query->result(); + } + + + + $user = $this->ion_auth->user()->row(); + $data['user_id'] = $user->id; + + $this->load->view('Medical/invoice_master_edit',$data); + + } + + public function LockIPD($inv_med_id,$lock=1) + { + if (!$this->input->is_ajax_request()) { exit('no valid req.'); } + + $sql = "select * from ipd_master where id=".$inv_med_id; + $query = $this->db->query($sql); + $ipd_master= $query->result(); + + $user = $this->ion_auth->user()->row(); + $user_id = $user->id; + $user_name = $user->first_name.''. $user->last_name; + + $old_remark=$ipd_master[0]->lock_remark; + + if($lock==1) + { + $new_remark='Locked By : '.$user_name.'['.$user_id.']'.' Date:'.date('d-m-Y h:i:s').PHP_EOL; + + }else{ + $new_remark='Unlocked By : '.$user_name.'['.$user_id.']'.' Date:'.date('d-m-Y h:i:s').PHP_EOL; + } + + $new_remark.= $old_remark; + + $dataupdate = array( + 'lock_medical' => $lock, + 'lock_remark' => $new_remark + ); + + $this->load->model('Ipd_M'); + $this->Ipd_M->update($dataupdate,$inv_med_id); + + $rvar=array( + 'update' =>1, + ); + + $encode_data = json_encode($rvar); + echo $encode_data; + + + } + + public function load_model_box($ipd_id) + { + $sql="select *,if(ipd_status=0,DATEDIFF(sysdate(),register_date), + DATEDIFF(discharge_date,register_date)) as no_days, + if(case_type=1,'MLC','Non MLC') as case_type_s, + Date_format(register_date,'%d-%m-%Y') as str_register_date from ipd_master + where id='".$ipd_id."' "; + $query = $this->db->query($sql); + $data['ipd_info']= $query->result(); + + $sql="select *,if(gender=1,'Male','Female') as xgender, + GET_AGE_1(dob,age,age_in_month,estimate_dob) AS age + from patient_master where id='".$data['ipd_info'][0]->p_id."' "; + $query = $this->db->query($sql); + $data['person_info']= $query->result(); + + $sql="select * from inv_med_group where med_type=1 and ipd_id=".$ipd_id; + $query = $this->db->query($sql); + $data['med_group_list']= $query->result(); + + $sql="select p.*,if(p.credit_debit=0,p.amount,p.amount*-1) as paid_amount, + Date_Format(payment_date,'%d-%m-%Y') as str_payment_date, + Concat((case p.payment_mode when 1 then 'Cash' when 2 then 'Bank Card' else 'Other' end),if(p.credit_debit=0,'',' Return')) as Payment_type_str + from payment_history_medical p join inv_med_group m + on p.group_id=m.med_group_id + where m.ipd_id=".$ipd_id." and m.med_type=1"; + $query = $this->db->query($sql); + $data['payment_history']= $query->result(); + + $sql="select * from inv_med_group where med_type=1 and ipd_id=".$ipd_id; + $query = $this->db->query($sql); + $data['inv_med_group']= $query->result(); + + + $phone_number_list=array($data['person_info'][0]->mphone1,$data['ipd_info'][0]->P_mobile1,$data['ipd_info'][0]->P_mobile2); + + $data['phone_number_list']=array_unique($phone_number_list); + + $this->load->view('Medical/Med_Model_Payment',$data); + } + + public function payment_receipt($ipd_id,$cash=0) + { + $cash_where=" "; + + if($cash==0) + { + $cash_where.=" and ipd_credit=0 "; + $med_type=1; + }elseif($cash==1) + { + $cash_where.=" and ipd_credit=1 and ipd_credit_type=1 "; + $med_type=2; + }elseif($cash==2) + { + $cash_where.=" and ipd_credit=1 and ipd_credit_type=0 "; + $med_type=3; + } + + $sql="select m.p_id,p.p_fname,m.ipd_code,p.p_code, m.doc_name, + m.org_id from v_ipd_list m join patient_master p on m.p_id=p.id + where m.id=".$ipd_id; + $query = $this->db->query($sql); + $data['ipd_master']= $query->result(); + + $sql="select * from organization_case_master where id='".$data['ipd_master'][0]->org_id."'"; + $query = $this->db->query($sql); + $data['orgcase']= $query->result(); + + $sql="select * from inv_med_group + where ipd_id='".$ipd_id."' and med_type=".$med_type; + $query = $this->db->query($sql); + $data['inv_med_group']= $query->result(); + + $sql="select p.*,if(p.credit_debit>0,p.amount*-1,p.amount) as paid_amount, + Date_Format(payment_date,'%d-%m-%Y') as str_payment_date, + (case p.payment_mode when 1 then 'Cash' when 2 then 'Bank Card' when 3 then 'Return Cash ' when 4 then 'Bank Return' when 5 then 'Cash Return' else 'Other' end) as Payment_type_str + from payment_history_medical p join inv_med_group m + on p.group_id=m.med_group_id + where m.ipd_id=".$ipd_id." and m.med_type=".$med_type; + $query = $this->db->query($sql); + $data['payment_history']= $query->result(); + + $this->load->view('Medical/Med_Payment_Receipt',$data); + + //load mPDF library + $this->load->library('m_pdf'); + $this->m_pdf->pdf->SetWatermarkText(M_store); + $this->m_pdf->pdf->showWatermarkText = true; + + $file_name='Report-payment_receipt-'.$ipd_id."-".date('Ymdhis').".pdf"; + $filepath=$file_name; + $content=$this->load->view('Medical/Med_Payment_Receipt',$data,TRUE); + $this->m_pdf->pdf->WriteHTML($content); + $this->m_pdf->pdf->Output($filepath,"I"); + + } + + public function payment_receipt_sms($ipd_id,$cash=0) + { + $inv_phone_number=$this->input->post('phone_number'); + + $cash_where=" "; + + if($cash==0) + { + $cash_where.=" and ipd_credit=0 "; + $med_type=1; + }elseif($cash==1) + { + $cash_where.=" and ipd_credit=1 and ipd_credit_type=1 "; + $med_type=2; + }elseif($cash==2) + { + $cash_where.=" and ipd_credit=1 and ipd_credit_type=0 "; + $med_type=3; + } + + $sql="select m.p_id,p.p_fname,m.ipd_code,p.p_code, m.doc_name, + m.org_id,m.P_mobile1,m.P_mobile2 from v_ipd_list m join patient_master p on m.p_id=p.id + where m.id=".$ipd_id; + $query = $this->db->query($sql); + $ipd_master= $query->result(); + + $sql="select * from inv_med_group + where ipd_id='".$ipd_id."' and med_type=".$med_type; + $query = $this->db->query($sql); + $inv_med_group= $query->result(); + + $sql="select * from invoice_med_master + where ipd_id='".$ipd_id."' and ipd_credit=0 order by id desc limit 1"; + $query = $this->db->query($sql); + $inv_med_master= $query->result(); + + $sql="select p.*,if(p.credit_debit>0,p.amount*-1,p.amount) as paid_amount, + Date_Format(payment_date,'%d-%m-%Y') as str_payment_date, + (case p.payment_mode when 1 then 'Cash' when 2 then 'Bank Card' when 3 then 'Return Cash ' when 4 then 'Bank Return' when 5 then 'Cash Return' else 'Other' end) as Payment_type_str + from payment_history_medical p join inv_med_group m + on p.group_id=m.med_group_id + where m.ipd_id=".$ipd_id." and m.med_type=".$med_type." order by id desc limit 1"; + $query = $this->db->query($sql); + $payment_history_last= $query->result(); + + $Last_Inv_Amt=0; + $Last_pay_Amt=0; + + if(count($inv_med_master)>0) + { + $Last_Inv_Amt=$inv_med_master[0]->net_amount; + } + + if(count($payment_history_last)>0) + { + $Last_pay_Amt=$payment_history_last[0]->paid_amount; + } + + $SMS_SEND= M_store_short." STORE BILL STATUS%nIPD No.: ".$ipd_master[0]->ipd_code."%nPName: ".Trim($ipd_master[0]->p_fname)."%nTot. Med Amt.: ".Round($inv_med_group[0]->net_amount,0)."%nLast Inv. Amt.: ".Round($Last_Inv_Amt,0)."%nTot. Paid Amt.: ".Round($inv_med_group[0]->payment_received)."%nLast Paid Amt.: ".Round($Last_pay_Amt,0)."%nBal. Amt.: ".Round($inv_med_group[0]->payment_balance,0)."%nFrom: DevSoftTech HMS"; + + + + //$inv_phone_number="9720958717"; + + $this->load->model('SMS_M'); + + $data=array( + 'to_number'=>$inv_phone_number, + 'message'=>$SMS_SEND + ); + + $insert_id=$this->SMS_M->insert_sms_outbox($data); + + + $rvar=array( + 'update' =>$insert_id, + 'msg_text'=>"Message Send" + ); + $encode_data = json_encode($rvar); + echo $encode_data; + + } + + public function group_confirm_payment() + { + if (!$this->input->is_ajax_request()) { exit('no valid req.'); } + + $this->load->model('Ipd_M'); + $this->load->model('Medical_M'); + + $ipd_id=$this->input->post('ipd_id'); + $amount=$this->input->post('amount'); + $Med_Group_id=$this->input->post('Med_Group_id'); + + $sql="select * from ipd_master where id=".$ipd_id; + $query = $this->db->query($sql); + $ipd_master= $query->result(); + + $user = $this->ion_auth->user()->row(); + $user_id = $user->id; + $user_name = $user->first_name.''. $user->last_name; + + $pay_remark=$this->input->post('cash_remark'); + $cr_dr=$this->input->post('cr_dr'); + + + $pay_datetime=str_to_MysqlDate($this->input->post('date_payment')).' '.date('H:i:s'); + + if($this->input->post('mode')==1) + { + $paydata = array( + 'payment_mode'=> '1', + 'Customerof_type'=>'2', + 'Customerof_id'=>$ipd_master[0]->p_id, + 'group_id'=>$Med_Group_id, + 'ipd_id'=>$ipd_id, + 'med_type'=>0, + 'credit_debit'=>$cr_dr, + 'amount'=>$amount, + 'payment_date'=>$pay_datetime, + 'remark'=>$pay_remark, + 'update_by'=>$user_name.'['.$user_id.']', + 'update_by_id'=>$user_id + ); + + $insert_id=$this->Medical_M->insert_payment($paydata); + + $this->Medical_M->update_invoice_group_gst($ipd_id); + + $rvar=array( + 'update' =>1, + 'ipd_id'=> $ipd_id, + 'payid' => $insert_id, + 'pay_date' =>$pay_datetime + ); + $encode_data = json_encode($rvar); + echo $encode_data; + } + + if($this->input->post('mode')==2) + { + + $FormRules = array( + array( + 'field' => 'input_card_mac', + 'label' => 'Card Bank Name', + 'rules' => 'required|min_length[1]|max_length[30]' + ) + /*, + array( + 'field' => 'input_card_digit', + 'label' => 'Card Last 4 Digit ', + 'rules' => 'required|min_length[1]|max_length[10]' + ), + array( + 'field' => 'input_card_bank', + 'label' => 'Bank Name ', + 'rules' => 'required|min_length[1]|max_length[50]' + ), + array( + 'field' => 'input_card_tran', + 'label' => 'Card Transcation ID', + 'rules' => 'required|min_length[1]|max_length[15]' + )*/ + ); + + $this->form_validation->set_rules($FormRules); + + if ($this->form_validation->run() == TRUE) + { + + + $paydata = array( + 'payment_mode'=> '2', + 'Customerof_type'=>'2', + 'Customerof_id'=>$ipd_master[0]->p_id, + 'group_id'=>$Med_Group_id, + 'ipd_id'=>$ipd_id, + 'med_type'=>0, + 'credit_debit'=>$cr_dr, + 'amount'=>$amount, + 'payment_date'=>$pay_datetime, + 'remark'=>$pay_remark, + 'update_by'=>$user_name.'['.$user_id.']', + 'update_by_id'=>$user_id, + 'card_bank'=>$this->input->post('input_card_mac'), + 'cust_card'=>$this->input->post('input_card_bank'), + 'card_remark'=>$this->input->post('input_card_digit'), + 'card_tran_id'=>$this->input->post('input_card_tran'), + + ); + + $insert_id=$this->Medical_M->insert_payment($paydata); + + $this->Medical_M->update_invoice_group_gst($ipd_id); + + $rvar=array( + 'update' =>1, + 'ipd_id'=> $ipd_id, + 'payid' => $insert_id, + 'pay_date' =>$pay_datetime + ); + $encode_data = json_encode($rvar); + echo $encode_data; + } + else{ + $send_error=validation_errors(); + $rvar=array( + 'update' =>0, + 'error_text'=>$send_error + ); + $encode_data = json_encode($rvar); + echo $encode_data; + } + } + + + if($this->input->post('mode')==5) + { + $FormRules = array( + array( + 'field' => 'input_person_name', + 'label' => 'Name on Chq.', + 'rules' => 'required|min_length[1]|max_length[30]' + ), + array( + 'field' => 'input_bank_tran', + 'label' => 'Chq. Number', + 'rules' => 'required|min_length[1]|max_length[15]' + ) + /*, + array( + 'field' => 'input_card_digit', + 'label' => 'Card Last 4 Digit ', + 'rules' => 'required|min_length[1]|max_length[10]' + ), + array( + 'field' => 'input_card_bank', + 'label' => 'Bank Name ', + 'rules' => 'required|min_length[1]|max_length[50]' + ), + */ + ); + + $this->form_validation->set_rules($FormRules); + + if ($this->form_validation->run() == TRUE) + { + $pay_remark='Chq Payment'; + + $paydata = array( + 'payment_mode'=> '2', + 'payof_type'=>'4', + 'payof_id'=>$ipd_master[0]->id, + 'payof_code'=>$ipd_master[0]->ipd_code, + 'credit_debit'=>$cr_dr, + 'amount' => $amount, + 'payment_date'=>$pay_datetime, + 'remark'=>$pay_remark, + 'update_by'=>$user_name.'['.$user_id.']', + 'card_bank'=>$this->input->post('input_bank_hospital'), + 'cust_card'=>$this->input->post('input_bank_name'), + 'card_remark'=>$this->input->post('input_person_name'), + 'card_tran_id'=>$this->input->post('input_bank_tran'), + 'update_by_id'=>$user_id + ); + + $insert_id=$this->Payment_M->insert($paydata); + + $data = array( + 'payment_mode'=> '2', + 'payment_mode_desc'=>'Bank Chq.-Draft', + 'payment_id'=>$insert_id, + 'pay_date'=>$pay_datetime, + 'enter_pay_date' => date('Y-m-d H:i:s'), + 'ipd_id' => $ipd_id, + 'amount' => $amount, + 'card_bank'=>$this->input->post('input_bank_hospital'), + 'card_remark'=>$this->input->post('input_card_digit'), + 'cust_card'=>$this->input->post('input_bank_name'), + 'card_tran_id'=>$this->input->post('input_bank_tran'), + 'prepared_by'=>$user_name.'['.$user_id.']', + 'prepared_by_id'=>$user_id + ); + + $insert_ipdpay_id=$this->Ipd_M->insert_payment_ipd( $data); + + $status='Bank Card'; + + + $rvar=array( + 'update' =>1, + 'ipd_id'=> $ipd_id, + 'payid' => $insert_ipdpay_id + ); + + $encode_data = json_encode($rvar); + echo $encode_data; + } + else{ + $send_error=validation_errors(); + $rvar=array( + 'update' =>0, + 'error_text'=>$send_error + ); + $encode_data = json_encode($rvar); + echo $encode_data; + } + } + } + + public function group_cash_print($ipd_id,$payid) + { + $sql="select *,date_format(payment_date,'%d-%m-%Y') as pay_date, + (case payment_mode when 1 then 'CASH' when 2 then 'Bank' Else 'Other' End) as payment_mode_desc + from payment_history_medical where id=".$payid; + $query = $this->db->query($sql); + $data['med_payment']= $query->result(); + + $sql="select * from ipd_master where id =".$ipd_id; + $query = $this->db->query($sql); + $data['ipd_master']= $query->result(); + + $pno=$data['ipd_master'][0]->p_id; + + $sql="select *,if(gender=1,'Male','Female') as xgender, + GET_AGE_1(dob,age,age_in_month,estimate_dob) AS age + from patient_master where id='".$pno."' "; + + $query = $this->db->query($sql); + $data['person_info']= $query->result(); + + $this->load->view('Medical/Med_Payment_receipt',$data); + + } + + public function Invoice_Item_Return($inv_type_id,$inv_type=0) + { + $data['inv_type_id']=$inv_type_id; + $data['inv_type']=$inv_type; + + $p_id=0; + + if($inv_type==0) + { + $sql="select * from ipd_master where id='".$inv_type_id."' "; + $query = $this->db->query($sql); + $data['ipd_master']= $query->result(); + + $sql_items="select m.id as inv_id,m.inv_med_code,date_format(inv_date,'%d-%m-%Y') as str_inv_date,m.ipd_id,m.patient_id,m.group_invoice_id,m.case_id, + t.id as item_id,t.item_Name,t.qty,t.batch_no,t.expiry,t.store_stock_id as ss_no,t.item_code,t.mrp,t.price, + t.amount,t.disc_amount,t.tamount,r.r_qty,r.id as return_id + from (invoice_med_master m join inv_med_item t on m.id=t.inv_med_id ) left join inv_med_item_return r on t.id=r.inv_item_id and return_status=0 + where m.ipd_id=".$inv_type_id. " order by t.item_Name,t.batch_no"; + + $p_id=$data['ipd_master'][0]->p_id; + + }elseif($inv_type==1){ + $sql="select * from organization_case_master where id='".$inv_type_id."' "; + $query = $this->db->query($sql); + $data['org_master']= $query->result(); + + $sql_items="select m.id as inv_id,m.inv_med_code,date_format(inv_date,'%d-%m-%Y') as str_inv_date,m.ipd_id,m.patient_id,m.group_invoice_id,m.case_id, + t.id as item_id,t.item_Name,t.qty,t.batch_no,t.expiry,t.store_stock_id as ss_no,t.item_code,t.mrp,t.price, + t.amount,t.disc_amount,t.tamount,r.r_qty,r.id as return_id + from (invoice_med_master m join inv_med_item t on m.id=t.inv_med_id ) left join inv_med_item_return r on t.id=r.inv_item_id and return_status=0 + where m.case_id=".$inv_type_id. " order by t.item_Name,t.batch_no"; + + $p_id=$data['org_master'][0]->p_id; + }else{ + $sql="select * from invoice_med_master where id='".$inv_type_id."' "; + $query = $this->db->query($sql); + $data['invoice_med_master']= $query->result(); + + $sql_items="select m.id as inv_id,m.inv_med_code,date_format(inv_date,'%d-%m-%Y') as str_inv_date,m.ipd_id,m.patient_id,m.group_invoice_id,m.case_id, + t.id as item_id,t.item_Name,t.qty,t.batch_no,t.expiry,t.store_stock_id as ss_no,t.item_code,t.mrp,t.price, + t.amount,t.disc_amount,t.tamount,r.r_qty,r.id as return_id + from (invoice_med_master m join inv_med_item t on m.id=t.inv_med_id ) left join inv_med_item_return r on t.id=r.inv_item_id and return_status=0 + where m.id=".$inv_type_id. " order by t.item_Name,t.batch_no"; + + $p_id=$data['invoice_med_master'][0]->patient_id; + } + + $sql="select * from patient_master_exten + where id='".$p_id."' "; + $query = $this->db->query($sql); + $data['person_info']= $query->result(); + + $query = $this->db->query($sql_items); + $data['inv_items']= $query->result(); + + $this->load->view('Medical/Medical_Invoice_Return',$data); + } + + public function Med_Return_invoice_search($r_inv_id) + { + $data['r_inv_id']=$r_inv_id; + $this->load->view('Medical/Med_Return_Invoice_search',$data); + } + + public function Invoice_Item_old() + { + $search_text=trim($this->input->post('search_text')); + $search_type=$this->input->post('search_type'); + + if($search_type==1){ + $sql="SELECT m.id AS inv_id,m.inv_med_code,m.inv_date,m.inv_name,m.inv_phone_number, + i.*,date_format(i.expiry,'%m-%Y') as exp_date,(i.disc_amount+disc_whole) as t_discount + FROM (invoice_med_master m JOIN inv_med_item i ON m.id=i.inv_med_id AND m.sale_return=0) + Where m.inv_phone_number='$search_text' and m.ipd_id=0 and m.case_id=0 "; + $query = $this->db->query($sql); + $data['med_inv_item_list']= $query->result(); + } + + if($search_type==2){ + $sql="SELECT count(id) as no_rec,group_concat(id) as p_id_list + From patient_master where p_code like '".$search_text."' "; + $query = $this->db->query($sql); + $patient_master= $query->result(); + + $search_id_list="0"; + if($patient_master[0]->no_rec) + { + $search_id_list=$patient_master[0]->p_id_list; + } + + $sql="SELECT m.id AS inv_id,m.inv_med_code,m.inv_date,m.inv_name,m.inv_phone_number, + i.*,date_format(i.expiry,'%m-%Y') as exp_date,(i.disc_amount+disc_whole) as t_discount + FROM (invoice_med_master m JOIN inv_med_item i ON m.id=i.inv_med_id AND m.sale_return=0) + Where m.patient_id in ($search_id_list) and m.ipd_id=0 and m.case_id=0"; + $query = $this->db->query($sql); + $data['med_inv_item_list']= $query->result(); + } + + if($search_type==3){ + $sql="SELECT m.id AS inv_id,m.inv_med_code,m.inv_date,m.inv_name,m.inv_phone_number, + i.*,date_format(i.expiry,'%m-%Y') as exp_date,(i.disc_amount+disc_whole) as t_discount + FROM (invoice_med_master m JOIN inv_med_item i ON m.id=i.inv_med_id AND m.sale_return=0) + Where m.inv_med_code like '".$search_text."%' and m.ipd_id=0 and m.case_id=0"; + $query = $this->db->query($sql); + $data['med_inv_item_list']= $query->result(); + } + + if($search_type==4){ + $sql="SELECT m.id AS inv_id,m.inv_med_code,m.inv_date,m.inv_name,m.inv_phone_number, + i.*,date_format(i.expiry,'%m-%Y') as exp_date,(i.disc_amount+disc_whole) as t_discount + FROM (invoice_med_master m JOIN inv_med_item i ON m.id=i.inv_med_id AND m.sale_return=0) + Where i.item_Name like '".$search_text."%' "; + $query = $this->db->query($sql); + $data['med_inv_item_list']= $query->result(); + } + + $this->load->view('Medical/Med_Item_old_list',$data); + } + + public function Invoice_old($inv_id) + { + $sql="Select * from invoice_med_master where id=$inv_id"; + $query = $this->db->query($sql); + $invoice_med_master= $query->result(); + + $phone_no=''; + $p_id=0; + $ipd_id=0; + + if(count($invoice_med_master)>0) + { + $phone_no=$invoice_med_master[0]->inv_phone_number; + $p_id=$invoice_med_master[0]->patient_id; + $ipd_id=$invoice_med_master[0]->ipd_id; + } + + if($ipd_id>0){ + $sql="SELECT m.id AS inv_id,m.inv_med_code,m.inv_date,m.inv_name,m.inv_phone_number, + i.*,date_format(i.expiry,'%m-%Y') as exp_date,(i.disc_amount+disc_whole) as t_discount, + m.net_amount + FROM (invoice_med_master m JOIN inv_med_item i ON m.id=i.inv_med_id AND m.sale_return=0) + Where m.id<>$inv_id and m.ipd_id=$ipd_id and m.case_id=0 + order by m.id desc"; + }else if($p_id>0) + { + $sql="SELECT m.id AS inv_id,m.inv_med_code,m.inv_date,m.inv_name,m.inv_phone_number, + i.*,date_format(i.expiry,'%m-%Y') as exp_date,(i.disc_amount+disc_whole) as t_discount, + m.net_amount + FROM (invoice_med_master m JOIN inv_med_item i ON m.id=i.inv_med_id AND m.sale_return=0) + Where m.patient_id='$p_id' and m.id<>$inv_id and m.ipd_id=0 and m.case_id=0 order by m.id desc"; + }else if($phone_no!=''){ + $sql="SELECT m.id AS inv_id,m.inv_med_code,m.inv_date,m.inv_name,m.inv_phone_number, + i.*,date_format(i.expiry,'%m-%Y') as exp_date,(i.disc_amount+disc_whole) as t_discount, + m.net_amount + FROM (invoice_med_master m JOIN inv_med_item i ON m.id=i.inv_med_id AND m.sale_return=0) + Where m.inv_phone_number='$phone_no' and m.id<>$inv_id and m.ipd_id=0 and m.case_id=0 order by m.id desc"; + }else{ + $sql="SELECT m.id AS inv_id,m.inv_med_code,m.inv_date,m.inv_name,m.inv_phone_number, + i.*,date_format(i.expiry,'%m-%Y') as exp_date,(i.disc_amount+disc_whole) as t_discount, + m.net_amount + FROM (invoice_med_master m JOIN inv_med_item i ON m.id=i.inv_med_id AND m.sale_return=0) + Where 1<>1 "; + } + + $query = $this->db->query($sql); + $data['med_inv_item_list']= $query->result(); + + $this->load->view('Medical/Med_old_invoice_list',$data); + } + + public function add_remove_item() + { + $this->load->model('Medical_M'); + + $inv_id=$this->input->post('inv_id'); + $item_id=$this->input->post('itemid'); + $rqty=$this->input->post('rqty'); + + $user = $this->ion_auth->user()->row(); + $user_update_info = $user->first_name.''. $user->last_name.'['.$user->id.']'.date('d-m-Y H:i:s'); + + $sql="select * from inv_med_item where id='".$item_id."' "; + $query = $this->db->query($sql); + $inv_med_item_result= $query->result_array(); + + $update=0; + $msg_box=""; + + if(count($inv_med_item_result)>0) + { + $inv_med_item=$inv_med_item_result[0]; + + $CGST=$inv_med_item['CGST_per']; + $SGST=$inv_med_item['SGST_per']; + + $item_rate=$inv_med_item['price']; + $amount_value=$rqty*$item_rate*-1; + + $disc_total=$inv_med_item['disc_amount']+$inv_med_item['disc_whole']; + $amount=$inv_med_item['amount']; + $twdisc_amount=$inv_med_item['twdisc_amount']; + + $margin=$amount-$twdisc_amount; + $desc_per=$margin*100/$amount; + + $disc_amount=$amount_value*$desc_per/100; + $Tamount_value=$amount_value-$disc_amount; + + unset($inv_med_item['id']); + + $inv_med_item['inv_med_id'] =$inv_id; + + //Old Qty Sale + $old_qty=$inv_med_item['qty']; + $inv_med_item['qty'] =$rqty; + + $inv_med_item['return_item_id']=$item_id; + $inv_med_item['sale_return']=1; + + $inv_med_item['amount'] = $amount_value; + $inv_med_item['tamount'] = $Tamount_value; + + $inv_med_item['disc_amount']=$disc_amount; + $inv_med_item['disc_per']=$desc_per; + + $inv_med_item['disc_whole']='0'; + $inv_med_item['twdisc_amount']=$Tamount_value; + + $inv_med_item['update_by_remark']=$user_update_info; + $inv_med_item['update_by_id']=$user->id; + + $sql="select * from inv_med_item + where sale_return=1 and inv_med_id='$inv_id' and return_item_id='$item_id' "; + $query = $this->db->query($sql); + $inv_med_item_return= $query->result(); + + $sql="select sum(qty) as t_r_qty from inv_med_item + where sale_return=1 and return_item_id='$item_id' "; + $query = $this->db->query($sql); + $med_item_return_total= $query->result(); + + $tot_qty=0; + + if(count($med_item_return_total)>0) + { + $tot_return=$med_item_return_total[0]->t_r_qty; + $tot_qty=$old_qty-$tot_return; + } + + if($tot_qty>=$rqty) + { + if(count($inv_med_item_return)==0) + { + $update=$this->Medical_M->add_invoiceitem( $inv_med_item); + $msg_box="Added Return list"; + }else{ + $update=$inv_med_item_return[0]->id; + + $this->Medical_M->update_invoiceitem( $inv_med_item,$update); + $msg_box="Update Return "; + } + }else{ + $update=0; + $msg_box="Item Already Returned"; + } + + }else{ + $update=0; + $msg_box="No item found"; + } + + $this->Medical_M->update_invoice_final($inv_id); + + $sql="select *,ifnull(DATEDIFF(expiry,CURDATE()),-1000) AS no_day from inv_med_item where inv_med_id=".$inv_id; + $query = $this->db->query($sql); + $data['inv_items']= $query->result(); + + $sql="Select sum(amount) as Gtotal,sum(tamount) as tamt, + sum(CGST) as TCGST,sum(SGST) as TSGST,sum(disc_amount) as t_dis_amt + from inv_med_item where inv_med_id=".$inv_id; + $query = $this->db->query($sql); + $data['invoiceGtotal']= $query->result(); + + $user = $this->ion_auth->user()->row(); + $data['user_id'] = $user->id; + + $sql="select * from invoice_med_master where id=".$inv_id; + $query = $this->db->query($sql); + $data['invoiceMaster']= $query->result(); + + + $data['sale_return']=$data['invoiceMaster'][0]->sale_return; + + $content=$this->load->view('Medical/Med_Item_List',$data,true); + + $rvar=array( + 'update' =>$update, + 'msg_text'=>$msg_box, + 'content'=>$content + ); + + $encode_data = json_encode($rvar); + echo $encode_data; + + } + + public function Update_Return() + { + $this->load->model('Medical_M'); + + $r_qty=$this->input->post('u_qty'); + $item_id=$this->input->post('itemid'); + + $sql="select * from inv_med_item where id='".$item_id."' "; + $query = $this->db->query($sql); + $inv_med_item_result= $query->result_array(); + + $user = $this->ion_auth->user()->row(); + $user_update_info = $user->first_name.''. $user->last_name.'['.$user->id.']'.date('d-m-Y H:i:s'); + + $update=0; + $msg_box=""; + + if(count($inv_med_item_result)>0) + { + $inv_med_item=$inv_med_item_result[0]; + + $CGST=$inv_med_item['CGST_per']; + $SGST=$inv_med_item['SGST_per']; + + $item_rate=$inv_med_item['price']; + $amount_value=$r_qty*$item_rate; + + $disc=$inv_med_item['disc_per']; + $disc_amount=$amount_value*$disc/100; + + $Tamount_value=$amount_value-$disc_amount; + + $inv_med_item['inv_item_id'] = $inv_med_item['id']; + unset($inv_med_item['id']); + $inv_med_item['r_qty'] =$r_qty; + + $inv_med_item['amount'] = $amount_value; + $inv_med_item['tamount'] = $Tamount_value; + + $inv_med_item['update_remark']=$user_update_info; + + $sql="select * from inv_med_item_return where return_status=0 and inv_item_id='".$item_id."' "; + $query = $this->db->query($sql); + $inv_med_item_return= $query->result_array(); + + if(count($inv_med_item_return)==0) + { + $update=$this->Medical_M->insert_inv_med_item_return_add( $inv_med_item); + $msg_box="Added in Pending Return list"; + }else{ + $update=1; + $this->Medical_M->delete_return_item($item_id); + $update=$this->Medical_M->insert_inv_med_item_return_add($inv_med_item); + $msg_box="Alerady in Pending Return list, Now Update Again "; + } + + }else{ + $update=0; + $msg_box="No item found"; + } + + $rvar=array( + 'update' =>$update, + 'msg_text'=>$msg_box + ); + + $encode_data = json_encode($rvar); + echo $encode_data; + } + + + public function undo_Return() + { + $this->load->model('Medical_M'); + + $item_id=$this->input->post('itemid'); + + $update=1; + $msg_box=""; + + $this->Medical_M->delete_return_item($item_id); + + $rvar=array( + 'update' =>$update, + 'msg_text'=>$msg_box + ); + + $encode_data = json_encode($rvar); + echo $encode_data; + } + + + public function pre_reurn_item_list($inv_type_id,$inv_type=0) + { + $data['inv_type_id']=$inv_type_id; + $data['inv_type']=$inv_type; + + $p_id=0; + + if($inv_type==0) + { + $sql="select * from ipd_master where id='".$inv_type_id."' "; + $query = $this->db->query($sql); + $data['ipd_master']= $query->result(); + + $sql_items="select m.id as inv_id,m.inv_med_code,date_format(inv_date,'%d-%m-%Y') as str_inv_date,m.ipd_id,m.patient_id,m.group_invoice_id,m.case_id, + t.id as item_id,t.item_Name,t.qty,t.batch_no,t.expiry,t.store_stock_id as ss_no,t.item_code,t.mrp,t.price, + t.amount,t.disc_amount,t.tamount,t.r_qty,t.id as return_id + from (invoice_med_master m join inv_med_item_return t on m.id=t.inv_med_id and t.return_status=0) + where m.ipd_id=".$inv_type_id. " order by t.item_Name,t.batch_no"; + + $p_id=$data['ipd_master'][0]->p_id; + + }elseif($inv_type==1){ + $sql="select * from organization_case_master where id='".$inv_type_id."' "; + $query = $this->db->query($sql); + $data['org_master']= $query->result(); + + $sql_items="select m.id as inv_id,m.inv_med_code,date_format(inv_date,'%d-%m-%Y') as str_inv_date,m.ipd_id,m.patient_id,m.group_invoice_id,m.case_id, + t.id as item_id,t.item_Name,t.qty,t.batch_no,t.expiry,t.store_stock_id as ss_no,t.item_code,t.mrp,t.price, + t.amount,t.disc_amount,t.tamount,t.r_qty,t.id as return_id + from (invoice_med_master m join inv_med_item_return t on m.id=t.inv_med_id and t.return_status=0) + where m.case_id=".$inv_type_id. " order by t.item_Name,t.batch_no"; + + $p_id=$data['org_master'][0]->p_id; + }else{ + $sql="select * from invoice_med_master where id='".$inv_type_id."' "; + $query = $this->db->query($sql); + $data['invoice_med_master']= $query->result(); + + $sql_items="select m.id as inv_id,m.inv_med_code,date_format(inv_date,'%d-%m-%Y') as str_inv_date,m.ipd_id,m.patient_id,m.group_invoice_id,m.case_id, + t.id as item_id,t.item_Name,t.qty,t.batch_no,t.expiry,t.store_stock_id as ss_no,t.item_code,t.mrp,t.price, + t.amount,t.disc_amount,t.tamount,t.r_qty,t.id as return_id + from (invoice_med_master m join inv_med_item_return t on m.id=t.inv_med_id and t.return_status=0) + where m.id=".$inv_type_id. " order by t.item_Name,t.batch_no"; + + $p_id=$data['invoice_med_master'][0]->patient_id; + } + + $sql="select * from patient_master_exten + where id='".$p_id."' "; + $query = $this->db->query($sql); + $data['person_info']= $query->result(); + + $query = $this->db->query($sql_items); + $data['inv_items']= $query->result(); + + $this->load->view('Medical/Medical_Invoice_Return_pre',$data); + } + + + public function Med_Return_final($inv_type_id,$inv_type=0) + { + $this->load->model('Medical_M'); + + $data['inv_type_id']=$inv_type_id; + $data['inv_type']=$inv_type; + + $p_id=0; + + if($inv_type==0) + { + $sql="select * from ipd_master where id='".$inv_type_id."' "; + $query = $this->db->query($sql); + $data['ipd_master']= $query->result(); + + $sql_items="select m.id as inv_id,m.inv_med_code,date_format(inv_date,'%d-%m-%Y') as str_inv_date,m.ipd_id,m.patient_id,m.group_invoice_id,m.case_id, + t.id as ritem_id,t.inv_item_id,t.item_Name,t.qty,t.batch_no,t.expiry,t.store_stock_id as ss_no,t.item_code,t.mrp,t.price, + t.amount,t.disc_per,t.disc_amount,t.tamount,t.r_qty,t.id as return_id + from (invoice_med_master m join inv_med_item_return t on m.id=t.inv_med_id and t.return_status=0) + where m.ipd_id=".$inv_type_id. " order by t.item_Name,t.batch_no"; + + $p_id=$data['ipd_master'][0]->p_id; + + }elseif($inv_type==1){ + $sql="select * from organization_case_master where id='".$inv_type_id."' "; + $query = $this->db->query($sql); + $data['org_master']= $query->result(); + + $sql_items="select m.id as inv_id,m.inv_med_code,date_format(inv_date,'%d-%m-%Y') as str_inv_date,m.ipd_id,m.patient_id,m.group_invoice_id,m.case_id, + t.id as ritem_id,t.inv_item_id,t.item_Name,t.qty,t.batch_no,t.expiry,t.store_stock_id as ss_no,t.item_code,t.mrp,t.price, + t.amount,t.disc_per,t.disc_amount,t.tamount,t.r_qty,t.id as return_id + from (invoice_med_master m join inv_med_item_return t on m.id=t.inv_med_id and t.return_status=0) + where m.case_id=".$inv_type_id. " order by t.item_Name,t.batch_no"; + + $p_id=$data['org_master'][0]->p_id; + }else{ + $sql="select * from invoice_med_master where id='".$inv_type_id."' "; + $query = $this->db->query($sql); + $data['invoice_med_master']= $query->result(); + + $sql_items="select m.id as inv_id,m.inv_med_code,date_format(inv_date,'%d-%m-%Y') as str_inv_date,m.ipd_id,m.patient_id,m.group_invoice_id,m.case_id, + t.id as ritem_id,t.inv_item_id,t.item_Name,t.qty,t.batch_no,t.expiry,t.store_stock_id as ss_no,t.item_code,t.mrp,t.price, + t.amount,t.disc_per,t.disc_amount,t.tamount,t.r_qty,t.id as return_id + from (invoice_med_master m join inv_med_item_return t on m.id=t.inv_med_id and t.return_status=0) + where m.id=".$inv_type_id. " order by t.item_Name,t.batch_no"; + + $p_id=$data['invoice_med_master'][0]->patient_id; + } + + $sql="select * from patient_master_exten + where id='".$p_id."' "; + $query = $this->db->query($sql); + $data['person_info']= $query->result(); + + $query = $this->db->query($sql_items); + $data['inv_items']= $query->result(); + + foreach($data['inv_items'] as $row) + { + $store_stock_id=$row->ss_no; + + $ritem_id=$row->ritem_id; + + $itemid=$row->inv_item_id; + + $item_rate=$row->price; + + $current_qty=$row->qty-$row->r_qty; + + $inv_id=$row->inv_id; + + $amount_value=$current_qty*$item_rate; + + $disc_per=$row->disc_per; + + $disc_amount=$amount_value*$disc_per/100; + + $Tamount_value=$amount_value-$disc_amount; + + $data['update_inv_med_item'] = array( + 'qty' => $current_qty, + 'disc_amount' => $disc_amount, + 'amount' => $amount_value, + 'tamount' => $Tamount_value, + 'store_stock_id' => $store_stock_id + ); + + $update_return_item = array( + 'return_status' => '1', + ); + + $this->Medical_M->update_return_item($update_return_item,$ritem_id); + + $this->Medical_M->update_invoiceitem($data['update_inv_med_item'],$itemid); + + $this->Medical_M->update_invoice_final($inv_id); + } + + redirect('/Medical/pre_reurn_item_list/'.$inv_type_id.'/'.$inv_type=0); + } + + + public function Med_Return_print($inv_type_id,$inv_type=0) + { + $this->load->model('Medical_M'); + + $data['inv_type_id']=$inv_type_id; + $data['inv_type']=$inv_type; + + $p_id=0; + + if($inv_type==0) + { + $sql="select * from v_ipd_list where id='".$inv_type_id."' "; + $query = $this->db->query($sql); + $data['ipd_master']= $query->result(); + + $sql_items="select m.id as inv_id,m.inv_med_code,date_format(inv_date,'%d-%m-%Y') as str_inv_date,m.ipd_id,m.patient_id,m.group_invoice_id,m.case_id, + t.id as ritem_id,t.inv_item_id,t.item_Name,t.qty,t.batch_no,t.expiry,t.store_stock_id as ss_no,t.item_code,t.mrp,t.price,t.update_remark,t.return_date_time, + t.amount,t.disc_per,t.disc_amount,t.tamount,t.r_qty,t.id as return_id + from (invoice_med_master m join inv_med_item_return t on m.id=t.inv_med_id and t.return_status=1) + where m.ipd_id=".$inv_type_id. " order by t.item_Name,t.batch_no"; + + $p_id=$data['ipd_master'][0]->p_id; + + }elseif($inv_type==1){ + $sql="select * from organization_case_master where id='".$inv_type_id."' "; + $query = $this->db->query($sql); + $data['org_master']= $query->result(); + + $sql_items="select m.id as inv_id,m.inv_med_code,date_format(inv_date,'%d-%m-%Y') as str_inv_date,m.ipd_id,m.patient_id,m.group_invoice_id,m.case_id, + t.id as ritem_id,t.inv_item_id,t.item_Name,t.qty,t.batch_no,t.expiry,t.store_stock_id as ss_no,t.item_code,t.mrp,t.price,t.update_remark,t.return_date_time, + t.amount,t.disc_per,t.disc_amount,t.tamount,t.r_qty,t.id as return_id + from (invoice_med_master m join inv_med_item_return t on m.id=t.inv_med_id and t.return_status=1) + where m.case_id=".$inv_type_id. " order by t.item_Name,t.batch_no"; + + $p_id=$data['org_master'][0]->p_id; + }else{ + $sql="select * from invoice_med_master where id='".$inv_type_id."' "; + $query = $this->db->query($sql); + $data['invoice_med_master']= $query->result(); + + $sql_items="select m.id as inv_id,m.inv_med_code,date_format(inv_date,'%d-%m-%Y') as str_inv_date,m.ipd_id,m.patient_id,m.group_invoice_id,m.case_id, + t.id as ritem_id,t.inv_item_id,t.item_Name,t.qty,t.batch_no,t.expiry,t.store_stock_id as ss_no,t.item_code,t.mrp,t.price,t.update_remark,t.return_date_time, + t.amount,t.disc_per,t.disc_amount,t.tamount,t.r_qty,t.id as return_id + from (invoice_med_master m join inv_med_item_return t on m.id=t.inv_med_id and t.return_status=1) + where m.id=".$inv_type_id. " order by t.item_Name,t.batch_no"; + + $p_id=$data['invoice_med_master'][0]->patient_id; + } + + $sql="select * from patient_master_exten + where id='".$p_id."' "; + $query = $this->db->query($sql); + $data['person_info']= $query->result(); + + $query = $this->db->query($sql_items); + $data['inv_items']= $query->result(); + + + $this->load->view('Medical/Medical_Invoice_Return_print',$data); + } + + + + + +} \ No newline at end of file diff --git a/old_code_ci3/controllers/Medical_05102022.php b/old_code_ci3/controllers/Medical_05102022.php new file mode 100644 index 0000000..8768e8a --- /dev/null +++ b/old_code_ci3/controllers/Medical_05102022.php @@ -0,0 +1,5252 @@ +load->view('Medical/Dashboard'); + } + + public function select_store($store_id) + { + $sql="select * from store_master where store_id=".$store_id; + $query = $this->db->query($sql); + $data['store_master']= $query->result(); + + $this->load->view('Medical/Store_Dashboard',$data); + } + + public function main_store() + { + $this->load->view('Medical/Stock/main_store_dashboard'); + } + + + public function DrugList() + { + $this->load->view('Medical/Drug_Details'); + + //$sql="select item_id,itemname,dosage from drug_temp_25072017"; + //$query = $this->db->query($sql); + //$data['drug_data']= $query->result(); + + //$this->load->view('Medical/Drug_Details_all',$data); + } + + public function Purchase() + { + $this->load->view('Medical/Purchase/supplier_list'); + } + + public function PurchaseMasterEdit($inv_id) + { + $sql="select * from med_supplier order by name_supplier"; + $query = $this->db->query($sql); + $data['supplier_data']= $query->result(); + + $sql="select p.*,s.name_supplier from purchase_invoice p join med_supplier s on p.sid=s.sid where p.id=".$inv_id; + $query = $this->db->query($sql); + $data['inv_master_data']= $query->result(); + + $sql="select * from purchase_invoice_item where purchase_id='".$inv_id."' "; + $query = $this->db->query($sql); + $data['purchase_item']= $query->result(); + + $this->load->view('Medical/Purchase/purchase_invoice_master_edit',$data); + + } + + public function UpdatePurchase() + { + $rec_id=$this->input->post('hid_purchaseid'); + $sid=$this->input->post('input_supplier'); + $invoice_code=$this->input->post('input_invoicecode'); + $d_invoice=$this->input->post('datepicker_invoice'); + $ischallan=$this->input->post('cbo_billtype'); + + $Udata = array( + 'sid'=> $sid, + 'date_of_invoice'=> str_to_MysqlDate($d_invoice), + 'Invoice_no'=> $invoice_code, + 'ischallan'=>$ischallan + ); + + $this->load->model('Medical_M'); + + $update_id=$this->Medical_M->update_purchase($Udata,$rec_id); + + $rvar=array( + 'insertid' =>1, + 'show_text'=>'Data Update' + ); + + $encode_data = json_encode($rvar); + echo $encode_data; + } + + public function UpdatePurchaseInvoiceStatus($purchase_inv_id,$inv_status) + { + $user = $this->ion_auth->user()->row(); + $user_id = $user->id; + $user_name_info = $user->first_name.''. $user->last_name .'['.$user_id.']'.date('d-m-Y H:i:s'); + + $Udata = array( + 'inv_status'=> $inv_status, + 'inv_status_update_by'=> $user_name_info, + ); + + $this->load->model('Medical_M'); + + $update_id=$this->Medical_M->update_purchase($Udata,$purchase_inv_id); + + redirect('Medical/PurchaseMasterEdit/'.$purchase_inv_id); + + } + + public function PurchaseNew() + { + $sql="select * from med_supplier where active=1 order by name_supplier"; + $query = $this->db->query($sql); + $data['supplier_data']= $query->result(); + + $this->load->view('Medical/Purchase/new_purchase_invoice',$data); + } + + public function SupplierList() + { + $sql="select * from med_supplier"; + $query = $this->db->query($sql); + $data['supplier_data']= $query->result(); + + $this->load->view('Medical/Purchase/supplier_master',$data); + } + + public function PurchaseInvoice() + { + $sdata=trim($this->input->post('txtsearch')); + + //$sdata = preg_replace('/[^A-Za-z0-9_ \-]/', '', $sdata); + + if(trim($sdata)=='') + { + $sql="select p.id,p.Invoice_no,p.date_of_invoice, + date_format(p.date_of_invoice,'%d-%m-%Y') as str_date_of_invoice,p.sid,s.name_supplier, + s.short_name,s.gst_no, + p.T_Net_Amount as tamount,p.ischallan + from (purchase_invoice p join med_supplier s on p.sid=s.sid) + + group by p.id + order by p.id desc limit 50"; + }else{ + + $numric_condition=""; + + if(is_numeric($sdata)) + { + $numric_condition=" OR p.Invoice_no=".$sdata ; + } + + $sql="select p.id,p.Invoice_no,p.date_of_invoice, + date_format(p.date_of_invoice,'%d-%m-%Y') as str_date_of_invoice, + p.sid,s.name_supplier,s.short_name,s.gst_no, + p.T_Net_Amount as tamount,p.ischallan + from (purchase_invoice p join med_supplier s on p.sid=s.sid) + where (p.Invoice_no LIKE '%".$sdata."%' ".$numric_condition." ) + group by p.id order by p.id desc limit 50"; + } + + $query = $this->db->query($sql); + $data['purchase_list']= $query->result(); + + $this->load->view('Medical/Purchase/purchase_supp_list',$data); + } + + public function PurchaseInvoiceEdit($inv_id) + { + $sql="select p.id,p.Invoice_no,p.date_of_invoice,date_format(p.date_of_invoice,'%d/%m/%Y') as str_date_of_invoice, + p.sid,s.name_supplier,s.short_name,s.gst_no,p.inv_status,p.ischallan + from purchase_invoice p join med_supplier s on p.sid=s.sid + where p.id=".$inv_id; + $query = $this->db->query($sql); + $data['purchase_invoice']= $query->result(); + + $sql="select * from purchase_invoice_item where purchase_id=".$inv_id; + $query = $this->db->query($sql); + $data['purchase_invoice_item']= $query->result(); + + $sql="select * from med_gst_per "; + $query = $this->db->query($sql); + $data['med_gst_per']= $query->result(); + + $this->load->view('Medical/Purchase/purchase_invoice_edit',$data); + } + + public function challan_invoice($supplier_id) + { + $sql="SELECT p.id,t.id AS ss_no,p.Invoice_no,p.date_of_invoice, + date_format(p.date_of_invoice,'%d-%m-%Y') as str_date_of_invoice,p.sid,s.name_supplier, + s.short_name,s.gst_no, + p.T_Net_Amount as tamount,p.ischallan, + t.Item_name,t.qty,t.qty_free,t.mrp + FROM (purchase_invoice p join med_supplier s on p.sid=s.sid) + JOIN purchase_invoice_item t ON p.id=t.purchase_id + where p.sid=$supplier_id and p.ischallan=1 + group by p.id,t.id "; + + $query = $this->db->query($sql); + $data['purchase_challan_item']= $query->result(); + + $this->load->view('Medical/Purchase/purchase_challan_list',$data); + } + + public function challan_item_to_purchase($ss_no,$purchase_id) + { + $sql="select * from purchase_invoice_item where id=$ss_no"; + $query = $this->db->query($sql); + $purchase_invoice_item= $query->result(); + + if(count($purchase_invoice_item)>0) + { + $old_purchase_id=$purchase_invoice_item[0]->purchase_id; + + $Pdata = array( + 'purchase_id' => $purchase_id, + 'old_purchase_id' => $old_purchase_id, + ); + + $this->load->model('Medical_M'); + $is_update_stock=$this->Medical_M->update_purchase_item($Pdata,$ss_no); + $this->db->query("CALL p_purchase_invoice(".$old_purchase_id.")"); + + $rvar=array( + 'is_transfer' =>$is_update_stock, + 'show_text'=>"Item Addedd Successfully", + ); + + }else{ + $rvar=array( + 'is_transfer' =>0, + 'show_text'=>"Item Not Found ", + ); + } + + $encode_data = json_encode($rvar); + echo $encode_data; + + } + + public function challan_item_return($ss_no) + { + $sql="select * from purchase_invoice_item where old_purchase_id>0 and id=$ss_no"; + $query = $this->db->query($sql); + $purchase_invoice_item= $query->result(); + + if(count($purchase_invoice_item)>0) + { + $old_challan_id=$purchase_invoice_item[0]->old_purchase_id; + $current_pur_id=$purchase_invoice_item[0]->purchase_id; + + $sql="select * from purchase_invoice where id=$old_challan_id"; + $query = $this->db->query($sql); + $challan_invoice= $query->result(); + + if(count($challan_invoice)>0) + { + $Pdata = array( + 'purchase_id' => $old_challan_id, + 'old_purchase_id' => 0, + ); + + $this->load->model('Medical_M'); + $is_update_stock=$this->Medical_M->update_purchase_item($Pdata,$ss_no); + $this->db->query("CALL p_purchase_invoice(".$current_pur_id.")"); + + $rvar=array( + 'is_transfer' =>$is_update_stock, + 'show_text'=>"Item Addedd Successfully", + ); + }else{ + + $Pdata = array( + 'purchase_id' => $old_challan_id, + 'old_purchase_id' => 0, + ); + + $this->load->model('Medical_M'); + $is_update_stock=$this->Medical_M->update_purchase_item($Pdata,$ss_no); + + + $rvar=array( + 'is_transfer' =>0, + 'show_text'=>"Challan Not Found ", + ); + } + + + }else{ + $rvar=array( + 'is_transfer' =>0, + 'show_text'=>"Item Not Found ", + ); + } + + $encode_data = json_encode($rvar); + echo $encode_data; + + } + + public function purchase_invoice_delete($inv_id) + { + + $sql="select * from purchase_invoice_item where purchase_id=$inv_id"; + $query = $this->db->query($sql); + $purchase_invoice_item= $query->result(); + + if (count($purchase_invoice_item)>0){ + $rvar=array( + 'is_delete' =>0, + 'show_text'=>"Invoice has Items, Empty the item list", + ); + }else{ + $this->load->model('Medical_M'); + $is_delete=$this->Medical_M->delete_purchase($inv_id); + $rvar=array( + 'is_delete' =>1, + 'show_text'=>"Invoice has been deleted", + ); + } + + + $encode_data = json_encode($rvar); + echo $encode_data; + + } + + public function SupplierListSub() + { + $sql="select * from med_supplier order by name_supplier"; + $query = $this->db->query($sql); + $data['supplier_data']= $query->result(); + + $this->load->view('Medical/Purchase/supplier_master_sub',$data); + } + + public function SupplierEdit($sid=0) + { + $sql="select * from med_supplier where sid=".$sid; + $query = $this->db->query($sql); + $data['supplier_data']= $query->result(); + + $sql="select * from india_state "; + $query = $this->db->query($sql); + $data['india_state']= $query->result(); + + $this->load->view('Medical/Purchase/supplier_Edit',$data); + } + + public function CreatePurchase() + { + if (!$this->input->is_ajax_request()) { exit('no valid req.'); } + + $FormRules = array( + array( + 'field' => 'input_invoicecode', + 'label' => 'Invoice No', + 'rules' => 'required|min_length[3]|max_length[30]' + ) + ); + + $this->form_validation->set_rules($FormRules); + + if ($this->form_validation->run() == TRUE) + { + $sid=$this->input->post('input_supplier'); + $invoice_code=$this->input->post('input_invoicecode'); + $d_invoice=$this->input->post('datepicker_invoice'); + $ischallan=$this->input->post('cbo_billtype'); + + $where=" where sid=$sid"; + + if(is_numeric($invoice_code)) + $where.=" and Invoice_no=".$invoice_code ; + else + $where.=" and Invoice_no='".$invoice_code."'"; + + $sql="select count(*) as no_rec from purchase_invoice ".$where; + $query = $this->db->query($sql); + $chk_rec= $query->result(); + + if($chk_rec[0]->no_rec==0) + { + $Udata = array( + 'sid'=> $sid, + 'date_of_invoice'=> str_to_MysqlDate($d_invoice), + 'Invoice_no'=> $invoice_code, + 'ischallan'=>$ischallan + ); + + $this->load->model('Medical_M'); + + $inser_id=$this->Medical_M->insert_purchase($Udata); + $send_msg="Added Successfully"; + + if($inser_id>0) + { + $show_text=$send_msg; + }else{ + $show_text=$send_msg; + } + }else{ + $show_text='Record Already Exist'; + $inser_id=0; + } + + $rvar=array( + 'insertid' =>$inser_id, + 'show_text'=>$show_text + ); + + $encode_data = json_encode($rvar); + echo $encode_data; + + } + else{ + $send_msg=validation_errors(); + $rvar=array( + 'insertid' =>0, + 'show_text'=>$send_msg + ); + $encode_data = json_encode($rvar); + echo $encode_data; + } + } + + + public function SupplierUpdate($sid=0) + { + if (!$this->input->is_ajax_request()) { exit('no valid req.'); } + + $FormRules = array( + array( + 'field' => 'input_name_supplier', + 'label' => 'Supplier Name', + 'rules' => 'required|min_length[3]|max_length[30]' + ), + array( + 'field' => 'input_short_name', + 'label' => 'Short Name', + 'rules' => 'required|min_length[1]|max_length[30]' + ), + array( + 'field' => 'input_gst_no', + 'label' => 'GST No.', + 'rules' => 'required|min_length[5]|max_length[15]' + ), + array( + 'field' => 'input_state', + 'label' => 'State', + 'rules' => 'required|min_length[1]|max_length[20]' + ) + ); + + $this->form_validation->set_rules($FormRules); + + if ($this->form_validation->run() == TRUE) + { + $sid=$this->input->post('hid_sid'); + $name_supplier=$this->input->post('input_name_supplier'); + $short_name=$this->input->post('input_short_name'); + $contact_no=$this->input->post('input_contact_no'); + $gst_no=$this->input->post('input_gst_no'); + $city=$this->input->post('input_city'); + $state=$this->input->post('input_state'); + + $Udata = array( + 'name_supplier'=> $name_supplier, + 'short_name'=> $short_name, + 'contact_no'=> $contact_no, + 'gst_no'=> $gst_no, + 'city'=> $city, + 'state'=> $state + ); + + $this->load->model('Medical_M'); + + if($sid>0) + { + $inser_id=$this->Medical_M->update_supplier($Udata,$sid); + $send_msg="Saved Successfully"; + }else{ + $inser_id=$this->Medical_M->insert_supplier($Udata); + $send_msg="Added Successfully"; + } + + if($inser_id>0) + { + $show_text=Show_Alert('success','Success',$send_msg); + }else{ + $show_text=Show_Alert('danger','Error',$send_msg); + } + + $rvar=array( + 'insertid' =>$inser_id, + 'show_text'=>$show_text + ); + + $encode_data = json_encode($rvar); + echo $encode_data; + + } + else{ + $send_msg=validation_errors(); + $rvar=array( + 'insertid' =>0, + 'show_text'=>Show_Alert('danger','Error',$send_msg) + ); + $encode_data = json_encode($rvar); + echo $encode_data; + } + + } + + public function StockDrugList() + { + $this->load->view('Medical/Medical_stock_drug'); + } + + public function add_stock() + { + if (!$this->input->is_ajax_request()) { exit('no valid req.'); } + + $FormRules = array( + array( + 'field' => 'input_product_code', + 'label' => 'Product Code', + 'rules' => 'required|min_length[3]|max_length[30]' + ), + array( + 'field' => 'input_product_name', + 'label' => 'Product Name', + 'rules' => 'required|min_length[3]|max_length[100]' + ), + array( + 'field' => 'input_product_mrp', + 'label' => 'Product MRP', + 'rules' => 'required|min_length[1]|max_length[10]' + ), + array( + 'field' => 'input_selling_price', + 'label' => 'Selling Price', + 'rules' => 'required|min_length[1]|max_length[10]' + ), + array( + 'field' => 'input_qty', + 'label' => 'Product Qty', + 'rules' => 'required|min_length[1]|max_length[10]' + ), + array( + 'field' => 'input_package', + 'label' => 'Package', + 'rules' => 'required|min_length[1]|max_length[10]' + ), + array( + 'field' => 'input_HSNCODE', + 'label' => 'HSNCODE', + 'rules' => 'required|min_length[1]|max_length[10]' + ), + array( + 'field' => 'input_CGST', + 'label' => 'CGST', + 'rules' => 'required|min_length[1]|max_length[10]' + ), + array( + 'field' => 'input_SGST', + 'label' => 'SGST', + 'rules' => 'required|min_length[1]|max_length[10]' + ) + ); + + $this->form_validation->set_rules($FormRules); + + if ($this->form_validation->run() == TRUE) + { + $item_code=$this->input->post('input_product_code'); + + if($item_code=='IC0000000') + { + $item_code='MC'.date('ymdhis'); + } + + $selling_price=$this->input->post('input_selling_price'); + + $package=$this->input->post('input_package'); + $qty=$this->input->post('input_qty'); + $total_unit=$package*$qty; + $unit_rate=$selling_price/$qty; + + $datepicker_doe_month=$this->input->post('datepicker_doe_month'); + $datepicker_doe_year=$this->input->post('datepicker_doe_year'); + + $datepicker_doe="20".$datepicker_doe_year."-".$datepicker_doe_month."-01"; + + $this->load->model('Medical_M'); + $data = array( + 'item_code' => $item_code, + 'item_name' => $this->input->post('input_product_name'), + 'rack_no' => $this->input->post('input_rack_no'), + 'shelf_no' => $this->input->post('input_shelf_no'), + 'cold_storage' => $this->input->post('input_storage'), + 'batch_no' => $this->input->post('input_batch_code'), + 'qty' => $this->input->post('input_qty'), + 'packing' => $this->input->post('input_package'), + 'expiry_date' => $datepicker_doe, + 'mrp' => $this->input->post('input_product_mrp'), + 'purchase_price' => $this->input->post('input_purchase_price'), + 'selling_price' => $this->input->post('input_selling_price'), + 'total_unit' => $total_unit, + 'unit_rate' => $unit_rate, + 'margin' => $this->input->post('input_margin'), + 'formulation' => $this->input->post('input_formulation'), + 'stock_date' => str_to_MysqlDate($this->input->post('datepicker_stock')), + 'min_qty' => $this->input->post('input_minqty'), + 'HSNCODE' => $this->input->post('input_HSNCODE'), + 'CGST' => $this->input->post('input_CGST'), + 'SGST' => $this->input->post('input_SGST'), + 'IGST' => $this->input->post('input_IGST'), + 'dosage' => $this->input->post('input_dosage'), + 'supplier_id' => $this->input->post('input_supplier') + ); + + $data_drug = array( + 'item_id' => $item_code, + 'itemname' => $this->input->post('input_product_name'), + 'mrp' => $this->input->post('input_product_mrp'), + 'formulation' => $this->input->post('input_formulation'), + 'HSNCODE' => $this->input->post('input_HSNCODE'), + 'CGST' => $this->input->post('input_CGST'), + 'SGST' => $this->input->post('input_SGST'), + 'IGST' => $this->input->post('input_IGST'), + 'dosage' => $this->input->post('input_dosage') + ); + $show_text=''; + + $sql="select * from drug_temp where item_id='".$item_code."'"; + $query = $this->db->query($sql); + $drug_item= $query->result(); + + if(count($drug_item)>0) + { + $inser_id=$this->Medical_M->update_drug($data_drug,$item_code); + }else{ + $inser_id=$this->Medical_M->insert_drug_add($data_drug); + } + + if($inser_id>0) + { + $inser_id=0; + $inser_id=$this->Medical_M->insert_stock_add($data); + if($inser_id>0) + { + $send_msg="Added"; + }else{ + $send_msg="Error : Add in Stock Table"; + } + }else{ + $send_msg="Error : Addition data in Master Drug Table"; + } + + if($inser_id>0) + { + $show_text=Show_Alert('success','Success',$send_msg); + }else{ + $show_text=Show_Alert('danger','Error',$send_msg); + } + + $rvar=array( + 'insertid' =>$inser_id, + 'product_code' => $item_code, + 'show_text'=>$show_text + ); + + $encode_data = json_encode($rvar); + echo $encode_data; + + } + else + { + $send_msg=validation_errors(); + $rvar=array( + 'insertid' =>0, + 'show_text'=>Show_Alert('danger','Error',$send_msg) + ); + $encode_data = json_encode($rvar); + echo $encode_data; + } + } + + public function update_master() + { + if (!$this->input->is_ajax_request()) { exit('no valid req.'); } + + $FormRules = array( + array( + 'field' => 'input_product_code', + 'label' => 'Product Code', + 'rules' => 'required|min_length[3]|max_length[30]' + ), + array( + 'field' => 'input_product_name', + 'label' => 'Product Name', + 'rules' => 'required|min_length[3]|max_length[100]' + ), + array( + 'field' => 'input_product_mrp', + 'label' => 'Product MRP', + 'rules' => 'required|min_length[1]|max_length[10]' + ), + array( + 'field' => 'input_selling_price', + 'label' => 'Selling Price', + 'rules' => 'required|min_length[1]|max_length[10]' + ), + array( + 'field' => 'input_HSNCODE', + 'label' => 'HSNCODE', + 'rules' => 'required|min_length[1]|max_length[10]' + ), + array( + 'field' => 'input_CGST', + 'label' => 'CGST', + 'rules' => 'required|min_length[1]|max_length[10]' + ), + array( + 'field' => 'input_SGST', + 'label' => 'SGST', + 'rules' => 'required|min_length[1]|max_length[10]' + ) + ); + + $this->form_validation->set_rules($FormRules); + + if ($this->form_validation->run() == TRUE) + { + $item_code=$this->input->post('input_product_code'); + + $this->load->model('Medical_M'); + + $data_drug = array( + 'item_id' => $item_code, + 'itemname' => $this->input->post('input_product_name'), + 'mrp' => $this->input->post('input_product_mrp'), + 'formulation' => $this->input->post('input_formulation'), + 'HSNCODE' => $this->input->post('input_HSNCODE'), + 'CGST' => $this->input->post('input_CGST'), + 'SGST' => $this->input->post('input_SGST'), + 'IGST' => $this->input->post('input_IGST'), + 'dosage' => $this->input->post('input_dosage') + ); + $show_text=''; + + $sql="select * from drug_temp where item_id='".$item_code."'"; + $query = $this->db->query($sql); + $drug_item= $query->result(); + + if(count($drug_item)>0) + { + $inser_id=$this->Medical_M->update_drug($data_drug,$item_code); + }else{ + $inser_id=$this->Medical_M->insert_drug_add($data_drug); + } + + if($inser_id>0) + { + $inser_id=0; + $inser_id=$this->Medical_M->insert_stock_add($data); + if($inser_id>0) + { + $send_msg="Update"; + }else{ + $send_msg="Error : Edit in Drug Master"; + } + }else{ + $send_msg="Error : Addition data in Master Drug Table"; + } + + if($inser_id>0) + { + $show_text=Show_Alert('success','Success',$send_msg); + }else{ + $show_text=Show_Alert('danger','Error',$send_msg); + } + + $rvar=array( + 'insertid' =>$inser_id, + 'product_code' => $item_code, + 'show_text'=>$show_text + ); + + $encode_data = json_encode($rvar); + echo $encode_data; + + } + else + { + $send_msg=validation_errors(); + $rvar=array( + 'insertid' =>0, + 'show_text'=>Show_Alert('danger','Error',$send_msg) + ); + $encode_data = json_encode($rvar); + echo $encode_data; + } + } + + public function update_stock($ss_no) + { + if (!$this->input->is_ajax_request()) { exit('no valid req.'); } + + $FormRules = array( + array( + 'field' => 'input_product_code', + 'label' => 'Product Code', + 'rules' => 'required|min_length[3]|max_length[30]' + ), + array( + 'field' => 'input_product_name', + 'label' => 'Product Name', + 'rules' => 'required|min_length[3]|max_length[100]' + ) + , + array( + 'field' => 'input_product_mrp', + 'label' => 'Product MRP', + 'rules' => 'required|min_length[1]|max_length[10]' + ), + array( + 'field' => 'input_selling_price', + 'label' => 'Selling Price', + 'rules' => 'required|min_length[1]|max_length[10]' + ), + array( + 'field' => 'input_qty', + 'label' => 'Product Qty', + 'rules' => 'required|min_length[1]|max_length[10]' + ), + array( + 'field' => 'input_package', + 'label' => 'Package', + 'rules' => 'required|min_length[1]|max_length[10]' + ), + array( + 'field' => 'input_HSNCODE', + 'label' => 'HSNCODE', + 'rules' => 'required|min_length[1]|max_length[10]' + ), + array( + 'field' => 'input_CGST', + 'label' => 'CGST', + 'rules' => 'required|min_length[1]|max_length[10]' + ), + array( + 'field' => 'input_SGST', + 'label' => 'SGST', + 'rules' => 'required|min_length[1]|max_length[10]' + ) + ); + + $this->form_validation->set_rules($FormRules); + + if ($this->form_validation->run() == TRUE) + { + $item_code=$this->input->post('input_product_code'); + + $selling_price=$this->input->post('input_selling_price'); + + $package=$this->input->post('input_package'); + $qty=$this->input->post('input_qty'); + $total_unit=$package*$qty; + $unit_rate=$selling_price/$qty; + + $datepicker_doe_month=$this->input->post('datepicker_doe_month'); + $datepicker_doe_year=$this->input->post('datepicker_doe_year'); + + $datepicker_doe="20".$datepicker_doe_year."-".$datepicker_doe_month."-01"; + + $this->load->model('Medical_M'); + $data = array( + 'item_code' => $item_code, + 'item_name' => $this->input->post('input_product_name'), + 'rack_no' => $this->input->post('input_rack_no'), + 'shelf_no' => $this->input->post('input_shelf_no'), + 'cold_storage' => $this->input->post('input_storage'), + 'batch_no' => $this->input->post('input_batch_code'), + 'qty' => $this->input->post('input_qty'), + 'packing' => $this->input->post('input_package'), + 'expiry_date' => $datepicker_doe, + 'mrp' => $this->input->post('input_product_mrp'), + 'purchase_price' => $this->input->post('input_purchase_price'), + 'selling_price' => $this->input->post('input_selling_price'), + 'total_unit' => $total_unit, + 'unit_rate' => $unit_rate, + 'margin' => $this->input->post('input_margin'), + 'formulation' => $this->input->post('input_formulation'), + 'stock_date' => str_to_MysqlDate($this->input->post('datepicker_stock')), + 'min_qty' => $this->input->post('input_minqty'), + 'HSNCODE' => $this->input->post('input_HSNCODE'), + 'CGST' => $this->input->post('input_CGST'), + 'SGST' => $this->input->post('input_SGST'), + 'IGST' => $this->input->post('input_IGST'), + 'supplier_id' => $this->input->post('input_supplier') + ); + + $show_text=''; + + $is_update_stock=0; + + $is_update_stock=$this->Medical_M->update_stock_upd($data,$ss_no); + + if($is_update_stock>0) + { + $send_msg="Updated"; + }else{ + $send_msg="Error : Update in Stock Table"; + } + + if($is_update_stock>0) + { + $show_text=Show_Alert('success','Updated',$send_msg); + }else{ + $show_text=Show_Alert('danger','Error',$send_msg); + } + + $rvar=array( + 'is_update_stock' =>$is_update_stock, + 'product_code' => $item_code, + 'show_text'=>$show_text + ); + + $encode_data = json_encode($rvar); + echo $encode_data; + + } + else + { + $send_msg=validation_errors(); + $rvar=array( + 'is_update_stock' =>0, + 'show_text'=>Show_Alert('danger','Error',$send_msg) + ); + $encode_data = json_encode($rvar); + echo $encode_data; + } + } + + public function purchase_update_stock($inv_id,$return_stock=0) + { + if (!$this->input->is_ajax_request()) { exit('no valid req.'); } + + $sql="select * from purchase_invoice where id=".$inv_id; + $query = $this->db->query($sql); + $purchase_invoice= $query->result(); + + $user = $this->ion_auth->user()->row(); + $user_id = $user->id; + $user_name_info = $user->first_name.''. $user->last_name .'['.$user_id.']'.date('d-m-Y H:i:s'); + + $FormRules = array( + array( + 'field' => 'input_product_code', + 'label' => 'Not Found in Database', + 'rules' => 'required|min_length[1]|max_length[30]' + ), + array( + 'field' => 'input_drug_hid', + 'label' => 'Product Name', + 'rules' => 'required|min_length[3]|max_length[100]' + ), + array( + 'field' => 'input_product_mrp', + 'label' => 'Product MRP', + 'rules' => 'required|min_length[1]|max_length[10]' + ), + array( + 'field' => 'input_selling_price', + 'label' => 'Selling Price', + 'rules' => 'required|min_length[1]|max_length[10]' + ), + array( + 'field' => 'input_Qty', + 'label' => 'Product Qty', + 'rules' => 'required|min_length[1]|max_length[10]' + ), + array( + 'field' => 'input_package', + 'label' => 'Package', + 'rules' => 'required|min_length[1]|max_length[10]' + ), + array( + 'field' => 'input_HSNCODE', + 'label' => 'HSNCODE', + 'rules' => 'required|min_length[1]|max_length[10]' + ), + array( + 'field' => 'input_CGST', + 'label' => 'CGST', + 'rules' => 'required|min_length[1]|max_length[10]' + ), + array( + 'field' => 'input_SGST', + 'label' => 'SGST', + 'rules' => 'required|min_length[1]|max_length[10]' + ), + array( + 'field' => 'input_purchase_price', + 'label' => 'Purchase Price', + 'rules' => 'required|min_length[1]|max_length[10]' + ) + ); + + $this->form_validation->set_rules($FormRules); + + if ($this->form_validation->run() == TRUE) + { + $item_code=$this->input->post('input_product_code'); + $item_id=$this->input->post('invoice_item_id'); + + $datepicker_doe_month=$this->input->post('datepicker_doe_month'); + $datepicker_doe_year=$this->input->post('datepicker_doe_year'); + + $datepicker_doe="20".$datepicker_doe_year."-".$datepicker_doe_month."-01"; + + $this->load->model('Medical_M'); + + $Pdata = array( + 'purchase_id' => $inv_id, + 'item_code' => $item_code, + 'item_name' => $this->input->post('input_drug_hid'), + 'packing' => $this->input->post('input_package'), + 'batch_no' => $this->input->post('input_batch_code'), + 'purchase_price' => $this->input->post('input_purchase_price'), + 'expiry_date' => $datepicker_doe, + 'mrp' => $this->input->post('input_product_mrp'), + + 'qty' => $this->input->post('input_Qty'), + 'qty_free' => $this->input->post('input_Qty_Free'), + + 'discount' => $this->input->post('input_disc_price'), + + 'CGST_per' => $this->input->post('input_CGST'), + 'SGST_per' => $this->input->post('input_SGST'), + + 'HSNCODE' => $this->input->post('input_HSNCODE'), + + 'cold_storage' => $this->input->post('input_storage'), + 'shelf_no' => $this->input->post('input_shelf_no'), + 'rack_no' => $this->input->post('input_rack_no'), + 'stock_date' => $purchase_invoice[0]->date_of_invoice, + + 'selling_price' => $this->input->post('input_selling_price'), + + 'sch_disc_amt' => $this->input->post('input_sch_amount'), + 'sch_disc_per' => $this->input->post('input_sch_disc'), + + 'insert_by' => $user_name_info, + + 'item_return' => $return_stock + ); + + $show_text=''; + + $is_update_stock=0; + + $send_msg=""; + + if($item_id<1) + { + $is_update_stock=$this->Medical_M->insert_purchase_item($Pdata); + $send_msg="Added"; + }else{ + $sql="select * from purchase_invoice_item where id='$item_id' "; + $query = $this->db->query($sql); + $drug_item= $query->result(); + + if(count($drug_item)>0){ + $tot_sale_qty=$drug_item[0]->total_sale_unit; + + $qty = $this->input->post('input_Qty'); + $qty_free= $this->input->post('input_Qty_Free'); + + $packing=$this->input->post('input_package'); + + $tot_qty=($qty+$qty_free)*$packing; + + if($tot_sale_qty<=$tot_qty) + { + $is_update_stock=$this->Medical_M->update_purchase_item($Pdata,$item_id); + if($is_update_stock>0) + { + $send_msg="Updated"; + }else{ + $send_msg="Error : Update in Stock Table"; + } + }else{ + $send_msg="Error : Update Qty is Less then saled Qty :".$tot_qty." / Saled :".$tot_sale_qty; + + //Update While Qty in Minus + + $is_update_stock=$this->Medical_M->update_purchase_item($Pdata,$item_id); + if($is_update_stock>0) + { + $send_msg="Updated : But Error : Update Qty is Less then saled Qty :".$tot_qty." / Saled :".$tot_sale_qty; + }else{ + $send_msg="Error : Update in Stock Table"; + } + + } + + }else{ + $send_msg="Error : Record Not Found in Stock Table"; + } + } + + $rvar=array( + 'is_update_stock' =>$is_update_stock, + 'product_code' => $item_code, + 'show_text'=>$send_msg + ); + + $encode_data = json_encode($rvar); + echo $encode_data; + + } + else + { + $send_msg=validation_errors(); + $rvar=array( + 'is_update_stock' =>0, + 'show_text'=>$send_msg + ); + $encode_data = json_encode($rvar); + echo $encode_data; + } + } + + function purchase_invoice_item_edit($inv_id,$inv_item_id) + { + $sql="select *, + date_format(expiry_date,'%m') as str_expiry_month , + date_format(expiry_date,'%y') as str_expiry_year + from purchase_invoice_item where id=".$inv_item_id." and purchase_id=".$inv_id; + $query = $this->db->query($sql); + $purchase_invoice_item= $query->result(); + + if(count($purchase_invoice_item)>0) + { + $rvar=array( + 'is_update_stock'=>'1', + 'item_id' =>$purchase_invoice_item[0]->id, + 'product_code' =>$purchase_invoice_item[0]->item_code, + 'product_mrp' => $purchase_invoice_item[0]->mrp, + 'selling_price'=>$purchase_invoice_item[0]->selling_price, + 'batch_code'=>$purchase_invoice_item[0]->batch_no, + 'disc_price'=>$purchase_invoice_item[0]->discount, + 'qty'=>$purchase_invoice_item[0]->qty, + 'qty_free'=>$purchase_invoice_item[0]->qty_free, + 'package'=>$purchase_invoice_item[0]->packing, + 'purchase_price'=>$purchase_invoice_item[0]->purchase_price, + 'datepicker_doe_month'=>$purchase_invoice_item[0]->str_expiry_month, + 'datepicker_doe_year'=>$purchase_invoice_item[0]->str_expiry_year, + 'drug'=>$purchase_invoice_item[0]->Item_name, + + 'sch_disc_amt'=>$purchase_invoice_item[0]->sch_disc_amt, + 'sch_disc_per'=>$purchase_invoice_item[0]->sch_disc_per, + + 'HSNCODE'=>$purchase_invoice_item[0]->HSNCODE, + 'CGST_per'=>$purchase_invoice_item[0]->CGST_per, + 'SGST_per'=>$purchase_invoice_item[0]->SGST_per, + + 'cold_storage'=>$purchase_invoice_item[0]->cold_storage, + 'shelf_no'=>$purchase_invoice_item[0]->shelf_no, + 'rack_no'=>$purchase_invoice_item[0]->rack_no, + + ); + }else{ + $rvar=array( + 'is_update_stock'=>'0', + 'show_text'=>$sql + ); + } + + $encode_data = json_encode($rvar); + echo $encode_data; + + } + + public function purchase_invoice_item_list($inv_id) + { + $sql="select *,date_format(expiry_date,'%m/%y') as exp_date_str from purchase_invoice_item where purchase_id='".$inv_id."' "; + $query = $this->db->query($sql); + $data['purchase_item']= $query->result(); + + $sql="select * from purchase_invoice where id='".$inv_id."' "; + $query = $this->db->query($sql); + $data['purchase_invoice']= $query->result(); + + + + $this->load->view('Medical/Purchase/purchase_invoice_item',$data); + + } + + public function purchase_invoice_item_list_old($item_code) + { + $sql="SELECT s.name_supplier, date_format(p.date_of_invoice,'%d-%m-%Y') as date_of_invoice_str, + i.Item_name,i.packing,i.purchase_price,i.qty,i.qty_free,i.mrp + FROM (purchase_invoice p JOIN purchase_invoice_item i ON p.id=i.purchase_id) + JOIN med_supplier s ON p.sid=s.sid + WHERE i.item_code=$item_code ORDER BY i.id DESC LIMIT 5 "; + $query = $this->db->query($sql); + $data['purchase_item_old']= $query->result(); + + $this->load->view('Medical/Purchase/purchase_item_old',$data); + + } + + public function purchase_invoice_item_delete($inv_id,$inv_item_del) + { + $this->load->model('Medical_M'); + + $sql="select * from purchase_invoice_item where id='$inv_item_del' "; + $query = $this->db->query($sql); + $drug_item= $query->result(); + + if(count($drug_item)>0){ + $sale_qty=$drug_item[0]->total_sale_unit; + + if($sale_qty>0) + { + $rvar=array( + 'is_update_stock' =>0, + 'show_text'=>'Sold some Quantity of this Item', + ); + + }else{ + $is_update_stock=$this->Medical_M->delete_purchase_item($inv_id,$inv_item_del); + $rvar=array( + 'is_update_stock' =>1, + 'show_text'=>'Removed Successfully', + ); + } + } + + $encode_data = json_encode($rvar); + echo $encode_data; + } + + public function AddDrugStock($drug_item_code) + { + $sql="select * from drug_temp where item_id='".$drug_item_code."' "; + $query = $this->db->query($sql); + $data['drug_item']= $query->result(); + + $sql="select * from stock_addition where item_code='".$drug_item_code."' "; + $query = $this->db->query($sql); + $data['drug_stock_item']= $query->result(); + + $sql="select * from med_supplier "; + $query = $this->db->query($sql); + $data['med_supplier']= $query->result(); + + $this->load->view('Medical/Drug_Stock_Add',$data); + } + + public function UpdateDrugStock($ss_no) + { + $sql="select * from stock_addition where ss_no='".$ss_no."' "; + $query = $this->db->query($sql); + $data['stock_item']= $query->result(); + + $sql="select * from med_supplier "; + $query = $this->db->query($sql); + $data['med_supplier']= $query->result(); + + $this->load->view('Medical/Stock_Update',$data); + } + + public function load_stock_data($item_code) + { + $sql="select * from stock_addition where item_code='".$item_code."' "; + $query = $this->db->query($sql); + $data['drug_stock_item']= $query->result(); + + echo ' + + + + + + + + + + + + + + '; + + $srno=0; + + foreach($data['drug_stock_item'] as $row) + { + $srno=$srno+1; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + } + + echo ''; + + echo ' + + + + + + + + + + + + +
Item CodeItem NameFormulationStorage/Shelf/Rack No.Batch No.Qty /Sale QtyExpiryMRPRate/Unit
'.$row->item_code.''.$row->item_name.''.$row->formulation.''.$row->cold_storage.'/'.$row->shelf_no.'/'.$row->rack_no.''.$row->batch_no.''.$row->total_unit.'/'.$row->total_sale_unit.''.$row->expiry_date.''.$row->mrp.''.$row->unit_rate.'
Item CodeItem NameFormulationStorage/Shelf/Rack No.Batch No.Qty /Sale QtyExpiryMRPRate/Unit
'; + } + + public function Invoice_counter() + { + $sql="select * from invoice_med_master"; + $query = $this->db->query($sql); + $data['invoiceMaster']= $query->result(); + + $sql="select * from inv_med_item"; + $query = $this->db->query($sql); + $data['inv_items']= $query->result(); + + $sql="select sum(amount) as Gtotal from inv_med_item"; + $query = $this->db->query($sql); + $data['invoiceGtotal']= $query->result(); + + $sql="select * from doctor_master where active=1"; + $query = $this->db->query($sql); + $data['doclist']= $query->result(); + + if($data['invoiceMaster'][0]->case_id > 0) + { + $sql="select * from organization_case_master where id=".$data['invoiceMaster'][0]->case_id; + $query = $this->db->query($sql); + $data['OCaseMaster']= $query->result(); + } + + $user = $this->ion_auth->user()->row(); + $data['user_id'] = $user->id; + + $this->load->view('Medical/Medical_Invoice_V',$data); + + } + + public function Invoice_Med_Draft() + { + $this->load->view('Medical/Draft_Med_Invoice'); + } + + public function Invoice_Med_Return() + { + $this->load->view('Medical/Draft_Med_Return_Invoice'); + } + + public function Invoice_med_show($inv_id) + { + $sql="select *,if(ipd_credit>0,'Credit to IPD','CASH') as credit_status, + if(case_credit>0,'Credit to Org','CASH') as credit_org_status from invoice_med_master + where id=$inv_id"; + $query = $this->db->query($sql); + $data['invoiceMaster']= $query->result(); + + $patient_id=$data['invoiceMaster'][0]->patient_id; + $inv_phone_number=$data['invoiceMaster'][0]->inv_phone_number; + + if($patient_id==0) + { + + } + + $sql="SELECT i.*,ifnull(DATEDIFF(expiry,CURDATE()),1000) AS no_day, + SUM(p.total_unit-p.total_sale_unit-total_return_unit-total_lost_unit)/p.packing AS cur_qty + FROM (inv_med_item i JOIN purchase_invoice_item p ON i.item_code=p.item_code AND p.remove_item=0 ) + where inv_med_id=".$inv_id." GROUP BY i.id"; + $query = $this->db->query($sql); + $data['inv_items']= $query->result(); + + $sql="select item_code + from inv_med_item where inv_med_id=".$inv_id." Group by item_code Having count(id)>1"; + $query = $this->db->query($sql); + $data['inv_items_multiple']= $query->result(); + + $sql="select sum(amount) as Gtotal,sum(tamount) as tamt,sum(CGST) as TCGST,sum(SGST) as TSGST,sum(disc_amount) as t_dis_amt from inv_med_item where inv_med_id=".$inv_id; + $query = $this->db->query($sql); + $data['invoiceGtotal']= $query->result(); + + $sql="select * from doctor_master where active=1"; + $query = $this->db->query($sql); + $data['doclist']= $query->result(); + + $sql="select *, + GET_AGE_1(dob,age,age_in_month,estimate_dob) AS age from patient_master where id='".$data['invoiceMaster'][0]->patient_id."' "; + $query = $this->db->query($sql); + $data['person_info']= $query->result(); + + $data['org_Name']=""; + $ipd_id=$data['invoiceMaster'][0]->ipd_id; + + if($ipd_id>0) + { + $sql="select * from ipd_master where id=".$ipd_id; + $query = $this->db->query($sql); + $ipd_master= $query->result(); + + $sql="select * from v_ipd_list m join patient_master p on m.p_id=p.id + where m.id=".$ipd_id; + $query = $this->db->query($sql); + $data['ipd_list']= $query->result(); + + $data['ipd_master']=$ipd_master; + + if(count($ipd_master)>0) + { + $p_ipd_id=$ipd_master[0]->id; + $p_ipd_code=$ipd_master[0]->ipd_code; + + if($ipd_master[0]->case_id>0) + { + $sql="select * from organization_case_master where id=".$ipd_master[0]->case_id; + $query = $this->db->query($sql); + $org_master= $query->result(); + + if(count($org_master)>0) + { + $data['org_Name']=$org_master[0]->insurance_company_name; + } + } + } + } + + if($data['invoiceMaster'][0]->case_id > 0) + { + $sql="select * from organization_case_master where id=".$data['invoiceMaster'][0]->case_id; + $query = $this->db->query($sql); + $data['OCaseMaster']= $query->result(); + } + + + + $user = $this->ion_auth->user()->row(); + $data['user_id'] = $user->id; + + $data['sale_return']=$data['invoiceMaster'][0]->sale_return; + + $data['content']=$this->load->view('Medical/Med_Item_List',$data,true); + + if($data['invoiceMaster'][0]->sale_return==0) + { + $this->load->view('Medical/Medical_Invoice_V',$data); + }else{ + $this->load->view('Medical/Medical_Invoice_Return_V',$data); + } + + } + + //New Invoice Edit + public function Invoice_med_datasheet($inv_id) + { + $sql="SELECT i.*,ifnull(DATEDIFF(expiry,CURDATE()),1000) AS no_day, + SUM(p.total_unit-p.total_sale_unit-total_return_unit-total_lost_unit)/p.packing AS cur_qty + FROM (inv_med_item i JOIN purchase_invoice_item p ON i.item_code=p.item_code AND p.remove_item=0 ) + where inv_med_id=".$inv_id." GROUP BY i.id"; + $query = $this->db->query($sql); + $data['invoiceMaster']= $query->result(); + + $sql="select *,ifnull(DATEDIFF(expiry,CURDATE()),1000) AS no_day from inv_med_item where inv_med_id=".$inv_id; + $query = $this->db->query($sql); + $data['inv_items']= $query->result(); + + $sql="select item_code + from inv_med_item where inv_med_id=".$inv_id." Group by item_code Having count(id)>1"; + $query = $this->db->query($sql); + $data['inv_items_multiple']= $query->result(); + + $sql="select sum(amount) as Gtotal,sum(tamount) as tamt,sum(CGST) as TCGST,sum(SGST) as TSGST,sum(disc_amount) as t_dis_amt from inv_med_item where inv_med_id=".$inv_id; + $query = $this->db->query($sql); + $data['invoiceGtotal']= $query->result(); + + $sql="select * from doctor_master where active=1"; + $query = $this->db->query($sql); + $data['doclist']= $query->result(); + + $sql="select *, + GET_AGE_1(dob,age,age_in_month,estimate_dob) AS age from patient_master where id='".$data['invoiceMaster'][0]->patient_id."' "; + $query = $this->db->query($sql); + $data['person_info']= $query->result(); + + $data['org_Name']=""; + $ipd_id=$data['invoiceMaster'][0]->ipd_id; + + if($ipd_id>0) + { + $sql="select * from ipd_master where id=".$ipd_id; + $query = $this->db->query($sql); + $ipd_master= $query->result(); + + $sql="select * from v_ipd_list m join patient_master p on m.p_id=p.id + where m.id=".$ipd_id; + $query = $this->db->query($sql); + $data['ipd_list']= $query->result(); + + $data['ipd_master']=$ipd_master; + + if(count($ipd_master)>0) + { + $p_ipd_id=$ipd_master[0]->id; + $p_ipd_code=$ipd_master[0]->ipd_code; + + if($ipd_master[0]->case_id>0) + { + $sql="select * from organization_case_master where id=".$ipd_master[0]->case_id; + $query = $this->db->query($sql); + $org_master= $query->result(); + + if(count($org_master)>0) + { + $data['org_Name']=$org_master[0]->insurance_company_name; + } + } + } + } + + if($data['invoiceMaster'][0]->case_id > 0) + { + $sql="select * from organization_case_master where id=".$data['invoiceMaster'][0]->case_id; + $query = $this->db->query($sql); + $data['OCaseMaster']= $query->result(); + } + + $user = $this->ion_auth->user()->row(); + $data['user_id'] = $user->id; + + $data['sale_return']=$data['invoiceMaster'][0]->sale_return; + + $data['content']=$this->load->view('Medical/Med_Item_List',$data,true); + + if($data['invoiceMaster'][0]->sale_return==0) + { + $this->load->view('Medical/Medical_Invoice_V',$data); + }else{ + $this->load->view('Medical/Medical_Invoice_Return_V',$data); + } + + + } + + + // Update Medical Invoice Master + + public function update_uhid() + { + $this->load->model('Medical_M'); + + $user = $this->ion_auth->user()->row(); + $data['user_id'] = $user->id; + + $inv_id=$this->input->post('med_invoice_id'); + $pid=$this->input->post('pid'); + + $sql="select * from invoice_med_master where id=".$inv_id; + $query = $this->db->query($sql); + $invoice_master= $query->result(); + + $sql="select * from patient_master_exten where id='".$pid."' "; + $query = $this->db->query($sql); + $person_info= $query->result(); + + if(count($person_info)>0) + { + $patient_id=$person_info[0]->id; + $patient_code_u=$person_info[0]->p_code; + $custmer_Name=$person_info[0]->p_fname; + + $data = array( + 'customer_type'=>1, + 'patient_id' => $patient_id, + 'patient_code' => $patient_code_u, + 'inv_name' => $custmer_Name, + 'ipd_credit'=>0, + 'case_credit'=>0, + 'case_credit'=>0, + ); + + $inser_id=$this->Medical_M->update_in_upv_item($data,$inv_id); + $this->Medical_M->update_invoice_group($inv_id); + $this->Medical_M->update_invoice_final($inv_id); + $status= 1; + $remark="Done"; + + }else{ + $status=0; + $remark="Not Done"; + } + + $rvar=array( + 'status' =>$status, + 'remark'=>$remark + ); + + $encode_data = json_encode($rvar); + echo $encode_data; + } + + public function update_ipd() + { + $this->load->model('Medical_M'); + + $user = $this->ion_auth->user()->row(); + $data['user_id'] = $user->id; + + $inv_id=$this->input->post('med_invoice_id'); + $ipd_id=$this->input->post('ipd_id'); + + $sql="select * from invoice_med_master where id=".$inv_id; + $query = $this->db->query($sql); + $invoice_master= $query->result(); + + $sql="select * from ipd_master where id=".$ipd_id; + $query = $this->db->query($sql); + $ipd_master= $query->result(); + + $pid=$ipd_master[0]->p_id; + + $sql="select * from patient_master_exten where id='".$pid."' "; + $query = $this->db->query($sql); + $person_info= $query->result(); + + if(count($person_info)>0) + { + $patient_id=$person_info[0]->id; + $patient_code_u=$person_info[0]->p_code; + $custmer_Name=$person_info[0]->p_fname; + + $ipd_id=$ipd_master[0]->id; + $ipd_code=$ipd_master[0]->ipd_code; + + $data = array( + 'customer_type'=>1, + 'patient_id' => $patient_id, + 'patient_code' => $patient_code_u, + 'inv_name' => $custmer_Name, + 'ipd_credit'=>0, + 'case_credit'=>0, + 'ipd_id'=> $ipd_id, + 'ipd_code'=>$ipd_code, + ); + + $inser_id=$this->Medical_M->update_in_upv_item($data,$inv_id); + $this->Medical_M->update_invoice_group($inv_id); + $this->Medical_M->update_invoice_final($inv_id); + $status= 1; + $remark="Done"; + + }else{ + $status=0; + $remark="Not Done"; + } + + $rvar=array( + 'status' =>$status, + 'remark'=>$remark + ); + $encode_data = json_encode($rvar); + echo $encode_data; + } + + public function update_org() + { + $this->load->model('Medical_M'); + + $user = $this->ion_auth->user()->row(); + $data['user_id'] = $user->id; + + $inv_id=$this->input->post('med_invoice_id'); + $org_id=$this->input->post('org_id'); + + $sql="select * from invoice_med_master where id=".$inv_id; + $query = $this->db->query($sql); + $invoice_master= $query->result(); + + $sql="select * from organization_case_master where case_type=0 and id=".$org_id; + $query = $this->db->query($sql); + $org_master= $query->result(); + + $pid=$org_master[0]->p_id; + + $sql="select * from patient_master_exten where id='".$pid."' "; + $query = $this->db->query($sql); + $person_info= $query->result(); + + if(count($person_info)>0) + { + $patient_id=$person_info[0]->id; + $patient_code_u=$person_info[0]->p_code; + $custmer_Name=$person_info[0]->p_fname; + + $org_id=$org_master[0]->id; + $org_code=$org_master[0]->case_id_code; + + $data = array( + 'customer_type'=>1, + 'patient_id' => $patient_id, + 'patient_code' => $patient_code_u, + 'inv_name' => $custmer_Name, + 'ipd_credit'=>0, + 'case_credit'=>1, + 'ipd_id'=> 0, + 'ipd_code'=>'', + 'case_id'=>$org_id, + ); + + $inser_id=$this->Medical_M->update_in_upv_item($data,$inv_id); + $this->Medical_M->update_invoice_group($inv_id); + $this->Medical_M->update_invoice_final($inv_id); + $status= 1; + $remark="Done"; + + }else{ + $status=0; + $remark="Not Done"; + } + + $rvar=array( + 'status' =>$status, + 'remark'=>$remark + ); + $encode_data = json_encode($rvar); + echo $encode_data; + } + + public function update_invdate() + { + $this->load->model('Medical_M'); + + $inv_id=$this->input->post('med_invoice_id'); + $inv_date=$this->input->post('inv_date'); + + $sql="select * from invoice_med_master where id=".$inv_id; + $query = $this->db->query($sql); + $invoice_master= $query->result(); + + $inv_date=str_to_MysqlDate($inv_date); + + $data = array( + 'inv_date' => $inv_date, + ); + + $inser_id=$this->Medical_M->update_in_upv_item($data,$inv_id); + + $status= 1; + $remark="Done"; + + $rvar=array( + 'status' =>$status, + 'remark'=>$remark + ); + $encode_data = json_encode($rvar); + echo $encode_data; + } + + public function update_name_phone() + { + $this->load->model('Medical_M'); + + $inv_id=$this->input->post('med_invoice_id'); + $pid=$this->input->post('pid'); + $customer_type=$this->input->post('customer_type'); + $P_Name=$this->input->post('P_Name'); + $P_Phone=$this->input->post('P_Phone'); + + $doc_id=$this->input->post('doc_id'); + $doc_name=$this->input->post('doc_name'); + + $refername=$doc_name; + + $sql="select * from doctor_master where id='".$doc_id."' "; + $query = $this->db->query($sql); + $doc_info= $query->result(); + + if(count($doc_info)>0) + { + $refername=$doc_info[0]->p_fname; + } + + + $data = array( + 'customer_type'=>$customer_type, + 'patient_id' => '0', + 'patient_code' => '', + 'inv_name' => $P_Name, + 'inv_phone_number' => $P_Phone, + 'ipd_credit'=>0, + 'case_credit'=>0, + 'ipd_id'=> 0, + 'ipd_code'=>'', + 'case_id'=>'0', + 'doc_id' => $doc_id, + 'doc_name' => $refername, + ); + + $inser_id=$this->Medical_M->update_in_upv_item($data,$inv_id); + + $status= 1; + $remark="Done"; + + $rvar=array( + 'status' =>$status, + 'remark'=>$remark + ); + $encode_data = json_encode($rvar); + echo $encode_data; + } + + public function update_doctor() + { + $this->load->model('Medical_M'); + + $inv_id=$this->input->post('med_invoice_id'); + + $doc_id=$this->input->post('doc_id'); + $doc_name=$this->input->post('doc_name'); + + $refername=$doc_name; + + $sql="select * from doctor_master where id='".$doc_id."' "; + $query = $this->db->query($sql); + $doc_info= $query->result(); + + if(count($doc_info)>0) + { + $refername=$doc_info[0]->p_fname; + } + + $data = array( + 'doc_id' => $doc_id, + 'doc_name' => $refername, + ); + + $inser_id=$this->Medical_M->update_in_upv_item($data,$inv_id); + + $status= 1; + $remark="Done"; + + $rvar=array( + 'status' =>$status, + 'remark'=>$remark + ); + $encode_data = json_encode($rvar); + echo $encode_data; + } + + + public function update_cr_status_ipd() + { + $this->load->model('Medical_M'); + + $inv_id=$this->input->post('med_invoice_id'); + $credit_ipd=$this->input->post('credit_ipd'); + + $sql="select * from invoice_med_master where id=".$inv_id; + $query = $this->db->query($sql); + $invoice_master= $query->result(); + + $ipd_id=$invoice_master[0]->ipd_id; + + $data = array( + 'ipd_credit' => $credit_ipd, + ); + + $inser_id=$this->Medical_M->update_in_upv_item($data,$inv_id); + + $status= 1; + $remark="Done"; + + $this->Medical_M->update_invoice_group_gst($ipd_id,'1'); + $this->Medical_M->update_invoice_group_gst($ipd_id,'2'); + $this->Medical_M->update_invoice_group_gst($ipd_id,'3'); + + $rvar=array( + 'status' =>$status, + 'remark'=>$remark + ); + $encode_data = json_encode($rvar); + echo $encode_data; + } + + // End Update Medical Invoice Master + + public function search_customer($sale=0) + { + $data['sale']=$sale; + $this->load->view('Medical/Search_Patient',$data); + } + + public function check_invoice($pno,$ipd_id,$case_id) + { + $sql="select * + from invoice_med_master where inv_date=curdate() and patient_id='".$pno."' "; + + $sql="SELECT m.id AS inv_id,m.inv_med_code,m.inv_date,m.inv_name,m.inv_phone_number, + i.*,date_format(i.expiry,'%m-%Y') as exp_date,(i.disc_amount+disc_whole) as t_discount, + m.net_amount + FROM (invoice_med_master m JOIN inv_med_item i ON m.id=i.inv_med_id AND m.sale_return=0) + Where m.patient_id=$pno and m.inv_date=curdate() + order by m.id desc"; + + $query = $this->db->query($sql); + $data['med_inv_item_list']= $query->result(); + + $data['pno']=$pno; + $data['ipd_id']=$ipd_id; + $data['case_id']=$case_id; + + $content=""; + + if(count($data['med_inv_item_list'])>0){ + + $this->load->view('Medical/mini_invoice',$data); + + }else{ + redirect('Medical/Invoice_counter_new/'.$pno.'/'.$ipd_id.'/'.$case_id); + } + + } + + public function Invoice_counter_new($pno,$ipd_id,$case_id) + { + + $select_doc=0; + $p_fname=''; + $p_pcode=''; + $p_pid=$pno; + $p_ipd_id=$ipd_id; + $p_ipd_code=''; + $customer_type=0; + $group_invoice_id=0; + + $select_doc=0; + $data['org_Name']=""; + $data['content']=""; + + if($pno>0) + { + $sql="select *,if(gender=1,'Male','Female') as xgender, + GET_AGE_1(dob,age,age_in_month,estimate_dob) AS age from patient_master where id='".$pno."' "; + $query = $this->db->query($sql); + $person_info= $query->result(); + + $sql="select doc_id from opd_master where p_id='".$pno."' order by opd_id desc limit 1"; + $query = $this->db->query($sql); + $data['opd_master']= $query->result(); + + $p_fname=$person_info[0]->p_fname; + $p_pcode=$person_info[0]->p_code; + + if(count($data['opd_master'])>0) + { + $select_doc=$data['opd_master'][0]->doc_id; + }else{ + $select_doc=0; + } + + $customer_type=1; + } + + if($ipd_id>0) + { + $sql="select * from ipd_master where id=".$ipd_id; + $query = $this->db->query($sql); + $data['ipd_master']= $query->result(); + + $sql="select * from v_ipd_list m join patient_master p on m.p_id=p.id + where m.id=".$ipd_id; + $query = $this->db->query($sql); + $data['ipd_list']= $query->result(); + + $p_ipd_code=$data['ipd_master'][0]->ipd_code; + + $group_invoice_id=1; + + if($data['ipd_master'][0]->case_id>0) + { + $sql="select * from organization_case_master where id=".$data['ipd_master'][0]->case_id; + $query = $this->db->query($sql); + $org_master= $query->result(); + + if(count($org_master)>0) + { + $data['org_Name']=$org_master[0]->insurance_company_name; + } + } + } + + $this->load->model('Medical_M'); + + $data['invoice_med_master'] = array( + 'patient_id' => $p_pid, + 'ipd_id' => $p_ipd_id, + 'ipd_code' => $p_ipd_code, + 'case_id' => $case_id, + 'inv_date' => str_to_MysqlDate(date('d/m/Y')), + 'inv_name' => $p_fname, + 'patient_code' => $p_pcode, + 'doc_id' => $select_doc, + 'sale_return'=>0, + 'case_credit'=>0, + 'customer_type'=>$customer_type, + 'group_invoice_id'=>$group_invoice_id, + ); + + if($case_id>0) + { + $data['invoice_med_master']['case_credit']=1; + } + + + + $inser_id=$this->Medical_M->add_invoice( $data['invoice_med_master']); + + if($inser_id) + { + $sql="select *,if(ipd_credit>0,'Credit to IPD','CASH') as credit_status from invoice_med_master where id=".$inser_id; + $query = $this->db->query($sql); + $data['invoiceMaster']= $query->result(); + + $sql="SELECT i.*,ifnull(DATEDIFF(expiry,CURDATE()),1000) AS no_day, + SUM(p.total_unit-p.total_sale_unit-total_return_unit-total_lost_unit)/p.packing AS cur_qty + FROM (inv_med_item i JOIN purchase_invoice_item p ON i.item_code=p.item_code AND p.remove_item=0 ) + where inv_med_id=".$inser_id." GROUP BY i.id"; + $query = $this->db->query($sql); + $data['inv_items']= $query->result(); + + $sql="select item_code + from inv_med_item where inv_med_id=".$inser_id." Group by item_code Having count(id)>1"; + $query = $this->db->query($sql); + $data['inv_items_multiple']= $query->result(); + + $sql="select sum(amount) as Gtotal,sum(tamount) as tamt,sum(CGST) as TCGST,sum(SGST) as TSGST,sum(disc_amount) as t_dis_amt from inv_med_item where inv_med_id=".$inser_id; + $query = $this->db->query($sql); + $data['invoiceGtotal']= $query->result(); + + $sql="select * from doctor_master where active=1"; + $query = $this->db->query($sql); + $data['doclist']= $query->result(); + + $sql="select * from organization_case_master where id=".$case_id; + $query = $this->db->query($sql); + $data['OCaseMaster']= $query->result(); + + $data['sale_return']=$data['invoiceMaster'][0]->sale_return; + + $data['content']=$this->load->view('Medical/Med_Item_List',$data,true); + + $this->load->view('Medical/Medical_Invoice_V',$data); + } + } + + public function Invoice_Return_new($pno) + { + + $select_doc=0; + $p_fname=''; + $p_pcode=''; + $p_pid=$pno; + $inv_phone_number=''; + + $data['content']=''; + + if($pno>0) + { + $sql="select *,if(gender=1,'Male','Female') as xgender, + GET_AGE_1(dob,age,age_in_month,estimate_dob) AS age from patient_master where id='".$pno."' "; + $query = $this->db->query($sql); + $person_info= $query->result(); + + $p_fname=$person_info[0]->p_fname; + $p_pcode=$person_info[0]->p_code; + $inv_phone_number=$person_info[0]->mphone1; + + $select_doc=0; + } + + $this->load->model('Medical_M'); + + $data['invoice_med_master'] = array( + 'patient_id' => $p_pid, + 'inv_date' => str_to_MysqlDate(date('d/m/Y')), + 'inv_name' => $p_fname, + 'patient_code' => $p_pcode, + 'doc_id' => $select_doc, + 'inv_phone_number'=>$inv_phone_number, + 'sale_return'=>1 + ); + + $inser_id=$this->Medical_M->add_invoice( $data['invoice_med_master']); + + if($inser_id) + { + $sql="select *,if(ipd_credit>0,'Credit to IPD','CASH') as credit_status from invoice_med_master where id=".$inser_id; + $query = $this->db->query($sql); + $data['invoiceMaster']= $query->result(); + + $sql="SELECT i.*,ifnull(DATEDIFF(expiry,CURDATE()),1000) AS no_day, + SUM(p.total_unit-p.total_sale_unit-total_return_unit-total_lost_unit)/p.packing AS cur_qty + FROM (inv_med_item i JOIN purchase_invoice_item p ON i.item_code=p.item_code AND p.remove_item=0 ) + where inv_med_id=".$inser_id." GROUP BY i.id"; + $query = $this->db->query($sql); + $data['inv_items']= $query->result(); + + $sql="select item_code + from inv_med_item where inv_med_id=".$inser_id." Group by item_code Having count(id)>1"; + $query = $this->db->query($sql); + $data['inv_items_multiple']= $query->result(); + + $sql="select sum(amount) as Gtotal,sum(tamount) as tamt,sum(CGST) as TCGST,sum(SGST) as TSGST,sum(disc_amount) as t_dis_amt from inv_med_item where inv_med_id=".$inser_id; + $query = $this->db->query($sql); + $data['invoiceGtotal']= $query->result(); + + $data['sale_return']=$data['invoiceMaster'][0]->sale_return; + + $data['content']=$this->load->view('Medical/Med_Item_List',$data,true); + + $this->load->view('Medical/Medical_Invoice_Return_V',$data); + } + } + + public function item_stock_list($item_code) + { + $sql="SELECT p.item_name,t.batch_no,t.expiry_date as expiry_date_str,t.expiry_date, + (t.total_unit-t.total_sale_unit-total_lost_unit-t.total_return_unit) AS c_qty, + t.id,t.mrp,t.selling_unit_rate,p.id AS item_code + FROM med_product_master p + JOIN purchase_invoice_item t ON p.id=t.item_code + where (t.total_unit-t.total_sale_unit)>0 + and (expiry_date>date_add(sysdate(),interval 1 month) or p.exp_date_applicable=0) + and p.id =$item_code"; + + $query = $this->db->query($sql); + $data['Item_list']=$query->result_array() ; + + $this->load->view('Medical/sale_item_list_for_add',$data); + } + + public function get_drug(){ + if (isset($_GET['term'])){ + $q = strtolower($_GET['term']); + + $sql="SELECT p.item_name as item_name,p.formulation,t.batch_no,t.expiry_date as expiry_date_str,t.expiry_date, + (t.total_unit-t.total_sale_unit-total_lost_unit-t.total_return_unit) AS c_qty, + t.id,t.mrp,t.selling_unit_rate,p.id AS item_code,t.packing + FROM med_product_master p + JOIN purchase_invoice_item t ON p.id=t.item_code + and (t.total_unit-t.total_sale_unit-t.total_lost_unit-t.total_return_unit)>0 + and (expiry_date>date_add(sysdate(),interval 1 day) or p.exp_date_applicable=0) + and t.remove_item=0 and t.item_return=0 + where (p.item_name like '".$q."%' "; + + if(strlen($q)>5) + { + $sql=$sql. " or p.item_name SOUNDS LIKE '".$q."'"; + } + + $sql=$sql.") order by p.item_name,id limit 100"; + + $query = $this->db->query($sql); + + if($query->num_rows() > 0){ + foreach ($query->result_array() as $row){ + $new_row['label']=htmlentities(stripslashes($row['item_name'].' '.$row['formulation'])).' |B:'.htmlentities(stripslashes($row['batch_no'])). ' |Pak:'.htmlentities(stripslashes($row['packing'])).' |Rs.'.htmlentities(stripslashes($row['mrp'])).' |Qty:'.htmlentities(stripslashes($row['c_qty'])); + $new_row['value']=htmlentities(stripslashes($row['item_name'])); + $new_row['l_item_code']=htmlentities(stripslashes($row['item_code'])); + $new_row['l_ss_no']=htmlentities(stripslashes($row['id'])); + $new_row['l_Batch']=htmlentities(stripslashes($row['batch_no'])); + $new_row['l_Expiry']=htmlentities(stripslashes($row['expiry_date_str'])); + $new_row['l_mrp']=htmlentities(stripslashes($row['mrp'])); + $new_row['l_unit_rate']=htmlentities(stripslashes($row['selling_unit_rate'])); + $new_row['l_c_qty']=htmlentities(stripslashes($row['c_qty'])); + $new_row['l_packing']=htmlentities(stripslashes($row['packing'])); + $new_row['sql']=$sql; + $row_set[] = $new_row; //build an array + } + echo json_encode($row_set); //format the array into json data + }else{ + $new_row['sql']=$sql; + $row_set[] = $new_row; + echo json_encode($row_set); + } + } + } + + public function get_drug_master(){ + + if (isset($_GET['term'])){ + $q = strtolower($_GET['term']); + + $sql="select * from purchase_invoice_item p + where p.id in (select max(id) from purchase_invoice_item t + where t.Item_name like '".$q."%' group by t.Item_name ) + order by p.Item_name "; + + $sql="SELECT m.* ,p.id as ss_no,m.packing as p_packing,p.mrp,p.purchase_price,p.discount, + p.batch_no,date_format(expiry_date,'%m') as str_expiry_month , + date_format(expiry_date,'%y') as str_expiry_year , + m.batch_applicable,m.exp_date_applicable, + if(p.id is null,m.CGST_per,p.CGST_per) as p_CGST_per, + if(p.id is null,m.SGST_per,p.SGST_per) as p_SGST_per, + if(p.id is null,m.rack_no,p.rack_no) as p_rack_no, + if(p.id is null,m.shelf_no,p.shelf_no) as p_shelf_no, + if(p.id is null,m.cold_storage,p.cold_storage) as p_cold_storage + + FROM med_product_master m + LEFT JOIN (SELECT * from purchase_invoice_item + WHERE id in (select max(id) from purchase_invoice_item + WHERE Item_name LIKE '".$q."%' + group BY item_code ) ) as p ON m.id=p.item_code + WHERE m.is_continue=1 and m.Item_name LIKE '".$q."%' + order BY m.item_name "; + + $sql=$sql." limit 20"; + + $query = $this->db->query($sql); + + if($query->num_rows() > 0){ + foreach ($query->result_array() as $row){ + $new_row['label']=htmlentities(stripslashes($row['item_name'])).' | '.htmlentities(stripslashes($row['p_packing'])).' | '.htmlentities(stripslashes($row['mrp'])); + $new_row['value']=htmlentities(stripslashes($row['item_name'])); + $new_row['l_item_code']=htmlentities(stripslashes($row['id'])); + $new_row['l_mrp']=htmlentities(stripslashes($row['mrp'])); + + $new_row['l_packing']=htmlentities(stripslashes($row['packing'])); + $new_row['l_CGST_per']=htmlentities(stripslashes($row['p_CGST_per'])); + $new_row['l_SGST_per']=htmlentities(stripslashes($row['p_SGST_per'])); + $new_row['l_HSNCODE']=htmlentities(stripslashes($row['HSNCODE'])); + + $new_row['l_batch_no']=htmlentities(stripslashes($row['batch_no'])); + + $new_row['l_purchase_price']=htmlentities(stripslashes($row['purchase_price'])); + + $new_row['l_package']=htmlentities(stripslashes($row['p_packing'])); + $new_row['l_disc_price']=htmlentities(stripslashes($row['discount'])); + + $new_row['l_rack_no']=htmlentities(stripslashes($row['p_rack_no'])); + $new_row['l_shelf_no']=htmlentities(stripslashes($row['p_shelf_no'])); + $new_row['l_cold_storage']=htmlentities(stripslashes($row['p_cold_storage'])); + + $new_row['batch_applicable']=htmlentities(stripslashes($row['batch_applicable'])); + $new_row['exp_date_applicable']=htmlentities(stripslashes($row['exp_date_applicable'])); + + $new_row['datepicker_doe_month']=htmlentities(stripslashes($row['str_expiry_month'])); + $new_row['datepicker_doe_year']=htmlentities(stripslashes($row['str_expiry_year'])); + + $row_set[] = $new_row; //build an array + } + echo json_encode($row_set); //format the array into json data + }else{ + $row_set[] = array(); + echo json_encode($row_set); + } + } + } + + public function get_formulation_desc(){ + + if (isset($_GET['term'])){ + $q = strtolower($_GET['term']); + + $sql="select * from drugs_formulation where formulation_desc like '".$q."%'"; + $query = $this->db->query($sql); + + if($query->num_rows() > 0){ + foreach ($query->result_array() as $row){ + $new_row['label']=htmlentities(stripslashes($row['formulation_desc'])); + $new_row['value']=htmlentities(stripslashes($row['formulation_desc'])); + $row_set[] = $new_row; //build an array + } + echo json_encode($row_set); //format the array into json data + } + } + } + + public function go_final() + { + $this->load->model('Medical_M'); + + $inv_id=$this->input->post('inv_id'); + $doc_id=$this->input->post('doc_id'); + $doc_name=$this->input->post('doc_name'); + $remark_ipd=$this->input->post('input_remark_ipd'); + $patient_code=$this->input->post('patient_code'); + $custmer_Name=$this->input->post('custmer_Name'); + $ipd_credit=$this->input->post('ipd_credit'); + + $org_credit=$this->input->post('org_credit'); + $inv_date=$this->input->post('inv_date'); + + $sql="select * from patient_master where p_code='".$patient_code."' "; + $query = $this->db->query($sql); + $person_info= $query->result(); + + $sql="select * from doctor_master where id='".$doc_id."' "; + $query = $this->db->query($sql); + $doc_info= $query->result(); + + $sql="select * from invoice_med_master where id=".$inv_id; + $query = $this->db->query($sql); + $data['invoice_master']= $query->result(); + + if($this->ion_auth->in_group('InvoiceDateChanged') || $this->ion_auth->in_group('admin')) + { + $inv_date=str_to_MysqlDate($inv_date); + }else{ + $inv_date=$data['invoice_master'][0]->inv_date; + } + + if(count($person_info)>0) + { + $patient_id=$person_info[0]->id; + $patient_code_u=$patient_code; + $custmer_Name=$person_info[0]->p_fname; + }else{ + $patient_id=0; + $patient_code_u=''; + } + + $refername=$doc_name; + + if(count($doc_info)>0) + { + $refername=$doc_info[0]->p_fname; + } + + $data = array( + 'patient_id' => $patient_id, + 'patient_code' => $patient_code_u, + 'doc_id' => $doc_id, + 'doc_name' => $refername, + 'inv_name' => $custmer_Name, + 'remark_ipd'=>$remark_ipd, + 'ipd_credit'=>$ipd_credit, + 'case_credit'=>$org_credit, + 'inv_date' => $inv_date + ); + + $inser_id=$this->Medical_M->update_in_upv_item($data,$inv_id); + $this->Medical_M->update_invoice_group($inv_id); + $this->Medical_M->update_invoice_final($inv_id); + + } + + public function getDrugTable() + { + + $requestData= $_REQUEST; + + $columns = array( + // datatable column index => database column name + 0 =>'item_id', + 1 => 'itemname', + 2 => 'formulation', + 3=> 'genericname', + 5=> 'company_name_idx', + 4=> 'mrp' + ); + + // getting total number records without any search + $sql_f_all = "select * "; + + $sql_count="Select count(*) as no_rec "; + + $sql_from=" from drug_temp "; + + $total_sql=$sql_count.$sql_from; + + $query = $this->db->query($total_sql); + $data['total_rec']= $query->result(); + $totalData=$data['total_rec'][0]->no_rec; + + $totalFiltered = $totalData; // when there is no search parameter then total number rows = total number filtered rows. + + $sql_where=" WHERE 1 = 1"; + + $sql_where_flag=0; + + // getting records as per search parameters + if( !empty($requestData['columns'][0]['search']['value']) ){ //item_id + $sql_where.=" AND item_id LIKE '".$requestData['columns'][0]['search']['value']."%' "; + $sql_where_flag=1; + } + + if( !empty($requestData['columns'][1]['search']['value']) ){ //itemname + $sql_where.=" AND itemname LIKE '%".$requestData['columns'][1]['search']['value']."%' "; + $sql_where_flag=1; + } + + if( !empty($requestData['columns'][2]['search']['value']) ){ //dosage + $sql_where.=" AND formulation LIKE '%".$requestData['columns'][2]['search']['value']."%' "; + $sql_where_flag=1; + } + + if( !empty($requestData['columns'][3]['search']['value']) ){ //formulation + $sql_where.=" AND genericname LIKE '%".$requestData['columns'][3]['search']['value']."%' "; + $sql_where_flag=1; + } + + if( !empty($requestData['columns'][4]['search']['value']) ){ //therapeutic + $sql_where.=" AND company_name_idx LIKE '%".$requestData['columns'][4]['search']['value']."%' "; + $sql_where_flag=1; + } + + $total_filer_sql=$sql_count.$sql_from.$sql_where; + + $query = $this->db->query($total_filer_sql); + $data['total_rec_filter']= $query->result();// when there is a search parameter then we have to modify total number filtered rows as per search result. + $totalFiltered=$data['total_rec_filter'][0]->no_rec; + + + $sql_order=" ORDER BY ". $columns[$requestData['order'][0]['column']]." ".$requestData['order'][0]['dir']." LIMIT ".$requestData['start']." ,".$requestData['length']." "; // adding length + + $Result_sql=$sql_f_all.$sql_from.$sql_where.$sql_order; + + $query = $this->db->query($Result_sql); + $rdata= $query->result_array(); + + $output = array( + "draw" => intval( $requestData['draw'] ), // for every request/draw by clientside , they send a number as a parameter, when they recieve a response/data they first check the draw number, so we are sending same number in draw. + "recordsTotal" => intval( $totalData ), // total number of records + "recordsFiltered" => intval( $totalFiltered ), // total number of records after searching, if there is no searching then totalFiltered = totalData + "data" => array(), + "sql" => $Result_sql + ); + + foreach($rdata as $aRow) + { + $row = array(); + + foreach($columns as $col) + { + $row[] = $aRow[$col]; + } + + $output['data'][] = $row; + } + + echo json_encode($output); // send data as json format + } + + public function getInvoiceTable() + { + //Single Store Remove Store ID feild + + $requestData= $_REQUEST; + + $columns = array( + // datatable column index => database column name + 0 => 'inv_med_code', + 1 => 'inv_name', + 2=> 'patient_code', + 3=> 'IPD_CODE', + 4=> 'inv_date_str', + 5=> 'net_amount', + 6=> 'payment_received', + 7=> 'payment_balance', + 8=> 'id', + ); + + // getting total number records without any search + $sql_f_all = "select m.inv_med_code,m.inv_name, + m.inv_phone_number, m.patient_code, + if(m.ipd_id>0,Concat('',m.ipd_code,'
'),'') AS IPD_CODE, + if(m.case_id>0,Concat(o.case_id_code,'
'),'') as ORG_CODE , + m.inv_date,Date_Format(m.inv_date,'%d-%m-%Y') as inv_date_str, + m.net_amount,m.id,m.payment_received,m.payment_balance "; + + $sql_count="Select count(*) as no_rec "; + + $sql_from=" from (invoice_med_master m left join ipd_master i on m.ipd_id=i.id ) + left join organization_case_master o on m.case_id=o.id + left join inv_med_group g on i.id=g.ipd_id AND g.med_group_id=m.med_group_id"; + + //$total_sql=$sql_count.$sql_from; + $total_sql="Select count(*) as no_rec from invoice_med_master"; + + $query = $this->db->query($total_sql); + $data['total_rec']= $query->result(); + $totalData=$data['total_rec'][0]->no_rec; + + $totalFiltered = $totalData; // when there is no search parameter then total number rows = total number filtered rows. + + if($this->ion_auth->in_group('MedicalStoreAdmin')) + { + $sql_where=" WHERE sale_return=0 "; + }else{ + $sql_where=" WHERE sale_return=0 and inv_date >= date_add(sysdate(),interval -50 day) "; + } + + $sql_where_flag=0; + + // getting records as per search parameters + if( !empty($requestData['columns'][0]['search']['value']) ){ //inv_med_code + $sql_where.=" AND inv_med_code LIKE '%".$requestData['columns'][0]['search']['value']."' "; + $sql_where_flag=1; + } + + if( !empty($requestData['columns'][1]['search']['value']) ){ //inv_name + $stext=$requestData['columns'][1]['search']['value']; + if(!is_numeric($stext) && strlen($stext)>3) + { + $sql_where.=" AND inv_name LIKE '%".$requestData['columns'][1]['search']['value']."%' "; + } + $sql_where_flag=1; + } + + if( !empty($requestData['columns'][2]['search']['value']) ){ //patient_code + $stext=$requestData['columns'][2]['search']['value']; + $sql_where.=" AND (patient_code LIKE '%".$stext."' )"; + $sql_where_flag=1; + } + + if( !empty($requestData['columns'][3]['search']['value']) ){ //patient_code + $stext=$requestData['columns'][4]['search']['value']; + $sql_where.=" AND (m.ipd_code LIKE '%".$stext."' AND m.ipd_id>0 ) "; + $sql_where_flag=1; + } + + + + $total_filer_sql=$sql_count.$sql_from.$sql_where; + + $query = $this->db->query($total_filer_sql); + $data['total_rec_filter']= $query->result();// when there is a search parameter then we have to modify total number filtered rows as per search result. + $totalFiltered=$data['total_rec_filter'][0]->no_rec; + + $sql_order=" ORDER BY id desc,". $columns[$requestData['order'][0]['column']]." ".$requestData['order'][0]['dir']." LIMIT ".$requestData['start']." ,".$requestData['length']." "; // adding length + + $Result_sql=$sql_f_all.$sql_from.$sql_where.$sql_order; + + $query = $this->db->query($Result_sql); + $rdata= $query->result_array(); + + //$totalFiltered=count($rdata); + + $output = array( + "draw" => intval( $requestData['draw'] ), // for every request/draw by clientside , they send a number as a parameter, when they recieve a response/data they first check the draw number, so we are sending same number in draw. + "recordsTotal" => intval( $totalData ), // total number of records + "recordsFiltered" => intval( $totalFiltered ), // total number of records after searching, if there is no searching then totalFiltered = totalData + "data" => array(), + "sql" => $Result_sql + ); + + foreach($rdata as $aRow) + { + $row = array(); + + foreach($columns as $col) + { + $row[] = $aRow[$col]; + } + + $output['data'][] = $row; + } + + echo json_encode($output); // send data as json format + + } + public function getReturnInvoiceTable() + { + //Single Store Remove Store ID feild + + $requestData= $_REQUEST; + + $columns = array( + // datatable column index => database column name + 0 => 'inv_med_code', + 1 => 'inv_name', + 2 => 'Code', + 3=> 'inv_date_str', + 4=> 'net_amount', + 5=> 'payment_received', + 6=> 'payment_balance', + 7=> 'id', + 8=> 'ipd_status', + 9=> 'org_status', + 10=> 'ipd_credit_type', + 11=> 'org_credit_type' + ); + + // getting total number records without any search + $sql_f_all = "select m.inv_med_code,m.inv_name, + Concat(if(m.patient_code<>'',Concat(m.patient_code,'
'),''), + if(m.ipd_code<>'',Concat('',m.ipd_code,'
'),''), + if(m.case_id>0,Concat(o.case_id_code,'
'),'')) as Code , + m.inv_date,Date_Format(m.inv_date,'%d-%m-%Y') as inv_date_str, + m.doc_name,m.net_amount,m.payment_received,m.payment_balance,m.id,i.ipd_status, + o.status as org_status, + m.ipd_credit as ipd_credit_type,m.case_credit as org_credit_type "; + + $sql_count="Select count(*) as no_rec "; + + $sql_from=" from (invoice_med_master m left join ipd_master i on m.ipd_id=i.id ) + left join organization_case_master o on m.case_id=o.id "; + + $total_sql=$sql_count.$sql_from; + + $query = $this->db->query($total_sql); + $data['total_rec']= $query->result(); + $totalData=$data['total_rec'][0]->no_rec; + + $totalFiltered = $totalData; // when there is no search parameter then total number rows = total number filtered rows. + + if($this->ion_auth->in_group('MedicalStoreAdmin')) + { + $sql_where=" WHERE sale_return=1 "; + }else{ + $sql_where=" WHERE sale_return=1 and inv_date >= date_add(sysdate(),interval -50 day) "; + } + + + $sql_where_flag=0; + + // getting records as per search parameters + if( !empty($requestData['columns'][0]['search']['value']) ){ //inv_med_code + $sql_where.=" AND inv_med_code LIKE '%".$requestData['columns'][0]['search']['value']."' "; + $sql_where_flag=1; + } + + if( !empty($requestData['columns'][1]['search']['value']) ){ //inv_name + $stext=$requestData['columns'][1]['search']['value']; + if(is_numeric($stext) && strlen($stext)>3) + { + $sql_where.=" AND inv_phone_number LIKE '".$stext."%' "; + }else{ + $sql_where.=" AND inv_name LIKE '%".$requestData['columns'][1]['search']['value']."%' "; + } + $sql_where_flag=1; + } + + if( !empty($requestData['columns'][2]['search']['value']) ){ //patient_code + $sql_where.=" AND (patient_code LIKE '%".$requestData['columns'][2]['search']['value']."' OR + m.ipd_code LIKE '%".$requestData['columns'][2]['search']['value']."' OR + o.case_id_code LIKE '%".$requestData['columns'][2]['search']['value']."' )"; + $sql_where_flag=1; + } + + $total_filer_sql=$sql_count.$sql_from.$sql_where; + + $query = $this->db->query($total_filer_sql); + $data['total_rec_filter']= $query->result();// when there is a search parameter then we have to modify total number filtered rows as per search result. + $totalFiltered=$data['total_rec_filter'][0]->no_rec; + + $sql_order=" ORDER BY id desc,". $columns[$requestData['order'][0]['column']]." ".$requestData['order'][0]['dir']." LIMIT ".$requestData['start']." ,".$requestData['length']." "; // adding length + + $Result_sql=$sql_f_all.$sql_from.$sql_where.$sql_order; + + $query = $this->db->query($Result_sql); + $rdata= $query->result_array(); + + $output = array( + "draw" => intval( $requestData['draw'] ), // for every request/draw by clientside , they send a number as a parameter, when they recieve a response/data they first check the draw number, so we are sending same number in draw. + "recordsTotal" => intval( $totalData ), // total number of records + "recordsFiltered" => intval( $totalFiltered ), // total number of records after searching, if there is no searching then totalFiltered = totalData + "data" => array(), + "sql" => $Result_sql + ); + + foreach($rdata as $aRow) + { + $row = array(); + + foreach($columns as $col) + { + $row[] = $aRow[$col]; + } + + $output['data'][] = $row; + } + + echo json_encode($output); // send data as json format + + } + + + public function getStockDrugTable() + { + + $requestData= $_REQUEST; + + $columns = array( + // datatable column index => database column name + 0 =>'ss_no', + 1 =>'item_code', + 2 => 'item_name', + 3 => 'formulation', + 4 => 'rack_no', + 5 => 'shelf_no', + 6 => 'batch_no', + 7 => 'total_unit', + 8 => 'expiry_date', + 9 => 'mrp', + 10 => 'update_stock_qty' + ); + + // getting total number records without any search + $sql_f_all = "select * "; + + $sql_count="Select count(*) as no_rec "; + + $sql_from=" from stock_addition "; + + $total_sql=$sql_count.$sql_from; + + $query = $this->db->query($total_sql); + $data['total_rec']= $query->result(); + $totalData=$data['total_rec'][0]->no_rec; + + $totalFiltered = $totalData; // when there is no search parameter then total number rows = total number filtered rows. + + $sql_where=" WHERE 1 = 1 "; + + $sql_where_flag=0; + + // getting records as per search parameters + if( !empty($requestData['columns'][0]['search']['value']) ){ //item_id + $sql_where.=" AND item_code LIKE '".$requestData['columns'][0]['search']['value']."%' "; + $sql_where_flag=1; + } + + if( !empty($requestData['columns'][1]['search']['value']) ){ //itemname + $sql_where.=" AND item_name LIKE '%".$requestData['columns'][1]['search']['value']."%' "; + $sql_where_flag=1; + } + + if( !empty($requestData['columns'][2]['search']['value']) ){ //dosage + $sql_where.=" AND formulation LIKE '%".$requestData['columns'][2]['search']['value']."%' "; + $sql_where_flag=1; + } + + if( !empty($requestData['columns'][3]['search']['value']) ){ //dosage + $sql_where.=" AND rack_no LIKE '%".$requestData['columns'][3]['search']['value']."%' "; + $sql_where_flag=1; + } + + if( !empty($requestData['columns'][4]['search']['value']) ){ //dosage + $sql_where.=" AND shelf_no LIKE '%".$requestData['columns'][4]['search']['value']."%' "; + $sql_where_flag=1; + } + + if( !empty($requestData['columns'][5]['search']['value']) ){ //dosage + $sql_where.=" AND batch_no LIKE '%".$requestData['columns'][5]['search']['value']."%' "; + $sql_where_flag=1; + } + + $total_filer_sql=$sql_count.$sql_from.$sql_where; + + $query = $this->db->query($total_filer_sql); + $data['total_rec_filter']= $query->result();// when there is a search parameter then we have to modify total number filtered rows as per search result. + $totalFiltered=$data['total_rec_filter'][0]->no_rec; + + $sql_order=" ORDER BY ". $columns[$requestData['order'][0]['column']]." ".$requestData['order'][0]['dir']." LIMIT ".$requestData['start']." ,".$requestData['length']." "; // adding length + + $Result_sql=$sql_f_all.$sql_from.$sql_where.$sql_order; + + $query = $this->db->query($Result_sql); + $rdata= $query->result_array(); + + $output = array( + "draw" => intval( $requestData['draw'] ), // for every request/draw by clientside , they send a number as a parameter, when they recieve a response/data they first check the draw number, so we are sending same number in draw. + "recordsTotal" => intval( $totalData ), // total number of records + "recordsFiltered" => intval( $totalFiltered ), // total number of records after searching, if there is no searching then totalFiltered = totalData + "data" => array(), + "sql" => $Result_sql + ); + + foreach($rdata as $aRow) + { + $row = array(); + + foreach($columns as $col) + { + $row[] = $aRow[$col]; + } + + $output['data'][] = $row; + } + + echo json_encode($output); // send data as json format + + } + + public function confirm_payment() + { + if (!$this->input->is_ajax_request()) { exit('no valid req.'); } + + $this->load->model('Medical_M'); + + $invoice_id=$this->input->post('med_invoice_id'); + $input_amount_paid=$this->input->post('input_amount_paid'); + + $sql="select * from invoice_med_master where id='".$invoice_id."'"; + $query = $this->db->query($sql); + $inv_master= $query->result(); + + $user = $this->ion_auth->user()->row(); + $user_id = $user->id; + $user_name = $user->first_name.''. $user->last_name; + + $showcontent1='
+
+ Print +
+
+ Payment Method by : '; + + $showcontent2='
'; + + $pay_remark=''; + + if($inv_master[0]->patient_id>0) + { + $Customerof_type=1; + }else{ + $Customerof_type=3; + } + + if($this->input->post('mode')==1) + { + $paydata = array( + 'payment_mode'=> '1', + 'Customerof_type'=>$Customerof_type, + 'Customerof_id'=>$inv_master[0]->patient_id, + 'Customerof_code'=>$inv_master[0]->patient_code, + 'Medical_invoice_id'=>$inv_master[0]->id, + 'Medical_invoice_code'=>$inv_master[0]->inv_med_code, + 'credit_debit'=>'0', + 'amount'=>$input_amount_paid, + 'payment_date'=>date('Y-m-d H:i:s'), + 'remark'=>$pay_remark, + 'update_by'=>$user_name.'['.$user_id.']', + 'update_by_id'=>$user_id + ); + + $insert_id=$this->Medical_M->insert_payment($paydata); + + $data = array( + + 'payment_mode'=> '1', + 'payment_status'=>'1', + 'invoice_status'=>'1', + 'payment_id'=>$insert_id, + 'payment_mode_desc'=>'Cash', + 'confirm_invoice'=>date('Y-m-d H:i:s'), + 'prepared_by'=>$user_name.'['.$user_id.']' + ); + + $this->Medical_M->update_in_upv_item( $data,$invoice_id); + + + + $status='CASH'; + $showcontent=$showcontent1.$status.$showcontent2; + + $rvar=array( + 'update' =>1, + 'showcontent'=>$showcontent + ); + + $encode_data = json_encode($rvar); + echo $encode_data; + } + + if($this->input->post('mode')==2) + { + $FormRules = array( + array( + 'field' => 'input_card_tran', + 'label' => 'Card Transcation ID', + 'rules' => 'required|min_length[3]|max_length[15]' + ) + ); + + $this->form_validation->set_rules($FormRules); + + if ($this->form_validation->run() == TRUE) + { + $paydata = array( + 'payment_mode'=> '2', + 'Customerof_type'=>$Customerof_type, + 'Customerof_id'=>$inv_master[0]->patient_id, + 'Customerof_code'=>$inv_master[0]->patient_code, + 'Medical_invoice_id'=>$inv_master[0]->id, + 'Medical_invoice_code'=>$inv_master[0]->inv_med_code, + 'credit_debit'=>'0', + 'amount'=>$input_amount_paid, + 'payment_date'=>date('Y-m-d H:i:s'), + 'remark'=>$pay_remark, + 'update_by'=>$user_name.'['.$user_id.']', + 'update_by_id'=>$user_id, + 'pay_bank_id'=>$this->input->post('cbo_pay_type'), + 'card_tran_id'=>$this->input->post('input_card_tran') + ); + + $insert_id=$this->Medical_M->insert_payment($paydata); + + $data = array( + 'payment_mode'=> '2', + 'payment_status'=>'1', + 'invoice_status'=>'1', + 'payment_mode_desc'=>'Bank Card', + 'confirm_invoice'=>date('Y-m-d H:i:s'), + 'payment_id'=>$insert_id, + 'card_tran_id'=>$this->input->post('input_card_tran'), + 'prepared_by'=>$user_name.'['.$user_id.']', + 'prepared_by_id'=>$user_id + ); + + $this->Medical_M->update_in_upv_item( $data,$invoice_id); + + $status='Bank Card'; + $showcontent=$showcontent1.$status.$showcontent2; + + $rvar=array( + 'update' =>1, + 'showcontent'=>$showcontent + ); + $encode_data = json_encode($rvar); + echo $encode_data; + } + else{ + $send_error=validation_errors(); + $rvar=array( + 'update' =>0, + 'error_text'=>$send_error + ); + $encode_data = json_encode($rvar); + echo $encode_data; + } + } + + if($this->input->post('mode')==3) + { + $data = array( + + 'payment_mode'=> '3', + 'payment_status'=>'1', + 'invoice_status'=>'1', + 'confirm_invoice'=>date('d/m/Y H:m:s'), + 'payment_mode_desc'=>'IPD Credit', + 'ipd_id'=>$this->input->post('ipd_id'), + 'prepared_by'=>$user_name.'['.$user_id.']' + ); + + $this->Medical_M->update_in_upv_item( $data,$invoice_id); + + $status='IPD Credit'; + $showcontent=$showcontent1.$status.$showcontent2; + + $rvar=array( + 'update' =>1, + 'showcontent'=>$showcontent + ); + + $encode_data = json_encode($rvar); + echo $encode_data; + } + + if($this->input->post('mode')==4) + { + $data = array( + 'payment_mode'=> '4', + 'payment_status'=>'1', + 'invoice_status'=>'1', + 'confirm_invoice'=>date('d/m/Y H:m:s'), + 'payment_mode_desc'=>'Org Credit', + 'case_id'=>$this->input->post('ipd_id'), + 'prepared_by'=>$user_name.'['.$user_id.']' + ); + + $this->Medical_M->update_in_upv_item( $data,$invoice_id); + + $status='Org Credit'; + $showcontent=$showcontent1.$status.$showcontent2; + + $rvar=array( + 'update' =>1, + 'showcontent'=>$showcontent + ); + + $encode_data = json_encode($rvar); + echo $encode_data; + } + + if($this->input->post('mode')==5) + { + if($input_amount_paid<0) + { + $input_amount_paid=$input_amount_paid*-1; + } + + $paydata = array( + 'payment_mode'=> '1', + 'Customerof_type'=>$Customerof_type, + 'Customerof_id'=>$inv_master[0]->patient_id, + 'Customerof_code'=>$inv_master[0]->patient_code, + 'Medical_invoice_id'=>$inv_master[0]->id, + 'Medical_invoice_code'=>$inv_master[0]->inv_med_code, + 'credit_debit'=>'1', + 'amount'=>$input_amount_paid, + 'payment_date'=>date('Y-m-d H:i:s'), + 'remark'=>$pay_remark, + 'update_by'=>$user_name.'['.$user_id.']', + 'update_by_id'=>$user_id + ); + + $insert_id=$this->Medical_M->insert_payment($paydata); + + $data = array( + + 'payment_mode'=> '1', + 'payment_status'=>'1', + 'invoice_status'=>'1', + 'payment_id'=>$insert_id, + 'payment_mode_desc'=>'Cash Return', + 'confirm_invoice'=>date('Y-m-d H:i:s'), + 'prepared_by'=>$user_name.'['.$user_id.']' + ); + + $this->Medical_M->update_in_upv_item( $data,$invoice_id); + + $status='CASH'; + $showcontent=$showcontent1.$status.$showcontent2; + + $rvar=array( + 'update' =>1, + 'showcontent'=>$showcontent + ); + + $encode_data = json_encode($rvar); + echo $encode_data; + } + + $this->Medical_M->update_invoice_final($invoice_id); + } + + public function Adjust_Payment() + { + if (!$this->input->is_ajax_request()) { exit('no valid req.'); } + + $this->load->model('Medical_M'); + + $invoice_id=$this->input->post('med_invoice_id'); + $input_amount_paid=$this->input->post('input_amount_paid'); + + $sql="select * from invoice_med_master where id='".$invoice_id."'"; + $query = $this->db->query($sql); + $inv_master= $query->result(); + + if(count($inv_master)>0) + { + if($inv_master[0]->ipd_id==0){ + + $discount=$inv_master[0]->discount_amount; + $discount=$discount+$input_amount_paid; + + $log=$inv_master[0]->log; + + $update_str="Adjust Balance Amt:".$input_amount_paid; + + $log=$log.PHP_EOL.PHP_EOL.$update_str; + + $dataupdate = array( + 'discount_amount' => $discount, + 'log' => $log, + ); + + $this->load->model('Medical_M'); + $this->Medical_M->update_in_upv_item($dataupdate,$invoice_id); + + $this->Medical_M->update_invoice_final($invoice_id); + } + + } + + + } + + public function invoice_print($inv_id,$print_format=0) + { + $this->load->model('Medical_M'); + $this->Medical_M->update_invoice_final($inv_id); + + $sql="select *,(discount_amount+item_discount_amount) as inv_disc_total,(CGST_Tamount+SGST_Tamount) as TGST from invoice_med_master where id=".$inv_id; + $query = $this->db->query($sql); + $data['invoice_master']= $query->result(); + + $sql="select *,(disc_amount+disc_whole) as d_amt,(CGST+SGST) as gst,(CGST_per+SGST_per) as gst_per from inv_med_item + where inv_med_id=".$inv_id; + $query = $this->db->query($sql); + $data['inv_items']= $query->result(); + + $sql="select * from ipd_master where id=".$data['invoice_master'][0]->ipd_id; + $query = $this->db->query($sql); + $data['ipd_master']= $query->result(); + + $sql="select * from organization_case_master where id=".$data['invoice_master'][0]->case_id; + $query = $this->db->query($sql); + $data['orgcase']= $query->result(); + + $sql="select sum(if(credit_debit>0,amount*-1,amount)) as paid_amount from payment_history_medical where Medical_invoice_id=".$inv_id; + $query = $this->db->query($sql); + $data['payment_history_medical']= $query->result(); + + $sql="select *,if(credit_debit>0,amount*-1,amount) as paid_amount, + (case payment_mode when 1 then 'Cash' when 2 then 'Bank Card' when 3 then 'Return Cash ' when 4 then 'Bank Return' when 5 then 'Cash Return' else 'Other' end) as Payment_type_str + from payment_history_medical where Medical_invoice_id=".$inv_id; + $query = $this->db->query($sql); + $data['payment_history']= $query->result(); + + if($print_format==0) + { + $this->load->view('Medical/Medical_invoice_print_2',$data); + }else{ + $this->load->view('Medical/Medical_invoice_print',$data); + } + + } + + + public function invoice_print_all($ipd_id,$cash=0) + { + //$cash 0 for Cash Only,1 for Credit only,2 Package Credit only,3 for All + $this->load->model('Medical_M'); + + $cash_where=" "; + + if($cash==0) + { + $cash_where.=" and ipd_credit=0 "; + $med_type=1; + }elseif($cash==1) + { + $cash_where.=" and ipd_credit=1 and ipd_credit_type=1 "; + $med_type=2; + }elseif($cash==2) + { + $cash_where.=" and ipd_credit=1 and ipd_credit_type=0 "; + $med_type=3; + } + + $this->Medical_M->update_invoice_group_gst($ipd_id,$med_type); + + + $sql="select i.inv_med_id,i.id,i.item_Name,i.formulation, + i.batch_no,Date_Format(i.expiry,'%m-%Y')as expiry, + i.price,i.qty,sum(i.amount) as amount,i.HSNCODE, + m.inv_med_code,m.id as m_id, + date_format(m.inv_date,'%d-%m-%Y') as str_inv_date, + sum(twdisc_amount) as twdisc_amount, + sum(i.disc_amount+i.disc_whole) as d_amt, + sum(i.CGST+i.SGST) as gst, + (i.CGST_per+i.SGST_per) as gst_per + from inv_med_item i join invoice_med_master m + on i.inv_med_id=m.id + where m.group_invoice_id>0 and m.ipd_id=".$ipd_id.$cash_where." group by i.inv_med_id,i.id WITH ROLLUP"; + $query = $this->db->query($sql); + $data['inv_items']= $query->result(); + + $sql="select sum(CGST_Tamount) as CGST_Tamount, + sum(SGST_Tamount) as SGST_Tamount, + sum(TaxableAmount) as TaxableAmount, + sum(net_amount) as net_amount, + sum(payment_received) as payment_received, + sum(payment_balance) as payment_balance, + sum(discount_amount+item_discount_amount) as inv_disc_total, + (CGST_Tamount+SGST_Tamount) as TGST from invoice_med_master + where group_invoice_id>0 and ipd_id=".$ipd_id.$cash_where." group by ipd_id"; + $query = $this->db->query($sql); + $data['invoice_master']= $query->result(); + + $sql="select m.p_id,p.p_fname,m.ipd_code,p.p_code, m.doc_name, + m.org_id from v_ipd_list m join patient_master p on m.p_id=p.id + where m.id=".$ipd_id; + $query = $this->db->query($sql); + $data['ipd_master']= $query->result(); + + $sql="select * from organization_case_master where id='".$data['ipd_master'][0]->org_id."'"; + $query = $this->db->query($sql); + $data['orgcase']= $query->result(); + + $sql="select sum(if(p.credit_debit>0,p.amount*-1,p.amount)) as paid_amount + from payment_history_medical p join inv_med_group m + on p.group_id=m.med_group_id + where m.ipd_id=".$ipd_id." and m.med_type=".$med_type; + $query = $this->db->query($sql); + $data['payment_Total']= $query->result(); + + $sql="select p.*,if(p.credit_debit>0,p.amount*-1,p.amount) as paid_amount, + (case p.payment_mode when 1 then 'Cash' when 2 then 'Bank Card' when 3 then 'Return Cash ' when 4 then 'Bank Return' when 5 then 'Cash Return' else 'Other' end) as Payment_type_str + from payment_history_medical p join inv_med_group m + on p.group_id=m.med_group_id + where m.ipd_id=".$ipd_id." and m.med_type=".$med_type; + $query = $this->db->query($sql); + $data['payment_history']= $query->result(); + + $sql="select * from inv_med_group + where ipd_id='".$ipd_id."' and med_type='".$med_type."'"; + $query = $this->db->query($sql); + $data['inv_med_group']= $query->result(); + + if($cash==0) + { + if($data['inv_med_group'][0]->bill_final==1) + { + $this->load->view('Medical/Medical_invoice_print_all',$data); + }else{ + $this->load->view('Medical/Medical_invoice_print_all_provisional',$data); + } + }else{ + $this->load->view('Medical/Medical_invoice_print_all',$data); + } + + } + + + public function final_invoice($inv_id) + { + $this->load->model('Medical_M'); + + //$this->Medical_M->update_invoice_group($inv_id); + $this->Medical_M->update_invoice_final($inv_id); + + $sql="select *,(discount_amount+item_discount_amount) as inv_disc_total,(CGST_Tamount+SGST_Tamount) as TGST from invoice_med_master where id=".$inv_id; + $query = $this->db->query($sql); + $data['invoiceMaster']= $query->result(); + + $sql="select * from inv_med_item where inv_med_id=".$inv_id; + $query = $this->db->query($sql); + $data['inv_items']= $query->result(); + + $sql="select *,if(gender=1,'Male','FeMale') as xgender, + GET_AGE_1(dob,age,age_in_month,estimate_dob) AS age + from patient_master where id='".$data['invoiceMaster'][0]->patient_id."' "; + $query = $this->db->query($sql); + $data['person_info']= $query->result(); + + $sql="select * from ipd_master where ipd_status=0 and id=".$data['invoiceMaster'][0]->ipd_id; + $query = $this->db->query($sql); + $data['ipd_master']= $query->result(); + + if($data['invoiceMaster'][0]->case_id > 0) + { + $sql="select * from organization_case_master where id=".$data['invoiceMaster'][0]->case_id; + $query = $this->db->query($sql); + $data['OCaseMaster']= $query->result(); + } + + $sql="select sum(if(credit_debit>0,amount*-1,amount)) as paid_amount from payment_history_medical where Medical_invoice_id=".$inv_id; + $query = $this->db->query($sql); + $data['payment_history_medical']= $query->result(); + + $sql="select s.id,s.pay_type,m.bank_name + From medical_bank m join medical_bank_payment_source s on m.id=s.bank_id"; + $query = $this->db->query($sql); + $data['bank_data']= $query->result(); + + if(count($data['invoiceMaster'])>0) + { + if($data['invoiceMaster'][0]->ipd_id>0) + { + redirect('Medical/list_med_inv/'.$data['invoiceMaster'][0]->ipd_id); + }else if($data['invoiceMaster'][0]->case_id>0 && $data['invoiceMaster'][0]->case_credit>0) + { + redirect('Medical/list_med_orginv/'.$data['invoiceMaster'][0]->case_id); + }else{ + $this->load->view('Medical/Medical_Final_Invoice',$data); + } + } + } + + public function final_return_invoice($inv_id) + { + $this->load->model('Medical_M'); + + $sql="select *,(discount_amount+item_discount_amount) as inv_disc_total,(CGST_Tamount+SGST_Tamount) as TGST from invoice_med_master where id=".$inv_id; + $query = $this->db->query($sql); + $data['invoiceMaster']= $query->result(); + + $sql="select *,ifnull(DATEDIFF(expiry,CURDATE()),1000) AS no_day from inv_med_item where inv_med_id=".$inv_id; + $query = $this->db->query($sql); + $data['inv_items']= $query->result(); + + $sql="select *,if(gender=1,'Male','FeMale') as xgender, + GET_AGE_1(dob,age,age_in_month,estimate_dob) AS age + from patient_master where id='".$data['invoiceMaster'][0]->patient_id."' "; + $query = $this->db->query($sql); + $data['person_info']= $query->result(); + + $sql="select sum(if(credit_debit>0,amount*-1,amount)) as paid_amount from payment_history_medical where Medical_invoice_id=".$inv_id; + $query = $this->db->query($sql); + $data['payment_history_medical']= $query->result(); + + if(count($data['invoiceMaster'])>0) + { + $this->load->view('Medical/Medical_Final_return_Invoice',$data); + }else{ + echo 'Error In Inv. No.'; + } + } + + public function add_item($type,$req=0) + { + $this->load->model('Medical_M'); + + $inser_id=1; + $Error_Show=''; + $exist=0; + $input_id=0; + + $store_stock_id=$this->input->post('l_ssno'); + + $user = $this->ion_auth->user()->row(); + $user_id = $user->id; + $user_name_info = $user->first_name.''. $user->last_name .'['.$user_id.']'.date('d-m-Y H:i:s'); + + if($type==1) + { + $inv_id=$this->input->post('inv_id'); + $qty=$this->input->post('qty'); + $disc=$this->input->post('disc'); + $product_unit_rate=$this->input->post('product_unit_rate'); + + $sql="SELECT p.item_name as item_name,t.batch_no,t.expiry_date, + (t.total_unit-t.total_sale_unit) AS S_qty, + t.mrp,t.selling_unit_rate,p.id AS master_product_id, + t.id as purchase_item_id,p.formulation, + t.HSNCODE,t.CGST_per,t.SGST_per,t.packing + FROM med_product_master p + JOIN purchase_invoice_item t ON p.id=t.item_code + where t.id= ".$store_stock_id; + $query = $this->db->query($sql); + $data['itemlist']= $query->result(); + + $sql="select * from inv_med_item where inv_med_id=".$inv_id." + and store_stock_id=".$store_stock_id; + $query = $this->db->query($sql); + $itemExist= $query->result(); + + $CGST=$data['itemlist'][0]->CGST_per; + $SGST=$data['itemlist'][0]->SGST_per; + + //$item_rate=$data['itemlist'][0]->unit_rate; + $item_rate=$product_unit_rate; + + $amount_value=$qty*$item_rate; + + $disc_amount=$amount_value*$disc/100; + + $Tamount_value=$amount_value-$disc_amount; + + $HSNCODE=$data['itemlist'][0]->HSNCODE; + + $stock_qty=$data['itemlist'][0]->S_qty; + + if($qty>$stock_qty) + { + $inser_id=0; + $Error_Show='Stock Qty. is less than Required Qty : Current Qty :'.$stock_qty; + }elseif($stock_qty==0){ + $stock_qty=0; + $inser_id=0; + $Error_Show='Stock is Empty'; + } + + if($inser_id>0) + { + $data['insert_inv_med_item'] = array( + 'inv_med_id' => $inv_id, + 'item_code' => $data['itemlist'][0]->master_product_id, + 'item_Name' => $data['itemlist'][0]->item_name, + 'formulation' => $data['itemlist'][0]->formulation, + 'qty' => $qty, + 'batch_no' => $data['itemlist'][0]->batch_no, + 'expiry' => $data['itemlist'][0]->expiry_date, + 'price' => $item_rate, + 'price2' => $item_rate, + 'mrp' => $data['itemlist'][0]->mrp, + 'disc_per' => $disc, + 'disc_amount' => $disc_amount, + 'amount' => $amount_value, + 'tamount' => $Tamount_value, + 'CGST_per'=> $CGST, + 'SGST_per'=> $SGST, + 'HSNCODE'=> $HSNCODE, + 'store_stock_id'=>$data['itemlist'][0]->purchase_item_id, + 'update_by_id'=>$user_id, + 'update_by_remark'=>$user_name_info, + 'packing'=>$data['itemlist'][0]->packing, + ); + + if(count($itemExist)>0) + { + $Error_Show='Please Check Also Same Item List'; + $exist=count($itemExist); + $input_id=$itemExist[0]->id; + $input_id=0; + } + + $inser_id=$this->Medical_M->add_invoiceitem( $data['insert_inv_med_item']); + } + } + else if($type==2) + { + $update_qty=$this->input->post('u_qty'); + $itemid=$this->input->post('itemid'); + + $sql="select * from inv_med_item where id=".$itemid; + $query = $this->db->query($sql); + $data['inv_med_item']= $query->result(); + + $CGST=$data['inv_med_item'][0]->CGST_per; + $SGST=$data['inv_med_item'][0]->SGST_per; + $disc=$data['inv_med_item'][0]->disc_per; + + $inv_id=$data['inv_med_item'][0]->inv_med_id; + + $store_stock_id=$data['inv_med_item'][0]->store_stock_id; + + $sql="SELECT p.item_name,t.batch_no,t.expiry_date, + (t.total_unit-t.total_sale_unit) AS S_qty, + t.mrp,t.selling_unit_rate,p.id AS master_product_id, + t.id as purchase_item_id,p.formulation, + t.HSNCODE,t.CGST_per,t.SGST_per,t.packing + FROM med_product_master p + JOIN purchase_invoice_item t ON p.id=t.item_code + where t.id= ".$store_stock_id; + + $query = $this->db->query($sql); + $item_master= $query->result(); + + $stock_qty=0; + + $old_qty=$data['inv_med_item'][0]->qty; + $diff_qty=$update_qty-$old_qty; + + if($diff_qty>0) + { + if(count($item_master)>0) + { + $stock_qty=$item_master[0]->S_qty; + if($diff_qty>$stock_qty) + { + $inser_id=0; + $Error_Show='Stock Qty. is less than Required Qty : Current Qty :'.$stock_qty; + } + }else{ + $stock_qty=0; + $inser_id=0; + $Error_Show='Stock is Empty'; + } + } + + if($inser_id>0) + { + $item_rate=$data['inv_med_item'][0]->price; + $amount_value=$update_qty*$item_rate; + + $disc_amount=$amount_value*$disc/100; + + $Tamount_value=$amount_value-$disc_amount; + + $data['update_inv_med_item'] = array( + 'qty' => $update_qty, + 'disc_amount' => $disc_amount, + 'amount' => $amount_value, + 'tamount' => $Tamount_value, + 'store_stock_id'=>$store_stock_id, + 'packing'=>$data['inv_med_item'][0]->packing, + 'inv_med_id' => $inv_id, + ); + + $this->Medical_M->update_invoiceitem($data['update_inv_med_item'],$itemid); + $inser_id=$itemid; + + } + + $this->Medical_M->update_invoice_group($inv_id); + $this->Medical_M->update_invoice_final($inv_id); + + }else{ + $inv_id=$this->input->post('inv_id'); + $itemid=$this->input->post('itemid'); + + $sql="select * from inv_med_item where id=".$itemid; + $query = $this->db->query($sql); + $inv_items= $query->row_array(); + + $this->Medical_M->delete_invoiceitem($itemid,$inv_items); + + } + + $content=''; + + if($inser_id>0) + { + $this->Medical_M->update_invoice_final($inv_id); + + $sql="SELECT i.*,ifnull(DATEDIFF(expiry,CURDATE()),1000) AS no_day, + SUM(p.total_unit-p.total_sale_unit-total_return_unit-total_lost_unit)/p.packing AS cur_qty + FROM (inv_med_item i JOIN purchase_invoice_item p ON i.item_code=p.item_code AND p.remove_item=0 ) + where inv_med_id=".$inv_id." GROUP BY i.id"; + $query = $this->db->query($sql); + $data['inv_items']= $query->result(); + + $sql="select item_code + from inv_med_item where inv_med_id=".$inv_id." Group by item_code Having count(id)>1"; + $query = $this->db->query($sql); + $data['inv_items_multiple']= $query->result(); + + $sql="select sum(amount) as Gtotal,sum(tamount) as tamt,sum(CGST) as TCGST,sum(SGST) as TSGST, + sum(disc_amount) as t_dis_amt from inv_med_item where inv_med_id=".$inv_id; + $query = $this->db->query($sql); + $data['invoiceGtotal']= $query->result(); + + $sql="select * from invoice_med_master where id=".$inv_id; + $query = $this->db->query($sql); + $data['invoiceMaster']= $query->result(); + + + $user = $this->ion_auth->user()->row(); + $data['user_id'] = $user->id; + + $data['sale_return']=$data['invoiceMaster'][0]->sale_return; + + $content=$this->load->view('Medical/Med_Item_List',$data,true); + } + + $rvar=array( + 'exist' =>$exist, + 'insertid' =>$inser_id, + 'content'=>$content, + 'error'=>$Error_Show, + 'input_id'=>$input_id, + 'csrf_dst_name_value'=>$this->security->get_csrf_hash() + ); + $encode_data = json_encode($rvar); + echo $encode_data; + } + + + + public function list_org_ipd() + { + $sql = "select *,(paid_amount-(charge_amount+med_amount)) as balance + from v_ipd_list where ipd_status=0 "; + $query = $this->db->query($sql); + $data['data']= $query->result(); + + $sql = "SELECT CONCAT('IPD : ',i.ipd_code,' /Name :',p.p_fname,' / Admit Dt: ',date_format(i.register_date,'%d-%m-%Y'), + ' /Balance :',m.payment_balance) AS show_content + FROM (inv_med_group m JOIN ipd_master i ON m.ipd_id=i.id) + JOIN patient_master p ON i.p_id=p.id + WHERE i.ipd_status=0 AND m.med_type=1 AND m.net_amount>0 + AND payment_balance>=50000 "; + $query = $this->db->query($sql); + $data['high_balance']= $query->result(); + + $this->load->view('Medical/Medical_ipd_org_list',$data); + } + + public function list_high_balance() + { + $sql = "SELECT i.*,p.p_code,p.p_fname,p.mphone1,m.payment_received,m.payment_balance + FROM (inv_med_group m JOIN ipd_master i ON m.ipd_id=i.id) + JOIN patient_master p ON i.p_id=p.id + WHERE i.ipd_status=0 AND m.med_type=1 AND m.net_amount>0 + AND payment_balance>=50000 "; + $query = $this->db->query($sql); + $data['high_balance']= $query->result(); + + $this->load->view('Medical/Report/Med_high_pending',$data); + + + } + + + public function list_org() + { + $sql = "select p.p_fname,p.p_code,p.p_relative,p.p_rname,o.insurance_company_name,o.case_id_code,o.id as org_id,o.p_id , + o.date_registration,Date_Format(o.date_registration,'%d-%m-%Y') as str_register_date,o.insurance_id + from organization_case_master o join patient_master p on o.p_id=p.id + and o.insurance_id >1 and o.`status`=0 and o.case_type=0 "; + $query = $this->db->query($sql); + $data['organization_case_master']= $query->result(); + + + $this->load->view('Medical/Medical_org_list',$data); + } + + public function list_med_inv($ipd_id) + { + + $sql="select *,if(ipd_credit=0,'CASH','CREDIT') as credit, + if(ipd_credit=1 and ipd_credit_type=0,'Yes','No') as Package + from invoice_med_master where ipd_id = ".$ipd_id." Order by inv_date,id"; + $query = $this->db->query($sql); + $data['inv_master']= $query->result(); + + $this->load->model('Medical_M'); + $this->Medical_M->update_invoice_group_gst($ipd_id,1); + + $sql="select sum(if(ipd_credit=0,net_amount,0)) as cash_netAmount, + sum(if(ipd_credit=1 and ipd_credit_type=1,net_amount,0)) as IPDCrAmount , + sum(if(ipd_credit=1 and ipd_credit_type=0,net_amount,0)) as PackageCrAmount, + sum(payment_balance) as t_payment_balance ,sum(net_amount) as t_net_amount + from invoice_med_master where ipd_id = ".$ipd_id; + $query = $this->db->query($sql); + $data['inv_master_total']= $query->result(); + + $sql="select * from ipd_master where id = ".$ipd_id; + $query = $this->db->query($sql); + $data['ipd_master']= $query->result(); + + $sql="select *,if(gender=1,'Male','Female') as xgender, + GET_AGE_1(dob,age,age_in_month,estimate_dob) AS age from patient_master where id='".$data['ipd_master'][0]->p_id."' "; + $query = $this->db->query($sql); + $data['person_info']= $query->result(); + + $sql="select * from v_ipd_list where id=".$ipd_id; + $query = $this->db->query($sql); + $data['ipd_list']= $query->result(); + + $sql="select * from inv_med_group where med_type=1 and ipd_id=".$ipd_id; + $query = $this->db->query($sql); + $data['med_group_list']= $query->result(); + + $sql="select b.ipd_id,b.bed_id,b.TDate,m.room_name,m.bed_no + from ipd_bed_assign b left join hc_bed_master m on b.bed_id=m.id + where b.ipd_id=".$ipd_id." order by TDate desc"; + $query = $this->db->query($sql); + $data['bed_list']= $query->result(); + + if($data['ipd_master'][0]->case_id>0) + { + $sql="select * from organization_case_master where id='".$data['ipd_master'][0]->case_id."'"; + $query = $this->db->query($sql); + $data['orgcase']= $query->result(); + + $ins_comp_id=$data['orgcase'][0]->insurance_id; + $inc_card_id=$data['orgcase'][0]->insurance_card_id; + + $sql="select * from hc_insurance_card where id='".$inc_card_id."'"; + $query = $this->db->query($sql); + $data['hc_insurance_card']= $query->result(); + + $sql="select * from hc_insurance where id='".$ins_comp_id."'"; + $query = $this->db->query($sql); + $data['insurance']= $query->result(); + } + + if(count($data['med_group_list'])>0) + { + if($data['med_group_list'][0]->discount_group_2<>0) + { + exit('Please Contact to Medical Store Admin '); + } + } + + $this->load->view('Medical/Medical_invoice_list',$data); + } + + public function list_med_orginv($org_id) + { + + $sql="select *,if(case_credit=0,'CASH','CREDIT') as credit + from invoice_med_master where case_id = ".$org_id." order by inv_date,id"; + $query = $this->db->query($sql); + $data['inv_master']= $query->result(); + + $sql="select * from organization_case_master where id = ".$org_id; + $query = $this->db->query($sql); + $data['orgcase_master']= $query->result(); + + $sql="select *,if(gender=1,'Male','Female') as xgender, + GET_AGE_1(dob,age,age_in_month,estimate_dob) AS age from patient_master where id='".$data['orgcase_master'][0]->p_id."' "; + $query = $this->db->query($sql); + $data['person_info']= $query->result(); + + $this->load->view('Medical/Medical_org_invoicelist',$data); + } + + public function update_discount() + { + $invoice_id=$this->input->post('med_invoice_id'); + + $user = $this->ion_auth->user()->row(); + $user_id = $user->id; + $user_name = $user->first_name.''. $user->last_name; + + $dataupdate = array( + 'discount_amount' => $this->input->post('input_dis_amt'), + 'discount_remark' => $this->input->post('input_dis_desc'), + 'discount_by'=>$user_name.'['.$user_id.']' + ); + + $this->load->model('Medical_M'); + $this->Medical_M->update_in_upv_item($dataupdate,$invoice_id); + + $this->Medical_M->update_invoice_final($invoice_id); + + } + + public function BillFinal($group_id) + { + + $user = $this->ion_auth->user()->row(); + $user_id = $user->id; + $user_name = $user->first_name.''. $user->last_name; + + $dataupdate = array( + 'bill_final' => '1', + 'bill_final_by'=>$user_name.'['.$user_id.']' + ); + + $this->load->model('Medical_M'); + $this->Medical_M->update_group_invoice($dataupdate,$group_id); + + $rvar=array( + 'update' =>1, + ); + $encode_data = json_encode($rvar); + echo $encode_data; + + } + + public function InvBillFinal($invoice_id) + { + $user = $this->ion_auth->user()->row(); + $user_id = $user->id; + $user_name = $user->first_name.''. $user->last_name; + + $dataupdate = array( + 'bill_final' => '1', + 'bill_final_by'=>$user_name.'['.$user_id.']' + ); + + $this->load->model('Medical_M'); + $this->Medical_M->update_in_upv_item($dataupdate,$invoice_id); + + $rvar=array( + 'update' =>1, + ); + $encode_data = json_encode($rvar); + echo $encode_data; + + } + + + public function search() + { + $sdata=$this->input->post('txtsearch'); + + $sdata = preg_replace('/[^A-Za-z0-9 _.@\-]/', '', trim($sdata)); + + if(strlen($sdata)==0) + { + $sql = "SELECT p.*,GET_AGE_1(dob,age,age_in_month,estimate_dob) AS age , + Max(o.apointment_date) as Last_OPD , + date_format(if(Max(o.apointment_date) IS NULL,p.insert_date,Max(o.apointment_date)),'%d-%m-%Y') AS Last_Visit + FROM patient_master p left join opd_master o on p.id=o.p_id + group BY p.id + order BY if(Max(o.apointment_date) IS NULL,p.insert_date,Max(o.apointment_date)) DESC + LIMIT 100"; + }else{ + + $sdate_array=explode(" ",$sdata); + $search_string=" 1=1 " ; + + foreach($sdate_array as $row_data) + { + if(is_numeric($row_data)) + { + $search_string.=" and (p.p_code like '%$row_data' + or p.mphone1 = '$row_data' + or p.udai='$row_data' )"; + }elseif(ctype_alpha($row_data)){ + $search_string.=" and (p.p_fname like '%$row_data%' + or p.email1 = '$row_data' + or SUBSTRING_INDEX(p.p_fname,' ',1) sounds like '".$row_data."')"; + }else{ + $search_string.=" and (p.p_code like '$row_data' + or p.email1 = '$row_data' )"; + } + } + + $sql = "SELECT p.*,GET_AGE_1(dob,age,age_in_month,estimate_dob) AS age , + Max(o.apointment_date) as Last_OPD , + date_format(if(Max(o.apointment_date) IS NULL,p.insert_date,Max(o.apointment_date)),'%d-%m-%Y') AS Last_Visit + FROM patient_master p left join opd_master o on p.id=o.p_id + WHERE $search_string + group BY p.id + order BY if(Max(o.apointment_date) IS NULL,p.insert_date,Max(o.apointment_date)) DESC "; + } + + + $query = $this->db->query($sql); + $data['data']= $query->result(); + + $this->load->view('Medical/Patient_Search_Result',$data); + } + + public function Update_Invoice_ipd_credit_type() + { + $ipd_credit_type= $this->input->post('ipd_credit_type'); + $inv_med_id = $this->input->post('inv_med_id'); + + $user = $this->ion_auth->user()->row(); + $user_id = $user->id; + $user_name = $user->first_name.''. $user->last_name.'['.$user_id.']T:'.date('d-m-Y'); + + if($inv_med_id=='1') + { + $ipd_credit_type_update='Include by : '.$user_name; + }else{ + $ipd_credit_type_update='Packeage by '.$user_name; + } + + $dataupdate = array( + 'ipd_credit_type' => $ipd_credit_type, + 'ipd_credit_type_update'=>$ipd_credit_type_update, + ); + + $this->load->model('Medical_M'); + $this->Medical_M->update_in_upv_item($dataupdate,$inv_med_id); + } + + + + public function Med_Inv_Group($inv_med_id) + { + if (!$this->input->is_ajax_request()) { exit('no valid req.'); } + + $sql = "select * from invoice_med_master where id=".$inv_med_id; + $query = $this->db->query($sql); + $invoice_med_master= $query->result(); + + $user = $this->ion_auth->user()->row(); + $user_id = $user->id; + $user_name = $user->first_name.''. $user->last_name; + + $old_remark=$invoice_med_master[0]->update_history; + + $new_remark='Group By : '.$user_name.'['.$user_id.']'.' Date:'.date('d-m-Y h:i:s').PHP_EOL; + + $new_remark.= $old_remark; + + $dataupdate = array( + 'med_group_id' => 1, + 'update_history' => $new_remark + ); + + $this->load->model('Medical_M'); + $this->Medical_M->update_in_upv_item($dataupdate,$inv_med_id); + $this->Medical_M->update_invoice_group($inv_med_id); + + $rvar=array( + 'update' =>1, + ); + $encode_data = json_encode($rvar); + echo $encode_data; + + } + + public function Update_Group_Discount($med_group_id) + { + $input_discount= $this->input->post('input_discount'); + $Ipd_ID= $this->input->post('ipd_id'); + + $user = $this->ion_auth->user()->row(); + $user_id = $user->id; + $user_name = $user->first_name.''. $user->last_name; + + $dataupdate = array( + 'discount_group' => $input_discount, + 'discount_by_group' => $user_name.'['.$user_id.']'.' Date:'.date('d-m-Y h:i:s') + ); + + $this->load->model('Medical_M'); + $this->Medical_M->update_group_invoice($dataupdate,$med_group_id); + $this->Medical_M->update_invoice_group_gst($Ipd_ID); + + $rvar=array( + 'update' =>1, + ); + + $encode_data = json_encode($rvar); + echo $encode_data; + } + + public function edit_invoice_edit($inv_id) + { + $sql="select *,if(ipd_credit>0,'Credit to IPD','CASH') as credit_status, + if(case_credit>0,'Credit to Org','CASH') as credit_org_status from invoice_med_master + where id=$inv_id"; + $query = $this->db->query($sql); + $data['invoiceMaster']= $query->result(); + + $sql="select sum(amount) as Gtotal,sum(tamount) as tamt,sum(CGST) as TCGST,sum(SGST) as TSGST,sum(disc_amount) as t_dis_amt from inv_med_item where inv_med_id=".$inv_id; + $query = $this->db->query($sql); + $data['invoiceGtotal']= $query->result(); + + $sql="select * from doctor_master where active=1"; + $query = $this->db->query($sql); + $data['doclist']= $query->result(); + + $sql="select *, + GET_AGE_1(dob,age,age_in_month,estimate_dob) AS age from patient_master where id='".$data['invoiceMaster'][0]->patient_id."' "; + $query = $this->db->query($sql); + $data['person_info']= $query->result(); + + $data['org_Name']=""; + $ipd_id=$data['invoiceMaster'][0]->ipd_id; + + if($ipd_id>0) + { + $sql="select * from ipd_master where id=".$ipd_id; + $query = $this->db->query($sql); + $ipd_master= $query->result(); + + $sql="select * from v_ipd_list m join patient_master p on m.p_id=p.id + where m.id=".$ipd_id; + $query = $this->db->query($sql); + $data['ipd_list']= $query->result(); + + $data['ipd_master']=$ipd_master; + + if(count($ipd_master)>0) + { + $p_ipd_id=$ipd_master[0]->id; + $p_ipd_code=$ipd_master[0]->ipd_code; + + if($ipd_master[0]->case_id>0) + { + $sql="select * from organization_case_master where id=".$ipd_master[0]->case_id; + $query = $this->db->query($sql); + $org_master= $query->result(); + + if(count($org_master)>0) + { + $data['org_Name']=$org_master[0]->insurance_company_name; + } + + } + } + } + + if($data['invoiceMaster'][0]->case_id > 0) + { + $sql="select * from organization_case_master where id=".$data['invoiceMaster'][0]->case_id; + $query = $this->db->query($sql); + $data['OCaseMaster']= $query->result(); + } + + + + $user = $this->ion_auth->user()->row(); + $data['user_id'] = $user->id; + + $this->load->view('Medical/invoice_master_edit',$data); + + } + + public function LockIPD($inv_med_id,$lock=1) + { + if (!$this->input->is_ajax_request()) { exit('no valid req.'); } + + $sql = "select * from ipd_master where id=".$inv_med_id; + $query = $this->db->query($sql); + $ipd_master= $query->result(); + + $user = $this->ion_auth->user()->row(); + $user_id = $user->id; + $user_name = $user->first_name.''. $user->last_name; + + $old_remark=$ipd_master[0]->lock_remark; + + if($lock==1) + { + $new_remark='Locked By : '.$user_name.'['.$user_id.']'.' Date:'.date('d-m-Y h:i:s').PHP_EOL; + + }else{ + $new_remark='Unlocked By : '.$user_name.'['.$user_id.']'.' Date:'.date('d-m-Y h:i:s').PHP_EOL; + } + + $new_remark.= $old_remark; + + $dataupdate = array( + 'lock_medical' => $lock, + 'lock_remark' => $new_remark + ); + + $this->load->model('Ipd_M'); + $this->Ipd_M->update($dataupdate,$inv_med_id); + + $rvar=array( + 'update' =>1, + ); + + $encode_data = json_encode($rvar); + echo $encode_data; + + + } + + public function load_model_box($ipd_id) + { + $this->load->model('Medical_M'); + + $this->Medical_M->update_invoice_group_gst($ipd_id,1); + + $sql="select *,if(ipd_status=0,DATEDIFF(sysdate(),register_date), + DATEDIFF(discharge_date,register_date)) as no_days, + if(case_type=1,'MLC','Non MLC') as case_type_s, + Date_format(register_date,'%d-%m-%Y') as str_register_date from ipd_master + where id='".$ipd_id."' "; + $query = $this->db->query($sql); + $data['ipd_info']= $query->result(); + + $sql="select *,if(gender=1,'Male','Female') as xgender, + GET_AGE_1(dob,age,age_in_month,estimate_dob) AS age + from patient_master where id='".$data['ipd_info'][0]->p_id."' "; + $query = $this->db->query($sql); + $data['person_info']= $query->result(); + + $sql="select * from inv_med_group where med_type=1 and ipd_id=".$ipd_id; + $query = $this->db->query($sql); + $data['med_group_list']= $query->result(); + + $sql="select p.*,if(p.credit_debit=0,p.amount,p.amount*-1) as paid_amount, + Date_Format(payment_date,'%d-%m-%Y') as str_payment_date, + Concat((case p.payment_mode when 1 then 'Cash' when 2 then 'Bank Card' else 'Other' end),if(p.credit_debit=0,'',' Return')) as Payment_type_str + from payment_history_medical p join inv_med_group m + on p.group_id=m.med_group_id + where m.ipd_id=".$ipd_id." and m.med_type=1"; + $query = $this->db->query($sql); + $data['payment_history']= $query->result(); + + $sql="select * from inv_med_group where med_type=1 and ipd_id=".$ipd_id; + $query = $this->db->query($sql); + $data['inv_med_group']= $query->result(); + + $sql="select s.id,s.pay_type,m.bank_name + From medical_bank m join medical_bank_payment_source s on m.id=s.bank_id"; + $query = $this->db->query($sql); + $data['bank_data']= $query->result(); + + $phone_number_list=array($data['person_info'][0]->mphone1,$data['ipd_info'][0]->P_mobile1,$data['ipd_info'][0]->P_mobile2); + + $data['phone_number_list']=array_unique($phone_number_list); + + $this->load->view('Medical/Med_Model_Payment',$data); + } + + public function payment_receipt($ipd_id,$cash=0) + { + $cash_where=" "; + + if($cash==0) + { + $cash_where.=" and ipd_credit=0 "; + $med_type=1; + }elseif($cash==1) + { + $cash_where.=" and ipd_credit=1 and ipd_credit_type=1 "; + $med_type=2; + }elseif($cash==2) + { + $cash_where.=" and ipd_credit=1 and ipd_credit_type=0 "; + $med_type=3; + } + + $sql="select m.p_id,p.p_fname,m.ipd_code,p.p_code, m.doc_name, + m.org_id from v_ipd_list m join patient_master p on m.p_id=p.id + where m.id=".$ipd_id; + $query = $this->db->query($sql); + $data['ipd_master']= $query->result(); + + $sql="select * from organization_case_master where id='".$data['ipd_master'][0]->org_id."'"; + $query = $this->db->query($sql); + $data['orgcase']= $query->result(); + + $sql="select * from inv_med_group + where ipd_id='".$ipd_id."' and med_type=".$med_type; + $query = $this->db->query($sql); + $data['inv_med_group']= $query->result(); + + $sql="select p.*,if(p.credit_debit>0,p.amount*-1,p.amount) as paid_amount, + Date_Format(payment_date,'%d-%m-%Y') as str_payment_date, + (case p.payment_mode when 1 then 'Cash' when 2 then 'Bank Card' when 3 then 'Return Cash ' when 4 then 'Bank Return' when 5 then 'Cash Return' else 'Other' end) as Payment_type_str + from payment_history_medical p join inv_med_group m + on p.group_id=m.med_group_id + where m.ipd_id=".$ipd_id." and m.med_type=".$med_type; + $query = $this->db->query($sql); + $data['payment_history']= $query->result(); + + $this->load->view('Medical/Med_Payment_Receipt',$data); + + //load mPDF library + $this->load->library('m_pdf'); + $this->m_pdf->pdf->SetWatermarkText(M_store); + $this->m_pdf->pdf->showWatermarkText = true; + + $file_name='Report-payment_receipt-'.$ipd_id."-".date('Ymdhis').".pdf"; + $filepath=$file_name; + $content=$this->load->view('Medical/Med_Payment_Receipt',$data,TRUE); + $this->m_pdf->pdf->WriteHTML($content); + $this->m_pdf->pdf->Output($filepath,"I"); + + } + + public function payment_receipt_sms($ipd_id,$cash=0) + { + $inv_phone_number=$this->input->post('phone_number'); + + $cash_where=" "; + + if($cash==0) + { + $cash_where.=" and ipd_credit=0 "; + $med_type=1; + }elseif($cash==1) + { + $cash_where.=" and ipd_credit=1 and ipd_credit_type=1 "; + $med_type=2; + }elseif($cash==2) + { + $cash_where.=" and ipd_credit=1 and ipd_credit_type=0 "; + $med_type=3; + } + + $sql="select m.p_id,p.p_fname,m.ipd_code,p.p_code, m.doc_name, + m.org_id,m.P_mobile1,m.P_mobile2 from v_ipd_list m join patient_master p on m.p_id=p.id + where m.id=".$ipd_id; + $query = $this->db->query($sql); + $ipd_master= $query->result(); + + $sql="select * from inv_med_group + where ipd_id='".$ipd_id."' and med_type=".$med_type; + $query = $this->db->query($sql); + $inv_med_group= $query->result(); + + $sql="select * from invoice_med_master + where ipd_id='".$ipd_id."' and ipd_credit=0 order by id desc limit 1"; + $query = $this->db->query($sql); + $inv_med_master= $query->result(); + + $sql="select p.*,if(p.credit_debit>0,p.amount*-1,p.amount) as paid_amount, + Date_Format(payment_date,'%d-%m-%Y') as str_payment_date, + (case p.payment_mode when 1 then 'Cash' when 2 then 'Bank Card' when 3 then 'Return Cash ' when 4 then 'Bank Return' when 5 then 'Cash Return' else 'Other' end) as Payment_type_str + from payment_history_medical p join inv_med_group m + on p.group_id=m.med_group_id + where m.ipd_id=".$ipd_id." and m.med_type=".$med_type." order by id desc limit 1"; + $query = $this->db->query($sql); + $payment_history_last= $query->result(); + + $Last_Inv_Amt=0; + $Last_pay_Amt=0; + + if(count($inv_med_master)>0) + { + $Last_Inv_Amt=$inv_med_master[0]->net_amount; + } + + if(count($payment_history_last)>0) + { + $Last_pay_Amt=$payment_history_last[0]->paid_amount; + } + + $SMS_SEND= M_store_short." STORE BILL STATUS%nIPD No.: ".$ipd_master[0]->ipd_code."%nPName: ".Trim($ipd_master[0]->p_fname)."%nTot. Med Amt.: ".Round($inv_med_group[0]->net_amount,0)."%nLast Inv. Amt.: ".Round($Last_Inv_Amt,0)."%nTot. Paid Amt.: ".Round($inv_med_group[0]->payment_received)."%nLast Paid Amt.: ".Round($Last_pay_Amt,0)."%nBal. Amt.: ".Round($inv_med_group[0]->payment_balance,0)."%nFrom: DevSoftTech HMS"; + + + + //$inv_phone_number="9720958717"; + + $this->load->model('SMS_M'); + + $data=array( + 'to_number'=>$inv_phone_number, + 'message'=>$SMS_SEND + ); + + $insert_id=$this->SMS_M->insert_sms_outbox($data); + + + $rvar=array( + 'update' =>$insert_id, + 'msg_text'=>"Message Send" + ); + $encode_data = json_encode($rvar); + echo $encode_data; + + } + + public function group_confirm_payment() + { + if (!$this->input->is_ajax_request()) { exit('no valid req.'); } + + $this->load->model('Ipd_M'); + $this->load->model('Medical_M'); + + $ipd_id=$this->input->post('ipd_id'); + $amount=$this->input->post('amount'); + $Med_Group_id=$this->input->post('Med_Group_id'); + + $sql="select * from ipd_master where id=".$ipd_id; + $query = $this->db->query($sql); + $ipd_master= $query->result(); + + $user = $this->ion_auth->user()->row(); + $user_id = $user->id; + $user_name = $user->first_name.''. $user->last_name; + + $pay_remark=$this->input->post('cash_remark'); + $cr_dr=$this->input->post('cr_dr'); + + + $pay_datetime=str_to_MysqlDate($this->input->post('date_payment')).' '.date('H:i:s'); + + if($this->input->post('mode')==1) + { + $paydata = array( + 'payment_mode'=> '1', + 'Customerof_type'=>'2', + 'Customerof_id'=>$ipd_master[0]->p_id, + 'group_id'=>$Med_Group_id, + 'ipd_id'=>$ipd_id, + 'med_type'=>0, + 'credit_debit'=>$cr_dr, + 'amount'=>$amount, + 'payment_date'=>$pay_datetime, + 'remark'=>$pay_remark, + 'update_by'=>$user_name.'['.$user_id.']', + 'update_by_id'=>$user_id + ); + + $insert_id=$this->Medical_M->insert_payment($paydata); + + $this->Medical_M->update_invoice_group_gst($ipd_id); + + $rvar=array( + 'update' =>1, + 'ipd_id'=> $ipd_id, + 'payid' => $insert_id, + 'pay_date' =>$pay_datetime + ); + $encode_data = json_encode($rvar); + echo $encode_data; + } + + if($this->input->post('mode')==2) + { + + $FormRules = array( + array( + 'field' => 'input_card_tran', + 'label' => 'Card Transcation ID', + 'rules' => 'required|min_length[1]|max_length[15]' + ) + ); + + $this->form_validation->set_rules($FormRules); + + if ($this->form_validation->run() == TRUE) + { + + + $paydata = array( + 'payment_mode'=> '2', + 'Customerof_type'=>'2', + 'Customerof_id'=>$ipd_master[0]->p_id, + 'group_id'=>$Med_Group_id, + 'ipd_id'=>$ipd_id, + 'med_type'=>0, + 'credit_debit'=>$cr_dr, + 'amount'=>$amount, + 'payment_date'=>$pay_datetime, + 'remark'=>$pay_remark, + 'update_by'=>$user_name.'['.$user_id.']', + 'update_by_id'=>$user_id, + 'pay_bank_id'=>$this->input->post('cbo_pay_type'), + 'card_tran_id'=>$this->input->post('input_card_tran'), + + ); + + $insert_id=$this->Medical_M->insert_payment($paydata); + + $this->Medical_M->update_invoice_group_gst($ipd_id); + + $rvar=array( + 'update' =>1, + 'ipd_id'=> $ipd_id, + 'payid' => $insert_id, + 'pay_date' =>$pay_datetime + ); + $encode_data = json_encode($rvar); + echo $encode_data; + } + else{ + $send_error=validation_errors(); + $rvar=array( + 'update' =>0, + 'error_text'=>$send_error + ); + $encode_data = json_encode($rvar); + echo $encode_data; + } + } + + + if($this->input->post('mode')==5) + { + $FormRules = array( + array( + 'field' => 'input_person_name', + 'label' => 'Name on Chq.', + 'rules' => 'required|min_length[1]|max_length[30]' + ), + array( + 'field' => 'input_bank_tran', + 'label' => 'Chq. Number', + 'rules' => 'required|min_length[1]|max_length[15]' + ) + /*, + array( + 'field' => 'input_card_digit', + 'label' => 'Card Last 4 Digit ', + 'rules' => 'required|min_length[1]|max_length[10]' + ), + array( + 'field' => 'input_card_bank', + 'label' => 'Bank Name ', + 'rules' => 'required|min_length[1]|max_length[50]' + ), + */ + ); + + $this->form_validation->set_rules($FormRules); + + if ($this->form_validation->run() == TRUE) + { + $pay_remark='Chq Payment'; + + $paydata = array( + 'payment_mode'=> '2', + 'payof_type'=>'4', + 'payof_id'=>$ipd_master[0]->id, + 'payof_code'=>$ipd_master[0]->ipd_code, + 'credit_debit'=>$cr_dr, + 'amount' => $amount, + 'payment_date'=>$pay_datetime, + 'remark'=>$pay_remark, + 'update_by'=>$user_name.'['.$user_id.']', + 'card_bank'=>$this->input->post('input_bank_hospital'), + 'cust_card'=>$this->input->post('input_bank_name'), + 'card_remark'=>$this->input->post('input_person_name'), + 'card_tran_id'=>$this->input->post('input_bank_tran'), + 'update_by_id'=>$user_id + ); + + $insert_id=$this->Payment_M->insert($paydata); + + $data = array( + 'payment_mode'=> '2', + 'payment_mode_desc'=>'Bank Chq.-Draft', + 'payment_id'=>$insert_id, + 'pay_date'=>$pay_datetime, + 'enter_pay_date' => date('Y-m-d H:i:s'), + 'ipd_id' => $ipd_id, + 'amount' => $amount, + 'card_bank'=>$this->input->post('input_bank_hospital'), + 'card_remark'=>$this->input->post('input_card_digit'), + 'cust_card'=>$this->input->post('input_bank_name'), + 'card_tran_id'=>$this->input->post('input_bank_tran'), + 'prepared_by'=>$user_name.'['.$user_id.']', + 'prepared_by_id'=>$user_id + ); + + $insert_ipdpay_id=$this->Ipd_M->insert_payment_ipd( $data); + + $status='Bank Card'; + + + $rvar=array( + 'update' =>1, + 'ipd_id'=> $ipd_id, + 'payid' => $insert_ipdpay_id + ); + + $encode_data = json_encode($rvar); + echo $encode_data; + } + else{ + $send_error=validation_errors(); + $rvar=array( + 'update' =>0, + 'error_text'=>$send_error + ); + $encode_data = json_encode($rvar); + echo $encode_data; + } + } + } + + public function group_cash_print($ipd_id,$payid) + { + $sql="select *,date_format(payment_date,'%d-%m-%Y') as pay_date, + (case payment_mode when 1 then 'CASH' when 2 then 'Bank' Else 'Other' End) as payment_mode_desc + from payment_history_medical where id=".$payid; + $query = $this->db->query($sql); + $data['med_payment']= $query->result(); + + $sql="select * from ipd_master where id =".$ipd_id; + $query = $this->db->query($sql); + $data['ipd_master']= $query->result(); + + $pno=$data['ipd_master'][0]->p_id; + + $sql="select *,if(gender=1,'Male','Female') as xgender, + GET_AGE_1(dob,age,age_in_month,estimate_dob) AS age + from patient_master where id='".$pno."' "; + + $query = $this->db->query($sql); + $data['person_info']= $query->result(); + + $this->load->view('Medical/Med_Payment_receipt',$data); + + } + + public function Invoice_Item_Return($inv_type_id,$inv_type=0) + { + $data['inv_type_id']=$inv_type_id; + $data['inv_type']=$inv_type; + + $p_id=0; + + if($inv_type==0) + { + $sql="select * from ipd_master where id='".$inv_type_id."' "; + $query = $this->db->query($sql); + $data['ipd_master']= $query->result(); + + $sql_items="select m.id as inv_id,m.inv_med_code,date_format(inv_date,'%d-%m-%Y') as str_inv_date,m.ipd_id,m.patient_id,m.group_invoice_id,m.case_id, + t.id as item_id,t.item_Name,t.qty,t.batch_no,t.expiry,t.store_stock_id as ss_no,t.item_code,t.mrp,t.price, + t.amount,t.disc_amount,t.tamount,r.r_qty,r.id as return_id + from (invoice_med_master m join inv_med_item t on m.id=t.inv_med_id ) left join inv_med_item_return r on t.id=r.inv_item_id and return_status=0 + where m.ipd_id=".$inv_type_id. " order by t.item_Name,t.batch_no"; + + $p_id=$data['ipd_master'][0]->p_id; + + }elseif($inv_type==1){ + $sql="select * from organization_case_master where id='".$inv_type_id."' "; + $query = $this->db->query($sql); + $data['org_master']= $query->result(); + + $sql_items="select m.id as inv_id,m.inv_med_code,date_format(inv_date,'%d-%m-%Y') as str_inv_date,m.ipd_id,m.patient_id,m.group_invoice_id,m.case_id, + t.id as item_id,t.item_Name,t.qty,t.batch_no,t.expiry,t.store_stock_id as ss_no,t.item_code,t.mrp,t.price, + t.amount,t.disc_amount,t.tamount,r.r_qty,r.id as return_id + from (invoice_med_master m join inv_med_item t on m.id=t.inv_med_id ) left join inv_med_item_return r on t.id=r.inv_item_id and return_status=0 + where m.case_id=".$inv_type_id. " order by t.item_Name,t.batch_no"; + + $p_id=$data['org_master'][0]->p_id; + }else{ + $sql="select * from invoice_med_master where id='".$inv_type_id."' "; + $query = $this->db->query($sql); + $data['invoice_med_master']= $query->result(); + + $sql_items="select m.id as inv_id,m.inv_med_code,date_format(inv_date,'%d-%m-%Y') as str_inv_date,m.ipd_id,m.patient_id,m.group_invoice_id,m.case_id, + t.id as item_id,t.item_Name,t.qty,t.batch_no,t.expiry,t.store_stock_id as ss_no,t.item_code,t.mrp,t.price, + t.amount,t.disc_amount,t.tamount,r.r_qty,r.id as return_id + from (invoice_med_master m join inv_med_item t on m.id=t.inv_med_id ) left join inv_med_item_return r on t.id=r.inv_item_id and return_status=0 + where m.id=".$inv_type_id. " order by t.item_Name,t.batch_no"; + + $p_id=$data['invoice_med_master'][0]->patient_id; + } + + $sql="select * from patient_master_exten + where id='".$p_id."' "; + $query = $this->db->query($sql); + $data['person_info']= $query->result(); + + $query = $this->db->query($sql_items); + $data['inv_items']= $query->result(); + + $this->load->view('Medical/Medical_Invoice_Return',$data); + } + + public function Invoice_Item_Return_new($inv_type_id,$inv_type=0) + { + $data['inv_type_id']=$inv_type_id; + $data['inv_type']=$inv_type; + + $p_id=0; + + $sql="select * from ipd_master where id='".$inv_type_id."' "; + $query = $this->db->query($sql); + $data['ipd_master']= $query->result(); + + $p_id=$data['ipd_master'][0]->p_id; + + + $sql="select * from patient_master_exten + where id='".$p_id."' "; + $query = $this->db->query($sql); + $data['person_info']= $query->result(); + + $this->load->view('Medical/IPD_return_medicine',$data); + } + + public function IPD_Item_Return_temp($inv_type_id,$inv_type=0) + { + $data['inv_type_id']=$inv_type_id; + $data['inv_type']=$inv_type; + + if($inv_type==0) + { + + $sql_items="select m.id as inv_id,m.inv_med_code,date_format(inv_date,'%d-%m-%Y') as str_inv_date,m.ipd_id,m.patient_id,m.group_invoice_id,m.case_id, + t.id as item_id,t.item_Name,t.qty,t.batch_no,t.expiry,t.store_stock_id as ss_no,t.item_code,t.mrp,t.price, + t.amount,t.disc_amount,t.tamount,r.r_qty,r.id as return_id + from (invoice_med_master m join inv_med_item t on m.id=t.inv_med_id ) + join inv_med_item_return r on t.id=r.inv_item_id and return_status=0 + where m.ipd_id=".$inv_type_id. " order by r.id desc"; + + + }elseif($inv_type==1){ + + $sql_items="select m.id as inv_id,m.inv_med_code,date_format(inv_date,'%d-%m-%Y') as str_inv_date,m.ipd_id,m.patient_id,m.group_invoice_id,m.case_id, + t.id as item_id,t.item_Name,t.qty,t.batch_no,t.expiry,t.store_stock_id as ss_no,t.item_code,t.mrp,t.price, + t.amount,t.disc_amount,t.tamount,r.r_qty,r.id as return_id + from (invoice_med_master m join inv_med_item t on m.id=t.inv_med_id ) + join inv_med_item_return r on t.id=r.inv_item_id and return_status=0 + where m.case_id=".$inv_type_id. " order by r.id desc"; + + }else{ + + $sql_items="select m.id as inv_id,m.inv_med_code,date_format(inv_date,'%d-%m-%Y') as str_inv_date,m.ipd_id,m.patient_id,m.group_invoice_id,m.case_id, + t.id as item_id,t.item_Name,t.qty,t.batch_no,t.expiry,t.store_stock_id as ss_no,t.item_code,t.mrp,t.price, + t.amount,t.disc_amount,t.tamount,r.r_qty,r.id as return_id + from (invoice_med_master m join inv_med_item t on m.id=t.inv_med_id ) + join inv_med_item_return r on t.id=r.inv_item_id and return_status=0 + where l m.id=".$inv_type_id. " order by r.id desc"; + + } + + $query = $this->db->query($sql_items); + $data['inv_items']= $query->result(); + + $this->load->view('Medical/Medical_Invoice_Return_list',$data); + } + + public function IPD_Item_list($inv_type_id) + { + $data['inv_type_id']=$inv_type_id; + + if (isset($_GET['term'])){ + $q = strtolower($_GET['term']); + + $sql="select m.id as inv_id,m.inv_med_code,date_format(inv_date,'%d-%m-%Y') as str_inv_date,m.ipd_id,m.patient_id,m.group_invoice_id,m.case_id, + t.id as item_id,t.item_Name,t.qty,t.batch_no,t.expiry,t.store_stock_id as ss_no,t.item_code,t.mrp,t.price, + t.amount,t.disc_amount,t.tamount,r.r_qty,r.id as return_id + from (invoice_med_master m join inv_med_item t on m.id=t.inv_med_id ) + left join inv_med_item_return r on t.id=r.inv_item_id and return_status=0 + where r.id is null and m.ipd_id=".$inv_type_id. " "; + + if(strlen($q)>0) + { + $sql.=" and t.item_name LIKE '".$q."%'"; + }else{ + $sql.=" and 1<>1 "; + } + + $sql.=" order by t.item_name,t.id"; + + $query = $this->db->query($sql); + + if($query->num_rows() > 0){ + foreach ($query->result_array() as $row){ + $new_row['label']=htmlentities(stripslashes($row['item_Name'])).' |B:'.htmlentities(stripslashes($row['batch_no'])). ' |Rs.'.htmlentities(stripslashes($row['mrp'])).' |Qty:'.htmlentities(stripslashes($row['qty'])); + $new_row['value']=htmlentities(stripslashes($row['item_Name'])); + $new_row['l_item_code']=htmlentities(stripslashes($row['item_id'])); + $new_row['l_Batch']=htmlentities(stripslashes($row['batch_no'])); + $new_row['l_mrp']=htmlentities(stripslashes($row['mrp'])); + $new_row['l_price']=htmlentities(stripslashes($row['price'])); + $new_row['l_qty']=htmlentities(stripslashes($row['qty'])); + $new_row['sql']=$sql; + $row_set[] = $new_row; //build an array + } + echo json_encode($row_set); //format the array into json data + }else{ + $new_row['sql']=$sql; + $row_set[] = $new_row; + echo json_encode($row_set); + } + } + + } + + + + public function Med_Return_invoice_search($r_inv_id) + { + $data['r_inv_id']=$r_inv_id; + $this->load->view('Medical/Med_Return_Invoice_search',$data); + } + + public function Invoice_Item_old() + { + $search_text=trim($this->input->post('search_text')); + $search_type=$this->input->post('search_type'); + + if($search_type==1){ + $sql="SELECT m.id AS inv_id,m.inv_med_code,m.inv_date,m.inv_name,m.inv_phone_number, + i.*,date_format(i.expiry,'%m-%Y') as exp_date,(i.disc_amount+disc_whole) as t_discount + FROM (invoice_med_master m JOIN inv_med_item i ON m.id=i.inv_med_id AND m.sale_return=0) + Where m.inv_date >=date_add(curdate(),interval -5 month) and m.inv_phone_number='$search_text' and m.ipd_id=0 and m.case_id=0 "; + $query = $this->db->query($sql); + $data['med_inv_item_list']= $query->result(); + } + + if($search_type==2){ + $sql="SELECT count(id) as no_rec,group_concat(id) as p_id_list + From patient_master where p_code like '".$search_text."' "; + $query = $this->db->query($sql); + $patient_master= $query->result(); + + $search_id_list="0"; + if($patient_master[0]->no_rec) + { + $search_id_list=$patient_master[0]->p_id_list; + } + + $sql="SELECT m.id AS inv_id,m.inv_med_code,m.inv_date,m.inv_name,m.inv_phone_number, + i.*,date_format(i.expiry,'%m-%Y') as exp_date,(i.disc_amount+disc_whole) as t_discount + FROM (invoice_med_master m JOIN inv_med_item i ON m.id=i.inv_med_id AND m.sale_return=0) + Where m.inv_date >=date_add(curdate(),interval -5 month) and m.patient_id in ($search_id_list) and m.ipd_id=0 and m.case_id=0"; + $query = $this->db->query($sql); + $data['med_inv_item_list']= $query->result(); + } + + if($search_type==3){ + $sql="SELECT m.id AS inv_id,m.inv_med_code,m.inv_date,m.inv_name,m.inv_phone_number, + i.*,date_format(i.expiry,'%m-%Y') as exp_date,(i.disc_amount+disc_whole) as t_discount + FROM (invoice_med_master m JOIN inv_med_item i ON m.id=i.inv_med_id AND m.sale_return=0) + Where m.inv_date >=date_add(curdate(),interval -5 month) and m.inv_med_code like '".$search_text."%' and m.ipd_id=0 and m.case_id=0"; + $query = $this->db->query($sql); + $data['med_inv_item_list']= $query->result(); + } + + if($search_type==4){ + $sql="SELECT m.id AS inv_id,m.inv_med_code,m.inv_date,m.inv_name,m.inv_phone_number, + i.*,date_format(i.expiry,'%m-%Y') as exp_date,(i.disc_amount+disc_whole) as t_discount + FROM (invoice_med_master m JOIN inv_med_item i ON m.id=i.inv_med_id AND m.sale_return=0) + Where m.inv_date >=date_add(curdate(),interval -5 month) and i.item_Name like '".$search_text."%' "; + $query = $this->db->query($sql); + $data['med_inv_item_list']= $query->result(); + } + + $this->load->view('Medical/Med_Item_old_list',$data); + } + + public function Invoice_old($inv_id) + { + $sql="Select * from invoice_med_master where id=$inv_id"; + $query = $this->db->query($sql); + $invoice_med_master= $query->result(); + + $phone_no=''; + $p_id=0; + $ipd_id=0; + + if(count($invoice_med_master)>0) + { + $phone_no=$invoice_med_master[0]->inv_phone_number; + $p_id=$invoice_med_master[0]->patient_id; + $ipd_id=$invoice_med_master[0]->ipd_id; + } + + if($ipd_id>0){ + $sql="SELECT m.id AS inv_id,m.inv_med_code,m.inv_date,m.inv_name,m.inv_phone_number, + i.*,date_format(i.expiry,'%m-%Y') as exp_date,(i.disc_amount+disc_whole) as t_discount, + m.net_amount + FROM (invoice_med_master m JOIN inv_med_item i ON m.id=i.inv_med_id AND m.sale_return=0) + Where m.id<>$inv_id and m.ipd_id=$ipd_id and m.case_id=0 + order by m.id desc"; + }else if($p_id>0) + { + $sql="SELECT m.id AS inv_id,m.inv_med_code,m.inv_date,m.inv_name,m.inv_phone_number, + i.*,date_format(i.expiry,'%m-%Y') as exp_date,(i.disc_amount+disc_whole) as t_discount, + m.net_amount + FROM (invoice_med_master m JOIN inv_med_item i ON m.id=i.inv_med_id AND m.sale_return=0) + Where m.patient_id='$p_id' and m.id<>$inv_id and m.ipd_id=0 and m.case_id=0 order by m.id desc"; + }else if($phone_no!=''){ + $sql="SELECT m.id AS inv_id,m.inv_med_code,m.inv_date,m.inv_name,m.inv_phone_number, + i.*,date_format(i.expiry,'%m-%Y') as exp_date,(i.disc_amount+disc_whole) as t_discount, + m.net_amount + FROM (invoice_med_master m JOIN inv_med_item i ON m.id=i.inv_med_id AND m.sale_return=0) + Where m.inv_phone_number='$phone_no' and m.id<>$inv_id and m.ipd_id=0 and m.case_id=0 order by m.id desc"; + }else{ + $sql="SELECT m.id AS inv_id,m.inv_med_code,m.inv_date,m.inv_name,m.inv_phone_number, + i.*,date_format(i.expiry,'%m-%Y') as exp_date,(i.disc_amount+disc_whole) as t_discount, + m.net_amount + FROM (invoice_med_master m JOIN inv_med_item i ON m.id=i.inv_med_id AND m.sale_return=0) + Where 1<>1 "; + } + + $query = $this->db->query($sql); + $data['med_inv_item_list']= $query->result(); + + $this->load->view('Medical/Med_old_invoice_list',$data); + } + + public function add_remove_item() + { + $this->load->model('Medical_M'); + + $inv_id=$this->input->post('inv_id'); + $item_id=$this->input->post('itemid'); + $rqty=$this->input->post('rqty'); + + $user = $this->ion_auth->user()->row(); + $user_update_info = $user->first_name.''. $user->last_name.'['.$user->id.']'.date('d-m-Y H:i:s'); + + $sql="select * from inv_med_item where id='".$item_id."' "; + $query = $this->db->query($sql); + $inv_med_item_result= $query->result_array(); + + $update=0; + $msg_box=""; + + if(count($inv_med_item_result)>0) + { + $inv_med_item=$inv_med_item_result[0]; + + $CGST=$inv_med_item['CGST_per']; + $SGST=$inv_med_item['SGST_per']; + + $item_rate=$inv_med_item['price2']; + $amount_value=$rqty*$item_rate*-1; + + $disc_total=$inv_med_item['disc_amount']+$inv_med_item['disc_whole']; + $amount=$inv_med_item['amount']; + $twdisc_amount=$inv_med_item['twdisc_amount']; + + $margin=$amount-$twdisc_amount; + $desc_per=$margin*100/$amount; + + $disc_amount=$amount_value*$desc_per/100; + $Tamount_value=$amount_value-$disc_amount; + + unset($inv_med_item['id']); + + $inv_med_item['inv_med_id'] =$inv_id; + + //Old Qty Sale + $old_qty=$inv_med_item['qty']; + $inv_med_item['qty'] =$rqty; + + $inv_med_item['return_item_id']=$item_id; + $inv_med_item['sale_return']=1; + + $inv_med_item['amount'] = $amount_value; + $inv_med_item['tamount'] = $Tamount_value; + + $inv_med_item['disc_amount']=$disc_amount; + $inv_med_item['disc_per']=$desc_per; + + $inv_med_item['disc_whole']='0'; + $inv_med_item['twdisc_amount']=$Tamount_value; + + $inv_med_item['update_by_remark']=$user_update_info; + $inv_med_item['update_by_id']=$user->id; + + $sql="select * from inv_med_item + where sale_return=1 and inv_med_id='$inv_id' and return_item_id='$item_id' "; + $query = $this->db->query($sql); + $inv_med_item_return= $query->result(); + + $sql="select sum(qty) as t_r_qty from inv_med_item + where sale_return=1 and return_item_id='$item_id' "; + $query = $this->db->query($sql); + $med_item_return_total= $query->result(); + + $tot_qty=0; + + if(count($med_item_return_total)>0) + { + $tot_return=$med_item_return_total[0]->t_r_qty; + $tot_qty=$old_qty-$tot_return; + } + + if($tot_qty>=$rqty) + { + if(count($inv_med_item_return)==0) + { + $update=$this->Medical_M->add_invoiceitem( $inv_med_item); + $msg_box="Added Return list"; + }else{ + $update=$inv_med_item_return[0]->id; + + $this->Medical_M->update_invoiceitem( $inv_med_item,$update); + $msg_box="Update Return "; + } + }else{ + $update=0; + $msg_box="Item Already Returned"; + } + + }else{ + $update=0; + $msg_box="No item found"; + } + + $this->Medical_M->update_invoice_final($inv_id); + + $sql="SELECT i.*,ifnull(DATEDIFF(expiry,CURDATE()),1000) AS no_day, + SUM(p.total_unit-p.total_sale_unit-total_return_unit-total_lost_unit)/p.packing AS cur_qty + FROM (inv_med_item i JOIN purchase_invoice_item p ON i.item_code=p.item_code AND p.remove_item=0 ) + where inv_med_id=".$inv_id." GROUP BY i.id"; + $query = $this->db->query($sql); + $data['inv_items']= $query->result(); + + $sql="select item_code + from inv_med_item where inv_med_id=".$inv_id." Group by item_code Having count(id)>1"; + $query = $this->db->query($sql); + $data['inv_items_multiple']= $query->result(); + + $sql="Select sum(amount) as Gtotal,sum(tamount) as tamt, + sum(CGST) as TCGST,sum(SGST) as TSGST,sum(disc_amount) as t_dis_amt + from inv_med_item where inv_med_id=".$inv_id; + $query = $this->db->query($sql); + $data['invoiceGtotal']= $query->result(); + + $user = $this->ion_auth->user()->row(); + $data['user_id'] = $user->id; + + $sql="select * from invoice_med_master where id=".$inv_id; + $query = $this->db->query($sql); + $data['invoiceMaster']= $query->result(); + + + $data['sale_return']=$data['invoiceMaster'][0]->sale_return; + + $content=$this->load->view('Medical/Med_Item_List',$data,true); + + $rvar=array( + 'update' =>$update, + 'msg_text'=>$msg_box, + 'content'=>$content + ); + + $encode_data = json_encode($rvar); + echo $encode_data; + + } + + public function Update_Return() + { + $this->load->model('Medical_M'); + + $r_qty=$this->input->post('u_qty'); + $item_id=$this->input->post('itemid'); + + $sql="select * from inv_med_item where id='".$item_id."' "; + $query = $this->db->query($sql); + $inv_med_item_result= $query->result_array(); + + $user = $this->ion_auth->user()->row(); + $user_update_info = $user->first_name.''. $user->last_name.'['.$user->id.']'.date('d-m-Y H:i:s'); + + $update=0; + $msg_box=""; + + if(count($inv_med_item_result)>0) + { + $inv_med_item=$inv_med_item_result[0]; + + $CGST=$inv_med_item['CGST_per']; + $SGST=$inv_med_item['SGST_per']; + + $item_rate=$inv_med_item['price']; + $amount_value=$r_qty*$item_rate; + + $disc=$inv_med_item['disc_per']; + $disc_amount=$amount_value*$disc/100; + + $Tamount_value=$amount_value-$disc_amount; + + $inv_med_item['inv_item_id'] = $inv_med_item['id']; + unset($inv_med_item['id']); + $inv_med_item['r_qty'] =$r_qty; + + $inv_med_item['amount'] = $amount_value; + $inv_med_item['tamount'] = $Tamount_value; + + $inv_med_item['update_remark']=$user_update_info; + + $sql="select * from inv_med_item_return where return_status=0 and inv_item_id='".$item_id."' "; + $query = $this->db->query($sql); + $inv_med_item_return= $query->result_array(); + + if(count($inv_med_item_return)==0) + { + $update=$this->Medical_M->insert_inv_med_item_return_add( $inv_med_item); + $msg_box="Added in Pending Return list"; + }else{ + $update=1; + $this->Medical_M->delete_return_item($item_id); + $update=$this->Medical_M->insert_inv_med_item_return_add($inv_med_item); + $msg_box="Alerady in Pending Return list, Now Update Again "; + } + + }else{ + $update=0; + $msg_box="No item found"; + } + + $rvar=array( + 'update' =>$update, + 'msg_text'=>$msg_box + ); + + $encode_data = json_encode($rvar); + echo $encode_data; + } + + + public function undo_Return() + { + $this->load->model('Medical_M'); + + $item_id=$this->input->post('itemid'); + + $update=1; + $msg_box=""; + + $this->Medical_M->delete_return_item($item_id); + + $rvar=array( + 'update' =>$update, + 'msg_text'=>$msg_box + ); + + $encode_data = json_encode($rvar); + echo $encode_data; + } + + + public function pre_reurn_item_list($inv_type_id,$inv_type=0) + { + $data['inv_type_id']=$inv_type_id; + $data['inv_type']=$inv_type; + + $p_id=0; + + if($inv_type==0) + { + $sql="select * from ipd_master where id='".$inv_type_id."' "; + $query = $this->db->query($sql); + $data['ipd_master']= $query->result(); + + $sql_items="select m.id as inv_id,m.inv_med_code,date_format(inv_date,'%d-%m-%Y') as str_inv_date,m.ipd_id,m.patient_id,m.group_invoice_id,m.case_id, + t.id as item_id,t.item_Name,t.qty,t.batch_no,t.expiry,t.store_stock_id as ss_no,t.item_code,t.mrp,t.price, + t.amount,t.disc_amount,t.tamount,t.r_qty,t.id as return_id + from (invoice_med_master m join inv_med_item_return t on m.id=t.inv_med_id and t.return_status=0) + where m.ipd_id=".$inv_type_id. " order by t.item_Name,t.batch_no"; + + $p_id=$data['ipd_master'][0]->p_id; + + }elseif($inv_type==1){ + $sql="select * from organization_case_master where id='".$inv_type_id."' "; + $query = $this->db->query($sql); + $data['org_master']= $query->result(); + + $sql_items="select m.id as inv_id,m.inv_med_code,date_format(inv_date,'%d-%m-%Y') as str_inv_date,m.ipd_id,m.patient_id,m.group_invoice_id,m.case_id, + t.id as item_id,t.item_Name,t.qty,t.batch_no,t.expiry,t.store_stock_id as ss_no,t.item_code,t.mrp,t.price, + t.amount,t.disc_amount,t.tamount,t.r_qty,t.id as return_id + from (invoice_med_master m join inv_med_item_return t on m.id=t.inv_med_id and t.return_status=0) + where m.case_id=".$inv_type_id. " order by t.item_Name,t.batch_no"; + + $p_id=$data['org_master'][0]->p_id; + }else{ + $sql="select * from invoice_med_master where id='".$inv_type_id."' "; + $query = $this->db->query($sql); + $data['invoice_med_master']= $query->result(); + + $sql_items="select m.id as inv_id,m.inv_med_code,date_format(inv_date,'%d-%m-%Y') as str_inv_date,m.ipd_id,m.patient_id,m.group_invoice_id,m.case_id, + t.id as item_id,t.item_Name,t.qty,t.batch_no,t.expiry,t.store_stock_id as ss_no,t.item_code,t.mrp,t.price, + t.amount,t.disc_amount,t.tamount,t.r_qty,t.id as return_id + from (invoice_med_master m join inv_med_item_return t on m.id=t.inv_med_id and t.return_status=0) + where m.id=".$inv_type_id. " order by t.item_Name,t.batch_no"; + + $p_id=$data['invoice_med_master'][0]->patient_id; + } + + $sql="select * from patient_master_exten + where id='".$p_id."' "; + $query = $this->db->query($sql); + $data['person_info']= $query->result(); + + $query = $this->db->query($sql_items); + $data['inv_items']= $query->result(); + + $this->load->view('Medical/Medical_Invoice_Return_pre',$data); + } + + + public function Med_Return_final($inv_type_id,$inv_type=0) + { + $this->load->model('Medical_M'); + + $data['inv_type_id']=$inv_type_id; + $data['inv_type']=$inv_type; + + $p_id=0; + + if($inv_type==0) + { + $sql="select * from ipd_master where id='".$inv_type_id."' "; + $query = $this->db->query($sql); + $data['ipd_master']= $query->result(); + + $sql_items="select m.id as inv_id,m.inv_med_code,date_format(inv_date,'%d-%m-%Y') as str_inv_date,m.ipd_id,m.patient_id,m.group_invoice_id,m.case_id, + t.id as ritem_id,t.inv_item_id,t.item_Name,t.qty,t.batch_no,t.expiry,t.store_stock_id as ss_no,t.item_code,t.mrp,t.price, + t.amount,t.disc_per,t.disc_amount,t.tamount,t.r_qty,t.id as return_id + from (invoice_med_master m join inv_med_item_return t on m.id=t.inv_med_id and t.return_status=0) + where m.ipd_id=".$inv_type_id. " order by t.item_Name,t.batch_no"; + + $p_id=$data['ipd_master'][0]->p_id; + + }elseif($inv_type==1){ + $sql="select * from organization_case_master where id='".$inv_type_id."' "; + $query = $this->db->query($sql); + $data['org_master']= $query->result(); + + $sql_items="select m.id as inv_id,m.inv_med_code,date_format(inv_date,'%d-%m-%Y') as str_inv_date,m.ipd_id,m.patient_id,m.group_invoice_id,m.case_id, + t.id as ritem_id,t.inv_item_id,t.item_Name,t.qty,t.batch_no,t.expiry,t.store_stock_id as ss_no,t.item_code,t.mrp,t.price, + t.amount,t.disc_per,t.disc_amount,t.tamount,t.r_qty,t.id as return_id + from (invoice_med_master m join inv_med_item_return t on m.id=t.inv_med_id and t.return_status=0) + where m.case_id=".$inv_type_id. " order by t.item_Name,t.batch_no"; + + $p_id=$data['org_master'][0]->p_id; + }else{ + $sql="select * from invoice_med_master where id='".$inv_type_id."' "; + $query = $this->db->query($sql); + $data['invoice_med_master']= $query->result(); + + $sql_items="select m.id as inv_id,m.inv_med_code,date_format(inv_date,'%d-%m-%Y') as str_inv_date,m.ipd_id,m.patient_id,m.group_invoice_id,m.case_id, + t.id as ritem_id,t.inv_item_id,t.item_Name,t.qty,t.batch_no,t.expiry,t.store_stock_id as ss_no,t.item_code,t.mrp,t.price, + t.amount,t.disc_per,t.disc_amount,t.tamount,t.r_qty,t.id as return_id + from (invoice_med_master m join inv_med_item_return t on m.id=t.inv_med_id and t.return_status=0) + where m.id=".$inv_type_id. " order by t.item_Name,t.batch_no"; + + $p_id=$data['invoice_med_master'][0]->patient_id; + } + + $sql="select * from patient_master_exten + where id='".$p_id."' "; + $query = $this->db->query($sql); + $data['person_info']= $query->result(); + + $query = $this->db->query($sql_items); + $data['inv_items']= $query->result(); + + foreach($data['inv_items'] as $row) + { + $store_stock_id=$row->ss_no; + + $ritem_id=$row->ritem_id; + + $itemid=$row->inv_item_id; + + $item_rate=$row->price; + + $current_qty=$row->qty-$row->r_qty; + + $inv_id=$row->inv_id; + + $amount_value=$current_qty*$item_rate; + + $disc_per=$row->disc_per; + + $disc_amount=$amount_value*$disc_per/100; + + $Tamount_value=$amount_value-$disc_amount; + + $data['update_inv_med_item'] = array( + 'qty' => $current_qty, + 'disc_amount' => $disc_amount, + 'amount' => $amount_value, + 'tamount' => $Tamount_value, + 'store_stock_id' => $store_stock_id, + 'inv_med_id' => $inv_id, + ); + + $update_return_item = array( + 'return_status' => '1', + ); + + $this->Medical_M->update_return_item($update_return_item,$ritem_id); + + $this->Medical_M->update_invoiceitem($data['update_inv_med_item'],$itemid); + + $this->Medical_M->update_invoice_final($inv_id); + } + + redirect('/Medical/pre_reurn_item_list/'.$inv_type_id.'/'.$inv_type=0); + } + + + public function Med_Return_print($inv_type_id,$inv_type=0) + { + $this->load->model('Medical_M'); + + $data['inv_type_id']=$inv_type_id; + $data['inv_type']=$inv_type; + + $p_id=0; + + if($inv_type==0) + { + $sql="select * from v_ipd_list where id='".$inv_type_id."' "; + $query = $this->db->query($sql); + $data['ipd_master']= $query->result(); + + $sql_items="select m.id as inv_id,m.inv_med_code,date_format(inv_date,'%d-%m-%Y') as str_inv_date, + date_format(return_date_time,'%d-%m-%Y') as str_ret_date,m.ipd_id,m.patient_id,m.group_invoice_id,m.case_id, + t.id as ritem_id,t.inv_item_id,t.item_Name,t.qty,t.batch_no,t.expiry,t.store_stock_id as ss_no,t.item_code,t.mrp,t.price, + t.update_remark,t.return_date_time, + t.amount,t.disc_per,t.disc_amount,t.tamount,t.r_qty,t.id as return_id + from (invoice_med_master m join inv_med_item_return t on m.id=t.inv_med_id and t.return_status=1) + where m.ipd_id=".$inv_type_id. " order by t.return_date_time,t.item_Name,t.batch_no"; + + $p_id=$data['ipd_master'][0]->p_id; + + }elseif($inv_type==1){ + $sql="select * from organization_case_master where id='".$inv_type_id."' "; + $query = $this->db->query($sql); + $data['org_master']= $query->result(); + + $sql_items="select m.id as inv_id,m.inv_med_code,date_format(inv_date,'%d-%m-%Y') as str_inv_date, + date_format(return_date_time,'%d-%m-%Y') as str_ret_date,m.ipd_id,m.patient_id,m.group_invoice_id,m.case_id, + t.id as ritem_id,t.inv_item_id,t.item_Name,t.qty,t.batch_no,t.expiry,t.store_stock_id as ss_no,t.item_code,t.mrp,t.price,t.update_remark,t.return_date_time, + t.amount,t.disc_per,t.disc_amount,t.tamount,t.r_qty,t.id as return_id + from (invoice_med_master m join inv_med_item_return t on m.id=t.inv_med_id and t.return_status=1) + where m.case_id=".$inv_type_id. " order by t.return_date_time,t.item_Name,t.batch_no"; + + $p_id=$data['org_master'][0]->p_id; + }else{ + $sql="select * from invoice_med_master where id='".$inv_type_id."' "; + $query = $this->db->query($sql); + $data['invoice_med_master']= $query->result(); + + $sql_items="select m.id as inv_id,m.inv_med_code,date_format(inv_date,'%d-%m-%Y') as str_inv_date, + date_format(return_date_time,'%d-%m-%Y') as str_ret_date,m.ipd_id,m.patient_id,m.group_invoice_id,m.case_id, + t.id as ritem_id,t.inv_item_id,t.item_Name,t.qty,t.batch_no,t.expiry,t.store_stock_id as ss_no,t.item_code,t.mrp,t.price,t.update_remark,t.return_date_time, + t.amount,t.disc_per,t.disc_amount,t.tamount,t.r_qty,t.id as return_id + from (invoice_med_master m join inv_med_item_return t on m.id=t.inv_med_id and t.return_status=1) + where m.id=".$inv_type_id. " order by t.return_date_time,t.item_Name,t.batch_no"; + + $p_id=$data['invoice_med_master'][0]->patient_id; + } + + $sql="select * from patient_master_exten + where id='".$p_id."' "; + $query = $this->db->query($sql); + $data['person_info']= $query->result(); + + $query = $this->db->query($sql_items); + $data['inv_items']= $query->result(); + + //load mPDF library + $this->load->library('m_pdf'); + + $this->m_pdf->pdf->SetWatermarkText(M_store); + $this->m_pdf->pdf->showWatermarkText = false; + + $file_name='Medical_Return_'.date('Ymdhis').".pdf"; + + $filepath=$file_name; + + + $content=$this->load->view('Medical/Print/Medical_return_medicine',$data,TRUE); + + + //echo $content; + + //generate the PDF from the given html + $this->m_pdf->pdf->WriteHTML($content); + + //download it. + $this->m_pdf->pdf->Output($filepath,"I"); + + //$this->load->view('Medical/Medical_Invoice_Return_print',$data); + } + + + //Medical Notification + public function get_medical_bill_pending_higher() + { + $sql="SELECT COUNT(i.id) AS No_IPD + FROM inv_med_group m JOIN ipd_master i ON m.ipd_id=i.id + WHERE i.ipd_status=0 AND m.med_type=1 AND m.net_amount>0 + AND payment_balance>=50000"; + $query = $this->db->query($sql); + $ipd_pending_balance= $query->result(); + + $No_IPD=$ipd_pending_balance[0]->No_IPD; + if($No_IPD>0) + { + echo 'High Bal. :'.$No_IPD; + }else{ + echo ''; + } + } + + + +} \ No newline at end of file diff --git a/old_code_ci3/controllers/Medical_1.php b/old_code_ci3/controllers/Medical_1.php new file mode 100644 index 0000000..700a216 --- /dev/null +++ b/old_code_ci3/controllers/Medical_1.php @@ -0,0 +1,3046 @@ +load->view('Medical/Dashboard'); + } + + public function DrugList() + { + $this->load->view('Medical/Drug_Details'); + + //$sql="select item_id,itemname,dosage from drug_temp_25072017"; + //$query = $this->db->query($sql); + //$data['drug_data']= $query->result(); + + //$this->load->view('Medical/Drug_Details_all',$data); + } + + public function Purchase() + { + $this->load->view('Medical/Purchase/supplier_list'); + } + + public function PurchaseNew() + { + $sql="select * from med_supplier"; + $query = $this->db->query($sql); + $data['supplier_data']= $query->result(); + + $this->load->view('Medical/Purchase/new_purchase_invoice',$data); + } + + public function SupplierList() + { + $sql="select * from med_supplier"; + $query = $this->db->query($sql); + $data['supplier_data']= $query->result(); + + $this->load->view('Medical/Purchase/Supplier_master',$data); + } + + public function PurchaseInvoice() + { + $sdata=$this->input->post('txtsearch'); + + $sdata = preg_replace('/[^A-Za-z0-9_ \-]/', '', $sdata); + + if(trim($sdata)=='') + { + $sql="select p.id,p.Invoice_no,p.date_of_invoice,p.sid,s.name_supplier,s.short_name,s.gst_no, + sum(t.amount) as tamount,count(t.id) as no_item + from (purchase_invoice p join med_supplier s on p.sid=s.sid) + left join purchase_invoice_item t on p.id=t.purchase_id + group by p.id + order by p.id desc limit 50"; + }else{ + $sql="select p.id,p.Invoice_no,p.date_of_invoice,p.sid,s.name_supplier,s.short_name,s.gst_no, + sum(t.amount) as tamount,count(t.id) as no_item + from (purchase_invoice p join med_supplier s on p.sid=s.sid) + left join purchase_invoice_item t on p.id=t.purchase_id + where (p.Invoice_no LIKE '%".$sdata."' + OR s.name_supplier LIKE '%".$sdata."%' + OR s.short_name LIKE '%".$sdata."%' + OR s.gst_no = '".$sdata."%') + group by p.id order by p.id desc limit 50"; + } + + $query = $this->db->query($sql); + $data['purchase_list']= $query->result(); + + $this->load->view('Medical/Purchase/purchase_supp_list',$data); + } + + public function PurchaseInvoiceEdit($inv_id) + { + $sql="select p.id,p.Invoice_no,p.date_of_invoice,date_format(p.date_of_invoice,'%d/%m/%Y') as str_date_of_invoice, + p.sid,s.name_supplier,s.short_name,s.gst_no + from purchase_invoice p join med_supplier s on p.sid=s.sid + where p.id=".$inv_id; + $query = $this->db->query($sql); + $data['purchase_invoice']= $query->result(); + + $sql="select * from purchase_invoice_item where purchase_id=".$inv_id; + $query = $this->db->query($sql); + $data['purchase_invoice_item']= $query->result(); + + $this->load->view('Medical/Purchase/Purchase_Invoice_Edit',$data); + } + + public function SupplierListSub() + { + $sql="select * from med_supplier"; + $query = $this->db->query($sql); + $data['supplier_data']= $query->result(); + + $this->load->view('Medical/Purchase/Supplier_master_sub',$data); + } + + public function SupplierEdit($sid=0) + { + $sql="select * from med_supplier where sid=".$sid; + $query = $this->db->query($sql); + $data['supplier_data']= $query->result(); + + $this->load->view('Medical/Purchase/Supplier_Edit',$data); + } + + public function CreatePurchase() + { + if (!$this->input->is_ajax_request()) { exit('no valid req.'); } + + $FormRules = array( + array( + 'field' => 'input_invoicecode', + 'label' => 'Invoice No', + 'rules' => 'required|min_length[3]|max_length[30]' + ) + ); + + $this->form_validation->set_rules($FormRules); + + if ($this->form_validation->run() == TRUE) + { + $sid=$this->input->post('input_supplier'); + $invoice_code=$this->input->post('input_invoicecode'); + $d_invoice=$this->input->post('datepicker_invoice'); + + $Udata = array( + 'sid'=> $sid, + 'date_of_invoice'=> str_to_MysqlDate($d_invoice), + 'Invoice_no'=> $invoice_code + ); + + $this->load->model('Medical_M'); + + $inser_id=$this->Medical_M->insert_purchase($Udata); + $send_msg="Added Successfully"; + + if($inser_id>0) + { + $show_text=Show_Alert('success','Success',$send_msg); + }else{ + $show_text=Show_Alert('danger','Error',$send_msg); + } + + $rvar=array( + 'insertid' =>$inser_id, + 'show_text'=>$show_text + ); + + $encode_data = json_encode($rvar); + echo $encode_data; + + } + else{ + $send_msg=validation_errors(); + $rvar=array( + 'insertid' =>0, + 'show_text'=>Show_Alert('danger','Error',$send_msg) + ); + $encode_data = json_encode($rvar); + echo $encode_data; + } + } + + + + + public function SupplierUpdate($sid=0) + { + if (!$this->input->is_ajax_request()) { exit('no valid req.'); } + + $FormRules = array( + array( + 'field' => 'input_name_supplier', + 'label' => 'Supplier Name', + 'rules' => 'required|min_length[3]|max_length[30]' + ), + array( + 'field' => 'input_short_name', + 'label' => 'Short Name', + 'rules' => 'required|min_length[1]|max_length[30]' + ), + array( + 'field' => 'input_gst_no', + 'label' => 'GST No.', + 'rules' => 'required|min_length[5]|max_length[15]' + ), + array( + 'field' => 'input_state', + 'label' => 'State', + 'rules' => 'required|min_length[1]|max_length[20]' + ) + ); + + $this->form_validation->set_rules($FormRules); + + if ($this->form_validation->run() == TRUE) + { + $sid=$this->input->post('hid_sid'); + $name_supplier=$this->input->post('input_name_supplier'); + $short_name=$this->input->post('input_short_name'); + $contact_no=$this->input->post('input_contact_no'); + $gst_no=$this->input->post('input_gst_no'); + $city=$this->input->post('input_city'); + $state=$this->input->post('input_state'); + + $Udata = array( + 'name_supplier'=> $name_supplier, + 'short_name'=> $short_name, + 'contact_no'=> $contact_no, + 'gst_no'=> $gst_no, + 'city'=> $city, + 'state'=> $state + ); + + $this->load->model('Medical_M'); + + if($sid>0) + { + $inser_id=$this->Medical_M->update_supplier($Udata,$sid); + $send_msg="Saved Successfully"; + }else{ + $inser_id=$this->Medical_M->insert_supplier($Udata); + $send_msg="Added Successfully"; + } + + if($inser_id>0) + { + $show_text=Show_Alert('success','Success',$send_msg); + }else{ + $show_text=Show_Alert('danger','Error',$send_msg); + } + + $rvar=array( + 'insertid' =>$inser_id, + 'show_text'=>$show_text + ); + + $encode_data = json_encode($rvar); + echo $encode_data; + + } + else{ + $send_msg=validation_errors(); + $rvar=array( + 'insertid' =>0, + 'show_text'=>Show_Alert('danger','Error',$send_msg) + ); + $encode_data = json_encode($rvar); + echo $encode_data; + } + + } + + public function StockDrugList() + { + $this->load->view('Medical/Medical_stock_drug'); + } + + public function add_stock() + { + if (!$this->input->is_ajax_request()) { exit('no valid req.'); } + + $FormRules = array( + array( + 'field' => 'input_product_code', + 'label' => 'Product Code', + 'rules' => 'required|min_length[3]|max_length[30]' + ), + array( + 'field' => 'input_product_name', + 'label' => 'Product Name', + 'rules' => 'required|min_length[3]|max_length[30]' + ), + array( + 'field' => 'input_product_mrp', + 'label' => 'Product MRP', + 'rules' => 'required|min_length[1]|max_length[10]' + ), + array( + 'field' => 'input_selling_price', + 'label' => 'Selling Price', + 'rules' => 'required|min_length[1]|max_length[10]' + ), + array( + 'field' => 'input_qty', + 'label' => 'Product Qty', + 'rules' => 'required|min_length[1]|max_length[10]' + ), + array( + 'field' => 'input_package', + 'label' => 'Package', + 'rules' => 'required|min_length[1]|max_length[10]' + ), + array( + 'field' => 'input_HSNCODE', + 'label' => 'HSNCODE', + 'rules' => 'required|min_length[1]|max_length[10]' + ), + array( + 'field' => 'input_CGST', + 'label' => 'CGST', + 'rules' => 'required|min_length[1]|max_length[10]' + ), + array( + 'field' => 'input_SGST', + 'label' => 'SGST', + 'rules' => 'required|min_length[1]|max_length[10]' + ) + ); + + $this->form_validation->set_rules($FormRules); + + if ($this->form_validation->run() == TRUE) + { + $item_code=$this->input->post('input_product_code'); + + if($item_code=='IC0000000') + { + $item_code='MC'.date('ymdhis'); + } + + $selling_price=$this->input->post('input_selling_price'); + + $package=$this->input->post('input_package'); + $qty=$this->input->post('input_qty'); + $total_unit=$package*$qty; + $unit_rate=$selling_price/$qty; + + $this->load->model('Medical_M'); + $data = array( + 'item_code' => $item_code, + 'item_name' => $this->input->post('input_product_name'), + 'rack_no' => $this->input->post('input_rack_no'), + 'shelf_no' => $this->input->post('input_shelf_no'), + 'cold_storage' => $this->input->post('input_storage'), + 'batch_no' => $this->input->post('input_batch_code'), + 'qty' => $this->input->post('input_qty'), + 'packing' => $this->input->post('input_package'), + 'expiry_date' => str_to_MysqlDate($this->input->post('datepicker_doe')), + 'mrp' => $this->input->post('input_product_mrp'), + 'purchase_price' => $this->input->post('input_purchase_price'), + 'selling_price' => $this->input->post('input_selling_price'), + 'total_unit' => $total_unit, + 'unit_rate' => $unit_rate, + 'margin' => $this->input->post('input_margin'), + 'formulation' => $this->input->post('input_formulation'), + 'stock_date' => str_to_MysqlDate($this->input->post('datepicker_stock')), + 'min_qty' => $this->input->post('input_minqty'), + 'HSNCODE' => $this->input->post('input_HSNCODE'), + 'CGST' => $this->input->post('input_CGST'), + 'SGST' => $this->input->post('input_SGST'), + 'IGST' => $this->input->post('input_IGST'), + 'dosage' => $this->input->post('input_dosage'), + 'supplier_id' => $this->input->post('input_supplier') + ); + + $data_drug = array( + 'item_id' => $item_code, + 'itemname' => $this->input->post('input_product_name'), + 'mrp' => $this->input->post('input_product_mrp'), + 'formulation' => $this->input->post('input_formulation'), + 'HSNCODE' => $this->input->post('input_HSNCODE'), + 'CGST' => $this->input->post('input_CGST'), + 'SGST' => $this->input->post('input_SGST'), + 'IGST' => $this->input->post('input_IGST'), + 'dosage' => $this->input->post('input_dosage') + ); + $show_text=''; + + $sql="select * from drug_temp where item_id='".$item_code."'"; + $query = $this->db->query($sql); + $drug_item= $query->result(); + + if(count($drug_item)>0) + { + $inser_id=$this->Medical_M->update_drug($data_drug,$item_code); + }else{ + $inser_id=$this->Medical_M->insert_drug_add($data_drug); + } + + if($inser_id>0) + { + $inser_id=0; + $inser_id=$this->Medical_M->insert_stock_add($data); + if($inser_id>0) + { + $send_msg="Added"; + }else{ + $send_msg="Error : Add in Stock Table"; + } + }else{ + $send_msg="Error : Addition data in Master Drug Table"; + } + + if($inser_id>0) + { + $show_text=Show_Alert('success','Success',$send_msg); + }else{ + $show_text=Show_Alert('danger','Error',$send_msg); + } + + $rvar=array( + 'insertid' =>$inser_id, + 'product_code' => $item_code, + 'show_text'=>$show_text + ); + + $encode_data = json_encode($rvar); + echo $encode_data; + + } + else + { + $send_msg=validation_errors(); + $rvar=array( + 'insertid' =>0, + 'show_text'=>Show_Alert('danger','Error',$send_msg) + ); + $encode_data = json_encode($rvar); + echo $encode_data; + } + } + + + public function update_master() + { + if (!$this->input->is_ajax_request()) { exit('no valid req.'); } + + $FormRules = array( + array( + 'field' => 'input_product_code', + 'label' => 'Product Code', + 'rules' => 'required|min_length[3]|max_length[30]' + ), + array( + 'field' => 'input_product_name', + 'label' => 'Product Name', + 'rules' => 'required|min_length[3]|max_length[30]' + ), + array( + 'field' => 'input_product_mrp', + 'label' => 'Product MRP', + 'rules' => 'required|min_length[1]|max_length[10]' + ), + array( + 'field' => 'input_selling_price', + 'label' => 'Selling Price', + 'rules' => 'required|min_length[1]|max_length[10]' + ), + array( + 'field' => 'input_HSNCODE', + 'label' => 'HSNCODE', + 'rules' => 'required|min_length[1]|max_length[10]' + ), + array( + 'field' => 'input_CGST', + 'label' => 'CGST', + 'rules' => 'required|min_length[1]|max_length[10]' + ), + array( + 'field' => 'input_SGST', + 'label' => 'SGST', + 'rules' => 'required|min_length[1]|max_length[10]' + ) + ); + + $this->form_validation->set_rules($FormRules); + + if ($this->form_validation->run() == TRUE) + { + $item_code=$this->input->post('input_product_code'); + + $this->load->model('Medical_M'); + + $data_drug = array( + 'item_id' => $item_code, + 'itemname' => $this->input->post('input_product_name'), + 'mrp' => $this->input->post('input_product_mrp'), + 'formulation' => $this->input->post('input_formulation'), + 'HSNCODE' => $this->input->post('input_HSNCODE'), + 'CGST' => $this->input->post('input_CGST'), + 'SGST' => $this->input->post('input_SGST'), + 'IGST' => $this->input->post('input_IGST'), + 'dosage' => $this->input->post('input_dosage') + ); + $show_text=''; + + $sql="select * from drug_temp where item_id='".$item_code."'"; + $query = $this->db->query($sql); + $drug_item= $query->result(); + + if(count($drug_item)>0) + { + $inser_id=$this->Medical_M->update_drug($data_drug,$item_code); + }else{ + $inser_id=$this->Medical_M->insert_drug_add($data_drug); + } + + if($inser_id>0) + { + $inser_id=0; + $inser_id=$this->Medical_M->insert_stock_add($data); + if($inser_id>0) + { + $send_msg="Update"; + }else{ + $send_msg="Error : Edit in Drug Master"; + } + }else{ + $send_msg="Error : Addition data in Master Drug Table"; + } + + if($inser_id>0) + { + $show_text=Show_Alert('success','Success',$send_msg); + }else{ + $show_text=Show_Alert('danger','Error',$send_msg); + } + + $rvar=array( + 'insertid' =>$inser_id, + 'product_code' => $item_code, + 'show_text'=>$show_text + ); + + $encode_data = json_encode($rvar); + echo $encode_data; + + } + else + { + $send_msg=validation_errors(); + $rvar=array( + 'insertid' =>0, + 'show_text'=>Show_Alert('danger','Error',$send_msg) + ); + $encode_data = json_encode($rvar); + echo $encode_data; + } + } + + + + public function update_stock($ss_no) + { + if (!$this->input->is_ajax_request()) { exit('no valid req.'); } + + $FormRules = array( + array( + 'field' => 'input_product_code', + 'label' => 'Product Code', + 'rules' => 'required|min_length[3]|max_length[30]' + ), + array( + 'field' => 'input_product_name', + 'label' => 'Product Name', + 'rules' => 'required|min_length[3]|max_length[30]' + ) + , + array( + 'field' => 'input_product_mrp', + 'label' => 'Product MRP', + 'rules' => 'required|min_length[1]|max_length[10]' + ), + array( + 'field' => 'input_selling_price', + 'label' => 'Selling Price', + 'rules' => 'required|min_length[1]|max_length[10]' + ), + array( + 'field' => 'input_qty', + 'label' => 'Product Qty', + 'rules' => 'required|min_length[1]|max_length[10]' + ), + array( + 'field' => 'input_package', + 'label' => 'Package', + 'rules' => 'required|min_length[1]|max_length[10]' + ), + array( + 'field' => 'input_HSNCODE', + 'label' => 'HSNCODE', + 'rules' => 'required|min_length[1]|max_length[10]' + ), + array( + 'field' => 'input_CGST', + 'label' => 'CGST', + 'rules' => 'required|min_length[1]|max_length[10]' + ), + array( + 'field' => 'input_SGST', + 'label' => 'SGST', + 'rules' => 'required|min_length[1]|max_length[10]' + ) + ); + + $this->form_validation->set_rules($FormRules); + + if ($this->form_validation->run() == TRUE) + { + $item_code=$this->input->post('input_product_code'); + + $selling_price=$this->input->post('input_selling_price'); + + $package=$this->input->post('input_package'); + $qty=$this->input->post('input_qty'); + $total_unit=$package*$qty; + $unit_rate=$selling_price/$qty; + + $this->load->model('Medical_M'); + $data = array( + 'item_code' => $item_code, + 'item_name' => $this->input->post('input_product_name'), + 'rack_no' => $this->input->post('input_rack_no'), + 'shelf_no' => $this->input->post('input_shelf_no'), + 'cold_storage' => $this->input->post('input_storage'), + 'batch_no' => $this->input->post('input_batch_code'), + 'qty' => $this->input->post('input_qty'), + 'packing' => $this->input->post('input_package'), + 'expiry_date' => str_to_MysqlDate($this->input->post('datepicker_doe')), + 'mrp' => $this->input->post('input_product_mrp'), + 'purchase_price' => $this->input->post('input_purchase_price'), + 'selling_price' => $this->input->post('input_selling_price'), + 'total_unit' => $total_unit, + 'unit_rate' => $unit_rate, + 'margin' => $this->input->post('input_margin'), + 'formulation' => $this->input->post('input_formulation'), + 'stock_date' => str_to_MysqlDate($this->input->post('datepicker_stock')), + 'min_qty' => $this->input->post('input_minqty'), + 'HSNCODE' => $this->input->post('input_HSNCODE'), + 'CGST' => $this->input->post('input_CGST'), + 'SGST' => $this->input->post('input_SGST'), + 'IGST' => $this->input->post('input_IGST'), + 'supplier_id' => $this->input->post('input_supplier') + ); + + $show_text=''; + + $is_update_stock=0; + + $is_update_stock=$this->Medical_M->update_stock_upd($data,$ss_no); + + if($is_update_stock>0) + { + $send_msg="Updated"; + }else{ + $send_msg="Error : Update in Stock Table"; + } + + + if($is_update_stock>0) + { + $show_text=Show_Alert('success','Updated',$send_msg); + }else{ + $show_text=Show_Alert('danger','Error',$send_msg); + } + + $rvar=array( + 'is_update_stock' =>$is_update_stock, + 'product_code' => $item_code, + 'show_text'=>$show_text + ); + + $encode_data = json_encode($rvar); + echo $encode_data; + + } + else + { + $send_msg=validation_errors(); + $rvar=array( + 'is_update_stock' =>0, + 'show_text'=>Show_Alert('danger','Error',$send_msg) + ); + $encode_data = json_encode($rvar); + echo $encode_data; + } + } + + + public function purchase_update_stock($inv_id,$return_stock=0) + { + if (!$this->input->is_ajax_request()) { exit('no valid req.'); } + + $sql="select * from purchase_invoice where id=".$inv_id; + $query = $this->db->query($sql); + $purchase_invoice= $query->result(); + + $FormRules = array( + + array( + 'field' => 'input_drug', + 'label' => 'Product Name', + 'rules' => 'required|min_length[3]|max_length[30]' + ), + array( + 'field' => 'input_product_mrp', + 'label' => 'Product MRP', + 'rules' => 'required|min_length[1]|max_length[10]' + ), + array( + 'field' => 'input_selling_price', + 'label' => 'Selling Price', + 'rules' => 'required|min_length[1]|max_length[10]' + ), + array( + 'field' => 'input_Qty', + 'label' => 'Product Qty', + 'rules' => 'required|min_length[1]|max_length[10]' + ), + array( + 'field' => 'input_package', + 'label' => 'Package', + 'rules' => 'required|min_length[1]|max_length[10]' + ), + array( + 'field' => 'input_HSNCODE', + 'label' => 'HSNCODE', + 'rules' => 'required|min_length[1]|max_length[10]' + ), + array( + 'field' => 'input_CGST', + 'label' => 'CGST', + 'rules' => 'required|min_length[1]|max_length[10]' + ), + array( + 'field' => 'input_SGST', + 'label' => 'SGST', + 'rules' => 'required|min_length[1]|max_length[10]' + ), + array( + 'field' => 'input_purchase_price', + 'label' => 'Purchase Price', + 'rules' => 'required|min_length[1]|max_length[10]' + ) + ); + + $this->form_validation->set_rules($FormRules); + + if ($this->form_validation->run() == TRUE) + { + $item_code=$this->input->post('input_product_code'); + $item_id=$this->input->post('invoice_item_id'); + + $this->load->model('Medical_M'); + + $Pdata = array( + 'purchase_id' => $inv_id, + 'item_code' => $item_code, + 'item_name' => $this->input->post('input_drug'), + 'packing' => $this->input->post('input_package'), + 'batch_no' => $this->input->post('input_batch_code'), + 'purchase_price' => $this->input->post('input_purchase_price'), + 'expiry_date' => str_to_MysqlDate($this->input->post('datepicker_doe')), + 'mrp' => $this->input->post('input_product_mrp'), + + 'qty' => $this->input->post('input_Qty'), + 'qty_free' => $this->input->post('input_Qty_Free'), + + 'discount' => $this->input->post('input_disc_price'), + + 'CGST_per' => $this->input->post('input_CGST'), + 'SGST_per' => $this->input->post('input_SGST'), + + 'HSNCODE' => $this->input->post('input_HSNCODE'), + + 'cold_storage' => $this->input->post('input_storage'), + 'shelf_no' => $this->input->post('input_shelf_no'), + 'rack_no' => $this->input->post('input_rack_no'), + 'stock_date' => $purchase_invoice[0]->date_of_invoice, + + 'selling_price' => $this->input->post('input_selling_price'), + + 'item_return' => $return_stock + ); + + $show_text=''; + + $is_update_stock=0; + + if($item_id<1) + { + $is_update_stock=$this->Medical_M->insert_purchase_item($Pdata); + }else{ + $is_update_stock=$this->Medical_M->update_purchase_item($Pdata,$item_id); + } + + if($is_update_stock>0) + { + $send_msg="Updated"; + }else{ + $send_msg="Error : Update in Stock Table"; + } + + + if($is_update_stock>0) + { + $show_text=Show_Alert('success','Updated',$send_msg); + }else{ + $show_text=Show_Alert('danger','Error',$send_msg); + } + + $rvar=array( + 'is_update_stock' =>$is_update_stock, + 'product_code' => $item_code, + 'show_text'=>$show_text + ); + + $encode_data = json_encode($rvar); + echo $encode_data; + + } + else + { + $send_msg=validation_errors(); + $rvar=array( + 'is_update_stock' =>0, + 'show_text'=>Show_Alert('danger','Error',$send_msg) + ); + $encode_data = json_encode($rvar); + echo $encode_data; + } + } + + function purchase_invoice_item_edit($inv_id,$inv_item_id) + { + $sql="select * from purchase_invoice_item where id=".$inv_item_id." and purchase_id=".$inv_id; + $query = $this->db->query($sql); + $purchase_invoice_item= $query->result(); + + if(count($purchase_invoice_item)>0) + { + $rvar=array( + 'is_update_stock'=>'1', + 'item_id' =>$purchase_invoice_item[0]->id, + 'product_code' =>$purchase_invoice_item[0]->item_code, + 'product_mrp' => $purchase_invoice_item[0]->mrp, + 'selling_price'=>$purchase_invoice_item[0]->selling_price, + 'batch_code'=>$purchase_invoice_item[0]->batch_no, + 'disc_price'=>$purchase_invoice_item[0]->discount, + 'qty'=>$purchase_invoice_item[0]->qty, + 'qty_free'=>$purchase_invoice_item[0]->qty_free, + 'package'=>$purchase_invoice_item[0]->packing, + 'purchase_price'=>$purchase_invoice_item[0]->purchase_price, + 'datepicker_doe'=>$purchase_invoice_item[0]->expiry_date, + 'drug'=>$purchase_invoice_item[0]->Item_name + ); + }else{ + $rvar=array( + 'is_update_stock'=>'0', + 'show_text'=>$sql + ); + } + + $encode_data = json_encode($rvar); + echo $encode_data; + + } + + public function purchase_invoice_item_list($inv_id) + { + $sql="select * from purchase_invoice_item where purchase_id='".$inv_id."' "; + $query = $this->db->query($sql); + $data['purchase_item']= $query->result(); + + $sql="select * from purchase_invoice where id='".$inv_id."' "; + $query = $this->db->query($sql); + $data['purchase_invoice']= $query->result(); + + $this->load->view('Medical/Purchase/purchase_invoice_item',$data); + + } + + public function purchase_invoice_item_delete($inv_id,$inv_item_del) + { + $this->load->model('Medical_M'); + + $is_update_stock=$this->Medical_M->delete_purchase_item($inv_id,$inv_item_del); + + $rvar=array( + 'is_update_stock' =>1, + 'show_text'=>'' + ); + $encode_data = json_encode($rvar); + echo $encode_data; + } + + public function AddDrugStock($drug_item_code) + { + $sql="select * from drug_temp where item_id='".$drug_item_code."' "; + $query = $this->db->query($sql); + $data['drug_item']= $query->result(); + + $sql="select * from stock_addition where item_code='".$drug_item_code."' "; + $query = $this->db->query($sql); + $data['drug_stock_item']= $query->result(); + + $sql="select * from med_supplier "; + $query = $this->db->query($sql); + $data['med_supplier']= $query->result(); + + $this->load->view('Medical/Drug_Stock_Add',$data); + } + + public function UpdateDrugStock($ss_no) + { + $sql="select * from stock_addition where ss_no='".$ss_no."' "; + $query = $this->db->query($sql); + $data['stock_item']= $query->result(); + + $sql="select * from med_supplier "; + $query = $this->db->query($sql); + $data['med_supplier']= $query->result(); + + $this->load->view('Medical/Stock_Update',$data); + } + + public function load_stock_data($item_code) + { + $sql="select * from stock_addition where item_code='".$item_code."' "; + $query = $this->db->query($sql); + $data['drug_stock_item']= $query->result(); + + echo ' + + + + + + + + + + + + + + '; + + $srno=0; + + foreach($data['drug_stock_item'] as $row) + { + $srno=$srno+1; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + } + + echo ''; + + echo ' + + + + + + + + + + + + +
Item CodeItem NameFormulationStorage/Shelf/Rack No.Batch No.Qty /Sale QtyExpiryMRPRate/Unit
'.$row->item_code.''.$row->item_name.''.$row->formulation.''.$row->cold_storage.'/'.$row->shelf_no.'/'.$row->rack_no.''.$row->batch_no.''.$row->total_unit.'/'.$row->total_sale_unit.''.$row->expiry_date.''.$row->mrp.''.$row->unit_rate.'
Item CodeItem NameFormulationStorage/Shelf/Rack No.Batch No.Qty /Sale QtyExpiryMRPRate/Unit
'; + } + + public function Invoice_counter() + { + $sql="select * from invoice_med_master"; + $query = $this->db->query($sql); + $data['invoiceMaster']= $query->result(); + + $sql="select * from inv_med_item"; + $query = $this->db->query($sql); + $data['inv_items']= $query->result(); + + $sql="select sum(amount) as Gtotal from inv_med_item"; + $query = $this->db->query($sql); + $data['invoiceGtotal']= $query->result(); + + $sql="select * from doctor_master where active=1"; + $query = $this->db->query($sql); + $data['doclist']= $query->result(); + + if($data['invoiceMaster'][0]->case_id > 0) + { + $sql="select * from organization_case_master where id=".$data['invoiceMaster'][0]->case_id; + $query = $this->db->query($sql); + $data['OCaseMaster']= $query->result(); + } + + $this->load->view('Medical/Medical_Invoice_V',$data); + + } + + public function Invoice_Med_Draft() + { + $sql="select *,if(ipd_id>0,'IPD',if(case_id>0,'Org.','Cash')) as ipd_case_id from invoice_med_master where 1<>1 "; + $query = $this->db->query($sql); + $data['invoice_list']= $query->result(); + + $this->load->view('Medical/Draft_Med_Invoice',$data); + } + + public function Invoice_med_show($inv_id) + { + $sql="select *,if(ipd_credit>0,'Credit to IPD','CASH') as credit_status, + if(case_credit>0,'Credit to Org','CASH') as credit_org_status from invoice_med_master where id=".$inv_id; + $query = $this->db->query($sql); + $data['invoiceMaster']= $query->result(); + + $sql="select * from inv_med_item where inv_med_id=".$inv_id; + $query = $this->db->query($sql); + $data['inv_items']= $query->result(); + + $sql="select sum(amount) as Gtotal,sum(tamount) as tamt,sum(CGST) as TCGST,sum(SGST) as TSGST,sum(disc_amount) as t_dis_amt from inv_med_item where inv_med_id=".$inv_id; + $query = $this->db->query($sql); + $data['invoiceGtotal']= $query->result(); + + $sql="select * from doctor_master where active=1"; + $query = $this->db->query($sql); + $data['doclist']= $query->result(); + + $sql="select *, + GET_AGE_1(dob,age,age_in_month,estimate_dob) AS age from patient_master where id='".$data['invoiceMaster'][0]->patient_id."' "; + $query = $this->db->query($sql); + $data['person_info']= $query->result(); + + $data['org_Name']=""; + $ipd_id=$data['invoiceMaster'][0]->ipd_id; + + if($ipd_id>0) + { + $sql="select * from ipd_master where id=".$ipd_id; + $query = $this->db->query($sql); + $ipd_master= $query->result(); + + if(count($ipd_master)>0) + { + $p_ipd_id=$ipd_master[0]->id; + $p_ipd_code=$ipd_master[0]->ipd_code; + + if($ipd_master[0]->case_id>0) + { + $sql="select * from organization_case_master where id=".$ipd_master[0]->case_id; + $query = $this->db->query($sql); + $org_master= $query->result(); + + if(count($org_master)>0) + { + $data['org_Name']=$org_master[0]->insurance_company_name; + } + + } + + } + } + + if($data['invoiceMaster'][0]->case_id > 0) + { + $sql="select * from organization_case_master where id=".$data['invoiceMaster'][0]->case_id; + $query = $this->db->query($sql); + $data['OCaseMaster']= $query->result(); + } + + $this->load->view('Medical/Medical_Invoice_V',$data); + } + + public function search_customer() + { + $this->load->view('Medical/Search_Patient'); + } + + public function Invoice_counter_new($pno,$ipd_id,$case_id) + { + + $p_fname=''; + $select_doc=0; + + if($pno>0){ + $sql="select *,if(gender=1,'Male','FeMale') as xgender, + GET_AGE_1(dob,age,age_in_month,estimate_dob) AS age from patient_master where id='".$pno."' "; + $query = $this->db->query($sql); + $person_info= $query->result(); + + $sql="select doc_id from opd_master where p_id='".$pno."' order by opd_id desc limit 1"; + $query = $this->db->query($sql); + $data['opd_master']= $query->result(); + + if(count($data['opd_master'])>0) + { + $select_doc=$data['opd_master'][0]->doc_id; + }else{ + $select_doc=0; + } + + $sql="select l.doc_id from ipd_master p join ipd_master_doc_list l on p.id=l.ipd_id + where p.ipd_status=0 and p.p_id=".$pno." "; + $query = $this->db->query($sql); + $data['ipd_master_docid']= $query->result(); + + if(count($data['ipd_master_docid'])>0) + { + $select_doc=$data['ipd_master_docid'][0]->doc_id; + } + + $data['org_Name']=""; + + if($ipd_id<1) + { + $sql="select * from ipd_master where ipd_status=0 and p_id=".$person_info[0]->id; + $query = $this->db->query($sql); + $ipd_master= $query->result(); + + if(count($ipd_master)>0) + { + $p_ipd_id=$ipd_master[0]->id; + $p_ipd_code=$ipd_master[0]->ipd_code; + if($ipd_master[0]->case_id>0) + { + $sql="select * from organization_case_master where id=".$ipd_master[0]->case_id; + $query = $this->db->query($sql); + $org_master= $query->result(); + + if(count($org_master)>0) + { + $data['org_Name']=$org_master[0]->insurance_company_name; + } + + } + + }else{ + $p_ipd_id=0; + $p_ipd_code=''; + } + }else{ + $sql="select * from ipd_master where id=".$ipd_id; + $query = $this->db->query($sql); + $ipd_master= $query->result(); + + if(count($ipd_master)>0) + { + $p_ipd_id=$ipd_master[0]->id; + $p_ipd_code=$ipd_master[0]->ipd_code; + + if($ipd_master[0]->case_id>0) + { + $sql="select * from organization_case_master where id=".$ipd_master[0]->case_id; + $query = $this->db->query($sql); + $org_master= $query->result(); + + if(count($org_master)>0) + { + $data['org_Name']=$org_master[0]->insurance_company_name; + } + + } + + }else{ + $p_ipd_id=0; + $p_ipd_code=''; + } + } + + $p_fname=$person_info[0]->p_fname; + $p_pcode=$person_info[0]->p_code; + $p_pid=$person_info[0]->id; + + + }else{ + $p_fname=''; + $p_pcode=''; + $p_pid=0; + $p_ipd_id=0; + $p_ipd_code=''; + } + + $sql="select * from doctor_master where active=1"; + $query = $this->db->query($sql); + $data['doclist']= $query->result(); + + $this->load->model('Medical_M'); + + $data['invoice_med_master'] = array( + 'patient_id' => $p_pid, + 'ipd_id' => $p_ipd_id, + 'ipd_code' => $p_ipd_code, + 'case_id' => $case_id, + 'inv_date' => str_to_MysqlDate(date('d/m/Y')), + 'inv_name' => $p_fname, + 'patient_code' => $p_pcode, + 'doc_id' => $select_doc + ); + + $inser_id=$this->Medical_M->add_invoice( $data['invoice_med_master']); + + if($inser_id) + { + $sql="select *,if(ipd_credit>0,'Credit to IPD','CASH') as credit_status from invoice_med_master where id=".$inser_id; + $query = $this->db->query($sql); + $data['invoiceMaster']= $query->result(); + + $sql="select * from inv_med_item where inv_med_id=".$inser_id; + $query = $this->db->query($sql); + $data['inv_items']= $query->result(); + + $sql="select sum(amount) as Gtotal,sum(tamount) as tamt,sum(CGST) as TCGST,sum(SGST) as TSGST,sum(disc_amount) as t_dis_amt from inv_med_item where inv_med_id=".$inser_id; + $query = $this->db->query($sql); + $data['invoiceGtotal']= $query->result(); + + $sql="select * from doctor_master where active=1"; + $query = $this->db->query($sql); + $data['doclist']= $query->result(); + + $this->load->view('Medical/Medical_Invoice_V',$data); + } + } + + public function get_drug_old(){ + + if (isset($_GET['term'])){ + $q = strtolower($_GET['term']); + + $sql="select * from stock_addition where expiry_date>date_add(sysdate(),interval 3 month) and update_stock_qty3) + { + $sql=$sql. " or batch_no like '".$q."%'"; + } + + $sql=$sql." limit 20"; + + $query = $this->db->query($sql); + + if($query->num_rows() > 0){ + foreach ($query->result_array() as $row){ + $new_row['label']=htmlentities(stripslashes($row['item_name'])).' | '.htmlentities(stripslashes($row['batch_no'])).' | '.htmlentities(stripslashes($row['expiry_date'])); + $new_row['value']=htmlentities(stripslashes($row['item_name'])); + $new_row['l_item_code']=htmlentities(stripslashes($row['item_code'])); + $new_row['l_ss_no']=htmlentities(stripslashes($row['ss_no'])); + $new_row['l_Batch']=htmlentities(stripslashes($row['batch_no'])); + $new_row['l_Expiry']=htmlentities(stripslashes($row['expiry_date'])); + $new_row['l_mrp']=htmlentities(stripslashes($row['mrp'])); + $new_row['l_unit_rate']=htmlentities(stripslashes($row['unit_rate'])); + $new_row['sql']=$sql; + $row_set[] = $new_row; //build an array + } + echo json_encode($row_set); //format the array into json data + } + } + } + + public function get_drug(){ + + if (isset($_GET['term'])){ + $q = strtolower($_GET['term']); + + $sql="select * from purchase_invoice_item + where expiry_date>date_add(sysdate(),interval 3 month) + and (total_unit-total_sale_unit-total_return_unit-total_lost_unit)>0 + and (item_name like '".$q."%' "; + + if(strlen($q)>3) + { + $sql=$sql. " or batch_no like '".$q."%'"; + } + + $sql=$sql.") limit 20"; + + $query = $this->db->query($sql); + + if($query->num_rows() > 0){ + foreach ($query->result_array() as $row){ + $new_row['label']=htmlentities(stripslashes($row['Item_name'])).' | '.htmlentities(stripslashes($row['batch_no'])).' | '.htmlentities(stripslashes($row['expiry_date'])); + $new_row['value']=htmlentities(stripslashes($row['Item_name'])); + $new_row['l_item_code']=htmlentities(stripslashes($row['item_code'])); + $new_row['l_ss_no']=htmlentities(stripslashes($row['id'])); + $new_row['l_Batch']=htmlentities(stripslashes($row['batch_no'])); + $new_row['l_Expiry']=htmlentities(stripslashes($row['expiry_date'])); + $new_row['l_mrp']=htmlentities(stripslashes($row['mrp'])); + $new_row['l_unit_rate']=htmlentities(stripslashes($row['selling_unit_rate'])); + $new_row['sql']=$sql; + $row_set[] = $new_row; //build an array + } + echo json_encode($row_set); //format the array into json data + } + } + } + + + public function get_drug_master(){ + + if (isset($_GET['term'])){ + $q = strtolower($_GET['term']); + + $sql="select * from purchase_invoice_item p + where p.id in (select max(id) from purchase_invoice_item t + where t.Item_name like '".$q."%' group by t.Item_name ) + order by p.Item_name "; + + $sql=$sql." limit 20"; + + $query = $this->db->query($sql); + + if($query->num_rows() > 0){ + foreach ($query->result_array() as $row){ + $new_row['label']=htmlentities(stripslashes($row['Item_name'])).' | '.htmlentities(stripslashes($row['packing'])).' | '.htmlentities(stripslashes($row['mrp'])); + $new_row['value']=htmlentities(stripslashes($row['Item_name'])); + $new_row['l_item_code']=htmlentities(stripslashes($row['item_code'])); + $new_row['l_mrp']=htmlentities(stripslashes($row['mrp'])); + + $new_row['l_packing']=htmlentities(stripslashes($row['packing'])); + $new_row['l_CGST_per']=htmlentities(stripslashes($row['CGST_per'])); + $new_row['l_SGST_per']=htmlentities(stripslashes($row['SGST_per'])); + $new_row['l_HSNCODE']=htmlentities(stripslashes($row['HSNCODE'])); + + $new_row['l_purchase_price']=htmlentities(stripslashes($row['purchase_price'])); + + $new_row['l_package']=htmlentities(stripslashes($row['packing'])); + $new_row['l_disc_price']=htmlentities(stripslashes($row['discount'])); + + $row_set[] = $new_row; //build an array + } + echo json_encode($row_set); //format the array into json data + } + } + } + + public function get_formulation_desc(){ + + if (isset($_GET['term'])){ + $q = strtolower($_GET['term']); + + $sql="select * from drugs_formulation where formulation_desc like '".$q."%'"; + $query = $this->db->query($sql); + + if($query->num_rows() > 0){ + foreach ($query->result_array() as $row){ + $new_row['label']=htmlentities(stripslashes($row['formulation_desc'])); + $new_row['value']=htmlentities(stripslashes($row['formulation_desc'])); + $row_set[] = $new_row; //build an array + } + echo json_encode($row_set); //format the array into json data + } + } + } + + public function go_final() + { + $this->load->model('Medical_M'); + + $inv_id=$this->input->post('inv_id'); + $doc_id=$this->input->post('doc_id'); + $doc_name=$this->input->post('doc_name'); + $remark_ipd=$this->input->post('input_remark_ipd'); + $patient_code=$this->input->post('patient_code'); + $custmer_Name=$this->input->post('custmer_Name'); + $ipd_credit=$this->input->post('ipd_credit'); + + $org_credit=$this->input->post('org_credit'); + $inv_date=$this->input->post('inv_date'); + + $sql="select * from patient_master where p_code='".$patient_code."' "; + $query = $this->db->query($sql); + $person_info= $query->result(); + + $sql="select * from doctor_master where id='".$doc_id."' "; + $query = $this->db->query($sql); + $doc_info= $query->result(); + + $sql="select * from invoice_med_master where id=".$inv_id; + $query = $this->db->query($sql); + $data['invoice_master']= $query->result(); + + if($this->ion_auth->in_group('InvoiceDateChanged') || $this->ion_auth->in_group('admin')) + { + $inv_date=str_to_MysqlDate($inv_date); + }else{ + $inv_date=$data['invoice_master'][0]->inv_date; + } + + if(count($person_info)>0) + { + $patient_id=$person_info[0]->id; + $patient_code_u=$patient_code; + $custmer_Name=$person_info[0]->p_fname; + }else{ + $patient_id=0; + $patient_code_u=''; + } + + $refername=$doc_name; + + if(count($doc_info)>0) + { + $refername=$doc_info[0]->p_fname; + } + + $data = array( + 'patient_id' => $patient_id, + 'patient_code' => $patient_code_u, + 'doc_id' => $doc_id, + 'doc_name' => $refername, + 'inv_name' => $custmer_Name, + 'remark_ipd'=>$remark_ipd, + 'ipd_credit'=>$ipd_credit, + 'case_credit'=>$org_credit, + 'inv_date' => $inv_date + ); + + $inser_id=$this->Medical_M->update_in_upv_item($data,$inv_id); + $this->Medical_M->update_invoice_group($inv_id); + $this->Medical_M->update_invoice_final($inv_id); + + } + + public function getDrugTable() + { + + $requestData= $_REQUEST; + + $columns = array( + // datatable column index => database column name + 0 =>'item_id', + 1 => 'itemname', + 2 => 'formulation', + 3=> 'genericname', + 5=> 'company_name_idx', + 4=> 'mrp' + ); + + // getting total number records without any search + $sql_f_all = "select * "; + + $sql_count="Select count(*) as no_rec "; + + $sql_from=" from drug_temp "; + + $total_sql=$sql_count.$sql_from; + + $query = $this->db->query($total_sql); + $data['total_rec']= $query->result(); + $totalData=$data['total_rec'][0]->no_rec; + + $totalFiltered = $totalData; // when there is no search parameter then total number rows = total number filtered rows. + + $sql_where=" WHERE 1 = 1"; + + $sql_where_flag=0; + + // getting records as per search parameters + if( !empty($requestData['columns'][0]['search']['value']) ){ //item_id + $sql_where.=" AND item_id LIKE '".$requestData['columns'][0]['search']['value']."%' "; + $sql_where_flag=1; + } + + if( !empty($requestData['columns'][1]['search']['value']) ){ //itemname + $sql_where.=" AND itemname LIKE '%".$requestData['columns'][1]['search']['value']."%' "; + $sql_where_flag=1; + } + + if( !empty($requestData['columns'][2]['search']['value']) ){ //dosage + $sql_where.=" AND formulation LIKE '%".$requestData['columns'][2]['search']['value']."%' "; + $sql_where_flag=1; + } + + if( !empty($requestData['columns'][3]['search']['value']) ){ //formulation + $sql_where.=" AND genericname LIKE '%".$requestData['columns'][3]['search']['value']."%' "; + $sql_where_flag=1; + } + + if( !empty($requestData['columns'][4]['search']['value']) ){ //therapeutic + $sql_where.=" AND company_name_idx LIKE '%".$requestData['columns'][4]['search']['value']."%' "; + $sql_where_flag=1; + } + + $total_filer_sql=$sql_count.$sql_from.$sql_where; + + $query = $this->db->query($total_filer_sql); + $data['total_rec_filter']= $query->result();// when there is a search parameter then we have to modify total number filtered rows as per search result. + $totalFiltered=$data['total_rec_filter'][0]->no_rec; + + + $sql_order=" ORDER BY ". $columns[$requestData['order'][0]['column']]." ".$requestData['order'][0]['dir']." LIMIT ".$requestData['start']." ,".$requestData['length']." "; // adding length + + $Result_sql=$sql_f_all.$sql_from.$sql_where.$sql_order; + + $query = $this->db->query($Result_sql); + $rdata= $query->result_array(); + + $output = array( + "draw" => intval( $requestData['draw'] ), // for every request/draw by clientside , they send a number as a parameter, when they recieve a response/data they first check the draw number, so we are sending same number in draw. + "recordsTotal" => intval( $totalData ), // total number of records + "recordsFiltered" => intval( $totalFiltered ), // total number of records after searching, if there is no searching then totalFiltered = totalData + "data" => array(), + "sql" => $Result_sql + ); + + foreach($rdata as $aRow) + { + $row = array(); + + foreach($columns as $col) + { + $row[] = $aRow[$col]; + } + + $output['data'][] = $row; + } + + echo json_encode($output); // send data as json format + } + + public function getInvoiceTable() + { + + $requestData= $_REQUEST; + + $columns = array( + // datatable column index => database column name + 0 => 'inv_med_code', + 1 => 'inv_name', + 2 => 'Code', + 3=> 'inv_date_str', + 4=> 'net_amount', + 5=> 'payment_received', + 6=> 'payment_balance', + 7=> 'id', + 8=> 'ipd_status', + 9=> 'org_status', + 10=> 'ipd_credit_type', + 11=> 'org_credit_type' + ); + + // getting total number records without any search + $sql_f_all = "select m.inv_med_code,m.inv_name, + Concat(if(m.patient_code<>'',Concat(m.patient_code,'
'),''), + if(m.ipd_code<>'',Concat('',m.ipd_code,'
'),''), + if(m.case_id>0,Concat(o.case_id_code,'
'),'')) as Code , + m.inv_date,Date_Format(m.inv_date,'%d-%m-%Y') as inv_date_str, + m.doc_name,m.net_amount,m.payment_received,m.payment_balance,m.id,i.ipd_status, + o.status as org_status, + m.ipd_credit as ipd_credit_type,m.case_credit as org_credit_type "; + + $sql_count="Select count(*) as no_rec "; + + $sql_from=" from (invoice_med_master m left join ipd_master i on m.ipd_id=i.id) + left join organization_case_master o on m.case_id=o.id "; + + $total_sql=$sql_count.$sql_from; + + $query = $this->db->query($total_sql); + $data['total_rec']= $query->result(); + $totalData=$data['total_rec'][0]->no_rec; + + $totalFiltered = $totalData; // when there is no search parameter then total number rows = total number filtered rows. + + $sql_where=" WHERE 1 = 1"; + + $sql_where_flag=0; + + // getting records as per search parameters + if( !empty($requestData['columns'][0]['search']['value']) ){ //inv_med_code + $sql_where.=" AND inv_med_code LIKE '%".$requestData['columns'][0]['search']['value']."' "; + $sql_where_flag=1; + } + + if( !empty($requestData['columns'][1]['search']['value']) ){ //inv_name + $sql_where.=" AND inv_name LIKE '%".$requestData['columns'][1]['search']['value']."%' "; + $sql_where_flag=1; + } + + if( !empty($requestData['columns'][2]['search']['value']) ){ //patient_code + $sql_where.=" AND (patient_code LIKE '%".$requestData['columns'][2]['search']['value']."' OR + m.ipd_code LIKE '%".$requestData['columns'][2]['search']['value']."' OR + o.case_id_code LIKE '%".$requestData['columns'][2]['search']['value']."' )"; + $sql_where_flag=1; + } + + $total_filer_sql=$sql_count.$sql_from.$sql_where; + + $query = $this->db->query($total_filer_sql); + $data['total_rec_filter']= $query->result();// when there is a search parameter then we have to modify total number filtered rows as per search result. + $totalFiltered=$data['total_rec_filter'][0]->no_rec; + + $sql_order=" ORDER BY id desc,". $columns[$requestData['order'][0]['column']]." ".$requestData['order'][0]['dir']." LIMIT ".$requestData['start']." ,".$requestData['length']." "; // adding length + + $Result_sql=$sql_f_all.$sql_from.$sql_where.$sql_order; + + $query = $this->db->query($Result_sql); + $rdata= $query->result_array(); + + $output = array( + "draw" => intval( $requestData['draw'] ), // for every request/draw by clientside , they send a number as a parameter, when they recieve a response/data they first check the draw number, so we are sending same number in draw. + "recordsTotal" => intval( $totalData ), // total number of records + "recordsFiltered" => intval( $totalFiltered ), // total number of records after searching, if there is no searching then totalFiltered = totalData + "data" => array(), + "sql" => $Result_sql + ); + + foreach($rdata as $aRow) + { + $row = array(); + + foreach($columns as $col) + { + $row[] = $aRow[$col]; + } + + $output['data'][] = $row; + } + + echo json_encode($output); // send data as json format + + } + + + public function getStockDrugTable() + { + + $requestData= $_REQUEST; + + $columns = array( + // datatable column index => database column name + 0 =>'ss_no', + 1 =>'item_code', + 2 => 'item_name', + 3 => 'formulation', + 4 => 'rack_no', + 5 => 'shelf_no', + 6 => 'batch_no', + 7 => 'total_unit', + 8 => 'expiry_date', + 9 => 'mrp', + 10 => 'update_stock_qty' + ); + + // getting total number records without any search + $sql_f_all = "select * "; + + $sql_count="Select count(*) as no_rec "; + + $sql_from=" from stock_addition "; + + $total_sql=$sql_count.$sql_from; + + $query = $this->db->query($total_sql); + $data['total_rec']= $query->result(); + $totalData=$data['total_rec'][0]->no_rec; + + $totalFiltered = $totalData; // when there is no search parameter then total number rows = total number filtered rows. + + $sql_where=" WHERE 1 = 1 "; + + $sql_where_flag=0; + + // getting records as per search parameters + if( !empty($requestData['columns'][0]['search']['value']) ){ //item_id + $sql_where.=" AND item_code LIKE '".$requestData['columns'][0]['search']['value']."%' "; + $sql_where_flag=1; + } + + if( !empty($requestData['columns'][1]['search']['value']) ){ //itemname + $sql_where.=" AND item_name LIKE '%".$requestData['columns'][1]['search']['value']."%' "; + $sql_where_flag=1; + } + + if( !empty($requestData['columns'][2]['search']['value']) ){ //dosage + $sql_where.=" AND formulation LIKE '%".$requestData['columns'][2]['search']['value']."%' "; + $sql_where_flag=1; + } + + if( !empty($requestData['columns'][3]['search']['value']) ){ //dosage + $sql_where.=" AND rack_no LIKE '%".$requestData['columns'][3]['search']['value']."%' "; + $sql_where_flag=1; + } + + if( !empty($requestData['columns'][4]['search']['value']) ){ //dosage + $sql_where.=" AND shelf_no LIKE '%".$requestData['columns'][4]['search']['value']."%' "; + $sql_where_flag=1; + } + + if( !empty($requestData['columns'][5]['search']['value']) ){ //dosage + $sql_where.=" AND batch_no LIKE '%".$requestData['columns'][5]['search']['value']."%' "; + $sql_where_flag=1; + } + + $total_filer_sql=$sql_count.$sql_from.$sql_where; + + $query = $this->db->query($total_filer_sql); + $data['total_rec_filter']= $query->result();// when there is a search parameter then we have to modify total number filtered rows as per search result. + $totalFiltered=$data['total_rec_filter'][0]->no_rec; + + $sql_order=" ORDER BY ". $columns[$requestData['order'][0]['column']]." ".$requestData['order'][0]['dir']." LIMIT ".$requestData['start']." ,".$requestData['length']." "; // adding length + + $Result_sql=$sql_f_all.$sql_from.$sql_where.$sql_order; + + $query = $this->db->query($Result_sql); + $rdata= $query->result_array(); + + $output = array( + "draw" => intval( $requestData['draw'] ), // for every request/draw by clientside , they send a number as a parameter, when they recieve a response/data they first check the draw number, so we are sending same number in draw. + "recordsTotal" => intval( $totalData ), // total number of records + "recordsFiltered" => intval( $totalFiltered ), // total number of records after searching, if there is no searching then totalFiltered = totalData + "data" => array(), + "sql" => $Result_sql + ); + + foreach($rdata as $aRow) + { + $row = array(); + + foreach($columns as $col) + { + $row[] = $aRow[$col]; + } + + $output['data'][] = $row; + } + + echo json_encode($output); // send data as json format + + } + + public function confirm_payment() + { + if (!$this->input->is_ajax_request()) { exit('no valid req.'); } + + $this->load->model('Medical_M'); + + $invoice_id=$this->input->post('med_invoice_id'); + $input_amount_paid=$this->input->post('input_amount_paid'); + + $sql="select * from invoice_med_master where id='".$invoice_id."'"; + $query = $this->db->query($sql); + $inv_master= $query->result(); + + $user = $this->ion_auth->user()->row(); + $user_id = $user->id; + $user_name = $user->first_name.''. $user->last_name; + + $showcontent1='
+
+ Print +
+
+ Payment Method by : '; + + $showcontent2='
'; + + $pay_remark=''; + + if($inv_master[0]->patient_id>0) + { + $Customerof_type=1; + }else{ + $Customerof_type=3; + } + + if($this->input->post('mode')==1) + { + $paydata = array( + 'payment_mode'=> '1', + 'Customerof_type'=>$Customerof_type, + 'Customerof_id'=>$inv_master[0]->patient_id, + 'Customerof_code'=>$inv_master[0]->patient_code, + 'Medical_invoice_id'=>$inv_master[0]->id, + 'Medical_invoice_code'=>$inv_master[0]->inv_med_code, + 'credit_debit'=>'0', + 'amount'=>$input_amount_paid, + 'payment_date'=>date('Y-m-d H:i:s'), + 'remark'=>$pay_remark, + 'update_by'=>$user_name.'['.$user_id.']', + 'update_by_id'=>$user_id + ); + + $insert_id=$this->Medical_M->insert_payment($paydata); + + $data = array( + + 'payment_mode'=> '1', + 'payment_status'=>'1', + 'invoice_status'=>'1', + 'payment_id'=>$insert_id, + 'payment_mode_desc'=>'Cash', + 'confirm_invoice'=>date('Y-m-d H:i:s'), + 'prepared_by'=>$user_name.'['.$user_id.']' + ); + + $this->Medical_M->update_in_upv_item( $data,$invoice_id); + + $status='CASH'; + $showcontent=$showcontent1.$status.$showcontent2; + + $rvar=array( + 'update' =>1, + 'showcontent'=>$showcontent + ); + + $encode_data = json_encode($rvar); + echo $encode_data; + } + + if($this->input->post('mode')==2) + { + $FormRules = array( + array( + 'field' => 'input_card_mac', + 'label' => 'Card Bank Name', + 'rules' => 'required|min_length[3]|max_length[30]' + ), + array( + 'field' => 'input_card_digit', + 'label' => 'Card Last 4 Digit ', + 'rules' => 'required|min_length[4]|max_length[4]' + ), + array( + 'field' => 'input_card_bank', + 'label' => 'Bank Name ', + 'rules' => 'required|min_length[1]|max_length[50]' + ), + array( + 'field' => 'input_card_tran', + 'label' => 'Card Transcation ID', + 'rules' => 'required|min_length[3]|max_length[15]' + ) + ); + + $this->form_validation->set_rules($FormRules); + + if ($this->form_validation->run() == TRUE) + { + $paydata = array( + 'payment_mode'=> '2', + 'Customerof_type'=>$Customerof_type, + 'Customerof_id'=>$inv_master[0]->patient_id, + 'Customerof_code'=>$inv_master[0]->patient_code, + 'Medical_invoice_id'=>$inv_master[0]->id, + 'Medical_invoice_code'=>$inv_master[0]->inv_med_code, + 'credit_debit'=>'0', + 'amount'=>$input_amount_paid, + 'payment_date'=>date('Y-m-d H:i:s'), + 'remark'=>$pay_remark, + 'update_by'=>$user_name.'['.$user_id.']', + 'update_by_id'=>$user_id, + 'card_bank'=>$this->input->post('input_card_mac'), + 'cust_card'=>$this->input->post('input_card_bank'), + 'card_remark'=>$this->input->post('input_card_digit'), + 'card_tran_id'=>$this->input->post('input_card_tran') + ); + + $insert_id=$this->Medical_M->insert_payment($paydata); + + $data = array( + 'payment_mode'=> '2', + 'payment_status'=>'1', + 'invoice_status'=>'1', + 'payment_mode_desc'=>'Bank Card', + 'confirm_invoice'=>date('Y-m-d H:i:s'), + 'payment_id'=>$insert_id, + 'card_bank'=>$this->input->post('input_card_mac'), + 'card_remark'=>$this->input->post('input_card_digit'), + 'cust_card'=>$this->input->post('input_card_bank'), + 'card_tran_id'=>$this->input->post('input_card_tran'), + 'prepared_by'=>$user_name.'['.$user_id.']', + 'prepared_by_id'=>$user_id + ); + + $this->Medical_M->update_in_upv_item( $data,$invoice_id); + + $status='Bank Card'; + $showcontent=$showcontent1.$status.$showcontent2; + + $rvar=array( + 'update' =>1, + 'showcontent'=>$showcontent + ); + $encode_data = json_encode($rvar); + echo $encode_data; + } + else{ + $send_error=validation_errors(); + $rvar=array( + 'update' =>0, + 'error_text'=>$send_error + ); + $encode_data = json_encode($rvar); + echo $encode_data; + } + } + + if($this->input->post('mode')==3) + { + $data = array( + + 'payment_mode'=> '3', + 'payment_status'=>'1', + 'invoice_status'=>'1', + 'confirm_invoice'=>date('d/m/Y H:m:s'), + 'payment_mode_desc'=>'IPD Credit', + 'ipd_id'=>$this->input->post('ipd_id'), + 'prepared_by'=>$user_name.'['.$user_id.']' + ); + + $this->Medical_M->update_in_upv_item( $data,$invoice_id); + + $status='IPD Credit'; + $showcontent=$showcontent1.$status.$showcontent2; + + $rvar=array( + 'update' =>1, + 'showcontent'=>$showcontent + ); + + $encode_data = json_encode($rvar); + echo $encode_data; + } + + if($this->input->post('mode')==4) + { + $data = array( + 'payment_mode'=> '4', + 'payment_status'=>'1', + 'invoice_status'=>'1', + 'confirm_invoice'=>date('d/m/Y H:m:s'), + 'payment_mode_desc'=>'Org Credit', + 'case_id'=>$this->input->post('ipd_id'), + 'prepared_by'=>$user_name.'['.$user_id.']' + ); + + $this->Medical_M->update_in_upv_item( $data,$invoice_id); + + $status='Org Credit'; + $showcontent=$showcontent1.$status.$showcontent2; + + $rvar=array( + 'update' =>1, + 'showcontent'=>$showcontent + ); + + $encode_data = json_encode($rvar); + echo $encode_data; + } + + + if($this->input->post('mode')==5) + { + if($input_amount_paid<0) + { + $input_amount_paid=$input_amount_paid*-1; + } + + $paydata = array( + 'payment_mode'=> '5', + 'Customerof_type'=>$Customerof_type, + 'Customerof_id'=>$inv_master[0]->patient_id, + 'Customerof_code'=>$inv_master[0]->patient_code, + 'Medical_invoice_id'=>$inv_master[0]->id, + 'Medical_invoice_code'=>$inv_master[0]->inv_med_code, + 'credit_debit'=>'1', + 'amount'=>$input_amount_paid, + 'payment_date'=>date('Y-m-d H:i:s'), + 'remark'=>$pay_remark, + 'update_by'=>$user_name.'['.$user_id.']', + 'update_by_id'=>$user_id + ); + + $insert_id=$this->Medical_M->insert_payment($paydata); + + $data = array( + 'payment_mode'=> '5', + 'payment_status'=>'1', + 'invoice_status'=>'1', + 'payment_id'=>$insert_id, + 'payment_mode_desc'=>'Cash Return', + 'confirm_invoice'=>date('Y-m-d H:i:s'), + 'prepared_by'=>$user_name.'['.$user_id.']' + ); + + $this->Medical_M->update_in_upv_item( $data,$invoice_id); + + $status='CASH'; + $showcontent=$showcontent1.$status.$showcontent2; + + $rvar=array( + 'update' =>1, + 'showcontent'=>$showcontent + ); + + $encode_data = json_encode($rvar); + echo $encode_data; + } + } + + public function invoice_print($inv_id,$print_format=0) + { + $this->load->model('Medical_M'); + $this->Medical_M->update_invoice_final($inv_id); + + $sql="select *,(discount_amount+item_discount_amount) as inv_disc_total,(CGST_Tamount+SGST_Tamount) as TGST from invoice_med_master where id=".$inv_id; + $query = $this->db->query($sql); + $data['invoice_master']= $query->result(); + + $sql="select *,(disc_amount+disc_whole) as d_amt,(CGST+SGST) as gst,(CGST_per+SGST_per) as gst_per from inv_med_item + where inv_med_id=".$inv_id; + $query = $this->db->query($sql); + $data['inv_items']= $query->result(); + + $sql="select * from ipd_master where id=".$data['invoice_master'][0]->ipd_id; + $query = $this->db->query($sql); + $data['ipd_master']= $query->result(); + + $sql="select * from organization_case_master where id=".$data['invoice_master'][0]->case_id; + $query = $this->db->query($sql); + $data['orgcase']= $query->result(); + + $sql="select sum(if(credit_debit>0,amount*-1,amount)) as paid_amount from payment_history_medical where Medical_invoice_id=".$inv_id; + $query = $this->db->query($sql); + $data['payment_history_medical']= $query->result(); + + $sql="select *,if(credit_debit>0,amount*-1,amount) as paid_amount, + (case payment_mode when 1 then 'Cash' when 2 then 'Bank Card' when 3 then 'Return Cash ' when 4 then 'Bank Return' when 5 then 'Cash Return' else 'Other' end) as Payment_type_str + from payment_history_medical where Medical_invoice_id=".$inv_id; + $query = $this->db->query($sql); + $data['payment_history']= $query->result(); + + if($print_format==0) + { + $this->load->view('Medical/Medical_invoice_print_2',$data); + }else{ + $this->load->view('Medical/Medical_invoice_print',$data); + } + + } + + + public function invoice_print_all($ipd_id,$cash=0) + { + //$cash 0 for Cash Only,1 for Credit only,2 Package Credit only,3 for All + $this->load->model('Medical_M'); + $this->Medical_M->update_invoice_group_gst($ipd_id); + + $cash_where=" "; + + if($cash==0) + { + $cash_where.=" and ipd_credit=0 "; + $med_type=1; + }elseif($cash==1) + { + $cash_where.=" and ipd_credit=1 and ipd_credit_type=1 "; + $med_type=2; + }elseif($cash==2) + { + $cash_where.=" and ipd_credit=1 and ipd_credit_type=0 "; + $med_type=3; + } + + $sql="select i.inv_med_id,i.id,i.item_Name,i.formulation, + i.batch_no,Date_Format(i.expiry,'%m-%Y')as expiry, + i.price,i.qty,sum(i.amount) as amount,i.HSNCODE, + m.inv_med_code,m.id as m_id, + date_format(m.inv_date,'%d-%m-%Y') as str_inv_date, + sum(twdisc_amount) as twdisc_amount, + sum(i.disc_amount+i.disc_whole) as d_amt, + sum(i.CGST+i.SGST) as gst, + (i.CGST_per+i.SGST_per) as gst_per + from inv_med_item i join invoice_med_master m + on i.inv_med_id=m.id + where m.group_invoice_id>0 and m.ipd_id=".$ipd_id.$cash_where." group by i.inv_med_id,i.id WITH ROLLUP"; + $query = $this->db->query($sql); + $data['inv_items']= $query->result(); + + $sql="select sum(CGST_Tamount) as CGST_Tamount, + sum(SGST_Tamount) as SGST_Tamount, + sum(TaxableAmount) as TaxableAmount, + sum(net_amount) as net_amount, + sum(payment_received) as payment_received, + sum(payment_balance) as payment_balance, + sum(discount_amount+item_discount_amount) as inv_disc_total, + (CGST_Tamount+SGST_Tamount) as TGST from invoice_med_master + where group_invoice_id>0 and ipd_id=".$ipd_id.$cash_where." group by ipd_id"; + $query = $this->db->query($sql); + $data['invoice_master']= $query->result(); + + $sql="select m.p_id,p.p_fname,m.ipd_code,p.p_code, m.doc_name, + m.org_id from v_ipd_list m join patient_master p on m.p_id=p.id + where m.id=".$ipd_id; + $query = $this->db->query($sql); + $data['ipd_master']= $query->result(); + + $sql="select * from organization_case_master where id='".$data['ipd_master'][0]->org_id."'"; + $query = $this->db->query($sql); + $data['orgcase']= $query->result(); + + $sql="select sum(if(p.credit_debit>0,p.amount*-1,p.amount)) as paid_amount + from payment_history_medical p join inv_med_group m + on p.group_id=m.med_group_id + where m.ipd_id=".$ipd_id." and m.med_type=".$med_type; + $query = $this->db->query($sql); + $data['payment_Total']= $query->result(); + + $sql="select p.*,if(p.credit_debit>0,p.amount*-1,p.amount) as paid_amount, + (case p.payment_mode when 1 then 'Cash' when 2 then 'Bank Card' when 3 then 'Return Cash ' when 4 then 'Bank Return' when 5 then 'Cash Return' else 'Other' end) as Payment_type_str + from payment_history_medical p join inv_med_group m + on p.group_id=m.med_group_id + where m.ipd_id=".$ipd_id." and m.med_type=".$med_type; + $query = $this->db->query($sql); + $data['payment_history']= $query->result(); + + $sql="select * from inv_med_group + where ipd_id='".$ipd_id."' and med_type=1"; + $query = $this->db->query($sql); + $data['inv_med_group']= $query->result(); + + $this->load->view('Medical/Medical_invoice_print_all',$data); + + } + + + public function final_invoice($inv_id) + { + $this->load->model('Medical_M'); + + $this->Medical_M->update_invoice_group($inv_id); + $this->Medical_M->update_invoice_final($inv_id); + + $sql="select *,(discount_amount+item_discount_amount) as inv_disc_total,(CGST_Tamount+SGST_Tamount) as TGST , + if(ipd_credit>0,'Credit to IPD','CASH') as credit_status,if(case_credit>0,'Credit to Org','CASH') as credit_org_status + from invoice_med_master where id=".$inv_id; + + $query = $this->db->query($sql); + $data['invoiceMaster']= $query->result(); + + $sql="select * from inv_med_item where inv_med_id=".$inv_id; + $query = $this->db->query($sql); + $data['inv_items']= $query->result(); + + $sql="select * from doctor_master where active=1"; + $query = $this->db->query($sql); + $data['doclist']= $query->result(); + + $sql="select *,if(gender=1,'Male','FeMale') as xgender, + GET_AGE_1(dob,age,age_in_month,estimate_dob) AS age from patient_master where id='".$data['invoiceMaster'][0]->patient_id."' "; + $query = $this->db->query($sql); + $data['person_info']= $query->result(); + + $sql="select * from ipd_master where ipd_status=0 and id=".$data['invoiceMaster'][0]->ipd_id; + $query = $this->db->query($sql); + $data['ipd_master']= $query->result(); + + if($data['invoiceMaster'][0]->case_id > 0) + { + $sql="select * from organization_case_master where id=".$data['invoiceMaster'][0]->case_id; + $query = $this->db->query($sql); + $data['OCaseMaster']= $query->result(); + } + + $sql="select sum(if(credit_debit>0,amount*-1,amount)) as paid_amount from payment_history_medical where Medical_invoice_id=".$inv_id; + $query = $this->db->query($sql); + $data['payment_history_medical']= $query->result(); + + $this->load->view('Medical/Medical_Final_Invoice',$data); + } + + public function add_item($type) + { + $this->load->model('Medical_M'); + + $inser_id=1; + + $ssno=$this->input->post('l_ssno'); + + if($type==1) + { + $inv_id=$this->input->post('inv_id'); + + $qty=$this->input->post('qty'); + $disc=$this->input->post('disc'); + $product_unit_rate=$this->input->post('product_unit_rate'); + + $sql="select * from purchase_invoice_item where id=".$ssno; + $query = $this->db->query($sql); + $data['itemlist']= $query->result(); + + $sql="select * from inv_med_item where inv_med_id=".$inv_id." and ss_no=".$ssno; + $query = $this->db->query($sql); + $itemExist= $query->result(); + + $CGST=$data['itemlist'][0]->CGST_per; + $SGST=$data['itemlist'][0]->SGST_per; + + //$item_rate=$data['itemlist'][0]->unit_rate; + $item_rate=$product_unit_rate; + + $amount_value=$qty*$item_rate; + + $disc_amount=$amount_value*$disc/100; + + $Tamount_value=$amount_value-$disc_amount; + + $ss_no=$data['itemlist'][0]->id; + $HSNCODE=$data['itemlist'][0]->HSNCODE; + + $data['insert_inv_med_item'] = array( + 'inv_med_id' => $inv_id, + 'item_code' => $data['itemlist'][0]->item_code, + 'item_Name' => $data['itemlist'][0]->Item_name, + 'formulation' => $data['itemlist'][0]->formulation, + 'qty' => $qty, + 'batch_no' => $data['itemlist'][0]->batch_no, + 'expiry' => $data['itemlist'][0]->expiry_date, + 'price' => $item_rate, + 'price2' => $item_rate, + 'mrp' => $data['itemlist'][0]->mrp, + 'disc_per' => $disc, + 'disc_amount' => $disc_amount, + 'amount' => $amount_value, + 'tamount' => $Tamount_value, + 'CGST_per'=> $CGST, + 'SGST_per'=> $SGST, + 'HSNCODE'=> $HSNCODE, + 'ss_no'=>$ss_no + ); + + if(count($itemExist)>0) + { + $inser_id=0; + }else{ + $inser_id=$this->Medical_M->add_invoiceitem( $data['insert_inv_med_item']); + $this->Medical_M->update_invoice_final($inv_id); + } + } + else if($type==2) + { + $update_qty=$this->input->post('u_qty'); + $itemid=$this->input->post('itemid'); + + + $sql="select * from inv_med_item where id=".$itemid; + $query = $this->db->query($sql); + $data['inv_med_item']= $query->result(); + + $CGST=$data['inv_med_item'][0]->CGST_per; + $SGST=$data['inv_med_item'][0]->SGST_per; + $disc=$data['inv_med_item'][0]->disc_per; + $ssno=$data['inv_med_item'][0]->ss_no; + $inv_id=$data['inv_med_item'][0]->inv_med_id; + + $item_rate=$data['inv_med_item'][0]->price; + + $amount_value=$update_qty*$item_rate; + + $disc_amount=$amount_value*$disc/100; + + $Tamount_value=$amount_value-$disc_amount; + + $data['update_inv_med_item'] = array( + 'qty' => $update_qty, + 'disc_amount' => $disc_amount, + 'amount' => $amount_value, + 'tamount' => $Tamount_value + ); + + $this->Medical_M->update_invoiceitem( $data['update_inv_med_item'],$itemid); + $inser_id=$itemid; + + $this->Medical_M->update_invoice_final($inv_id); + + }else{ + $inv_id=$this->input->post('inv_id'); + $itemid=$this->input->post('itemid'); + + $sql="select * from inv_med_item where id=".$itemid; + $query = $this->db->query($sql); + $data['inv_med_item']= $query->result(); + + $ssno=$data['inv_med_item'][0]->ss_no; + + $this->Medical_M->delete_invoiceitem($itemid); + + $this->Medical_M->update_invoice_final($inv_id); + } + + $content=''; + + if($inser_id>0) + { + $this->Medical_M->update_invoice_final($inv_id); + + $sql="select * from inv_med_item where inv_med_id=".$inv_id; + $query = $this->db->query($sql); + $data['invoiceDetails']= $query->result(); + + $sql="select sum(amount) as Gtotal,sum(tamount) as tamt,sum(CGST) as TCGST,sum(SGST) as TSGST,sum(disc_amount) as t_dis_amt from inv_med_item where inv_med_id=".$inv_id; + $query = $this->db->query($sql); + $data['invoiceGtotal']= $query->result(); + + /* $sql="select sum(qty) as total_qty from inv_med_item where ss_no=".$ssno; + $query = $this->db->query($sql); + $inv_med_item= $query->result(); + + $update_item_qty = array( + 'update_stock_qty' => $inv_med_item[0]->total_qty + ); + + $this->Medical_M->update_stock_upd($update_item_qty,$ssno); */ + + $content.=' + + + + + + + + + + + + + '; + + $srno=0; + + foreach($data['invoiceDetails'] as $row) + { + $srno=$srno+1; + $content.= ''; + $content.= ''; + $content.= ''; + $content.= ''; + $content.= ''; + $content.= ''; + $content.= ''; + $content.= ''; + $content.= ''; + $content.= ''; + $content.= ''; + $content.= ''; + $content.= ''; + } + + $content.= ''; + + $content.= ' + + + + + + + + + + + + +
#Item NameBatch NoExp.RateSaved Qty.Qty.PriceDisc.Amount
'.$srno.''.$row->item_Name.'['.$row->formulation.']'.$row->batch_no.''.$row->expiry.''.$row->price.''.$row->qty.''.$row->amount.''.$row->disc_amount.''.$row->tamount.' + +
#Gross Total'.$data['invoiceGtotal'][0]->Gtotal.''.$data['invoiceGtotal'][0]->t_dis_amt.''.$data['invoiceGtotal'][0]->tamt.'
'; + } + + $rvar=array( + 'insertid' =>$inser_id, + 'content'=>$content, + 'error'=>'Already in Item List' + ); + $encode_data = json_encode($rvar); + echo $encode_data; + + } + + public function list_org_ipd() + { + $sql = "select *,(paid_amount-(charge_amount+med_amount)) as balance from v_ipd_list where ipd_status=0 "; + $query = $this->db->query($sql); + $data['data']= $query->result(); + + $this->load->view('Medical/Medical_ipd_org_list',$data); + } + + + public function list_org() + { + $sql = "select p.p_fname,p.p_code,p.p_relative,p.p_rname,o.insurance_company_name,o.case_id_code,o.id as org_id,o.p_id , + o.date_registration,Date_Format(o.date_registration,'%d-%m-%Y') as str_register_date,o.insurance_id + from organization_case_master o join patient_master p on o.p_id=p.id and o.insurance_id in (2,53) and o.`status`=0"; + $query = $this->db->query($sql); + $data['data']= $query->result(); + + $this->load->view('Medical/Medical_org_list',$data); + } + + + + public function list_med_inv($ipd_id) + { + $sql="select *,if(ipd_credit=0,'CASH','CREDIT') as credit, + if(ipd_credit=1 and ipd_credit_type=0,'Yes','No') as Package + from invoice_med_master where ipd_id = ".$ipd_id; + $query = $this->db->query($sql); + $data['inv_master']= $query->result(); + + $sql="select sum(if(ipd_credit=0,net_amount,0)) as cash_netAmount, + sum(if(ipd_credit=1 and ipd_credit_type=1,net_amount,0)) as IPDCrAmount , + sum(if(ipd_credit=1 and ipd_credit_type=0,net_amount,0)) as PackageCrAmount, + sum(payment_balance) as t_payment_balance ,sum(net_amount) as t_net_amount + from invoice_med_master where ipd_id = ".$ipd_id; + $query = $this->db->query($sql); + $data['inv_master_total']= $query->result(); + + $sql="select * from ipd_master where id = ".$ipd_id; + $query = $this->db->query($sql); + $data['ipd_master']= $query->result(); + + $sql="select *,if(gender=1,'Male','FeMale') as xgender, + GET_AGE_1(dob,age,age_in_month,estimate_dob) AS age from patient_master where id='".$data['ipd_master'][0]->p_id."' "; + $query = $this->db->query($sql); + $data['person_info']= $query->result(); + + $sql="select * from v_ipd_list where id=".$ipd_id; + $query = $this->db->query($sql); + $data['ipd_list']= $query->result(); + + $sql="select * from inv_med_group where med_type=1 and ipd_id=".$ipd_id; + $query = $this->db->query($sql); + $data['med_group_list']= $query->result(); + + $sql="select b.ipd_id,b.bed_id,b.TDate,m.room_name,m.bed_no + from ipd_bed_assign b left join hc_bed_master m on b.bed_id=m.id + where b.ipd_id=".$ipd_id." order by TDate desc"; + $query = $this->db->query($sql); + $data['bed_list']= $query->result(); + + if($data['ipd_master'][0]->case_id>0) + { + $sql="select * from organization_case_master where id='".$data['ipd_master'][0]->case_id."'"; + $query = $this->db->query($sql); + $data['orgcase']= $query->result(); + + $ins_comp_id=$data['orgcase'][0]->insurance_id; + $inc_card_id=$data['orgcase'][0]->insurance_card_id; + + $sql="select * from hc_insurance_card where id='".$inc_card_id."'"; + $query = $this->db->query($sql); + $data['hc_insurance_card']= $query->result(); + + $sql="select * from hc_insurance where id='".$ins_comp_id."'"; + $query = $this->db->query($sql); + $data['insurance']= $query->result(); + } + + $this->load->view('Medical/Medical_invoice_list',$data); + } + + public function list_med_orginv($org_id) + { + + $sql="select *,if(case_credit=0,'CASH','CREDIT') as credit from invoice_med_master where case_id = ".$org_id; + $query = $this->db->query($sql); + $data['inv_master']= $query->result(); + + $sql="select * from organization_case_master where id = ".$org_id; + $query = $this->db->query($sql); + $data['orgcase_master']= $query->result(); + + $sql="select *,if(gender=1,'Male','FeMale') as xgender, + GET_AGE_1(dob,age,age_in_month,estimate_dob) AS age from patient_master where id='".$data['orgcase_master'][0]->p_id."' "; + $query = $this->db->query($sql); + $data['person_info']= $query->result(); + + $this->load->view('Medical/Medical_org_invoicelist',$data); + } + + public function update_discount() + { + $invoice_id=$this->input->post('med_invoice_id'); + + $user = $this->ion_auth->user()->row(); + $user_id = $user->id; + $user_name = $user->first_name.''. $user->last_name; + + $dataupdate = array( + 'discount_amount' => $this->input->post('input_dis_amt'), + 'discount_remark' => $this->input->post('input_dis_desc'), + 'discount_by'=>$user_name.'['.$user_id.']' + ); + + $this->load->model('Medical_M'); + $this->Medical_M->update_in_upv_item($dataupdate,$invoice_id); + + $this->Medical_M->update_invoice_final($invoice_id); + + } + + public function BillFinal($group_id) + { + + $user = $this->ion_auth->user()->row(); + $user_id = $user->id; + $user_name = $user->first_name.''. $user->last_name; + + $dataupdate = array( + 'bill_final' => '1', + 'bill_final_by'=>$user_name.'['.$user_id.']' + ); + + $this->load->model('Medical_M'); + $this->Medical_M->update_group_invoice($dataupdate,$group_id); + + $rvar=array( + 'update' =>1, + ); + $encode_data = json_encode($rvar); + echo $encode_data; + + } + + public function InvBillFinal($invoice_id) + { + + $user = $this->ion_auth->user()->row(); + $user_id = $user->id; + $user_name = $user->first_name.''. $user->last_name; + + $dataupdate = array( + 'bill_final' => '1', + 'bill_final_by'=>$user_name.'['.$user_id.']' + ); + + $this->load->model('Medical_M'); + $this->Medical_M->update_in_upv_item($dataupdate,$invoice_id); + + $rvar=array( + 'update' =>1, + ); + $encode_data = json_encode($rvar); + echo $encode_data; + + } + + + + public function final_discount($ipd_id) + { + + $user = $this->ion_auth->user()->row(); + $user_id = $user->id; + $user_name = $user->first_name.''. $user->last_name; + + $dataupdate = array( + 'discount_amount' => $this->input->post('input_dis_amt'), + 'discount_remark' => $this->input->post('input_dis_desc'), + 'discount_by'=>$user_name.'['.$user_id.']' + ); + + $this->load->model('Medical_M'); + $this->Medical_M->update_in_upv_item($dataupdate,$invoice_id); + + $this->Medical_M->update_invoice_final($invoice_id); + } + + public function search() + { + $sdata=$this->input->post('txtsearch'); + + $sdata = preg_replace('/[^A-Za-z0-9 _\-]/', '', $sdata); + + $sql = "SELECT *,GET_AGE_1(dob,age,age_in_month,estimate_dob) AS age + FROM patient_master + WHERE p_code like '%".$sdata."' or p_fname like '%".$sdata."%' or + mphone1 = '".$sdata."' or email1 = '".$sdata."' order by id desc limit 20"; + + $query = $this->db->query($sql); + $data['data']= $query->result(); + + $this->load->view('Medical/Patient_Search_Result',$data); + } + + public function Update_Invoice_ipd_credit_type() + { + $ipd_credit_type= $this->input->post('ipd_credit_type'); + $inv_med_id = $this->input->post('inv_med_id'); + + $dataupdate = array( + 'ipd_credit_type' => $ipd_credit_type + ); + + $this->load->model('Medical_M'); + $this->Medical_M->update_in_upv_item($dataupdate,$inv_med_id); + } + + + + public function Med_Inv_Group($inv_med_id) + { + if (!$this->input->is_ajax_request()) { exit('no valid req.'); } + + $sql = "select * from invoice_med_master where id=".$inv_med_id; + $query = $this->db->query($sql); + $invoice_med_master= $query->result(); + + $user = $this->ion_auth->user()->row(); + $user_id = $user->id; + $user_name = $user->first_name.''. $user->last_name; + + $old_remark=$invoice_med_master[0]->update_history; + + $new_remark='Group By : '.$user_name.'['.$user_id.']'.' Date:'.date('d-m-Y h:i:s').PHP_EOL; + + $new_remark.= $old_remark; + + $dataupdate = array( + 'med_group_id' => 1, + 'update_history' => $new_remark + ); + + $this->load->model('Medical_M'); + $this->Medical_M->update_in_upv_item($dataupdate,$inv_med_id); + $this->Medical_M->update_invoice_group($inv_med_id); + + $rvar=array( + 'update' =>1, + ); + $encode_data = json_encode($rvar); + echo $encode_data; + + + } + + public function Update_Group_Discount($med_group_id) + { + $input_discount= $this->input->post('input_discount'); + $Ipd_ID= $this->input->post('ipd_id'); + + $user = $this->ion_auth->user()->row(); + $user_id = $user->id; + $user_name = $user->first_name.''. $user->last_name; + + $dataupdate = array( + 'discount_group' => $input_discount, + 'discount_by_group' => $user_name.'['.$user_id.']'.' Date:'.date('d-m-Y h:i:s') + ); + + $this->load->model('Medical_M'); + $this->Medical_M->update_group_invoice($dataupdate,$med_group_id); + $this->Medical_M->update_invoice_group_gst($Ipd_ID); + + $rvar=array( + 'update' =>1, + ); + + $encode_data = json_encode($rvar); + echo $encode_data; + } + + + + public function LockIPD($inv_med_id,$lock=1) + { + if (!$this->input->is_ajax_request()) { exit('no valid req.'); } + + $sql = "select * from ipd_master where id=".$inv_med_id; + $query = $this->db->query($sql); + $ipd_master= $query->result(); + + $user = $this->ion_auth->user()->row(); + $user_id = $user->id; + $user_name = $user->first_name.''. $user->last_name; + + $old_remark=$ipd_master[0]->lock_remark; + + if($lock==1) + { + $new_remark='Locked By : '.$user_name.'['.$user_id.']'.' Date:'.date('d-m-Y h:i:s').PHP_EOL; + + }else{ + $new_remark='Unlocked By : '.$user_name.'['.$user_id.']'.' Date:'.date('d-m-Y h:i:s').PHP_EOL; + } + + $new_remark.= $old_remark; + + $dataupdate = array( + 'lock_medical' => $lock, + 'lock_remark' => $new_remark + ); + + $this->load->model('Ipd_M'); + $this->Ipd_M->update($dataupdate,$inv_med_id); + + $rvar=array( + 'update' =>1, + ); + + $encode_data = json_encode($rvar); + echo $encode_data; + + + } + + public function load_model_box($ipd_id) + { + $sql="select *,if(ipd_status=0,DATEDIFF(sysdate(),register_date),DATEDIFF(discharge_date,register_date)) as no_days,if(case_type=1,'MLC','Non MLC') as case_type_s, Date_format(register_date,'%d-%m-%Y') as str_register_date from ipd_master where id='".$ipd_id."' "; + $query = $this->db->query($sql); + $data['ipd_info']= $query->result(); + + $sql="select *,if(gender=1,'Male','FeMale') as xgender, + GET_AGE_1(dob,age,age_in_month,estimate_dob) AS age from patient_master where id='".$data['ipd_info'][0]->p_id."' "; + $query = $this->db->query($sql); + $data['person_info']= $query->result(); + + $sql="select * from inv_med_group where med_type=1 and ipd_id=".$ipd_id; + $query = $this->db->query($sql); + $data['med_group_list']= $query->result(); + + $sql="select p.*,if(p.credit_debit>0,p.amount*-1,p.amount) as paid_amount, + Date_Format(payment_date,'%d-%m-%Y') as str_payment_date, + (case p.payment_mode when 1 then 'Cash' when 2 then 'Bank Card' when 3 then 'Return Cash ' when 4 then 'Bank Return' when 5 then 'Cash Return' else 'Other' end) as Payment_type_str + from payment_history_medical p join inv_med_group m + on p.group_id=m.med_group_id + where m.ipd_id=".$ipd_id." and m.med_type=1"; + $query = $this->db->query($sql); + $data['payment_history']= $query->result(); + + $sql="select * from inv_med_group where med_type=1 and ipd_id=".$ipd_id; + $query = $this->db->query($sql); + $data['inv_med_group']= $query->result(); + + $this->load->view('Medical/Med_Model_Payment',$data); + } + + public function payment_receipt($ipd_id,$cash=0) + { + $cash_where=" "; + + if($cash==0) + { + $cash_where.=" and ipd_credit=0 "; + $med_type=1; + }elseif($cash==1) + { + $cash_where.=" and ipd_credit=1 and ipd_credit_type=1 "; + $med_type=2; + }elseif($cash==2) + { + $cash_where.=" and ipd_credit=1 and ipd_credit_type=0 "; + $med_type=3; + } + + $sql="select m.p_id,p.p_fname,m.ipd_code,p.p_code, m.doc_name, + m.org_id from v_ipd_list m join patient_master p on m.p_id=p.id + where m.id=".$ipd_id; + $query = $this->db->query($sql); + $data['ipd_master']= $query->result(); + + $sql="select * from organization_case_master where id='".$data['ipd_master'][0]->org_id."'"; + $query = $this->db->query($sql); + $data['orgcase']= $query->result(); + + $sql="select * from inv_med_group + where ipd_id='".$ipd_id."' and med_type=".$med_type; + $query = $this->db->query($sql); + $data['inv_med_group']= $query->result(); + + $sql="select p.*,if(p.credit_debit>0,p.amount*-1,p.amount) as paid_amount, + Date_Format(payment_date,'%d-%m-%Y') as str_payment_date, + (case p.payment_mode when 1 then 'Cash' when 2 then 'Bank Card' when 3 then 'Return Cash ' when 4 then 'Bank Return' when 5 then 'Cash Return' else 'Other' end) as Payment_type_str + from payment_history_medical p join inv_med_group m + on p.group_id=m.med_group_id + where m.ipd_id=".$ipd_id." and m.med_type=".$med_type; + $query = $this->db->query($sql); + $data['payment_history']= $query->result(); + + $this->load->view('Medical/Med_Payment_Receipt',$data); + } + + public function group_confirm_payment() + { + if (!$this->input->is_ajax_request()) { exit('no valid req.'); } + + $this->load->model('Ipd_M'); + $this->load->model('Medical_M'); + + $ipd_id=$this->input->post('ipd_id'); + $amount=$this->input->post('amount'); + $Med_Group_id=$this->input->post('Med_Group_id'); + + $sql="select * from ipd_master where id=".$ipd_id; + $query = $this->db->query($sql); + $ipd_master= $query->result(); + + $user = $this->ion_auth->user()->row(); + $user_id = $user->id; + $user_name = $user->first_name.''. $user->last_name; + + $pay_remark=$this->input->post('cash_remark'); + + $pay_datetime=str_to_MysqlDate($this->input->post('date_payment')).' '.date('H:i:s'); + + if($this->input->post('mode')==1) + { + $paydata = array( + 'payment_mode'=> '1', + 'Customerof_type'=>'2', + 'Customerof_id'=>$ipd_master[0]->p_id, + 'group_id'=>$Med_Group_id, + 'ipd_id'=>$ipd_id, + 'med_type'=>0, + 'credit_debit'=>'0', + 'amount'=>$amount, + 'payment_date'=>$pay_datetime, + 'remark'=>$pay_remark, + 'update_by'=>$user_name.'['.$user_id.']', + 'update_by_id'=>$user_id + ); + + $insert_id=$this->Medical_M->insert_payment($paydata); + + $this->Medical_M->update_invoice_group_gst($ipd_id); + + $rvar=array( + 'update' =>1, + 'ipd_id'=> $ipd_id, + 'payid' => $insert_id, + 'pay_date' =>$pay_datetime + ); + $encode_data = json_encode($rvar); + echo $encode_data; + } + + if($this->input->post('mode')==2) + { + + $FormRules = array( + array( + 'field' => 'input_card_mac', + 'label' => 'Card Bank Name', + 'rules' => 'required|min_length[1]|max_length[30]' + ) + /*, + array( + 'field' => 'input_card_digit', + 'label' => 'Card Last 4 Digit ', + 'rules' => 'required|min_length[1]|max_length[10]' + ), + array( + 'field' => 'input_card_bank', + 'label' => 'Bank Name ', + 'rules' => 'required|min_length[1]|max_length[50]' + ), + array( + 'field' => 'input_card_tran', + 'label' => 'Card Transcation ID', + 'rules' => 'required|min_length[1]|max_length[15]' + )*/ + ); + + $this->form_validation->set_rules($FormRules); + + if ($this->form_validation->run() == TRUE) + { + $paydata = array( + 'payment_mode'=> '2', + 'Customerof_type'=>'2', + 'Customerof_id'=>$ipd_master[0]->p_id, + 'group_id'=>$Med_Group_id, + 'ipd_id'=>$ipd_id, + 'med_type'=>0, + 'credit_debit'=>'0', + 'amount'=>$amount, + 'payment_date'=>$pay_datetime, + 'remark'=>$pay_remark, + 'update_by'=>$user_name.'['.$user_id.']', + 'update_by_id'=>$user_id, + 'card_bank'=>$this->input->post('input_card_mac'), + 'cust_card'=>$this->input->post('input_card_bank'), + 'card_remark'=>$this->input->post('input_card_digit'), + 'card_tran_id'=>$this->input->post('input_card_tran'), + + ); + + $insert_id=$this->Medical_M->insert_payment($paydata); + + $this->Medical_M->update_invoice_group_gst($ipd_id); + + $rvar=array( + 'update' =>1, + 'ipd_id'=> $ipd_id, + 'payid' => $insert_id, + 'pay_date' =>$pay_datetime + ); + $encode_data = json_encode($rvar); + echo $encode_data; + } + else{ + $send_error=validation_errors(); + $rvar=array( + 'update' =>0, + 'error_text'=>$send_error + ); + $encode_data = json_encode($rvar); + echo $encode_data; + } + } + + + if($this->input->post('mode')==5) + { + $FormRules = array( + array( + 'field' => 'input_person_name', + 'label' => 'Name on Chq.', + 'rules' => 'required|min_length[1]|max_length[30]' + ), + array( + 'field' => 'input_bank_tran', + 'label' => 'Chq. Number', + 'rules' => 'required|min_length[1]|max_length[15]' + ) + /*, + array( + 'field' => 'input_card_digit', + 'label' => 'Card Last 4 Digit ', + 'rules' => 'required|min_length[1]|max_length[10]' + ), + array( + 'field' => 'input_card_bank', + 'label' => 'Bank Name ', + 'rules' => 'required|min_length[1]|max_length[50]' + ), + */ + ); + + $this->form_validation->set_rules($FormRules); + + if ($this->form_validation->run() == TRUE) + { + $pay_remark='Chq Payment'; + + $paydata = array( + 'payment_mode'=> '2', + 'payof_type'=>'4', + 'payof_id'=>$ipd_master[0]->id, + 'payof_code'=>$ipd_master[0]->ipd_code, + 'credit_debit'=>'0', + 'amount' => $amount, + 'payment_date'=>$pay_datetime, + 'remark'=>$pay_remark, + 'update_by'=>$user_name.'['.$user_id.']', + 'card_bank'=>$this->input->post('input_bank_hospital'), + 'cust_card'=>$this->input->post('input_bank_name'), + 'card_remark'=>$this->input->post('input_person_name'), + 'card_tran_id'=>$this->input->post('input_bank_tran'), + 'update_by_id'=>$user_id + ); + + $insert_id=$this->Payment_M->insert($paydata); + + $data = array( + 'payment_mode'=> '2', + 'payment_mode_desc'=>'Bank Chq.-Draft', + 'payment_id'=>$insert_id, + 'pay_date'=>$pay_datetime, + 'enter_pay_date' => date('Y-m-d H:i:s'), + 'ipd_id' => $ipd_id, + 'amount' => $amount, + 'card_bank'=>$this->input->post('input_bank_hospital'), + 'card_remark'=>$this->input->post('input_card_digit'), + 'cust_card'=>$this->input->post('input_bank_name'), + 'card_tran_id'=>$this->input->post('input_bank_tran'), + 'prepared_by'=>$user_name.'['.$user_id.']', + 'prepared_by_id'=>$user_id + ); + + $insert_ipdpay_id=$this->Ipd_M->insert_payment_ipd( $data); + + $status='Bank Card'; + + + $rvar=array( + 'update' =>1, + 'ipd_id'=> $ipd_id, + 'payid' => $insert_ipdpay_id + ); + + $encode_data = json_encode($rvar); + echo $encode_data; + } + else{ + $send_error=validation_errors(); + $rvar=array( + 'update' =>0, + 'error_text'=>$send_error + ); + $encode_data = json_encode($rvar); + echo $encode_data; + } + } + } + + public function group_cash_print($ipd_id,$payid) + { + $sql="select *,date_format(payment_date,'%d-%m-%Y') as pay_date, + (case payment_mode when 1 then 'CASH' when 2 then 'Bank' Else 'Other' End) as payment_mode_desc + from payment_history_medical where id=".$payid; + $query = $this->db->query($sql); + $data['med_payment']= $query->result(); + + $sql="select * from ipd_master where id =".$ipd_id; + $query = $this->db->query($sql); + $data['ipd_master']= $query->result(); + + $pno=$data['ipd_master'][0]->p_id; + + $sql="select *,if(gender=1,'Male','FeMale') as xgender, + GET_AGE_1(dob,age,age_in_month,estimate_dob) AS age + from patient_master where id='".$pno."' "; + + $query = $this->db->query($sql); + $data['person_info']= $query->result(); + + $this->load->view('Medical/Med_Payment_receipt',$data); + + } + +} \ No newline at end of file diff --git a/old_code_ci3/controllers/Medical_130621.php b/old_code_ci3/controllers/Medical_130621.php new file mode 100644 index 0000000..49028f4 --- /dev/null +++ b/old_code_ci3/controllers/Medical_130621.php @@ -0,0 +1,4747 @@ +load->view('Medical/Dashboard'); + } + + public function select_store($store_id) + { + $sql="select * from store_master where store_id=".$store_id; + $query = $this->db->query($sql); + $data['store_master']= $query->result(); + + $this->load->view('Medical/Store_Dashboard',$data); + } + + public function main_store() + { + $this->load->view('Medical/Stock/main_store_dashboard'); + } + + + public function DrugList() + { + $this->load->view('Medical/Drug_Details'); + + //$sql="select item_id,itemname,dosage from drug_temp_25072017"; + //$query = $this->db->query($sql); + //$data['drug_data']= $query->result(); + + //$this->load->view('Medical/Drug_Details_all',$data); + } + + public function Purchase() + { + $this->load->view('Medical/Purchase/supplier_list'); + } + + public function PurchaseMasterEdit($inv_id) + { + $sql="select * from med_supplier order by name_supplier"; + $query = $this->db->query($sql); + $data['supplier_data']= $query->result(); + + $sql="select p.*,s.name_supplier from purchase_invoice p join med_supplier s on p.sid=s.sid where p.id=".$inv_id; + $query = $this->db->query($sql); + $data['inv_master_data']= $query->result(); + + $sql="select * from purchase_invoice_item where purchase_id='".$inv_id."' "; + $query = $this->db->query($sql); + $data['purchase_item']= $query->result(); + + $this->load->view('Medical/Purchase/purchase_invoice_master_edit',$data); + + } + + public function UpdatePurchase() + { + $rec_id=$this->input->post('hid_purchaseid'); + $sid=$this->input->post('input_supplier'); + $invoice_code=$this->input->post('input_invoicecode'); + $d_invoice=$this->input->post('datepicker_invoice'); + + $Udata = array( + 'sid'=> $sid, + 'date_of_invoice'=> str_to_MysqlDate($d_invoice), + 'Invoice_no'=> $invoice_code + ); + + $this->load->model('Medical_M'); + + $update_id=$this->Medical_M->update_purchase($Udata,$rec_id); + + $rvar=array( + 'insertid' =>1, + 'show_text'=>'Data Update' + ); + + $encode_data = json_encode($rvar); + echo $encode_data; + + } + + public function UpdatePurchaseInvoiceStatus($purchase_inv_id,$inv_status) + { + $user = $this->ion_auth->user()->row(); + $user_id = $user->id; + $user_name_info = $user->first_name.''. $user->last_name .'['.$user_id.']'.date('d-m-Y H:i:s'); + + $Udata = array( + 'inv_status'=> $inv_status, + 'inv_status_update_by'=> $user_name_info, + ); + + $this->load->model('Medical_M'); + + $update_id=$this->Medical_M->update_purchase($Udata,$purchase_inv_id); + + redirect('Medical/PurchaseMasterEdit/'.$purchase_inv_id); + + } + + public function PurchaseNew() + { + $sql="select * from med_supplier order by name_supplier"; + $query = $this->db->query($sql); + $data['supplier_data']= $query->result(); + + $this->load->view('Medical/Purchase/new_purchase_invoice',$data); + } + + public function SupplierList() + { + $sql="select * from med_supplier"; + $query = $this->db->query($sql); + $data['supplier_data']= $query->result(); + + $this->load->view('Medical/Purchase/Supplier_master',$data); + } + + public function PurchaseInvoice() + { + $sdata=$this->input->post('txtsearch'); + + $sdata = preg_replace('/[^A-Za-z0-9_ \-]/', '', $sdata); + + if(trim($sdata)=='') + { + $sql="select p.id,p.Invoice_no,p.date_of_invoice, + date_format(p.date_of_invoice,'%d-%m-%Y') as str_date_of_invoice,p.sid,s.name_supplier, + s.short_name,s.gst_no, + p.T_Net_Amount as tamount + from (purchase_invoice p join med_supplier s on p.sid=s.sid) + + group by p.id + order by p.id desc limit 50"; + }else{ + + $numric_condition=""; + + if(is_numeric($sdata)) + { + $numric_condition=" OR p.Invoice_no=".$sdata ; + } + + $sql="select p.id,p.Invoice_no,p.date_of_invoice, + date_format(p.date_of_invoice,'%d-%m-%Y') as str_date_of_invoice, + p.sid,s.name_supplier,s.short_name,s.gst_no, + p.T_Net_Amount as tamount + from (purchase_invoice p join med_supplier s on p.sid=s.sid) + where (p.Invoice_no LIKE '%".$sdata."' ".$numric_condition." ) + group by p.id order by p.id desc limit 50"; + } + + $query = $this->db->query($sql); + $data['purchase_list']= $query->result(); + + $this->load->view('Medical/Purchase/purchase_supp_list',$data); + } + + public function PurchaseInvoiceEdit($inv_id) + { + $sql="select p.id,p.Invoice_no,p.date_of_invoice,date_format(p.date_of_invoice,'%d/%m/%Y') as str_date_of_invoice, + p.sid,s.name_supplier,s.short_name,s.gst_no,p.inv_status + from purchase_invoice p join med_supplier s on p.sid=s.sid + where p.id=".$inv_id; + $query = $this->db->query($sql); + $data['purchase_invoice']= $query->result(); + + $sql="select * from purchase_invoice_item where purchase_id=".$inv_id; + $query = $this->db->query($sql); + $data['purchase_invoice_item']= $query->result(); + + $this->load->view('Medical/Purchase/Purchase_Invoice_Edit',$data); + } + + public function purchase_invoice_delete($inv_id) + { + + $sql="select * from purchase_invoice_item where purchase_id=$inv_id"; + $query = $this->db->query($sql); + $purchase_invoice_item= $query->result(); + + if (count($purchase_invoice_item)>0){ + $rvar=array( + 'is_delete' =>0, + 'show_text'=>"Invoice has Items, Empty the item list", + ); + }else{ + $this->load->model('Medical_M'); + $is_delete=$this->Medical_M->delete_purchase($inv_id); + $rvar=array( + 'is_delete' =>1, + 'show_text'=>"Invoice has been deleted", + ); + } + + + $encode_data = json_encode($rvar); + echo $encode_data; + + } + + public function SupplierListSub() + { + $sql="select * from med_supplier order by name_supplier"; + $query = $this->db->query($sql); + $data['supplier_data']= $query->result(); + + $this->load->view('Medical/Purchase/Supplier_master_sub',$data); + } + + public function SupplierEdit($sid=0) + { + $sql="select * from med_supplier where sid=".$sid; + $query = $this->db->query($sql); + $data['supplier_data']= $query->result(); + + $this->load->view('Medical/Purchase/Supplier_Edit',$data); + } + + public function CreatePurchase() + { + if (!$this->input->is_ajax_request()) { exit('no valid req.'); } + + $FormRules = array( + array( + 'field' => 'input_invoicecode', + 'label' => 'Invoice No', + 'rules' => 'required|min_length[3]|max_length[30]' + ) + ); + + $this->form_validation->set_rules($FormRules); + + if ($this->form_validation->run() == TRUE) + { + $sid=$this->input->post('input_supplier'); + $invoice_code=$this->input->post('input_invoicecode'); + $d_invoice=$this->input->post('datepicker_invoice'); + + $invoice_date=date_create(str_to_MysqlDate($d_invoice)); + + $where=" where sid=$sid"; + + if(is_numeric($invoice_code)) + $where.=" and Invoice_no=".$invoice_code ; + else + $where.=" and Invoice_no='".$invoice_code."'"; + + $where.=" and date_of_invoice BETWEEN get_financial_year_start('".str_to_MysqlDate($d_invoice)."') AND get_financial_year_end('".str_to_MysqlDate($d_invoice)."')"; + + $sql="select count(*) as no_rec from purchase_invoice ".$where; + $query = $this->db->query($sql); + $chk_rec= $query->result(); + + if($chk_rec[0]->no_rec==0) + { + $Udata = array( + 'sid'=> $sid, + 'date_of_invoice'=> str_to_MysqlDate($d_invoice), + 'Invoice_no'=> $invoice_code, + ); + + $this->load->model('Medical_M'); + + $inser_id=$this->Medical_M->insert_purchase($Udata); + $send_msg="Added Successfully"; + + if($inser_id>0) + { + $show_text=Show_Alert('success','Success',$send_msg); + }else{ + $show_text=Show_Alert('danger','Error',$send_msg); + } + }else{ + $show_text=Show_Alert('danger','Error',' Record Already Exist'); + $inser_id=0; + } + + $rvar=array( + 'insertid' =>$inser_id, + 'show_text'=>$show_text + ); + + $encode_data = json_encode($rvar); + echo $encode_data; + + } + else{ + $send_msg=validation_errors(); + $rvar=array( + 'insertid' =>0, + 'show_text'=>Show_Alert('danger','Error',$send_msg) + ); + $encode_data = json_encode($rvar); + echo $encode_data; + } + } + + + public function SupplierUpdate($sid=0) + { + if (!$this->input->is_ajax_request()) { exit('no valid req.'); } + + $FormRules = array( + array( + 'field' => 'input_name_supplier', + 'label' => 'Supplier Name', + 'rules' => 'required|min_length[3]|max_length[30]' + ), + array( + 'field' => 'input_short_name', + 'label' => 'Short Name', + 'rules' => 'required|min_length[1]|max_length[30]' + ), + array( + 'field' => 'input_gst_no', + 'label' => 'GST No.', + 'rules' => 'required|min_length[5]|max_length[15]' + ), + array( + 'field' => 'input_state', + 'label' => 'State', + 'rules' => 'required|min_length[1]|max_length[20]' + ) + ); + + $this->form_validation->set_rules($FormRules); + + if ($this->form_validation->run() == TRUE) + { + $sid=$this->input->post('hid_sid'); + $name_supplier=$this->input->post('input_name_supplier'); + $short_name=$this->input->post('input_short_name'); + $contact_no=$this->input->post('input_contact_no'); + $gst_no=$this->input->post('input_gst_no'); + $city=$this->input->post('input_city'); + $state=$this->input->post('input_state'); + + $Udata = array( + 'name_supplier'=> $name_supplier, + 'short_name'=> $short_name, + 'contact_no'=> $contact_no, + 'gst_no'=> $gst_no, + 'city'=> $city, + 'state'=> $state + ); + + $this->load->model('Medical_M'); + + if($sid>0) + { + $inser_id=$this->Medical_M->update_supplier($Udata,$sid); + $send_msg="Saved Successfully"; + }else{ + $inser_id=$this->Medical_M->insert_supplier($Udata); + $send_msg="Added Successfully"; + } + + if($inser_id>0) + { + $show_text=Show_Alert('success','Success',$send_msg); + }else{ + $show_text=Show_Alert('danger','Error',$send_msg); + } + + $rvar=array( + 'insertid' =>$inser_id, + 'show_text'=>$show_text + ); + + $encode_data = json_encode($rvar); + echo $encode_data; + + } + else{ + $send_msg=validation_errors(); + $rvar=array( + 'insertid' =>0, + 'show_text'=>Show_Alert('danger','Error',$send_msg) + ); + $encode_data = json_encode($rvar); + echo $encode_data; + } + + } + + public function StockDrugList() + { + $this->load->view('Medical/Medical_stock_drug'); + } + + public function add_stock() + { + if (!$this->input->is_ajax_request()) { exit('no valid req.'); } + + $FormRules = array( + array( + 'field' => 'input_product_code', + 'label' => 'Product Code', + 'rules' => 'required|min_length[3]|max_length[30]' + ), + array( + 'field' => 'input_product_name', + 'label' => 'Product Name', + 'rules' => 'required|min_length[3]|max_length[100]' + ), + array( + 'field' => 'input_product_mrp', + 'label' => 'Product MRP', + 'rules' => 'required|min_length[1]|max_length[10]' + ), + array( + 'field' => 'input_selling_price', + 'label' => 'Selling Price', + 'rules' => 'required|min_length[1]|max_length[10]' + ), + array( + 'field' => 'input_qty', + 'label' => 'Product Qty', + 'rules' => 'required|min_length[1]|max_length[10]' + ), + array( + 'field' => 'input_package', + 'label' => 'Package', + 'rules' => 'required|min_length[1]|max_length[10]' + ), + array( + 'field' => 'input_HSNCODE', + 'label' => 'HSNCODE', + 'rules' => 'required|min_length[1]|max_length[10]' + ), + array( + 'field' => 'input_CGST', + 'label' => 'CGST', + 'rules' => 'required|min_length[1]|max_length[10]' + ), + array( + 'field' => 'input_SGST', + 'label' => 'SGST', + 'rules' => 'required|min_length[1]|max_length[10]' + ) + ); + + $this->form_validation->set_rules($FormRules); + + if ($this->form_validation->run() == TRUE) + { + $item_code=$this->input->post('input_product_code'); + + if($item_code=='IC0000000') + { + $item_code='MC'.date('ymdhis'); + } + + $selling_price=$this->input->post('input_selling_price'); + + $package=$this->input->post('input_package'); + $qty=$this->input->post('input_qty'); + $total_unit=$package*$qty; + $unit_rate=$selling_price/$qty; + + $datepicker_doe_month=$this->input->post('datepicker_doe_month'); + $datepicker_doe_year=$this->input->post('datepicker_doe_year'); + + $datepicker_doe="20".$datepicker_doe_year."-".$datepicker_doe_month."-01"; + + $this->load->model('Medical_M'); + $data = array( + 'item_code' => $item_code, + 'item_name' => $this->input->post('input_product_name'), + 'rack_no' => $this->input->post('input_rack_no'), + 'shelf_no' => $this->input->post('input_shelf_no'), + 'cold_storage' => $this->input->post('input_storage'), + 'batch_no' => $this->input->post('input_batch_code'), + 'qty' => $this->input->post('input_qty'), + 'packing' => $this->input->post('input_package'), + 'expiry_date' => $datepicker_doe, + 'mrp' => $this->input->post('input_product_mrp'), + 'purchase_price' => $this->input->post('input_purchase_price'), + 'selling_price' => $this->input->post('input_selling_price'), + 'total_unit' => $total_unit, + 'unit_rate' => $unit_rate, + 'margin' => $this->input->post('input_margin'), + 'formulation' => $this->input->post('input_formulation'), + 'stock_date' => str_to_MysqlDate($this->input->post('datepicker_stock')), + 'min_qty' => $this->input->post('input_minqty'), + 'HSNCODE' => $this->input->post('input_HSNCODE'), + 'CGST' => $this->input->post('input_CGST'), + 'SGST' => $this->input->post('input_SGST'), + 'IGST' => $this->input->post('input_IGST'), + 'dosage' => $this->input->post('input_dosage'), + 'supplier_id' => $this->input->post('input_supplier') + ); + + $data_drug = array( + 'item_id' => $item_code, + 'itemname' => $this->input->post('input_product_name'), + 'mrp' => $this->input->post('input_product_mrp'), + 'formulation' => $this->input->post('input_formulation'), + 'HSNCODE' => $this->input->post('input_HSNCODE'), + 'CGST' => $this->input->post('input_CGST'), + 'SGST' => $this->input->post('input_SGST'), + 'IGST' => $this->input->post('input_IGST'), + 'dosage' => $this->input->post('input_dosage') + ); + $show_text=''; + + $sql="select * from drug_temp where item_id='".$item_code."'"; + $query = $this->db->query($sql); + $drug_item= $query->result(); + + if(count($drug_item)>0) + { + $inser_id=$this->Medical_M->update_drug($data_drug,$item_code); + }else{ + $inser_id=$this->Medical_M->insert_drug_add($data_drug); + } + + if($inser_id>0) + { + $inser_id=0; + $inser_id=$this->Medical_M->insert_stock_add($data); + if($inser_id>0) + { + $send_msg="Added"; + }else{ + $send_msg="Error : Add in Stock Table"; + } + }else{ + $send_msg="Error : Addition data in Master Drug Table"; + } + + if($inser_id>0) + { + $show_text=Show_Alert('success','Success',$send_msg); + }else{ + $show_text=Show_Alert('danger','Error',$send_msg); + } + + $rvar=array( + 'insertid' =>$inser_id, + 'product_code' => $item_code, + 'show_text'=>$show_text + ); + + $encode_data = json_encode($rvar); + echo $encode_data; + + } + else + { + $send_msg=validation_errors(); + $rvar=array( + 'insertid' =>0, + 'show_text'=>Show_Alert('danger','Error',$send_msg) + ); + $encode_data = json_encode($rvar); + echo $encode_data; + } + } + + public function update_master() + { + if (!$this->input->is_ajax_request()) { exit('no valid req.'); } + + $FormRules = array( + array( + 'field' => 'input_product_code', + 'label' => 'Product Code', + 'rules' => 'required|min_length[3]|max_length[30]' + ), + array( + 'field' => 'input_product_name', + 'label' => 'Product Name', + 'rules' => 'required|min_length[3]|max_length[100]' + ), + array( + 'field' => 'input_product_mrp', + 'label' => 'Product MRP', + 'rules' => 'required|min_length[1]|max_length[10]' + ), + array( + 'field' => 'input_selling_price', + 'label' => 'Selling Price', + 'rules' => 'required|min_length[1]|max_length[10]' + ), + array( + 'field' => 'input_HSNCODE', + 'label' => 'HSNCODE', + 'rules' => 'required|min_length[1]|max_length[10]' + ), + array( + 'field' => 'input_CGST', + 'label' => 'CGST', + 'rules' => 'required|min_length[1]|max_length[10]' + ), + array( + 'field' => 'input_SGST', + 'label' => 'SGST', + 'rules' => 'required|min_length[1]|max_length[10]' + ) + ); + + $this->form_validation->set_rules($FormRules); + + if ($this->form_validation->run() == TRUE) + { + $item_code=$this->input->post('input_product_code'); + + $this->load->model('Medical_M'); + + $data_drug = array( + 'item_id' => $item_code, + 'itemname' => $this->input->post('input_product_name'), + 'mrp' => $this->input->post('input_product_mrp'), + 'formulation' => $this->input->post('input_formulation'), + 'HSNCODE' => $this->input->post('input_HSNCODE'), + 'CGST' => $this->input->post('input_CGST'), + 'SGST' => $this->input->post('input_SGST'), + 'IGST' => $this->input->post('input_IGST'), + 'dosage' => $this->input->post('input_dosage') + ); + $show_text=''; + + $sql="select * from drug_temp where item_id='".$item_code."'"; + $query = $this->db->query($sql); + $drug_item= $query->result(); + + if(count($drug_item)>0) + { + $inser_id=$this->Medical_M->update_drug($data_drug,$item_code); + }else{ + $inser_id=$this->Medical_M->insert_drug_add($data_drug); + } + + if($inser_id>0) + { + $inser_id=0; + $inser_id=$this->Medical_M->insert_stock_add($data); + if($inser_id>0) + { + $send_msg="Update"; + }else{ + $send_msg="Error : Edit in Drug Master"; + } + }else{ + $send_msg="Error : Addition data in Master Drug Table"; + } + + if($inser_id>0) + { + $show_text=Show_Alert('success','Success',$send_msg); + }else{ + $show_text=Show_Alert('danger','Error',$send_msg); + } + + $rvar=array( + 'insertid' =>$inser_id, + 'product_code' => $item_code, + 'show_text'=>$show_text + ); + + $encode_data = json_encode($rvar); + echo $encode_data; + + } + else + { + $send_msg=validation_errors(); + $rvar=array( + 'insertid' =>0, + 'show_text'=>Show_Alert('danger','Error',$send_msg) + ); + $encode_data = json_encode($rvar); + echo $encode_data; + } + } + + public function update_stock($ss_no) + { + if (!$this->input->is_ajax_request()) { exit('no valid req.'); } + + $FormRules = array( + array( + 'field' => 'input_product_code', + 'label' => 'Product Code', + 'rules' => 'required|min_length[3]|max_length[30]' + ), + array( + 'field' => 'input_product_name', + 'label' => 'Product Name', + 'rules' => 'required|min_length[3]|max_length[100]' + ) + , + array( + 'field' => 'input_product_mrp', + 'label' => 'Product MRP', + 'rules' => 'required|min_length[1]|max_length[10]' + ), + array( + 'field' => 'input_selling_price', + 'label' => 'Selling Price', + 'rules' => 'required|min_length[1]|max_length[10]' + ), + array( + 'field' => 'input_qty', + 'label' => 'Product Qty', + 'rules' => 'required|min_length[1]|max_length[10]' + ), + array( + 'field' => 'input_package', + 'label' => 'Package', + 'rules' => 'required|min_length[1]|max_length[10]' + ), + array( + 'field' => 'input_HSNCODE', + 'label' => 'HSNCODE', + 'rules' => 'required|min_length[1]|max_length[10]' + ), + array( + 'field' => 'input_CGST', + 'label' => 'CGST', + 'rules' => 'required|min_length[1]|max_length[10]' + ), + array( + 'field' => 'input_SGST', + 'label' => 'SGST', + 'rules' => 'required|min_length[1]|max_length[10]' + ) + ); + + $this->form_validation->set_rules($FormRules); + + if ($this->form_validation->run() == TRUE) + { + $item_code=$this->input->post('input_product_code'); + + $selling_price=$this->input->post('input_selling_price'); + + $package=$this->input->post('input_package'); + $qty=$this->input->post('input_qty'); + $total_unit=$package*$qty; + $unit_rate=$selling_price/$qty; + + $datepicker_doe_month=$this->input->post('datepicker_doe_month'); + $datepicker_doe_year=$this->input->post('datepicker_doe_year'); + + $datepicker_doe="20".$datepicker_doe_year."-".$datepicker_doe_month."-01"; + + $this->load->model('Medical_M'); + $data = array( + 'item_code' => $item_code, + 'item_name' => $this->input->post('input_product_name'), + 'rack_no' => $this->input->post('input_rack_no'), + 'shelf_no' => $this->input->post('input_shelf_no'), + 'cold_storage' => $this->input->post('input_storage'), + 'batch_no' => $this->input->post('input_batch_code'), + 'qty' => $this->input->post('input_qty'), + 'packing' => $this->input->post('input_package'), + 'expiry_date' => $datepicker_doe, + 'mrp' => $this->input->post('input_product_mrp'), + 'purchase_price' => $this->input->post('input_purchase_price'), + 'selling_price' => $this->input->post('input_selling_price'), + 'total_unit' => $total_unit, + 'unit_rate' => $unit_rate, + 'margin' => $this->input->post('input_margin'), + 'formulation' => $this->input->post('input_formulation'), + 'stock_date' => str_to_MysqlDate($this->input->post('datepicker_stock')), + 'min_qty' => $this->input->post('input_minqty'), + 'HSNCODE' => $this->input->post('input_HSNCODE'), + 'CGST' => $this->input->post('input_CGST'), + 'SGST' => $this->input->post('input_SGST'), + 'IGST' => $this->input->post('input_IGST'), + 'supplier_id' => $this->input->post('input_supplier') + ); + + $show_text=''; + + $is_update_stock=0; + + $is_update_stock=$this->Medical_M->update_stock_upd($data,$ss_no); + + if($is_update_stock>0) + { + $send_msg="Updated"; + }else{ + $send_msg="Error : Update in Stock Table"; + } + + if($is_update_stock>0) + { + $show_text=Show_Alert('success','Updated',$send_msg); + }else{ + $show_text=Show_Alert('danger','Error',$send_msg); + } + + $rvar=array( + 'is_update_stock' =>$is_update_stock, + 'product_code' => $item_code, + 'show_text'=>$show_text + ); + + $encode_data = json_encode($rvar); + echo $encode_data; + + } + else + { + $send_msg=validation_errors(); + $rvar=array( + 'is_update_stock' =>0, + 'show_text'=>Show_Alert('danger','Error',$send_msg) + ); + $encode_data = json_encode($rvar); + echo $encode_data; + } + } + + public function purchase_update_stock($inv_id,$return_stock=0) + { + if (!$this->input->is_ajax_request()) { exit('no valid req.'); } + + $sql="select * from purchase_invoice where id=".$inv_id; + $query = $this->db->query($sql); + $purchase_invoice= $query->result(); + + $user = $this->ion_auth->user()->row(); + $user_id = $user->id; + $user_name_info = $user->first_name.''. $user->last_name .'['.$user_id.']'.date('d-m-Y H:i:s'); + + $FormRules = array( + array( + 'field' => 'input_product_code', + 'label' => 'Not Found in Database', + 'rules' => 'required|min_length[1]|max_length[30]' + ), + array( + 'field' => 'input_drug_hid', + 'label' => 'Product Name', + 'rules' => 'required|min_length[3]|max_length[100]' + ), + array( + 'field' => 'input_product_mrp', + 'label' => 'Product MRP', + 'rules' => 'required|min_length[1]|max_length[10]' + ), + array( + 'field' => 'input_selling_price', + 'label' => 'Selling Price', + 'rules' => 'required|min_length[1]|max_length[10]' + ), + array( + 'field' => 'input_Qty', + 'label' => 'Product Qty', + 'rules' => 'required|min_length[1]|max_length[10]' + ), + array( + 'field' => 'input_package', + 'label' => 'Package', + 'rules' => 'required|min_length[1]|max_length[10]' + ), + array( + 'field' => 'input_HSNCODE', + 'label' => 'HSNCODE', + 'rules' => 'required|min_length[1]|max_length[10]' + ), + array( + 'field' => 'input_CGST', + 'label' => 'CGST', + 'rules' => 'required|min_length[1]|max_length[10]' + ), + array( + 'field' => 'input_SGST', + 'label' => 'SGST', + 'rules' => 'required|min_length[1]|max_length[10]' + ), + array( + 'field' => 'input_purchase_price', + 'label' => 'Purchase Price', + 'rules' => 'required|min_length[1]|max_length[10]' + ) + ); + + $this->form_validation->set_rules($FormRules); + + if ($this->form_validation->run() == TRUE) + { + $item_code=$this->input->post('input_product_code'); + $item_id=$this->input->post('invoice_item_id'); + + $datepicker_doe_month=$this->input->post('datepicker_doe_month'); + $datepicker_doe_year=$this->input->post('datepicker_doe_year'); + + $datepicker_doe="20".$datepicker_doe_year."-".$datepicker_doe_month."-01"; + + $this->load->model('Medical_M'); + + $Pdata = array( + 'purchase_id' => $inv_id, + 'item_code' => $item_code, + 'item_name' => $this->input->post('input_drug_hid'), + 'packing' => $this->input->post('input_package'), + 'batch_no' => $this->input->post('input_batch_code'), + 'purchase_price' => $this->input->post('input_purchase_price'), + 'expiry_date' => $datepicker_doe, + 'mrp' => $this->input->post('input_product_mrp'), + + 'qty' => $this->input->post('input_Qty'), + 'qty_free' => $this->input->post('input_Qty_Free'), + + 'discount' => $this->input->post('input_disc_price'), + + 'CGST_per' => $this->input->post('input_CGST'), + 'SGST_per' => $this->input->post('input_SGST'), + + 'HSNCODE' => $this->input->post('input_HSNCODE'), + + 'cold_storage' => $this->input->post('input_storage'), + 'shelf_no' => $this->input->post('input_shelf_no'), + 'rack_no' => $this->input->post('input_rack_no'), + 'stock_date' => $purchase_invoice[0]->date_of_invoice, + + 'selling_price' => $this->input->post('input_selling_price'), + + 'sch_disc_amt' => $this->input->post('input_sch_amount'), + 'sch_disc_per' => $this->input->post('input_sch_disc'), + + 'insert_by' => $user_name_info, + + 'item_return' => $return_stock + ); + + $show_text=''; + + $is_update_stock=0; + + if($item_id<1) + { + $is_update_stock=$this->Medical_M->insert_purchase_item($Pdata); + }else{ + $is_update_stock=$this->Medical_M->update_purchase_item($Pdata,$item_id); + } + + if($is_update_stock>0) + { + $send_msg="Updated"; + }else{ + $send_msg="Error : Update in Stock Table"; + } + + if($is_update_stock>0) + { + $show_text=$send_msg; + }else{ + $show_text=$send_msg; + } + + $rvar=array( + 'is_update_stock' =>$is_update_stock, + 'product_code' => $item_code, + 'show_text'=>$show_text + ); + + $encode_data = json_encode($rvar); + echo $encode_data; + + } + else + { + $send_msg=validation_errors(); + $rvar=array( + 'is_update_stock' =>0, + 'show_text'=>$send_msg + ); + $encode_data = json_encode($rvar); + echo $encode_data; + } + } + + function purchase_invoice_item_edit($inv_id,$inv_item_id) + { + $sql="select *, + date_format(expiry_date,'%m') as str_expiry_month , + date_format(expiry_date,'%y') as str_expiry_year + from purchase_invoice_item where id=".$inv_item_id." and purchase_id=".$inv_id; + $query = $this->db->query($sql); + $purchase_invoice_item= $query->result(); + + if(count($purchase_invoice_item)>0) + { + $rvar=array( + 'is_update_stock'=>'1', + 'item_id' =>$purchase_invoice_item[0]->id, + 'product_code' =>$purchase_invoice_item[0]->item_code, + 'product_mrp' => $purchase_invoice_item[0]->mrp, + 'selling_price'=>$purchase_invoice_item[0]->selling_price, + 'batch_code'=>$purchase_invoice_item[0]->batch_no, + 'disc_price'=>$purchase_invoice_item[0]->discount, + 'qty'=>$purchase_invoice_item[0]->qty, + 'qty_free'=>$purchase_invoice_item[0]->qty_free, + 'package'=>$purchase_invoice_item[0]->packing, + 'purchase_price'=>$purchase_invoice_item[0]->purchase_price, + 'datepicker_doe_month'=>$purchase_invoice_item[0]->str_expiry_month, + 'datepicker_doe_year'=>$purchase_invoice_item[0]->str_expiry_year, + 'drug'=>$purchase_invoice_item[0]->Item_name, + + 'HSNCODE'=>$purchase_invoice_item[0]->HSNCODE, + 'CGST_per'=>$purchase_invoice_item[0]->CGST_per, + 'SGST_per'=>$purchase_invoice_item[0]->SGST_per, + + 'cold_storage'=>$purchase_invoice_item[0]->cold_storage, + 'shelf_no'=>$purchase_invoice_item[0]->shelf_no, + 'rack_no'=>$purchase_invoice_item[0]->rack_no, + + ); + }else{ + $rvar=array( + 'is_update_stock'=>'0', + 'show_text'=>$sql + ); + } + + $encode_data = json_encode($rvar); + echo $encode_data; + + } + + public function purchase_invoice_item_list($inv_id) + { + $sql="select *,date_format(expiry_date,'%m/%y') as exp_date_str from purchase_invoice_item where purchase_id='".$inv_id."' "; + $query = $this->db->query($sql); + $data['purchase_item']= $query->result(); + + $sql="select * from purchase_invoice where id='".$inv_id."' "; + $query = $this->db->query($sql); + $data['purchase_invoice']= $query->result(); + + $this->load->view('Medical/Purchase/purchase_invoice_item',$data); + + } + + public function purchase_invoice_item_list_old($item_code) + { + $sql="SELECT s.name_supplier, date_format(p.date_of_invoice,'%d-%m-%Y') as date_of_invoice_str, + i.Item_name,i.packing,i.purchase_price,i.qty,i.qty_free,i.mrp + FROM (purchase_invoice p JOIN purchase_invoice_item i ON p.id=i.purchase_id) + JOIN med_supplier s ON p.sid=s.sid + WHERE i.item_code=$item_code ORDER BY i.id DESC LIMIT 5 "; + $query = $this->db->query($sql); + $data['purchase_item_old']= $query->result(); + + $this->load->view('Medical/Purchase/purchase_item_old',$data); + + } + + public function purchase_invoice_item_delete($inv_id,$inv_item_del) + { + $this->load->model('Medical_M'); + + $is_update_stock=$this->Medical_M->delete_purchase_item($inv_id,$inv_item_del); + + if($is_update_stock==0) + { + $rvar=array( + 'is_update_stock' =>0, + 'show_text'=>'Sold some Quantity of this Item', + ); + }else{ + $rvar=array( + 'is_update_stock' =>1, + 'show_text'=>'Removed Successfully', + ); + } + + $encode_data = json_encode($rvar); + echo $encode_data; + } + + public function AddDrugStock($drug_item_code) + { + $sql="select * from drug_temp where item_id='".$drug_item_code."' "; + $query = $this->db->query($sql); + $data['drug_item']= $query->result(); + + $sql="select * from stock_addition where item_code='".$drug_item_code."' "; + $query = $this->db->query($sql); + $data['drug_stock_item']= $query->result(); + + $sql="select * from med_supplier "; + $query = $this->db->query($sql); + $data['med_supplier']= $query->result(); + + $this->load->view('Medical/Drug_Stock_Add',$data); + } + + public function UpdateDrugStock($ss_no) + { + $sql="select * from stock_addition where ss_no='".$ss_no."' "; + $query = $this->db->query($sql); + $data['stock_item']= $query->result(); + + $sql="select * from med_supplier "; + $query = $this->db->query($sql); + $data['med_supplier']= $query->result(); + + $this->load->view('Medical/Stock_Update',$data); + } + + public function load_stock_data($item_code) + { + $sql="select * from stock_addition where item_code='".$item_code."' "; + $query = $this->db->query($sql); + $data['drug_stock_item']= $query->result(); + + echo ' + + + + + + + + + + + + + + '; + + $srno=0; + + foreach($data['drug_stock_item'] as $row) + { + $srno=$srno+1; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + } + + echo ''; + + echo ' + + + + + + + + + + + + +
Item CodeItem NameFormulationStorage/Shelf/Rack No.Batch No.Qty /Sale QtyExpiryMRPRate/Unit
'.$row->item_code.''.$row->item_name.''.$row->formulation.''.$row->cold_storage.'/'.$row->shelf_no.'/'.$row->rack_no.''.$row->batch_no.''.$row->total_unit.'/'.$row->total_sale_unit.''.$row->expiry_date.''.$row->mrp.''.$row->unit_rate.'
Item CodeItem NameFormulationStorage/Shelf/Rack No.Batch No.Qty /Sale QtyExpiryMRPRate/Unit
'; + } + + public function Invoice_counter() + { + $sql="select * from invoice_med_master"; + $query = $this->db->query($sql); + $data['invoiceMaster']= $query->result(); + + $sql="select * from inv_med_item"; + $query = $this->db->query($sql); + $data['inv_items']= $query->result(); + + $sql="select sum(amount) as Gtotal from inv_med_item"; + $query = $this->db->query($sql); + $data['invoiceGtotal']= $query->result(); + + $sql="select * from doctor_master where active=1"; + $query = $this->db->query($sql); + $data['doclist']= $query->result(); + + if($data['invoiceMaster'][0]->case_id > 0) + { + $sql="select * from organization_case_master where id=".$data['invoiceMaster'][0]->case_id; + $query = $this->db->query($sql); + $data['OCaseMaster']= $query->result(); + } + + $user = $this->ion_auth->user()->row(); + $data['user_id'] = $user->id; + + $this->load->view('Medical/Medical_Invoice_V',$data); + + } + + public function Invoice_Med_Draft() + { + $this->load->view('Medical/Draft_Med_Invoice'); + } + + public function Invoice_Med_Return() + { + $this->load->view('Medical/Draft_Med_Return_Invoice'); + } + + + public function Invoice_med_show($inv_id) + { + $sql="select *,if(ipd_credit>0,'Credit to IPD','CASH') as credit_status, + if(case_credit>0,'Credit to Org','CASH') as credit_org_status from invoice_med_master + where id=$inv_id"; + $query = $this->db->query($sql); + $data['invoiceMaster']= $query->result(); + + $patient_id=$data['invoiceMaster'][0]->patient_id; + $inv_phone_number=$data['invoiceMaster'][0]->inv_phone_number; + + if($patient_id==0) + { + + } + + $sql="select * from inv_med_item where inv_med_id=".$inv_id; + $query = $this->db->query($sql); + $data['inv_items']= $query->result(); + + $sql="select sum(amount) as Gtotal,sum(tamount) as tamt,sum(CGST) as TCGST,sum(SGST) as TSGST,sum(disc_amount) as t_dis_amt from inv_med_item where inv_med_id=".$inv_id; + $query = $this->db->query($sql); + $data['invoiceGtotal']= $query->result(); + + $sql="select * from doctor_master where active=1"; + $query = $this->db->query($sql); + $data['doclist']= $query->result(); + + $sql="select *, + GET_AGE_1(dob,age,age_in_month,estimate_dob) AS age from patient_master where id='".$data['invoiceMaster'][0]->patient_id."' "; + $query = $this->db->query($sql); + $data['person_info']= $query->result(); + + $data['org_Name']=""; + $ipd_id=$data['invoiceMaster'][0]->ipd_id; + + if($ipd_id>0) + { + $sql="select * from ipd_master where id=".$ipd_id; + $query = $this->db->query($sql); + $ipd_master= $query->result(); + + $sql="select * from v_ipd_list m join patient_master p on m.p_id=p.id + where m.id=".$ipd_id; + $query = $this->db->query($sql); + $data['ipd_list']= $query->result(); + + $data['ipd_master']=$ipd_master; + + if(count($ipd_master)>0) + { + $p_ipd_id=$ipd_master[0]->id; + $p_ipd_code=$ipd_master[0]->ipd_code; + + if($ipd_master[0]->case_id>0) + { + $sql="select * from organization_case_master where id=".$ipd_master[0]->case_id; + $query = $this->db->query($sql); + $org_master= $query->result(); + + if(count($org_master)>0) + { + $data['org_Name']=$org_master[0]->insurance_company_name; + } + } + } + } + + if($data['invoiceMaster'][0]->case_id > 0) + { + $sql="select * from organization_case_master where id=".$data['invoiceMaster'][0]->case_id; + $query = $this->db->query($sql); + $data['OCaseMaster']= $query->result(); + } + + $user = $this->ion_auth->user()->row(); + $data['user_id'] = $user->id; + + $data['sale_return']=$data['invoiceMaster'][0]->sale_return; + + $data['content']=$this->load->view('Medical/Med_Item_List',$data,true); + + if($data['invoiceMaster'][0]->sale_return==0) + { + $this->load->view('Medical/Medical_Invoice_V',$data); + }else{ + $this->load->view('Medical/Medical_Invoice_Return_V',$data); + } + + } + + //New Invoice Edit + public function Invoice_med_datasheet($inv_id) + { + $sql="select *,if(ipd_credit>0,'Credit to IPD','CASH') as credit_status, + if(case_credit>0,'Credit to Org','CASH') as credit_org_status from invoice_med_master + where id=$inv_id"; + $query = $this->db->query($sql); + $data['invoiceMaster']= $query->result(); + + $sql="select * from inv_med_item where inv_med_id=".$inv_id; + $query = $this->db->query($sql); + $data['inv_items']= $query->result(); + + $sql="select sum(amount) as Gtotal,sum(tamount) as tamt,sum(CGST) as TCGST,sum(SGST) as TSGST,sum(disc_amount) as t_dis_amt from inv_med_item where inv_med_id=".$inv_id; + $query = $this->db->query($sql); + $data['invoiceGtotal']= $query->result(); + + $sql="select * from doctor_master where active=1"; + $query = $this->db->query($sql); + $data['doclist']= $query->result(); + + $sql="select *, + GET_AGE_1(dob,age,age_in_month,estimate_dob) AS age from patient_master where id='".$data['invoiceMaster'][0]->patient_id."' "; + $query = $this->db->query($sql); + $data['person_info']= $query->result(); + + $data['org_Name']=""; + $ipd_id=$data['invoiceMaster'][0]->ipd_id; + + if($ipd_id>0) + { + $sql="select * from ipd_master where id=".$ipd_id; + $query = $this->db->query($sql); + $ipd_master= $query->result(); + + $sql="select * from v_ipd_list m join patient_master p on m.p_id=p.id + where m.id=".$ipd_id; + $query = $this->db->query($sql); + $data['ipd_list']= $query->result(); + + $data['ipd_master']=$ipd_master; + + if(count($ipd_master)>0) + { + $p_ipd_id=$ipd_master[0]->id; + $p_ipd_code=$ipd_master[0]->ipd_code; + + if($ipd_master[0]->case_id>0) + { + $sql="select * from organization_case_master where id=".$ipd_master[0]->case_id; + $query = $this->db->query($sql); + $org_master= $query->result(); + + if(count($org_master)>0) + { + $data['org_Name']=$org_master[0]->insurance_company_name; + } + } + } + } + + if($data['invoiceMaster'][0]->case_id > 0) + { + $sql="select * from organization_case_master where id=".$data['invoiceMaster'][0]->case_id; + $query = $this->db->query($sql); + $data['OCaseMaster']= $query->result(); + } + + $user = $this->ion_auth->user()->row(); + $data['user_id'] = $user->id; + + $data['sale_return']=$data['invoiceMaster'][0]->sale_return; + + $data['content']=$this->load->view('Medical/Med_Item_List',$data,true); + + if($data['invoiceMaster'][0]->sale_return==0) + { + $this->load->view('Medical/Medical_Invoice_V',$data); + }else{ + $this->load->view('Medical/Medical_Invoice_Return_V',$data); + } + + + } + + + // Update Medical Invoice Master + + public function update_uhid() + { + $this->load->model('Medical_M'); + + $user = $this->ion_auth->user()->row(); + $data['user_id'] = $user->id; + + $inv_id=$this->input->post('med_invoice_id'); + $pid=$this->input->post('pid'); + + $sql="select * from invoice_med_master where id=".$inv_id; + $query = $this->db->query($sql); + $invoice_master= $query->result(); + + $sql="select * from patient_master_exten where id='".$pid."' "; + $query = $this->db->query($sql); + $person_info= $query->result(); + + if(count($person_info)>0) + { + $patient_id=$person_info[0]->id; + $patient_code_u=$person_info[0]->p_code; + $custmer_Name=$person_info[0]->p_fname; + + $data = array( + 'customer_type'=>1, + 'patient_id' => $patient_id, + 'patient_code' => $patient_code_u, + 'inv_name' => $custmer_Name, + 'ipd_credit'=>0, + 'case_credit'=>0, + 'case_credit'=>0, + ); + + $inser_id=$this->Medical_M->update_in_upv_item($data,$inv_id); + $this->Medical_M->update_invoice_group($inv_id); + $this->Medical_M->update_invoice_final($inv_id); + $status= 1; + $remark="Done"; + + }else{ + $status=0; + $remark="Not Done"; + } + + $rvar=array( + 'status' =>$status, + 'remark'=>$remark + ); + + $encode_data = json_encode($rvar); + echo $encode_data; + } + + public function update_ipd() + { + $this->load->model('Medical_M'); + + $user = $this->ion_auth->user()->row(); + $data['user_id'] = $user->id; + + $inv_id=$this->input->post('med_invoice_id'); + $ipd_id=$this->input->post('ipd_id'); + + $sql="select * from invoice_med_master where id=".$inv_id; + $query = $this->db->query($sql); + $invoice_master= $query->result(); + + $sql="select * from ipd_master where id=".$ipd_id; + $query = $this->db->query($sql); + $ipd_master= $query->result(); + + $pid=$ipd_master[0]->p_id; + + $sql="select * from patient_master_exten where id='".$pid."' "; + $query = $this->db->query($sql); + $person_info= $query->result(); + + if(count($person_info)>0) + { + $patient_id=$person_info[0]->id; + $patient_code_u=$person_info[0]->p_code; + $custmer_Name=$person_info[0]->p_fname; + + $ipd_id=$ipd_master[0]->id; + $ipd_code=$ipd_master[0]->ipd_code; + + $data = array( + 'customer_type'=>1, + 'patient_id' => $patient_id, + 'patient_code' => $patient_code_u, + 'inv_name' => $custmer_Name, + 'ipd_credit'=>0, + 'case_credit'=>0, + 'ipd_id'=> $ipd_id, + 'ipd_code'=>$ipd_code, + ); + + $inser_id=$this->Medical_M->update_in_upv_item($data,$inv_id); + $this->Medical_M->update_invoice_group($inv_id); + $this->Medical_M->update_invoice_final($inv_id); + $status= 1; + $remark="Done"; + + }else{ + $status=0; + $remark="Not Done"; + } + + $rvar=array( + 'status' =>$status, + 'remark'=>$remark + ); + $encode_data = json_encode($rvar); + echo $encode_data; + } + + public function update_org() + { + $this->load->model('Medical_M'); + + $user = $this->ion_auth->user()->row(); + $data['user_id'] = $user->id; + + $inv_id=$this->input->post('med_invoice_id'); + $org_id=$this->input->post('org_id'); + + $sql="select * from invoice_med_master where id=".$inv_id; + $query = $this->db->query($sql); + $invoice_master= $query->result(); + + $sql="select * from organization_case_master where case_type=0 and id=".$org_id; + $query = $this->db->query($sql); + $org_master= $query->result(); + + $pid=$org_master[0]->p_id; + + $sql="select * from patient_master_exten where id='".$pid."' "; + $query = $this->db->query($sql); + $person_info= $query->result(); + + if(count($person_info)>0) + { + $patient_id=$person_info[0]->id; + $patient_code_u=$person_info[0]->p_code; + $custmer_Name=$person_info[0]->p_fname; + + $org_id=$org_master[0]->id; + $org_code=$org_master[0]->case_id_code; + + $data = array( + 'customer_type'=>1, + 'patient_id' => $patient_id, + 'patient_code' => $patient_code_u, + 'inv_name' => $custmer_Name, + 'ipd_credit'=>0, + 'case_credit'=>1, + 'ipd_id'=> 0, + 'ipd_code'=>'', + 'case_id'=>$org_id, + ); + + $inser_id=$this->Medical_M->update_in_upv_item($data,$inv_id); + $this->Medical_M->update_invoice_group($inv_id); + $this->Medical_M->update_invoice_final($inv_id); + $status= 1; + $remark="Done"; + + }else{ + $status=0; + $remark="Not Done"; + } + + $rvar=array( + 'status' =>$status, + 'remark'=>$remark + ); + $encode_data = json_encode($rvar); + echo $encode_data; + } + + public function update_invdate() + { + $this->load->model('Medical_M'); + + $inv_id=$this->input->post('med_invoice_id'); + $inv_date=$this->input->post('inv_date'); + + $sql="select * from invoice_med_master where id=".$inv_id; + $query = $this->db->query($sql); + $invoice_master= $query->result(); + + $inv_date=str_to_MysqlDate($inv_date); + + $data = array( + 'inv_date' => $inv_date, + ); + + $inser_id=$this->Medical_M->update_in_upv_item($data,$inv_id); + + $status= 1; + $remark="Done"; + + $rvar=array( + 'status' =>$status, + 'remark'=>$remark + ); + $encode_data = json_encode($rvar); + echo $encode_data; + } + + public function update_name_phone() + { + $this->load->model('Medical_M'); + + $inv_id=$this->input->post('med_invoice_id'); + $pid=$this->input->post('pid'); + $customer_type=$this->input->post('customer_type'); + $P_Name=$this->input->post('P_Name'); + $P_Phone=$this->input->post('P_Phone'); + + $doc_id=$this->input->post('doc_id'); + $doc_name=$this->input->post('doc_name'); + + $refername=$doc_name; + + $sql="select * from doctor_master where id='".$doc_id."' "; + $query = $this->db->query($sql); + $doc_info= $query->result(); + + if(count($doc_info)>0) + { + $refername=$doc_info[0]->p_fname; + } + + + $data = array( + 'customer_type'=>$customer_type, + 'patient_id' => '0', + 'patient_code' => '', + 'inv_name' => $P_Name, + 'inv_phone_number' => $P_Phone, + 'ipd_credit'=>0, + 'case_credit'=>0, + 'ipd_id'=> 0, + 'ipd_code'=>'', + 'case_id'=>'0', + 'doc_id' => $doc_id, + 'doc_name' => $refername, + ); + + $inser_id=$this->Medical_M->update_in_upv_item($data,$inv_id); + + $status= 1; + $remark="Done"; + + $rvar=array( + 'status' =>$status, + 'remark'=>$remark + ); + $encode_data = json_encode($rvar); + echo $encode_data; + } + + public function update_doctor() + { + $this->load->model('Medical_M'); + + $inv_id=$this->input->post('med_invoice_id'); + + $doc_id=$this->input->post('doc_id'); + $doc_name=$this->input->post('doc_name'); + + $refername=$doc_name; + + $sql="select * from doctor_master where id='".$doc_id."' "; + $query = $this->db->query($sql); + $doc_info= $query->result(); + + if(count($doc_info)>0) + { + $refername=$doc_info[0]->p_fname; + } + + $data = array( + 'doc_id' => $doc_id, + 'doc_name' => $refername, + ); + + $inser_id=$this->Medical_M->update_in_upv_item($data,$inv_id); + + $status= 1; + $remark="Done"; + + $rvar=array( + 'status' =>$status, + 'remark'=>$remark + ); + $encode_data = json_encode($rvar); + echo $encode_data; + } + + + public function update_cr_status_ipd() + { + $this->load->model('Medical_M'); + + $inv_id=$this->input->post('med_invoice_id'); + $credit_ipd=$this->input->post('credit_ipd'); + + $sql="select * from invoice_med_master where id=".$inv_id; + $query = $this->db->query($sql); + $invoice_master= $query->result(); + + $ipd_id=$invoice_master[0]->ipd_id; + + $data = array( + 'ipd_credit' => $credit_ipd, + ); + + $inser_id=$this->Medical_M->update_in_upv_item($data,$inv_id); + + $status= 1; + $remark="Done"; + + $this->Medical_M->update_invoice_group_gst($ipd_id,'1'); + $this->Medical_M->update_invoice_group_gst($ipd_id,'2'); + $this->Medical_M->update_invoice_group_gst($ipd_id,'3'); + + $rvar=array( + 'status' =>$status, + 'remark'=>$remark + ); + $encode_data = json_encode($rvar); + echo $encode_data; + } + + // End Update Medical Invoice Master + + public function search_customer($sale=0) + { + $data['sale']=$sale; + $this->load->view('Medical/Search_Patient',$data); + } + + public function Invoice_counter_new($pno,$ipd_id,$case_id) + { + + $select_doc=0; + $p_fname=''; + $p_pcode=''; + $p_pid=$pno; + $p_ipd_id=$ipd_id; + $p_ipd_code=''; + $customer_type=0; + + $select_doc=0; + $data['org_Name']=""; + $data['content']=""; + + if($pno>0) + { + $sql="select *,if(gender=1,'Male','Female') as xgender, + GET_AGE_1(dob,age,age_in_month,estimate_dob) AS age from patient_master where id='".$pno."' "; + $query = $this->db->query($sql); + $person_info= $query->result(); + + $sql="select doc_id from opd_master where p_id='".$pno."' order by opd_id desc limit 1"; + $query = $this->db->query($sql); + $data['opd_master']= $query->result(); + + $p_fname=$person_info[0]->p_fname; + $p_pcode=$person_info[0]->p_code; + + if(count($data['opd_master'])>0) + { + $select_doc=$data['opd_master'][0]->doc_id; + }else{ + $select_doc=0; + } + + $customer_type=1; + } + + if($ipd_id>0) + { + $sql="select * from ipd_master where id=".$ipd_id; + $query = $this->db->query($sql); + $data['ipd_master']= $query->result(); + + $sql="select * from v_ipd_list m join patient_master p on m.p_id=p.id + where m.id=".$ipd_id; + $query = $this->db->query($sql); + $data['ipd_list']= $query->result(); + + $p_ipd_code=$data['ipd_master'][0]->ipd_code; + + if($data['ipd_master'][0]->case_id>0) + { + $sql="select * from organization_case_master where id=".$data['ipd_master'][0]->case_id; + $query = $this->db->query($sql); + $org_master= $query->result(); + + if(count($org_master)>0) + { + $data['org_Name']=$org_master[0]->insurance_company_name; + } + } + } + + $this->load->model('Medical_M'); + + $data['invoice_med_master'] = array( + 'patient_id' => $p_pid, + 'ipd_id' => $p_ipd_id, + 'ipd_code' => $p_ipd_code, + 'case_id' => $case_id, + 'inv_date' => str_to_MysqlDate(date('d/m/Y')), + 'inv_name' => $p_fname, + 'patient_code' => $p_pcode, + 'doc_id' => $select_doc, + 'sale_return'=>0, + 'case_credit'=>0, + 'customer_type'=>$customer_type, + ); + + if($case_id>0) + { + $data['invoice_med_master']['case_credit']=1; + } + + $inser_id=$this->Medical_M->add_invoice( $data['invoice_med_master']); + + if($inser_id) + { + $sql="select *,if(ipd_credit>0,'Credit to IPD','CASH') as credit_status from invoice_med_master where id=".$inser_id; + $query = $this->db->query($sql); + $data['invoiceMaster']= $query->result(); + + $sql="select * from inv_med_item where inv_med_id=".$inser_id; + $query = $this->db->query($sql); + $data['inv_items']= $query->result(); + + $sql="select sum(amount) as Gtotal,sum(tamount) as tamt,sum(CGST) as TCGST,sum(SGST) as TSGST,sum(disc_amount) as t_dis_amt from inv_med_item where inv_med_id=".$inser_id; + $query = $this->db->query($sql); + $data['invoiceGtotal']= $query->result(); + + $sql="select * from doctor_master where active=1"; + $query = $this->db->query($sql); + $data['doclist']= $query->result(); + + $sql="select * from organization_case_master where id=".$case_id; + $query = $this->db->query($sql); + $data['OCaseMaster']= $query->result(); + + $data['sale_return']=$data['invoiceMaster'][0]->sale_return; + + $data['content']=$this->load->view('Medical/Med_Item_List',$data,true); + + $this->load->view('Medical/Medical_Invoice_V',$data); + } + } + + public function Invoice_Return_new($pno) + { + + $select_doc=0; + $p_fname=''; + $p_pcode=''; + $p_pid=$pno; + $inv_phone_number=''; + + $data['content']=''; + + if($pno>0) + { + $sql="select *,if(gender=1,'Male','Female') as xgender, + GET_AGE_1(dob,age,age_in_month,estimate_dob) AS age from patient_master where id='".$pno."' "; + $query = $this->db->query($sql); + $person_info= $query->result(); + + $p_fname=$person_info[0]->p_fname; + $p_pcode=$person_info[0]->p_code; + $inv_phone_number=$person_info[0]->mphone1; + + $select_doc=0; + } + + $this->load->model('Medical_M'); + + $data['invoice_med_master'] = array( + 'patient_id' => $p_pid, + 'inv_date' => str_to_MysqlDate(date('d/m/Y')), + 'inv_name' => $p_fname, + 'patient_code' => $p_pcode, + 'doc_id' => $select_doc, + 'inv_phone_number'=>$inv_phone_number, + 'sale_return'=>1 + ); + + $inser_id=$this->Medical_M->add_invoice( $data['invoice_med_master']); + + if($inser_id) + { + $sql="select *,if(ipd_credit>0,'Credit to IPD','CASH') as credit_status from invoice_med_master where id=".$inser_id; + $query = $this->db->query($sql); + $data['invoiceMaster']= $query->result(); + + $sql="select * from inv_med_item where inv_med_id=".$inser_id; + $query = $this->db->query($sql); + $data['inv_items']= $query->result(); + + $sql="select sum(amount) as Gtotal,sum(tamount) as tamt,sum(CGST) as TCGST,sum(SGST) as TSGST,sum(disc_amount) as t_dis_amt from inv_med_item where inv_med_id=".$inser_id; + $query = $this->db->query($sql); + $data['invoiceGtotal']= $query->result(); + + $data['sale_return']=$data['invoiceMaster'][0]->sale_return; + + $data['content']=$this->load->view('Medical/Med_Item_List',$data,true); + + $this->load->view('Medical/Medical_Invoice_Return_V',$data); + } + } + + public function item_stock_list($item_code) + { + $sql="SELECT p.item_name,t.batch_no,t.expiry_date as expiry_date_str,t.expiry_date, + (t.total_unit-t.total_sale_unit) AS c_qty, + t.id,t.mrp,t.selling_unit_rate,p.id AS item_code + FROM med_product_master p + JOIN purchase_invoice_item t ON p.id=t.item_code + where (t.total_unit-t.total_sale_unit)>0 + and (expiry_date>date_add(sysdate(),interval 1 month) or p.exp_date_applicable=0) + and p.id =$item_code"; + + $query = $this->db->query($sql); + $data['Item_list']=$query->result_array() ; + + $this->load->view('Medical/sale_item_list_for_add',$data); + } + + public function get_drug(){ + if (isset($_GET['term'])){ + $q = strtolower($_GET['term']); + + $sql="SELECT p.id as item_code, p.item_name, + IFNULL(s.item_code,0) AS item_found, + date_format(s.expiry_date,'%m-%y') as expiry_date_str, + s.batch_no, + s.mrp, + ifnull(s.packing,p.packing) as packing, + s.Cur_Qty, + p.HSNCODE as HSNCODE, + p.CGST_per as CGST_per, + p.SGST_per as SGST_per, + s.mrp as selling_price, + (s.mrp/p.packing) as sell_unit_rate + FROM med_product_master p LEFT JOIN sale_purchase_stock_tran s ON p.id=s.item_code AND s.Cur_Qty>0 + Where (p.item_name like '".$q."%' "; + + if(strlen($q)>5) + { + $sql=$sql. " or p.item_name SOUNDS LIKE '".$q."'"; + } + + $sql=$sql.") order by p.item_name limit 100"; + + $query = $this->db->query($sql); + + if($query->num_rows() > 0){ + foreach ($query->result_array() as $row){ + + if($row['item_found']>0) + { + $new_row['label']=htmlentities(stripslashes($row['item_name'])).' |B:'.htmlentities(stripslashes($row['batch_no'])).' |Pak:'.htmlentities(stripslashes($row['packing'])).' |Rs.'.htmlentities(stripslashes($row['mrp'])). ' |Qty:'.htmlentities(stripslashes($row['Cur_Qty'])); + }else{ + $new_row['label']=htmlentities(stripslashes($row['item_name'])); + } + + + $new_row['value']=htmlentities(stripslashes($row['item_name'])); + $new_row['l_item_code']=htmlentities(stripslashes($row['item_code'])); + $new_row['l_Batch']=htmlentities(stripslashes($row['batch_no'])); + $new_row['l_Expiry']=htmlentities(stripslashes($row['expiry_date_str'])); + $new_row['l_mrp']=htmlentities(stripslashes($row['mrp'])); + $new_row['l_unit_rate']=htmlentities(stripslashes($row['sell_unit_rate'])); + $new_row['l_c_qty']=htmlentities(stripslashes($row['Cur_Qty'])); + $new_row['l_packing']=htmlentities(stripslashes($row['packing'])); + $new_row['l_item_found']=htmlentities(stripslashes($row['item_found'])); + + $new_row['l_HSNCODE']=htmlentities(stripslashes($row['HSNCODE'])); + $new_row['l_CGST_per']=htmlentities(stripslashes($row['CGST_per'])); + $new_row['l_SGST_per']=htmlentities(stripslashes($row['SGST_per'])); + $new_row['sql']=""; + $row_set[] = $new_row; //build an array + } + echo json_encode($row_set); //format the array into json data + }else{ + $new_row['sql']=""; + $row_set[] = $new_row; + echo json_encode($row_set); + } + } + } + + public function get_drug_master(){ + + if (isset($_GET['term'])){ + $q = strtolower($_GET['term']); + + $sql="select * from purchase_invoice_item p + where p.id in (select max(id) from purchase_invoice_item t + where t.Item_name like '".$q."%' group by t.Item_name ) + order by p.Item_name "; + + $sql="SELECT m.* ,p.id as ss_no,m.packing as p_packing,p.mrp,p.purchase_price,p.discount, + p.batch_no,date_format(expiry_date,'%m') as str_expiry_month , + date_format(expiry_date,'%y') as str_expiry_year , + m.batch_applicable,m.exp_date_applicable, + if(p.id is null,m.CGST_per,p.CGST_per) as p_CGST_per, + if(p.id is null,m.SGST_per,p.SGST_per) as p_SGST_per, + if(p.id is null,m.rack_no,p.rack_no) as p_rack_no, + if(p.id is null,m.shelf_no,p.shelf_no) as p_shelf_no, + if(p.id is null,m.cold_storage,p.cold_storage) as p_cold_storage + + FROM med_product_master m + LEFT JOIN (SELECT * from purchase_invoice_item + WHERE id in (select max(id) from purchase_invoice_item + WHERE Item_name LIKE '".$q."%' + group BY item_code ) ) as p ON m.id=p.item_code + WHERE m.Item_name LIKE '".$q."%' + order BY m.item_name "; + + $sql=$sql." limit 20"; + + $query = $this->db->query($sql); + + if($query->num_rows() > 0){ + foreach ($query->result_array() as $row){ + $new_row['label']=htmlentities(stripslashes($row['item_name'])).' | '.htmlentities(stripslashes($row['p_packing'])).' | '.htmlentities(stripslashes($row['mrp'])); + $new_row['value']=htmlentities(stripslashes($row['item_name'])); + $new_row['l_item_code']=htmlentities(stripslashes($row['id'])); + $new_row['l_mrp']=htmlentities(stripslashes($row['mrp'])); + + $new_row['l_packing']=htmlentities(stripslashes($row['packing'])); + $new_row['l_CGST_per']=htmlentities(stripslashes($row['p_CGST_per'])); + $new_row['l_SGST_per']=htmlentities(stripslashes($row['p_SGST_per'])); + $new_row['l_HSNCODE']=htmlentities(stripslashes($row['HSNCODE'])); + + $new_row['l_batch_no']=htmlentities(stripslashes($row['batch_no'])); + + $new_row['l_purchase_price']=htmlentities(stripslashes($row['purchase_price'])); + + $new_row['l_package']=htmlentities(stripslashes($row['p_packing'])); + $new_row['l_disc_price']=htmlentities(stripslashes($row['discount'])); + + $new_row['l_rack_no']=htmlentities(stripslashes($row['p_rack_no'])); + $new_row['l_shelf_no']=htmlentities(stripslashes($row['p_shelf_no'])); + $new_row['l_cold_storage']=htmlentities(stripslashes($row['p_cold_storage'])); + + $new_row['batch_applicable']=htmlentities(stripslashes($row['batch_applicable'])); + $new_row['exp_date_applicable']=htmlentities(stripslashes($row['exp_date_applicable'])); + + $new_row['datepicker_doe_month']=htmlentities(stripslashes($row['str_expiry_month'])); + $new_row['datepicker_doe_year']=htmlentities(stripslashes($row['str_expiry_year'])); + + $row_set[] = $new_row; //build an array + } + echo json_encode($row_set); //format the array into json data + }else{ + $row_set[] = array(); + echo json_encode($row_set); + } + } + } + + public function get_formulation_desc(){ + + if (isset($_GET['term'])){ + $q = strtolower($_GET['term']); + + $sql="select * from drugs_formulation where formulation_desc like '".$q."%'"; + $query = $this->db->query($sql); + + if($query->num_rows() > 0){ + foreach ($query->result_array() as $row){ + $new_row['label']=htmlentities(stripslashes($row['formulation_desc'])); + $new_row['value']=htmlentities(stripslashes($row['formulation_desc'])); + $row_set[] = $new_row; //build an array + } + echo json_encode($row_set); //format the array into json data + } + } + } + + public function go_final() + { + $this->load->model('Medical_M'); + + $inv_id=$this->input->post('inv_id'); + $doc_id=$this->input->post('doc_id'); + $doc_name=$this->input->post('doc_name'); + $remark_ipd=$this->input->post('input_remark_ipd'); + $patient_code=$this->input->post('patient_code'); + $custmer_Name=$this->input->post('custmer_Name'); + $ipd_credit=$this->input->post('ipd_credit'); + + $org_credit=$this->input->post('org_credit'); + $inv_date=$this->input->post('inv_date'); + + $sql="select * from patient_master where p_code='".$patient_code."' "; + $query = $this->db->query($sql); + $person_info= $query->result(); + + $sql="select * from doctor_master where id='".$doc_id."' "; + $query = $this->db->query($sql); + $doc_info= $query->result(); + + $sql="select * from invoice_med_master where id=".$inv_id; + $query = $this->db->query($sql); + $data['invoice_master']= $query->result(); + + if($this->ion_auth->in_group('InvoiceDateChanged') || $this->ion_auth->in_group('admin')) + { + $inv_date=str_to_MysqlDate($inv_date); + }else{ + $inv_date=$data['invoice_master'][0]->inv_date; + } + + if(count($person_info)>0) + { + $patient_id=$person_info[0]->id; + $patient_code_u=$patient_code; + $custmer_Name=$person_info[0]->p_fname; + }else{ + $patient_id=0; + $patient_code_u=''; + } + + $refername=$doc_name; + + if(count($doc_info)>0) + { + $refername=$doc_info[0]->p_fname; + } + + $data = array( + 'patient_id' => $patient_id, + 'patient_code' => $patient_code_u, + 'doc_id' => $doc_id, + 'doc_name' => $refername, + 'inv_name' => $custmer_Name, + 'remark_ipd'=>$remark_ipd, + 'ipd_credit'=>$ipd_credit, + 'case_credit'=>$org_credit, + 'inv_date' => $inv_date + ); + + $inser_id=$this->Medical_M->update_in_upv_item($data,$inv_id); + $this->Medical_M->update_invoice_group($inv_id); + $this->Medical_M->update_invoice_final($inv_id); + + } + + public function getDrugTable() + { + + $requestData= $_REQUEST; + + $columns = array( + // datatable column index => database column name + 0 =>'item_id', + 1 => 'itemname', + 2 => 'formulation', + 3=> 'genericname', + 5=> 'company_name_idx', + 4=> 'mrp' + ); + + // getting total number records without any search + $sql_f_all = "select * "; + + $sql_count="Select count(*) as no_rec "; + + $sql_from=" from drug_temp "; + + $total_sql=$sql_count.$sql_from; + + $query = $this->db->query($total_sql); + $data['total_rec']= $query->result(); + $totalData=$data['total_rec'][0]->no_rec; + + $totalFiltered = $totalData; // when there is no search parameter then total number rows = total number filtered rows. + + $sql_where=" WHERE 1 = 1"; + + $sql_where_flag=0; + + // getting records as per search parameters + if( !empty($requestData['columns'][0]['search']['value']) ){ //item_id + $sql_where.=" AND item_id LIKE '".$requestData['columns'][0]['search']['value']."%' "; + $sql_where_flag=1; + } + + if( !empty($requestData['columns'][1]['search']['value']) ){ //itemname + $sql_where.=" AND itemname LIKE '%".$requestData['columns'][1]['search']['value']."%' "; + $sql_where_flag=1; + } + + if( !empty($requestData['columns'][2]['search']['value']) ){ //dosage + $sql_where.=" AND formulation LIKE '%".$requestData['columns'][2]['search']['value']."%' "; + $sql_where_flag=1; + } + + if( !empty($requestData['columns'][3]['search']['value']) ){ //formulation + $sql_where.=" AND genericname LIKE '%".$requestData['columns'][3]['search']['value']."%' "; + $sql_where_flag=1; + } + + if( !empty($requestData['columns'][4]['search']['value']) ){ //therapeutic + $sql_where.=" AND company_name_idx LIKE '%".$requestData['columns'][4]['search']['value']."%' "; + $sql_where_flag=1; + } + + $total_filer_sql=$sql_count.$sql_from.$sql_where; + + $query = $this->db->query($total_filer_sql); + $data['total_rec_filter']= $query->result();// when there is a search parameter then we have to modify total number filtered rows as per search result. + $totalFiltered=$data['total_rec_filter'][0]->no_rec; + + + $sql_order=" ORDER BY ". $columns[$requestData['order'][0]['column']]." ".$requestData['order'][0]['dir']." LIMIT ".$requestData['start']." ,".$requestData['length']." "; // adding length + + $Result_sql=$sql_f_all.$sql_from.$sql_where.$sql_order; + + $query = $this->db->query($Result_sql); + $rdata= $query->result_array(); + + $output = array( + "draw" => intval( $requestData['draw'] ), // for every request/draw by clientside , they send a number as a parameter, when they recieve a response/data they first check the draw number, so we are sending same number in draw. + "recordsTotal" => intval( $totalData ), // total number of records + "recordsFiltered" => intval( $totalFiltered ), // total number of records after searching, if there is no searching then totalFiltered = totalData + "data" => array(), + "sql" => $Result_sql + ); + + foreach($rdata as $aRow) + { + $row = array(); + + foreach($columns as $col) + { + $row[] = $aRow[$col]; + } + + $output['data'][] = $row; + } + + echo json_encode($output); // send data as json format + } + + public function getInvoiceTable() + { + //Single Store Remove Store ID feild + + $requestData= $_REQUEST; + + $columns = array( + // datatable column index => database column name + 0 => 'inv_med_code', + 1 => 'inv_name', + 2 => 'Code', + 3=> 'inv_date_str', + 4=> 'net_amount', + 5=> 'payment_received', + 6=> 'payment_balance', + 7=> 'id', + 8=> 'ipd_status', + 9=> 'org_status', + 10=> 'ipd_credit_type', + 11=> 'org_credit_type' + ); + + // getting total number records without any search + $sql_f_all = "select m.inv_med_code,m.inv_name, + Concat(if(m.patient_code<>'',Concat(m.patient_code,'
'),''), + if(m.ipd_code<>'',Concat('',m.ipd_code,'
'),''), + if(m.case_id>0,Concat(o.case_id_code,'
'),'')) as Code , + m.inv_date,Date_Format(m.inv_date,'%d-%m-%Y') as inv_date_str, + m.doc_name,m.net_amount,m.payment_received,m.payment_balance,m.id,i.ipd_status, + o.status as org_status, + m.ipd_credit as ipd_credit_type,m.case_credit as org_credit_type "; + + $sql_count="Select count(*) as no_rec "; + + $sql_from=" from (invoice_med_master m left join ipd_master i on m.ipd_id=i.id ) + left join organization_case_master o on m.case_id=o.id "; + + $total_sql=$sql_count.$sql_from; + + $query = $this->db->query($total_sql); + $data['total_rec']= $query->result(); + $totalData=$data['total_rec'][0]->no_rec; + + $totalFiltered = $totalData; // when there is no search parameter then total number rows = total number filtered rows. + + if($this->ion_auth->in_group('MedicalStoreAdmin')) + { + $sql_where=" WHERE sale_return=0 "; + }else{ + $sql_where=" WHERE sale_return=0 and inv_date >= date_add(sysdate(),interval -50 day) "; + } + + + $sql_where_flag=0; + + // getting records as per search parameters + if( !empty($requestData['columns'][0]['search']['value']) ){ //inv_med_code + $sql_where.=" AND inv_med_code LIKE '%".$requestData['columns'][0]['search']['value']."' "; + $sql_where_flag=1; + } + + if( !empty($requestData['columns'][1]['search']['value']) ){ //inv_name + $stext=$requestData['columns'][1]['search']['value']; + if(is_numeric($stext) && strlen($stext)>3) + { + $sql_where.=" AND inv_phone_number LIKE '".$stext."%' "; + }else{ + $sql_where.=" AND inv_name LIKE '%".$requestData['columns'][1]['search']['value']."%' "; + } + $sql_where_flag=1; + } + + if( !empty($requestData['columns'][2]['search']['value']) ){ //patient_code + $sql_where.=" AND (patient_code LIKE '%".$requestData['columns'][2]['search']['value']."' OR + m.ipd_code LIKE '%".$requestData['columns'][2]['search']['value']."' OR + o.case_id_code LIKE '%".$requestData['columns'][2]['search']['value']."' )"; + $sql_where_flag=1; + } + + $total_filer_sql=$sql_count.$sql_from.$sql_where; + + $query = $this->db->query($total_filer_sql); + $data['total_rec_filter']= $query->result();// when there is a search parameter then we have to modify total number filtered rows as per search result. + $totalFiltered=$data['total_rec_filter'][0]->no_rec; + + $sql_order=" ORDER BY id desc,". $columns[$requestData['order'][0]['column']]." ".$requestData['order'][0]['dir']." LIMIT ".$requestData['start']." ,".$requestData['length']." "; // adding length + + $Result_sql=$sql_f_all.$sql_from.$sql_where.$sql_order; + + $query = $this->db->query($Result_sql); + $rdata= $query->result_array(); + + $output = array( + "draw" => intval( $requestData['draw'] ), // for every request/draw by clientside , they send a number as a parameter, when they recieve a response/data they first check the draw number, so we are sending same number in draw. + "recordsTotal" => intval( $totalData ), // total number of records + "recordsFiltered" => intval( $totalFiltered ), // total number of records after searching, if there is no searching then totalFiltered = totalData + "data" => array(), + "sql" => $Result_sql + ); + + foreach($rdata as $aRow) + { + $row = array(); + + foreach($columns as $col) + { + $row[] = $aRow[$col]; + } + + $output['data'][] = $row; + } + + echo json_encode($output); // send data as json format + + } + + public function getReturnInvoiceTable() + { + //Single Store Remove Store ID feild + + $requestData= $_REQUEST; + + $columns = array( + // datatable column index => database column name + 0 => 'inv_med_code', + 1 => 'inv_name', + 2 => 'Code', + 3=> 'inv_date_str', + 4=> 'net_amount', + 5=> 'payment_received', + 6=> 'payment_balance', + 7=> 'id', + 8=> 'ipd_status', + 9=> 'org_status', + 10=> 'ipd_credit_type', + 11=> 'org_credit_type' + ); + + // getting total number records without any search + $sql_f_all = "select m.inv_med_code,m.inv_name, + Concat(if(m.patient_code<>'',Concat(m.patient_code,'
'),''), + if(m.ipd_code<>'',Concat('',m.ipd_code,'
'),''), + if(m.case_id>0,Concat(o.case_id_code,'
'),'')) as Code , + m.inv_date,Date_Format(m.inv_date,'%d-%m-%Y') as inv_date_str, + m.doc_name,m.net_amount,m.payment_received,m.payment_balance,m.id,i.ipd_status, + o.status as org_status, + m.ipd_credit as ipd_credit_type,m.case_credit as org_credit_type "; + + $sql_count="Select count(*) as no_rec "; + + $sql_from=" from (invoice_med_master m left join ipd_master i on m.ipd_id=i.id ) + left join organization_case_master o on m.case_id=o.id "; + + $total_sql=$sql_count.$sql_from; + + $query = $this->db->query($total_sql); + $data['total_rec']= $query->result(); + $totalData=$data['total_rec'][0]->no_rec; + + $totalFiltered = $totalData; // when there is no search parameter then total number rows = total number filtered rows. + + if($this->ion_auth->in_group('MedicalStoreAdmin')) + { + $sql_where=" WHERE sale_return=1 "; + }else{ + $sql_where=" WHERE sale_return=1 and inv_date >= date_add(sysdate(),interval -50 day) "; + } + + + $sql_where_flag=0; + + // getting records as per search parameters + if( !empty($requestData['columns'][0]['search']['value']) ){ //inv_med_code + $sql_where.=" AND inv_med_code LIKE '%".$requestData['columns'][0]['search']['value']."' "; + $sql_where_flag=1; + } + + if( !empty($requestData['columns'][1]['search']['value']) ){ //inv_name + $stext=$requestData['columns'][1]['search']['value']; + if(is_numeric($stext) && strlen($stext)>3) + { + $sql_where.=" AND inv_phone_number LIKE '".$stext."%' "; + }else{ + $sql_where.=" AND inv_name LIKE '%".$requestData['columns'][1]['search']['value']."%' "; + } + $sql_where_flag=1; + } + + if( !empty($requestData['columns'][2]['search']['value']) ){ //patient_code + $sql_where.=" AND (patient_code LIKE '%".$requestData['columns'][2]['search']['value']."' OR + m.ipd_code LIKE '%".$requestData['columns'][2]['search']['value']."' OR + o.case_id_code LIKE '%".$requestData['columns'][2]['search']['value']."' )"; + $sql_where_flag=1; + } + + $total_filer_sql=$sql_count.$sql_from.$sql_where; + + $query = $this->db->query($total_filer_sql); + $data['total_rec_filter']= $query->result();// when there is a search parameter then we have to modify total number filtered rows as per search result. + $totalFiltered=$data['total_rec_filter'][0]->no_rec; + + $sql_order=" ORDER BY id desc,". $columns[$requestData['order'][0]['column']]." ".$requestData['order'][0]['dir']." LIMIT ".$requestData['start']." ,".$requestData['length']." "; // adding length + + $Result_sql=$sql_f_all.$sql_from.$sql_where.$sql_order; + + $query = $this->db->query($Result_sql); + $rdata= $query->result_array(); + + $output = array( + "draw" => intval( $requestData['draw'] ), // for every request/draw by clientside , they send a number as a parameter, when they recieve a response/data they first check the draw number, so we are sending same number in draw. + "recordsTotal" => intval( $totalData ), // total number of records + "recordsFiltered" => intval( $totalFiltered ), // total number of records after searching, if there is no searching then totalFiltered = totalData + "data" => array(), + "sql" => $Result_sql + ); + + foreach($rdata as $aRow) + { + $row = array(); + + foreach($columns as $col) + { + $row[] = $aRow[$col]; + } + + $output['data'][] = $row; + } + + echo json_encode($output); // send data as json format + + } + + + public function getStockDrugTable() + { + + $requestData= $_REQUEST; + + $columns = array( + // datatable column index => database column name + 0 =>'ss_no', + 1 =>'item_code', + 2 => 'item_name', + 3 => 'formulation', + 4 => 'rack_no', + 5 => 'shelf_no', + 6 => 'batch_no', + 7 => 'total_unit', + 8 => 'expiry_date', + 9 => 'mrp', + 10 => 'update_stock_qty' + ); + + // getting total number records without any search + $sql_f_all = "select * "; + + $sql_count="Select count(*) as no_rec "; + + $sql_from=" from stock_addition "; + + $total_sql=$sql_count.$sql_from; + + $query = $this->db->query($total_sql); + $data['total_rec']= $query->result(); + $totalData=$data['total_rec'][0]->no_rec; + + $totalFiltered = $totalData; // when there is no search parameter then total number rows = total number filtered rows. + + $sql_where=" WHERE 1 = 1 "; + + $sql_where_flag=0; + + // getting records as per search parameters + if( !empty($requestData['columns'][0]['search']['value']) ){ //item_id + $sql_where.=" AND item_code LIKE '".$requestData['columns'][0]['search']['value']."%' "; + $sql_where_flag=1; + } + + if( !empty($requestData['columns'][1]['search']['value']) ){ //itemname + $sql_where.=" AND item_name LIKE '%".$requestData['columns'][1]['search']['value']."%' "; + $sql_where_flag=1; + } + + if( !empty($requestData['columns'][2]['search']['value']) ){ //dosage + $sql_where.=" AND formulation LIKE '%".$requestData['columns'][2]['search']['value']."%' "; + $sql_where_flag=1; + } + + if( !empty($requestData['columns'][3]['search']['value']) ){ //dosage + $sql_where.=" AND rack_no LIKE '%".$requestData['columns'][3]['search']['value']."%' "; + $sql_where_flag=1; + } + + if( !empty($requestData['columns'][4]['search']['value']) ){ //dosage + $sql_where.=" AND shelf_no LIKE '%".$requestData['columns'][4]['search']['value']."%' "; + $sql_where_flag=1; + } + + if( !empty($requestData['columns'][5]['search']['value']) ){ //dosage + $sql_where.=" AND batch_no LIKE '%".$requestData['columns'][5]['search']['value']."%' "; + $sql_where_flag=1; + } + + $total_filer_sql=$sql_count.$sql_from.$sql_where; + + $query = $this->db->query($total_filer_sql); + $data['total_rec_filter']= $query->result();// when there is a search parameter then we have to modify total number filtered rows as per search result. + $totalFiltered=$data['total_rec_filter'][0]->no_rec; + + $sql_order=" ORDER BY ". $columns[$requestData['order'][0]['column']]." ".$requestData['order'][0]['dir']." LIMIT ".$requestData['start']." ,".$requestData['length']." "; // adding length + + $Result_sql=$sql_f_all.$sql_from.$sql_where.$sql_order; + + $query = $this->db->query($Result_sql); + $rdata= $query->result_array(); + + $output = array( + "draw" => intval( $requestData['draw'] ), // for every request/draw by clientside , they send a number as a parameter, when they recieve a response/data they first check the draw number, so we are sending same number in draw. + "recordsTotal" => intval( $totalData ), // total number of records + "recordsFiltered" => intval( $totalFiltered ), // total number of records after searching, if there is no searching then totalFiltered = totalData + "data" => array(), + "sql" => $Result_sql + ); + + foreach($rdata as $aRow) + { + $row = array(); + + foreach($columns as $col) + { + $row[] = $aRow[$col]; + } + + $output['data'][] = $row; + } + + echo json_encode($output); // send data as json format + + } + + public function confirm_payment() + { + if (!$this->input->is_ajax_request()) { exit('no valid req.'); } + + $this->load->model('Medical_M'); + + $invoice_id=$this->input->post('med_invoice_id'); + $input_amount_paid=$this->input->post('input_amount_paid'); + + $sql="select * from invoice_med_master where id='".$invoice_id."'"; + $query = $this->db->query($sql); + $inv_master= $query->result(); + + $user = $this->ion_auth->user()->row(); + $user_id = $user->id; + $user_name = $user->first_name.''. $user->last_name; + + $showcontent1='
+
+ Print +
+
+ Payment Method by : '; + + $showcontent2='
'; + + $pay_remark=''; + + if($inv_master[0]->patient_id>0) + { + $Customerof_type=1; + }else{ + $Customerof_type=3; + } + + if($this->input->post('mode')==1) + { + $paydata = array( + 'payment_mode'=> '1', + 'Customerof_type'=>$Customerof_type, + 'Customerof_id'=>$inv_master[0]->patient_id, + 'Customerof_code'=>$inv_master[0]->patient_code, + 'Medical_invoice_id'=>$inv_master[0]->id, + 'Medical_invoice_code'=>$inv_master[0]->inv_med_code, + 'credit_debit'=>'0', + 'amount'=>$input_amount_paid, + 'payment_date'=>date('Y-m-d H:i:s'), + 'remark'=>$pay_remark, + 'update_by'=>$user_name.'['.$user_id.']', + 'update_by_id'=>$user_id + ); + + $insert_id=$this->Medical_M->insert_payment($paydata); + + $data = array( + + 'payment_mode'=> '1', + 'payment_status'=>'1', + 'invoice_status'=>'1', + 'payment_id'=>$insert_id, + 'payment_mode_desc'=>'Cash', + 'confirm_invoice'=>date('Y-m-d H:i:s'), + 'prepared_by'=>$user_name.'['.$user_id.']' + ); + + $this->Medical_M->update_in_upv_item( $data,$invoice_id); + + $status='CASH'; + $showcontent=$showcontent1.$status.$showcontent2; + + $rvar=array( + 'update' =>1, + 'showcontent'=>$showcontent + ); + + $encode_data = json_encode($rvar); + echo $encode_data; + } + + if($this->input->post('mode')==2) + { + $FormRules = array( + array( + 'field' => 'input_card_mac', + 'label' => 'Card Bank Name', + 'rules' => 'required|min_length[1]|max_length[30]' + ), + array( + 'field' => 'input_card_digit', + 'label' => 'Card Last 4 Digit ', + 'rules' => 'required|min_length[4]' + ), + array( + 'field' => 'input_card_bank', + 'label' => 'Bank Name ', + 'rules' => 'required|min_length[1]|max_length[50]' + ), + array( + 'field' => 'input_card_tran', + 'label' => 'Card Transcation ID', + 'rules' => 'required|min_length[3]|max_length[15]' + ) + ); + + $this->form_validation->set_rules($FormRules); + + if ($this->form_validation->run() == TRUE) + { + $paydata = array( + 'payment_mode'=> '2', + 'Customerof_type'=>$Customerof_type, + 'Customerof_id'=>$inv_master[0]->patient_id, + 'Customerof_code'=>$inv_master[0]->patient_code, + 'Medical_invoice_id'=>$inv_master[0]->id, + 'Medical_invoice_code'=>$inv_master[0]->inv_med_code, + 'credit_debit'=>'0', + 'amount'=>$input_amount_paid, + 'payment_date'=>date('Y-m-d H:i:s'), + 'remark'=>$pay_remark, + 'update_by'=>$user_name.'['.$user_id.']', + 'update_by_id'=>$user_id, + 'card_bank'=>$this->input->post('input_card_mac'), + 'cust_card'=>$this->input->post('input_card_bank'), + 'card_remark'=>$this->input->post('input_card_digit'), + 'card_tran_id'=>$this->input->post('input_card_tran') + ); + + $insert_id=$this->Medical_M->insert_payment($paydata); + + $data = array( + 'payment_mode'=> '2', + 'payment_status'=>'1', + 'invoice_status'=>'1', + 'payment_mode_desc'=>'Bank Card', + 'confirm_invoice'=>date('Y-m-d H:i:s'), + 'payment_id'=>$insert_id, + 'card_bank'=>$this->input->post('input_card_mac'), + 'card_remark'=>$this->input->post('input_card_digit'), + 'cust_card'=>$this->input->post('input_card_bank'), + 'card_tran_id'=>$this->input->post('input_card_tran'), + 'prepared_by'=>$user_name.'['.$user_id.']', + 'prepared_by_id'=>$user_id + ); + + $this->Medical_M->update_in_upv_item( $data,$invoice_id); + + $status='Bank Card'; + $showcontent=$showcontent1.$status.$showcontent2; + + $rvar=array( + 'update' =>1, + 'showcontent'=>$showcontent + ); + $encode_data = json_encode($rvar); + echo $encode_data; + } + else{ + $send_error=validation_errors(); + $rvar=array( + 'update' =>0, + 'error_text'=>$send_error + ); + $encode_data = json_encode($rvar); + echo $encode_data; + } + } + + if($this->input->post('mode')==3) + { + $data = array( + + 'payment_mode'=> '3', + 'payment_status'=>'1', + 'invoice_status'=>'1', + 'confirm_invoice'=>date('d/m/Y H:m:s'), + 'payment_mode_desc'=>'IPD Credit', + 'ipd_id'=>$this->input->post('ipd_id'), + 'prepared_by'=>$user_name.'['.$user_id.']' + ); + + $this->Medical_M->update_in_upv_item( $data,$invoice_id); + + $status='IPD Credit'; + $showcontent=$showcontent1.$status.$showcontent2; + + $rvar=array( + 'update' =>1, + 'showcontent'=>$showcontent + ); + + $encode_data = json_encode($rvar); + echo $encode_data; + } + + if($this->input->post('mode')==4) + { + $data = array( + 'payment_mode'=> '4', + 'payment_status'=>'1', + 'invoice_status'=>'1', + 'confirm_invoice'=>date('d/m/Y H:m:s'), + 'payment_mode_desc'=>'Org Credit', + 'case_id'=>$this->input->post('ipd_id'), + 'prepared_by'=>$user_name.'['.$user_id.']' + ); + + $this->Medical_M->update_in_upv_item( $data,$invoice_id); + + $status='Org Credit'; + $showcontent=$showcontent1.$status.$showcontent2; + + $rvar=array( + 'update' =>1, + 'showcontent'=>$showcontent + ); + + $encode_data = json_encode($rvar); + echo $encode_data; + } + + if($this->input->post('mode')==5) + { + if($input_amount_paid<0) + { + $input_amount_paid=$input_amount_paid*-1; + } + + $paydata = array( + 'payment_mode'=> '1', + 'Customerof_type'=>$Customerof_type, + 'Customerof_id'=>$inv_master[0]->patient_id, + 'Customerof_code'=>$inv_master[0]->patient_code, + 'Medical_invoice_id'=>$inv_master[0]->id, + 'Medical_invoice_code'=>$inv_master[0]->inv_med_code, + 'credit_debit'=>'1', + 'amount'=>$input_amount_paid, + 'payment_date'=>date('Y-m-d H:i:s'), + 'remark'=>$pay_remark, + 'update_by'=>$user_name.'['.$user_id.']', + 'update_by_id'=>$user_id + ); + + $insert_id=$this->Medical_M->insert_payment($paydata); + + $data = array( + + 'payment_mode'=> '1', + 'payment_status'=>'1', + 'invoice_status'=>'1', + 'payment_id'=>$insert_id, + 'payment_mode_desc'=>'Cash Return', + 'confirm_invoice'=>date('Y-m-d H:i:s'), + 'prepared_by'=>$user_name.'['.$user_id.']' + ); + + $this->Medical_M->update_in_upv_item( $data,$invoice_id); + + $status='CASH'; + $showcontent=$showcontent1.$status.$showcontent2; + + $rvar=array( + 'update' =>1, + 'showcontent'=>$showcontent + ); + + $encode_data = json_encode($rvar); + echo $encode_data; + } + } + + public function invoice_print($inv_id,$print_format=0) + { + $this->load->model('Medical_M'); + $this->Medical_M->update_invoice_final($inv_id); + + $sql="select *,(discount_amount+item_discount_amount) as inv_disc_total,(CGST_Tamount+SGST_Tamount) as TGST from invoice_med_master where id=".$inv_id; + $query = $this->db->query($sql); + $data['invoice_master']= $query->result(); + + $sql="select *,(disc_amount+disc_whole) as d_amt,(CGST+SGST) as gst,(CGST_per+SGST_per) as gst_per from inv_med_item + where inv_med_id=".$inv_id; + $query = $this->db->query($sql); + $data['inv_items']= $query->result(); + + $sql="select * from ipd_master where id=".$data['invoice_master'][0]->ipd_id; + $query = $this->db->query($sql); + $data['ipd_master']= $query->result(); + + $sql="select * from organization_case_master where id=".$data['invoice_master'][0]->case_id; + $query = $this->db->query($sql); + $data['orgcase']= $query->result(); + + $sql="select sum(if(credit_debit>0,amount*-1,amount)) as paid_amount from payment_history_medical where Medical_invoice_id=".$inv_id; + $query = $this->db->query($sql); + $data['payment_history_medical']= $query->result(); + + $sql="select *,if(credit_debit>0,amount*-1,amount) as paid_amount, + (case payment_mode when 1 then 'Cash' when 2 then 'Bank Card' when 3 then 'Return Cash ' when 4 then 'Bank Return' when 5 then 'Cash Return' else 'Other' end) as Payment_type_str + from payment_history_medical where Medical_invoice_id=".$inv_id; + $query = $this->db->query($sql); + $data['payment_history']= $query->result(); + + if($print_format==0) + { + $this->load->view('Medical/Medical_invoice_print_2',$data); + }else{ + $this->load->view('Medical/Medical_invoice_print',$data); + } + + } + + + public function invoice_print_all($ipd_id,$cash=0) + { + //$cash 0 for Cash Only,1 for Credit only,2 Package Credit only,3 for All + $this->load->model('Medical_M'); + + $cash_where=" "; + + if($cash==0) + { + $cash_where.=" and ipd_credit=0 "; + $med_type=1; + }elseif($cash==1) + { + $cash_where.=" and ipd_credit=1 and ipd_credit_type=1 "; + $med_type=2; + }elseif($cash==2) + { + $cash_where.=" and ipd_credit=1 and ipd_credit_type=0 "; + $med_type=3; + } + + $this->Medical_M->update_invoice_group_gst($ipd_id,$med_type); + + + $sql="select i.inv_med_id,i.id,i.item_Name,i.formulation, + i.batch_no,Date_Format(i.expiry,'%m-%Y')as expiry, + i.price,i.qty,sum(i.amount) as amount,i.HSNCODE, + m.inv_med_code,m.id as m_id, + date_format(m.inv_date,'%d-%m-%Y') as str_inv_date, + sum(twdisc_amount) as twdisc_amount, + sum(i.disc_amount+i.disc_whole) as d_amt, + sum(i.CGST+i.SGST) as gst, + (i.CGST_per+i.SGST_per) as gst_per + from inv_med_item i join invoice_med_master m + on i.inv_med_id=m.id + where m.group_invoice_id>0 and m.ipd_id=".$ipd_id.$cash_where." group by i.inv_med_id,i.id WITH ROLLUP"; + $query = $this->db->query($sql); + $data['inv_items']= $query->result(); + + $sql="select sum(CGST_Tamount) as CGST_Tamount, + sum(SGST_Tamount) as SGST_Tamount, + sum(TaxableAmount) as TaxableAmount, + sum(net_amount) as net_amount, + sum(payment_received) as payment_received, + sum(payment_balance) as payment_balance, + sum(discount_amount+item_discount_amount) as inv_disc_total, + (CGST_Tamount+SGST_Tamount) as TGST from invoice_med_master + where group_invoice_id>0 and ipd_id=".$ipd_id.$cash_where." group by ipd_id"; + $query = $this->db->query($sql); + $data['invoice_master']= $query->result(); + + $sql="select m.p_id,p.p_fname,m.ipd_code,p.p_code, m.doc_name, + m.org_id from v_ipd_list m join patient_master p on m.p_id=p.id + where m.id=".$ipd_id; + $query = $this->db->query($sql); + $data['ipd_master']= $query->result(); + + $sql="select * from organization_case_master where id='".$data['ipd_master'][0]->org_id."'"; + $query = $this->db->query($sql); + $data['orgcase']= $query->result(); + + $sql="select sum(if(p.credit_debit>0,p.amount*-1,p.amount)) as paid_amount + from payment_history_medical p join inv_med_group m + on p.group_id=m.med_group_id + where m.ipd_id=".$ipd_id." and m.med_type=".$med_type; + $query = $this->db->query($sql); + $data['payment_Total']= $query->result(); + + $sql="select p.*,if(p.credit_debit>0,p.amount*-1,p.amount) as paid_amount, + (case p.payment_mode when 1 then 'Cash' when 2 then 'Bank Card' when 3 then 'Return Cash ' when 4 then 'Bank Return' when 5 then 'Cash Return' else 'Other' end) as Payment_type_str + from payment_history_medical p join inv_med_group m + on p.group_id=m.med_group_id + where m.ipd_id=".$ipd_id." and m.med_type=".$med_type; + $query = $this->db->query($sql); + $data['payment_history']= $query->result(); + + $sql="select * from inv_med_group + where ipd_id='".$ipd_id."' and med_type='".$med_type."'"; + $query = $this->db->query($sql); + $data['inv_med_group']= $query->result(); + + if($cash==0) + { + if($data['inv_med_group'][0]->bill_final==1) + { + $this->load->view('Medical/Medical_invoice_print_all',$data); + }else{ + $this->load->view('Medical/Medical_invoice_print_all_provisional',$data); + } + }else{ + $this->load->view('Medical/Medical_invoice_print_all',$data); + } + + } + + + public function final_invoice($inv_id) + { + $this->load->model('Medical_M'); + + $this->Medical_M->update_invoice_group($inv_id); + $this->Medical_M->update_invoice_final($inv_id); + + $sql="select *,(discount_amount+item_discount_amount) as inv_disc_total,(CGST_Tamount+SGST_Tamount) as TGST from invoice_med_master where id=".$inv_id; + $query = $this->db->query($sql); + $data['invoiceMaster']= $query->result(); + + $sql="select * from inv_med_item where inv_med_id=".$inv_id; + $query = $this->db->query($sql); + $data['inv_items']= $query->result(); + + $sql="select *,if(gender=1,'Male','FeMale') as xgender, + GET_AGE_1(dob,age,age_in_month,estimate_dob) AS age + from patient_master where id='".$data['invoiceMaster'][0]->patient_id."' "; + $query = $this->db->query($sql); + $data['person_info']= $query->result(); + + $sql="select * from ipd_master where ipd_status=0 and id=".$data['invoiceMaster'][0]->ipd_id; + $query = $this->db->query($sql); + $data['ipd_master']= $query->result(); + + if($data['invoiceMaster'][0]->case_id > 0) + { + $sql="select * from organization_case_master where id=".$data['invoiceMaster'][0]->case_id; + $query = $this->db->query($sql); + $data['OCaseMaster']= $query->result(); + } + + $sql="select sum(if(credit_debit>0,amount*-1,amount)) as paid_amount from payment_history_medical where Medical_invoice_id=".$inv_id; + $query = $this->db->query($sql); + $data['payment_history_medical']= $query->result(); + + if(count($data['invoiceMaster'])>0) + { + if($data['invoiceMaster'][0]->ipd_id>0) + { + redirect('Medical/list_med_inv/'.$data['invoiceMaster'][0]->ipd_id); + }else if($data['invoiceMaster'][0]->case_id>0 && $data['invoiceMaster'][0]->case_credit>0) + { + redirect('Medical/list_med_orginv/'.$data['invoiceMaster'][0]->case_id); + }else{ + $this->load->view('Medical/Medical_Final_Invoice',$data); + } + } + } + + public function final_return_invoice($inv_id) + { + $this->load->model('Medical_M'); + + $sql="select *,(discount_amount+item_discount_amount) as inv_disc_total,(CGST_Tamount+SGST_Tamount) as TGST from invoice_med_master where id=".$inv_id; + $query = $this->db->query($sql); + $data['invoiceMaster']= $query->result(); + + $sql="select * from inv_med_item where inv_med_id=".$inv_id; + $query = $this->db->query($sql); + $data['inv_items']= $query->result(); + + $sql="select *,if(gender=1,'Male','FeMale') as xgender, + GET_AGE_1(dob,age,age_in_month,estimate_dob) AS age + from patient_master where id='".$data['invoiceMaster'][0]->patient_id."' "; + $query = $this->db->query($sql); + $data['person_info']= $query->result(); + + $sql="select sum(if(credit_debit>0,amount*-1,amount)) as paid_amount from payment_history_medical where Medical_invoice_id=".$inv_id; + $query = $this->db->query($sql); + $data['payment_history_medical']= $query->result(); + + if(count($data['invoiceMaster'])>0) + { + $this->load->view('Medical/Medical_Final_return_Invoice',$data); + }else{ + echo 'Error In Inv. No.'; + } + } + + public function add_item($type,$req=0) + { + $this->load->model('Medical_M'); + + $inser_id=1; + $Error_Show=''; + + $store_stock_id=$this->input->post('l_ssno'); + + $user = $this->ion_auth->user()->row(); + $user_id = $user->id; + $user_name_info = $user->first_name.''. $user->last_name .'['.$user_id.']'.date('d-m-Y H:i:s'); + + if($type==1) + { + $inv_id=$this->input->post('inv_id'); + $qty=$this->input->post('qty'); + $disc=$this->input->post('disc'); + $mrp=$this->input->post('mrp'); + $product_unit_rate=$this->input->post('product_unit_rate'); + $item_code=$this->input->post('item_code'); + $Batch_no=$this->input->post('Batch_no'); + $ExpDt=$this->input->post('ExpDt'); + + $packing=$this->input->post('packing'); + + $CGST=$this->input->post('CGST'); + $SGST=$this->input->post('SGST'); + $HSNCODE=$this->input->post('HSNCODE'); + + $sql="SELECT * + FROM med_product_master i + where id= $item_code "; + $query = $this->db->query($sql); + $data['itemlist']= $query->result(); + + $sql="select * from inv_med_item + where inv_med_id='$inv_id' and batch_no='$Batch_no' and item_code='$item_code'"; + $query = $this->db->query($sql); + $itemExist= $query->result(); + + $item_rate=$product_unit_rate; + + $amount_value=$qty*$item_rate; + + $disc_amount=$amount_value*$disc/100; + + $Tamount_value=$amount_value-$disc_amount; + + if($inser_id>0) + { + $data['insert_inv_med_item'] = array( + 'inv_med_id' => $inv_id, + 'item_code' => $item_code, + 'item_Name' => $data['itemlist'][0]->item_name, + 'formulation' => $data['itemlist'][0]->formulation, + 'qty' => $qty, + 'batch_no' => $Batch_no, + 'expiry' => $ExpDt, + 'price' => $item_rate, + 'price2' => $item_rate, + 'mrp' => $mrp, + 'disc_per' => $disc, + 'disc_amount' => $disc_amount, + 'amount' => $amount_value, + 'tamount' => $Tamount_value, + 'CGST_per'=> $CGST, + 'SGST_per'=> $SGST, + 'HSNCODE'=> $HSNCODE, + 'packing'=> $packing, + 'update_by_id'=>$user_id, + 'update_by_remark'=>$user_name_info, + ); + + if(count($itemExist)>0) + { + $inser_id=0; + $Error_Show='Already in Item List'; + }else{ + $inser_id=$this->Medical_M->add_invoiceitem( $data['insert_inv_med_item']); + + } + } + } + else if($type==2) + { + $update_qty=$this->input->post('u_qty'); + $itemid=$this->input->post('itemid'); + + $sql="select * from inv_med_item where id=".$itemid; + $query = $this->db->query($sql); + $data['inv_med_item']= $query->result(); + + $CGST=$data['inv_med_item'][0]->CGST_per; + $SGST=$data['inv_med_item'][0]->SGST_per; + $disc=$data['inv_med_item'][0]->disc_per; + + $inv_id=$data['inv_med_item'][0]->inv_med_id; + + $stock_qty=0; + + $old_qty=$data['inv_med_item'][0]->qty; + $diff_qty=$update_qty-$old_qty; + + + $item_rate=$data['inv_med_item'][0]->price; + $amount_value=$update_qty*$item_rate; + + $disc_amount=$amount_value*$disc/100; + + $Tamount_value=$amount_value-$disc_amount; + + $update_inv_med_item = array( + 'qty' => $update_qty, + 'disc_amount' => $disc_amount, + 'amount' => $amount_value, + 'tamount' => $Tamount_value, + 'item_code' => $data['inv_med_item'][0]->item_code, + 'batch_no' => $data['inv_med_item'][0]->batch_no, + 'mrp' => $data['inv_med_item'][0]->mrp, + 'packing' => $data['inv_med_item'][0]->packing, + ); + + $this->Medical_M->update_invoiceitem($update_inv_med_item,$itemid); + $inser_id=$itemid; + + $this->Medical_M->update_invoice_group($inv_id); + $this->Medical_M->update_invoice_final($inv_id); + + }else{ + $inv_id=$this->input->post('inv_id'); + $itemid=$this->input->post('itemid'); + + $this->Medical_M->delete_invoiceitem($itemid); + + } + + $content=''; + + if($inser_id>0) + { + $this->Medical_M->update_invoice_final($inv_id); + + $sql="select * from inv_med_item where inv_med_id=".$inv_id; + $query = $this->db->query($sql); + $data['inv_items']= $query->result(); + + $sql="select sum(amount) as Gtotal,sum(tamount) as tamt,sum(CGST) as TCGST,sum(SGST) as TSGST, + sum(disc_amount) as t_dis_amt from inv_med_item where inv_med_id=".$inv_id; + $query = $this->db->query($sql); + $data['invoiceGtotal']= $query->result(); + + $sql="select * from invoice_med_master where id=".$inv_id; + $query = $this->db->query($sql); + $data['invoiceMaster']= $query->result(); + + //$user = $this->ion_auth->user()->row(); + //$data['user_id'] = $user->id; + + $data['sale_return']=$data['invoiceMaster'][0]->sale_return; + + $content=$this->load->view('Medical/Med_Item_List',$data,true); + } + + + $rvar=array( + 'insertid' =>$inser_id, + 'content'=>$content, + 'error'=>$Error_Show, + 'csrf_dst_name_value'=>$this->security->get_csrf_hash() + ); + $encode_data = json_encode($rvar); + echo $encode_data; + } + + + + public function list_org_ipd() + { + $sql = "select *,(paid_amount-(charge_amount+med_amount)) as balance + from v_ipd_list where ipd_status=0 "; + $query = $this->db->query($sql); + $data['data']= $query->result(); + + $this->load->view('Medical/Medical_ipd_org_list',$data); + } + + + public function list_org() + { + $sql = "select p.p_fname,p.p_code,p.p_relative,p.p_rname,o.insurance_company_name,o.case_id_code,o.id as org_id,o.p_id , + o.date_registration,Date_Format(o.date_registration,'%d-%m-%Y') as str_register_date,o.insurance_id + from organization_case_master o join patient_master p on o.p_id=p.id + and o.insurance_id >1 and o.`status`=0 and o.case_type=0 "; + $query = $this->db->query($sql); + $data['organization_case_master']= $query->result(); + + + $this->load->view('Medical/Medical_org_list',$data); + } + + public function list_med_inv($ipd_id) + { + $sql="select *,if(ipd_credit=0,'CASH','CREDIT') as credit, + if(ipd_credit=1 and ipd_credit_type=0,'Yes','No') as Package + from invoice_med_master where ipd_id = ".$ipd_id." Order by inv_date,id"; + $query = $this->db->query($sql); + $data['inv_master']= $query->result(); + + $sql="select sum(if(ipd_credit=0,net_amount,0)) as cash_netAmount, + sum(if(ipd_credit=1 and ipd_credit_type=1,net_amount,0)) as IPDCrAmount , + sum(if(ipd_credit=1 and ipd_credit_type=0,net_amount,0)) as PackageCrAmount, + sum(payment_balance) as t_payment_balance ,sum(net_amount) as t_net_amount + from invoice_med_master where ipd_id = ".$ipd_id; + $query = $this->db->query($sql); + $data['inv_master_total']= $query->result(); + + $sql="select * from ipd_master where id = ".$ipd_id; + $query = $this->db->query($sql); + $data['ipd_master']= $query->result(); + + $sql="select *,if(gender=1,'Male','Female') as xgender, + GET_AGE_1(dob,age,age_in_month,estimate_dob) AS age from patient_master where id='".$data['ipd_master'][0]->p_id."' "; + $query = $this->db->query($sql); + $data['person_info']= $query->result(); + + $sql="select * from v_ipd_list where id=".$ipd_id; + $query = $this->db->query($sql); + $data['ipd_list']= $query->result(); + + $sql="select * from inv_med_group where med_type=1 and ipd_id=".$ipd_id; + $query = $this->db->query($sql); + $data['med_group_list']= $query->result(); + + $sql="select b.ipd_id,b.bed_id,b.TDate,m.room_name,m.bed_no + from ipd_bed_assign b left join hc_bed_master m on b.bed_id=m.id + where b.ipd_id=".$ipd_id." order by TDate desc"; + $query = $this->db->query($sql); + $data['bed_list']= $query->result(); + + if($data['ipd_master'][0]->case_id>0) + { + $sql="select * from organization_case_master where id='".$data['ipd_master'][0]->case_id."'"; + $query = $this->db->query($sql); + $data['orgcase']= $query->result(); + + $ins_comp_id=$data['orgcase'][0]->insurance_id; + $inc_card_id=$data['orgcase'][0]->insurance_card_id; + + $sql="select * from hc_insurance_card where id='".$inc_card_id."'"; + $query = $this->db->query($sql); + $data['hc_insurance_card']= $query->result(); + + $sql="select * from hc_insurance where id='".$ins_comp_id."'"; + $query = $this->db->query($sql); + $data['insurance']= $query->result(); + } + + $this->load->view('Medical/Medical_invoice_list',$data); + } + + public function list_med_orginv($org_id) + { + + $sql="select *,if(case_credit=0,'CASH','CREDIT') as credit + from invoice_med_master where case_id = ".$org_id." order by inv_date,id"; + $query = $this->db->query($sql); + $data['inv_master']= $query->result(); + + $sql="select * from organization_case_master where id = ".$org_id; + $query = $this->db->query($sql); + $data['orgcase_master']= $query->result(); + + $sql="select *,if(gender=1,'Male','Female') as xgender, + GET_AGE_1(dob,age,age_in_month,estimate_dob) AS age from patient_master where id='".$data['orgcase_master'][0]->p_id."' "; + $query = $this->db->query($sql); + $data['person_info']= $query->result(); + + $this->load->view('Medical/Medical_org_invoicelist',$data); + } + + public function update_discount() + { + $invoice_id=$this->input->post('med_invoice_id'); + + $user = $this->ion_auth->user()->row(); + $user_id = $user->id; + $user_name = $user->first_name.''. $user->last_name; + + $dataupdate = array( + 'discount_amount' => $this->input->post('input_dis_amt'), + 'discount_remark' => $this->input->post('input_dis_desc'), + 'discount_by'=>$user_name.'['.$user_id.']' + ); + + $this->load->model('Medical_M'); + $this->Medical_M->update_in_upv_item($dataupdate,$invoice_id); + + $this->Medical_M->update_invoice_final($invoice_id); + + } + + public function BillFinal($group_id) + { + + $user = $this->ion_auth->user()->row(); + $user_id = $user->id; + $user_name = $user->first_name.''. $user->last_name; + + $dataupdate = array( + 'bill_final' => '1', + 'bill_final_by'=>$user_name.'['.$user_id.']' + ); + + $this->load->model('Medical_M'); + $this->Medical_M->update_group_invoice($dataupdate,$group_id); + + $rvar=array( + 'update' =>1, + ); + $encode_data = json_encode($rvar); + echo $encode_data; + + } + + public function InvBillFinal($invoice_id) + { + $user = $this->ion_auth->user()->row(); + $user_id = $user->id; + $user_name = $user->first_name.''. $user->last_name; + + $dataupdate = array( + 'bill_final' => '1', + 'bill_final_by'=>$user_name.'['.$user_id.']' + ); + + $this->load->model('Medical_M'); + $this->Medical_M->update_in_upv_item($dataupdate,$invoice_id); + + $rvar=array( + 'update' =>1, + ); + $encode_data = json_encode($rvar); + echo $encode_data; + + } + + + public function search() + { + $sdata=$this->input->post('txtsearch'); + + $sdata = preg_replace('/[^A-Za-z0-9 _.@\-]/', '', trim($sdata)); + + if(strlen($sdata)==0) + { + $sql = "SELECT p.*,GET_AGE_1(dob,age,age_in_month,estimate_dob) AS age , + Max(o.apointment_date) as Last_OPD , + date_format(if(Max(o.apointment_date) IS NULL,p.insert_date,Max(o.apointment_date)),'%d-%m-%Y') AS Last_Visit + FROM patient_master p left join opd_master o on p.id=o.p_id + group BY p.id + order BY if(Max(o.apointment_date) IS NULL,p.insert_date,Max(o.apointment_date)) DESC + LIMIT 100"; + }else{ + + $sdate_array=explode(" ",$sdata); + $search_string=" 1=1 " ; + + foreach($sdate_array as $row_data) + { + if(is_numeric($row_data)) + { + $search_string.=" and (p.p_code like '%$row_data' + or p.mphone1 = '$row_data' + or p.udai='$row_data' )"; + }elseif(ctype_alpha($row_data)){ + $search_string.=" and (p.p_fname like '%$row_data%' + or p.email1 = '$row_data' + or SUBSTRING_INDEX(p.p_fname,' ',1) sounds like '".$row_data."')"; + }else{ + $search_string.=" and (p.p_code like '$row_data' + or p.email1 = '$row_data' )"; + } + } + + $sql = "SELECT p.*,GET_AGE_1(dob,age,age_in_month,estimate_dob) AS age , + Max(o.apointment_date) as Last_OPD , + date_format(if(Max(o.apointment_date) IS NULL,p.insert_date,Max(o.apointment_date)),'%d-%m-%Y') AS Last_Visit + FROM patient_master p left join opd_master o on p.id=o.p_id + WHERE $search_string + group BY p.id + order BY if(Max(o.apointment_date) IS NULL,p.insert_date,Max(o.apointment_date)) DESC "; + } + + + $query = $this->db->query($sql); + $data['data']= $query->result(); + + $this->load->view('Medical/Patient_Search_Result',$data); + } + + public function Update_Invoice_ipd_credit_type() + { + $ipd_credit_type= $this->input->post('ipd_credit_type'); + $inv_med_id = $this->input->post('inv_med_id'); + + $user = $this->ion_auth->user()->row(); + $user_id = $user->id; + $user_name = $user->first_name.''. $user->last_name.'['.$user_id.']T:'.date('d-m-Y'); + + if($inv_med_id=='1') + { + $ipd_credit_type_update='Include by : '.$user_name; + }else{ + $ipd_credit_type_update='Packeage by '.$user_name; + } + + $dataupdate = array( + 'ipd_credit_type' => $ipd_credit_type, + 'ipd_credit_type_update'=>$ipd_credit_type_update, + ); + + $this->load->model('Medical_M'); + $this->Medical_M->update_in_upv_item($dataupdate,$inv_med_id); + } + + + + public function Med_Inv_Group($inv_med_id) + { + if (!$this->input->is_ajax_request()) { exit('no valid req.'); } + + $sql = "select * from invoice_med_master where id=".$inv_med_id; + $query = $this->db->query($sql); + $invoice_med_master= $query->result(); + + $user = $this->ion_auth->user()->row(); + $user_id = $user->id; + $user_name = $user->first_name.''. $user->last_name; + + $old_remark=$invoice_med_master[0]->update_history; + + $new_remark='Group By : '.$user_name.'['.$user_id.']'.' Date:'.date('d-m-Y h:i:s').PHP_EOL; + + $new_remark.= $old_remark; + + $dataupdate = array( + 'med_group_id' => 1, + 'update_history' => $new_remark + ); + + $this->load->model('Medical_M'); + $this->Medical_M->update_in_upv_item($dataupdate,$inv_med_id); + $this->Medical_M->update_invoice_group($inv_med_id); + + $rvar=array( + 'update' =>1, + ); + $encode_data = json_encode($rvar); + echo $encode_data; + + } + + public function Update_Group_Discount($med_group_id) + { + $input_discount= $this->input->post('input_discount'); + $Ipd_ID= $this->input->post('ipd_id'); + + $user = $this->ion_auth->user()->row(); + $user_id = $user->id; + $user_name = $user->first_name.''. $user->last_name; + + $dataupdate = array( + 'discount_group' => $input_discount, + 'discount_by_group' => $user_name.'['.$user_id.']'.' Date:'.date('d-m-Y h:i:s') + ); + + $this->load->model('Medical_M'); + $this->Medical_M->update_group_invoice($dataupdate,$med_group_id); + $this->Medical_M->update_invoice_group_gst($Ipd_ID); + + $rvar=array( + 'update' =>1, + ); + + $encode_data = json_encode($rvar); + echo $encode_data; + } + + public function edit_invoice_edit($inv_id) + { + $sql="select *,if(ipd_credit>0,'Credit to IPD','CASH') as credit_status, + if(case_credit>0,'Credit to Org','CASH') as credit_org_status from invoice_med_master + where id=$inv_id"; + $query = $this->db->query($sql); + $data['invoiceMaster']= $query->result(); + + $sql="select sum(amount) as Gtotal,sum(tamount) as tamt,sum(CGST) as TCGST,sum(SGST) as TSGST,sum(disc_amount) as t_dis_amt from inv_med_item where inv_med_id=".$inv_id; + $query = $this->db->query($sql); + $data['invoiceGtotal']= $query->result(); + + $sql="select * from doctor_master where active=1"; + $query = $this->db->query($sql); + $data['doclist']= $query->result(); + + $sql="select *, + GET_AGE_1(dob,age,age_in_month,estimate_dob) AS age from patient_master where id='".$data['invoiceMaster'][0]->patient_id."' "; + $query = $this->db->query($sql); + $data['person_info']= $query->result(); + + $data['org_Name']=""; + $ipd_id=$data['invoiceMaster'][0]->ipd_id; + + if($ipd_id>0) + { + $sql="select * from ipd_master where id=".$ipd_id; + $query = $this->db->query($sql); + $ipd_master= $query->result(); + + $sql="select * from v_ipd_list m join patient_master p on m.p_id=p.id + where m.id=".$ipd_id; + $query = $this->db->query($sql); + $data['ipd_list']= $query->result(); + + $data['ipd_master']=$ipd_master; + + if(count($ipd_master)>0) + { + $p_ipd_id=$ipd_master[0]->id; + $p_ipd_code=$ipd_master[0]->ipd_code; + + if($ipd_master[0]->case_id>0) + { + $sql="select * from organization_case_master where id=".$ipd_master[0]->case_id; + $query = $this->db->query($sql); + $org_master= $query->result(); + + if(count($org_master)>0) + { + $data['org_Name']=$org_master[0]->insurance_company_name; + } + + } + } + } + + if($data['invoiceMaster'][0]->case_id > 0) + { + $sql="select * from organization_case_master where id=".$data['invoiceMaster'][0]->case_id; + $query = $this->db->query($sql); + $data['OCaseMaster']= $query->result(); + } + + + + $user = $this->ion_auth->user()->row(); + $data['user_id'] = $user->id; + + $this->load->view('Medical/invoice_master_edit',$data); + + } + + public function LockIPD($inv_med_id,$lock=1) + { + if (!$this->input->is_ajax_request()) { exit('no valid req.'); } + + $sql = "select * from ipd_master where id=".$inv_med_id; + $query = $this->db->query($sql); + $ipd_master= $query->result(); + + $user = $this->ion_auth->user()->row(); + $user_id = $user->id; + $user_name = $user->first_name.''. $user->last_name; + + $old_remark=$ipd_master[0]->lock_remark; + + if($lock==1) + { + $new_remark='Locked By : '.$user_name.'['.$user_id.']'.' Date:'.date('d-m-Y h:i:s').PHP_EOL; + + }else{ + $new_remark='Unlocked By : '.$user_name.'['.$user_id.']'.' Date:'.date('d-m-Y h:i:s').PHP_EOL; + } + + $new_remark.= $old_remark; + + $dataupdate = array( + 'lock_medical' => $lock, + 'lock_remark' => $new_remark + ); + + $this->load->model('Ipd_M'); + $this->Ipd_M->update($dataupdate,$inv_med_id); + + $rvar=array( + 'update' =>1, + ); + + $encode_data = json_encode($rvar); + echo $encode_data; + + + } + + public function load_model_box($ipd_id) + { + $sql="select *,if(ipd_status=0,DATEDIFF(sysdate(),register_date), + DATEDIFF(discharge_date,register_date)) as no_days, + if(case_type=1,'MLC','Non MLC') as case_type_s, + Date_format(register_date,'%d-%m-%Y') as str_register_date from ipd_master + where id='".$ipd_id."' "; + $query = $this->db->query($sql); + $data['ipd_info']= $query->result(); + + $sql="select *,if(gender=1,'Male','Female') as xgender, + GET_AGE_1(dob,age,age_in_month,estimate_dob) AS age + from patient_master where id='".$data['ipd_info'][0]->p_id."' "; + $query = $this->db->query($sql); + $data['person_info']= $query->result(); + + $sql="select * from inv_med_group where med_type=1 and ipd_id=".$ipd_id; + $query = $this->db->query($sql); + $data['med_group_list']= $query->result(); + + $sql="select p.*,if(p.credit_debit=0,p.amount,p.amount*-1) as paid_amount, + Date_Format(payment_date,'%d-%m-%Y') as str_payment_date, + Concat((case p.payment_mode when 1 then 'Cash' when 2 then 'Bank Card' else 'Other' end),if(p.credit_debit=0,'',' Return')) as Payment_type_str + from payment_history_medical p join inv_med_group m + on p.group_id=m.med_group_id + where m.ipd_id=".$ipd_id." and m.med_type=1"; + $query = $this->db->query($sql); + $data['payment_history']= $query->result(); + + $sql="select * from inv_med_group where med_type=1 and ipd_id=".$ipd_id; + $query = $this->db->query($sql); + $data['inv_med_group']= $query->result(); + + + $phone_number_list=array($data['person_info'][0]->mphone1,$data['ipd_info'][0]->P_mobile1,$data['ipd_info'][0]->P_mobile2); + + $data['phone_number_list']=array_unique($phone_number_list); + + $this->load->view('Medical/Med_Model_Payment',$data); + } + + public function payment_receipt($ipd_id,$cash=0) + { + $cash_where=" "; + + if($cash==0) + { + $cash_where.=" and ipd_credit=0 "; + $med_type=1; + }elseif($cash==1) + { + $cash_where.=" and ipd_credit=1 and ipd_credit_type=1 "; + $med_type=2; + }elseif($cash==2) + { + $cash_where.=" and ipd_credit=1 and ipd_credit_type=0 "; + $med_type=3; + } + + $sql="select m.p_id,p.p_fname,m.ipd_code,p.p_code, m.doc_name, + m.org_id from v_ipd_list m join patient_master p on m.p_id=p.id + where m.id=".$ipd_id; + $query = $this->db->query($sql); + $data['ipd_master']= $query->result(); + + $sql="select * from organization_case_master where id='".$data['ipd_master'][0]->org_id."'"; + $query = $this->db->query($sql); + $data['orgcase']= $query->result(); + + $sql="select * from inv_med_group + where ipd_id='".$ipd_id."' and med_type=".$med_type; + $query = $this->db->query($sql); + $data['inv_med_group']= $query->result(); + + $sql="select p.*,if(p.credit_debit>0,p.amount*-1,p.amount) as paid_amount, + Date_Format(payment_date,'%d-%m-%Y') as str_payment_date, + (case p.payment_mode when 1 then 'Cash' when 2 then 'Bank Card' when 3 then 'Return Cash ' when 4 then 'Bank Return' when 5 then 'Cash Return' else 'Other' end) as Payment_type_str + from payment_history_medical p join inv_med_group m + on p.group_id=m.med_group_id + where m.ipd_id=".$ipd_id." and m.med_type=".$med_type; + $query = $this->db->query($sql); + $data['payment_history']= $query->result(); + + $this->load->view('Medical/Med_Payment_Receipt',$data); + + //load mPDF library + $this->load->library('m_pdf'); + $this->m_pdf->pdf->SetWatermarkText(M_store); + $this->m_pdf->pdf->showWatermarkText = true; + + $file_name='Report-payment_receipt-'.$ipd_id."-".date('Ymdhis').".pdf"; + $filepath=$file_name; + $content=$this->load->view('Medical/Med_Payment_Receipt',$data,TRUE); + $this->m_pdf->pdf->WriteHTML($content); + $this->m_pdf->pdf->Output($filepath,"I"); + + } + + public function payment_receipt_sms($ipd_id,$cash=0) + { + $inv_phone_number=$this->input->post('phone_number'); + + $cash_where=" "; + + if($cash==0) + { + $cash_where.=" and ipd_credit=0 "; + $med_type=1; + }elseif($cash==1) + { + $cash_where.=" and ipd_credit=1 and ipd_credit_type=1 "; + $med_type=2; + }elseif($cash==2) + { + $cash_where.=" and ipd_credit=1 and ipd_credit_type=0 "; + $med_type=3; + } + + $sql="select m.p_id,p.p_fname,m.ipd_code,p.p_code, m.doc_name, + m.org_id,m.P_mobile1,m.P_mobile2 from v_ipd_list m join patient_master p on m.p_id=p.id + where m.id=".$ipd_id; + $query = $this->db->query($sql); + $ipd_master= $query->result(); + + $sql="select * from inv_med_group + where ipd_id='".$ipd_id."' and med_type=".$med_type; + $query = $this->db->query($sql); + $inv_med_group= $query->result(); + + $sql="select * from invoice_med_master + where ipd_id='".$ipd_id."' and ipd_credit=0 order by id desc limit 1"; + $query = $this->db->query($sql); + $inv_med_master= $query->result(); + + $sql="select p.*,if(p.credit_debit>0,p.amount*-1,p.amount) as paid_amount, + Date_Format(payment_date,'%d-%m-%Y') as str_payment_date, + (case p.payment_mode when 1 then 'Cash' when 2 then 'Bank Card' when 3 then 'Return Cash ' when 4 then 'Bank Return' when 5 then 'Cash Return' else 'Other' end) as Payment_type_str + from payment_history_medical p join inv_med_group m + on p.group_id=m.med_group_id + where m.ipd_id=".$ipd_id." and m.med_type=".$med_type." order by id desc limit 1"; + $query = $this->db->query($sql); + $payment_history_last= $query->result(); + + $Last_Inv_Amt=0; + $Last_pay_Amt=0; + + if(count($inv_med_master)>0) + { + $Last_Inv_Amt=$inv_med_master[0]->net_amount; + } + + if(count($payment_history_last)>0) + { + $Last_pay_Amt=$payment_history_last[0]->paid_amount; + } + + $SMS_SEND= M_store_short." STORE BILL STATUS%nIPD No.: ".$ipd_master[0]->ipd_code."%nPName: ".Trim($ipd_master[0]->p_fname)."%nTot. Med Amt.: ".Round($inv_med_group[0]->net_amount,0)."%nLast Inv. Amt.: ".Round($Last_Inv_Amt,0)."%nTot. Paid Amt.: ".Round($inv_med_group[0]->payment_received)."%nLast Paid Amt.: ".Round($Last_pay_Amt,0)."%nBal. Amt.: ".Round($inv_med_group[0]->payment_balance,0)."%nFrom: DevSoftTech HMS"; + + + + //$inv_phone_number="9720958717"; + + $this->load->model('SMS_M'); + + $data=array( + 'to_number'=>$inv_phone_number, + 'message'=>$SMS_SEND + ); + + $insert_id=$this->SMS_M->insert_sms_outbox($data); + + + $rvar=array( + 'update' =>$insert_id, + 'msg_text'=>"Message Send" + ); + $encode_data = json_encode($rvar); + echo $encode_data; + + } + + public function group_confirm_payment() + { + if (!$this->input->is_ajax_request()) { exit('no valid req.'); } + + $this->load->model('Ipd_M'); + $this->load->model('Medical_M'); + + $ipd_id=$this->input->post('ipd_id'); + $amount=$this->input->post('amount'); + $Med_Group_id=$this->input->post('Med_Group_id'); + + $sql="select * from ipd_master where id=".$ipd_id; + $query = $this->db->query($sql); + $ipd_master= $query->result(); + + $user = $this->ion_auth->user()->row(); + $user_id = $user->id; + $user_name = $user->first_name.''. $user->last_name; + + $pay_remark=$this->input->post('cash_remark'); + $cr_dr=$this->input->post('cr_dr'); + + + $pay_datetime=str_to_MysqlDate($this->input->post('date_payment')).' '.date('H:i:s'); + + if($this->input->post('mode')==1) + { + $paydata = array( + 'payment_mode'=> '1', + 'Customerof_type'=>'2', + 'Customerof_id'=>$ipd_master[0]->p_id, + 'group_id'=>$Med_Group_id, + 'ipd_id'=>$ipd_id, + 'med_type'=>0, + 'credit_debit'=>$cr_dr, + 'amount'=>$amount, + 'payment_date'=>$pay_datetime, + 'remark'=>$pay_remark, + 'update_by'=>$user_name.'['.$user_id.']', + 'update_by_id'=>$user_id + ); + + $insert_id=$this->Medical_M->insert_payment($paydata); + + $this->Medical_M->update_invoice_group_gst($ipd_id); + + $rvar=array( + 'update' =>1, + 'ipd_id'=> $ipd_id, + 'payid' => $insert_id, + 'pay_date' =>$pay_datetime + ); + $encode_data = json_encode($rvar); + echo $encode_data; + } + + if($this->input->post('mode')==2) + { + + $FormRules = array( + array( + 'field' => 'input_card_mac', + 'label' => 'Card Bank Name', + 'rules' => 'required|min_length[1]|max_length[30]' + ) + /*, + array( + 'field' => 'input_card_digit', + 'label' => 'Card Last 4 Digit ', + 'rules' => 'required|min_length[1]|max_length[10]' + ), + array( + 'field' => 'input_card_bank', + 'label' => 'Bank Name ', + 'rules' => 'required|min_length[1]|max_length[50]' + ), + array( + 'field' => 'input_card_tran', + 'label' => 'Card Transcation ID', + 'rules' => 'required|min_length[1]|max_length[15]' + )*/ + ); + + $this->form_validation->set_rules($FormRules); + + if ($this->form_validation->run() == TRUE) + { + + + $paydata = array( + 'payment_mode'=> '2', + 'Customerof_type'=>'2', + 'Customerof_id'=>$ipd_master[0]->p_id, + 'group_id'=>$Med_Group_id, + 'ipd_id'=>$ipd_id, + 'med_type'=>0, + 'credit_debit'=>$cr_dr, + 'amount'=>$amount, + 'payment_date'=>$pay_datetime, + 'remark'=>$pay_remark, + 'update_by'=>$user_name.'['.$user_id.']', + 'update_by_id'=>$user_id, + 'card_bank'=>$this->input->post('input_card_mac'), + 'cust_card'=>$this->input->post('input_card_bank'), + 'card_remark'=>$this->input->post('input_card_digit'), + 'card_tran_id'=>$this->input->post('input_card_tran'), + + ); + + $insert_id=$this->Medical_M->insert_payment($paydata); + + $this->Medical_M->update_invoice_group_gst($ipd_id); + + $rvar=array( + 'update' =>1, + 'ipd_id'=> $ipd_id, + 'payid' => $insert_id, + 'pay_date' =>$pay_datetime + ); + $encode_data = json_encode($rvar); + echo $encode_data; + } + else{ + $send_error=validation_errors(); + $rvar=array( + 'update' =>0, + 'error_text'=>$send_error + ); + $encode_data = json_encode($rvar); + echo $encode_data; + } + } + + + if($this->input->post('mode')==5) + { + $FormRules = array( + array( + 'field' => 'input_person_name', + 'label' => 'Name on Chq.', + 'rules' => 'required|min_length[1]|max_length[30]' + ), + array( + 'field' => 'input_bank_tran', + 'label' => 'Chq. Number', + 'rules' => 'required|min_length[1]|max_length[15]' + ) + /*, + array( + 'field' => 'input_card_digit', + 'label' => 'Card Last 4 Digit ', + 'rules' => 'required|min_length[1]|max_length[10]' + ), + array( + 'field' => 'input_card_bank', + 'label' => 'Bank Name ', + 'rules' => 'required|min_length[1]|max_length[50]' + ), + */ + ); + + $this->form_validation->set_rules($FormRules); + + if ($this->form_validation->run() == TRUE) + { + $pay_remark='Chq Payment'; + + $paydata = array( + 'payment_mode'=> '2', + 'payof_type'=>'4', + 'payof_id'=>$ipd_master[0]->id, + 'payof_code'=>$ipd_master[0]->ipd_code, + 'credit_debit'=>$cr_dr, + 'amount' => $amount, + 'payment_date'=>$pay_datetime, + 'remark'=>$pay_remark, + 'update_by'=>$user_name.'['.$user_id.']', + 'card_bank'=>$this->input->post('input_bank_hospital'), + 'cust_card'=>$this->input->post('input_bank_name'), + 'card_remark'=>$this->input->post('input_person_name'), + 'card_tran_id'=>$this->input->post('input_bank_tran'), + 'update_by_id'=>$user_id + ); + + $insert_id=$this->Payment_M->insert($paydata); + + $data = array( + 'payment_mode'=> '2', + 'payment_mode_desc'=>'Bank Chq.-Draft', + 'payment_id'=>$insert_id, + 'pay_date'=>$pay_datetime, + 'enter_pay_date' => date('Y-m-d H:i:s'), + 'ipd_id' => $ipd_id, + 'amount' => $amount, + 'card_bank'=>$this->input->post('input_bank_hospital'), + 'card_remark'=>$this->input->post('input_card_digit'), + 'cust_card'=>$this->input->post('input_bank_name'), + 'card_tran_id'=>$this->input->post('input_bank_tran'), + 'prepared_by'=>$user_name.'['.$user_id.']', + 'prepared_by_id'=>$user_id + ); + + $insert_ipdpay_id=$this->Ipd_M->insert_payment_ipd( $data); + + $status='Bank Card'; + + + $rvar=array( + 'update' =>1, + 'ipd_id'=> $ipd_id, + 'payid' => $insert_ipdpay_id + ); + + $encode_data = json_encode($rvar); + echo $encode_data; + } + else{ + $send_error=validation_errors(); + $rvar=array( + 'update' =>0, + 'error_text'=>$send_error + ); + $encode_data = json_encode($rvar); + echo $encode_data; + } + } + } + + public function group_cash_print($ipd_id,$payid) + { + $sql="select *,date_format(payment_date,'%d-%m-%Y') as pay_date, + (case payment_mode when 1 then 'CASH' when 2 then 'Bank' Else 'Other' End) as payment_mode_desc + from payment_history_medical where id=".$payid; + $query = $this->db->query($sql); + $data['med_payment']= $query->result(); + + $sql="select * from ipd_master where id =".$ipd_id; + $query = $this->db->query($sql); + $data['ipd_master']= $query->result(); + + $pno=$data['ipd_master'][0]->p_id; + + $sql="select *,if(gender=1,'Male','Female') as xgender, + GET_AGE_1(dob,age,age_in_month,estimate_dob) AS age + from patient_master where id='".$pno."' "; + + $query = $this->db->query($sql); + $data['person_info']= $query->result(); + + $this->load->view('Medical/Med_Payment_receipt',$data); + + } + + public function Invoice_Item_Return($inv_type_id,$inv_type=0) + { + $data['inv_type_id']=$inv_type_id; + $data['inv_type']=$inv_type; + + $p_id=0; + + if($inv_type==0) + { + $sql="select * from ipd_master where id='".$inv_type_id."' "; + $query = $this->db->query($sql); + $data['ipd_master']= $query->result(); + + $sql_items="select m.id as inv_id,m.inv_med_code,date_format(inv_date,'%d-%m-%Y') as str_inv_date,m.ipd_id,m.patient_id,m.group_invoice_id,m.case_id, + t.id as item_id,t.item_Name,t.qty,t.batch_no,t.expiry,t.store_stock_id as ss_no,t.item_code,t.mrp,t.price, + t.amount,t.disc_amount,t.tamount,r.r_qty,r.id as return_id + from (invoice_med_master m join inv_med_item t on m.id=t.inv_med_id ) left join inv_med_item_return r on t.id=r.inv_item_id and return_status=0 + where m.ipd_id=".$inv_type_id. " order by t.item_Name,t.batch_no"; + + $p_id=$data['ipd_master'][0]->p_id; + + }elseif($inv_type==1){ + $sql="select * from organization_case_master where id='".$inv_type_id."' "; + $query = $this->db->query($sql); + $data['org_master']= $query->result(); + + $sql_items="select m.id as inv_id,m.inv_med_code,date_format(inv_date,'%d-%m-%Y') as str_inv_date,m.ipd_id,m.patient_id,m.group_invoice_id,m.case_id, + t.id as item_id,t.item_Name,t.qty,t.batch_no,t.expiry,t.store_stock_id as ss_no,t.item_code,t.mrp,t.price, + t.amount,t.disc_amount,t.tamount,r.r_qty,r.id as return_id + from (invoice_med_master m join inv_med_item t on m.id=t.inv_med_id ) left join inv_med_item_return r on t.id=r.inv_item_id and return_status=0 + where m.case_id=".$inv_type_id. " order by t.item_Name,t.batch_no"; + + $p_id=$data['org_master'][0]->p_id; + }else{ + $sql="select * from invoice_med_master where id='".$inv_type_id."' "; + $query = $this->db->query($sql); + $data['invoice_med_master']= $query->result(); + + $sql_items="select m.id as inv_id,m.inv_med_code,date_format(inv_date,'%d-%m-%Y') as str_inv_date,m.ipd_id,m.patient_id,m.group_invoice_id,m.case_id, + t.id as item_id,t.item_Name,t.qty,t.batch_no,t.expiry,t.store_stock_id as ss_no,t.item_code,t.mrp,t.price, + t.amount,t.disc_amount,t.tamount,r.r_qty,r.id as return_id + from (invoice_med_master m join inv_med_item t on m.id=t.inv_med_id ) left join inv_med_item_return r on t.id=r.inv_item_id and return_status=0 + where m.id=".$inv_type_id. " order by t.item_Name,t.batch_no"; + + $p_id=$data['invoice_med_master'][0]->patient_id; + } + + $sql="select * from patient_master_exten + where id='".$p_id."' "; + $query = $this->db->query($sql); + $data['person_info']= $query->result(); + + $query = $this->db->query($sql_items); + $data['inv_items']= $query->result(); + + $this->load->view('Medical/Medical_Invoice_Return',$data); + } + + public function Med_Return_invoice_search($r_inv_id) + { + $data['r_inv_id']=$r_inv_id; + $this->load->view('Medical/Med_Return_Invoice_search',$data); + } + + public function Invoice_Item_old() + { + $search_text=trim($this->input->post('search_text')); + $search_type=$this->input->post('search_type'); + + if($search_type==1){ + $sql="SELECT m.id AS inv_id,m.inv_med_code,m.inv_date,m.inv_name,m.inv_phone_number, + i.*,date_format(i.expiry,'%m-%Y') as exp_date,(i.disc_amount+disc_whole) as t_discount + FROM (invoice_med_master m JOIN inv_med_item i ON m.id=i.inv_med_id AND m.sale_return=0) + Where m.inv_phone_number='$search_text' and m.ipd_id=0 and m.case_id=0 "; + $query = $this->db->query($sql); + $data['med_inv_item_list']= $query->result(); + } + + if($search_type==2){ + $sql="SELECT count(id) as no_rec,group_concat(id) as p_id_list + From patient_master where p_code like '".$search_text."' "; + $query = $this->db->query($sql); + $patient_master= $query->result(); + + $search_id_list="0"; + if($patient_master[0]->no_rec) + { + $search_id_list=$patient_master[0]->p_id_list; + } + + $sql="SELECT m.id AS inv_id,m.inv_med_code,m.inv_date,m.inv_name,m.inv_phone_number, + i.*,date_format(i.expiry,'%m-%Y') as exp_date,(i.disc_amount+disc_whole) as t_discount + FROM (invoice_med_master m JOIN inv_med_item i ON m.id=i.inv_med_id AND m.sale_return=0) + Where m.patient_id in ($search_id_list) and m.ipd_id=0 and m.case_id=0"; + $query = $this->db->query($sql); + $data['med_inv_item_list']= $query->result(); + } + + if($search_type==3){ + $sql="SELECT m.id AS inv_id,m.inv_med_code,m.inv_date,m.inv_name,m.inv_phone_number, + i.*,date_format(i.expiry,'%m-%Y') as exp_date,(i.disc_amount+disc_whole) as t_discount + FROM (invoice_med_master m JOIN inv_med_item i ON m.id=i.inv_med_id AND m.sale_return=0) + Where m.inv_med_code like '".$search_text."%' and m.ipd_id=0 and m.case_id=0"; + $query = $this->db->query($sql); + $data['med_inv_item_list']= $query->result(); + } + + if($search_type==4){ + $sql="SELECT m.id AS inv_id,m.inv_med_code,m.inv_date,m.inv_name,m.inv_phone_number, + i.*,date_format(i.expiry,'%m-%Y') as exp_date,(i.disc_amount+disc_whole) as t_discount + FROM (invoice_med_master m JOIN inv_med_item i ON m.id=i.inv_med_id AND m.sale_return=0) + Where i.item_Name like '".$search_text."%' "; + $query = $this->db->query($sql); + $data['med_inv_item_list']= $query->result(); + } + + $this->load->view('Medical/Med_Item_old_list',$data); + } + + public function Invoice_old($inv_id) + { + $sql="Select * from invoice_med_master where id=$inv_id"; + $query = $this->db->query($sql); + $invoice_med_master= $query->result(); + + $phone_no=''; + $p_id=0; + $ipd_id=0; + + if(count($invoice_med_master)>0) + { + $phone_no=$invoice_med_master[0]->inv_phone_number; + $p_id=$invoice_med_master[0]->patient_id; + $ipd_id=$invoice_med_master[0]->ipd_id; + } + + if($ipd_id>0){ + $sql="SELECT m.id AS inv_id,m.inv_med_code,m.inv_date,m.inv_name,m.inv_phone_number, + i.*,date_format(i.expiry,'%m-%Y') as exp_date,(i.disc_amount+disc_whole) as t_discount, + m.net_amount + FROM (invoice_med_master m JOIN inv_med_item i ON m.id=i.inv_med_id AND m.sale_return=0) + Where m.id<>$inv_id and m.ipd_id=$ipd_id and m.case_id=0 + order by m.id desc"; + }else if($p_id>0) + { + $sql="SELECT m.id AS inv_id,m.inv_med_code,m.inv_date,m.inv_name,m.inv_phone_number, + i.*,date_format(i.expiry,'%m-%Y') as exp_date,(i.disc_amount+disc_whole) as t_discount, + m.net_amount + FROM (invoice_med_master m JOIN inv_med_item i ON m.id=i.inv_med_id AND m.sale_return=0) + Where m.patient_id='$p_id' and m.id<>$inv_id and m.ipd_id=0 and m.case_id=0 order by m.id desc"; + }else if($phone_no!=''){ + $sql="SELECT m.id AS inv_id,m.inv_med_code,m.inv_date,m.inv_name,m.inv_phone_number, + i.*,date_format(i.expiry,'%m-%Y') as exp_date,(i.disc_amount+disc_whole) as t_discount, + m.net_amount + FROM (invoice_med_master m JOIN inv_med_item i ON m.id=i.inv_med_id AND m.sale_return=0) + Where m.inv_phone_number='$phone_no' and m.id<>$inv_id and m.ipd_id=0 and m.case_id=0 order by m.id desc"; + }else{ + $sql="SELECT m.id AS inv_id,m.inv_med_code,m.inv_date,m.inv_name,m.inv_phone_number, + i.*,date_format(i.expiry,'%m-%Y') as exp_date,(i.disc_amount+disc_whole) as t_discount, + m.net_amount + FROM (invoice_med_master m JOIN inv_med_item i ON m.id=i.inv_med_id AND m.sale_return=0) + Where 1<>1 "; + } + + $query = $this->db->query($sql); + $data['med_inv_item_list']= $query->result(); + + $this->load->view('Medical/Med_old_invoice_list',$data); + } + + public function add_remove_item() + { + $this->load->model('Medical_M'); + + $inv_id=$this->input->post('inv_id'); + $item_id=$this->input->post('itemid'); + $rqty=$this->input->post('rqty'); + + $user = $this->ion_auth->user()->row(); + $user_update_info = $user->first_name.''. $user->last_name.'['.$user->id.']'.date('d-m-Y H:i:s'); + + $sql="select * from inv_med_item where id='".$item_id."' "; + $query = $this->db->query($sql); + $inv_med_item_result= $query->result_array(); + + $update=0; + $msg_box=""; + + if(count($inv_med_item_result)>0) + { + $inv_med_item=$inv_med_item_result[0]; + + $CGST=$inv_med_item['CGST_per']; + $SGST=$inv_med_item['SGST_per']; + + $item_rate=$inv_med_item['price']; + $amount_value=$rqty*$item_rate*-1; + + $disc_total=$inv_med_item['disc_amount']+$inv_med_item['disc_whole']; + $amount=$inv_med_item['amount']; + $twdisc_amount=$inv_med_item['twdisc_amount']; + + $margin=$amount-$twdisc_amount; + $desc_per=$margin*100/$amount; + + $disc_amount=$amount_value*$desc_per/100; + $Tamount_value=$amount_value-$disc_amount; + + unset($inv_med_item['id']); + + $inv_med_item['inv_med_id'] =$inv_id; + + //Old Qty Sale + $old_qty=$inv_med_item['qty']; + $inv_med_item['qty'] =$rqty; + + $inv_med_item['return_item_id']=$item_id; + $inv_med_item['sale_return']=1; + + $inv_med_item['amount'] = $amount_value; + $inv_med_item['tamount'] = $Tamount_value; + + $inv_med_item['disc_amount']=$disc_amount; + $inv_med_item['disc_per']=$desc_per; + + $inv_med_item['disc_whole']='0'; + $inv_med_item['twdisc_amount']=$Tamount_value; + + $inv_med_item['update_by_remark']=$user_update_info; + $inv_med_item['update_by_id']=$user->id; + + $sql="select * from inv_med_item + where sale_return=1 and inv_med_id='$inv_id' and return_item_id='$item_id' "; + $query = $this->db->query($sql); + $inv_med_item_return= $query->result(); + + $sql="select sum(qty) as t_r_qty from inv_med_item + where sale_return=1 and return_item_id='$item_id' "; + $query = $this->db->query($sql); + $med_item_return_total= $query->result(); + + $tot_qty=0; + + if(count($med_item_return_total)>0) + { + $tot_return=$med_item_return_total[0]->t_r_qty; + $tot_qty=$old_qty-$tot_return; + } + + if($tot_qty>=$rqty) + { + if(count($inv_med_item_return)==0) + { + $update=$this->Medical_M->add_invoiceitem( $inv_med_item); + $msg_box="Added Return list"; + }else{ + $update=$inv_med_item_return[0]->id; + + $this->Medical_M->update_invoiceitem( $inv_med_item,$update); + $msg_box="Update Return "; + } + }else{ + $update=0; + $msg_box="Item Already Returned"; + } + + }else{ + $update=0; + $msg_box="No item found"; + } + + $this->Medical_M->update_invoice_final($inv_id); + + $sql="select * from inv_med_item where inv_med_id=".$inv_id; + $query = $this->db->query($sql); + $data['inv_items']= $query->result(); + + $sql="Select sum(amount) as Gtotal,sum(tamount) as tamt, + sum(CGST) as TCGST,sum(SGST) as TSGST,sum(disc_amount) as t_dis_amt + from inv_med_item where inv_med_id=".$inv_id; + $query = $this->db->query($sql); + $data['invoiceGtotal']= $query->result(); + + $user = $this->ion_auth->user()->row(); + $data['user_id'] = $user->id; + + $sql="select * from invoice_med_master where id=".$inv_id; + $query = $this->db->query($sql); + $data['invoiceMaster']= $query->result(); + + + $data['sale_return']=$data['invoiceMaster'][0]->sale_return; + + $content=$this->load->view('Medical/Med_Item_List',$data,true); + + $rvar=array( + 'update' =>$update, + 'msg_text'=>$msg_box, + 'content'=>$content + ); + + $encode_data = json_encode($rvar); + echo $encode_data; + + } + + public function Update_Return() + { + $this->load->model('Medical_M'); + + $r_qty=$this->input->post('u_qty'); + $item_id=$this->input->post('itemid'); + + $sql="select * from inv_med_item where id='".$item_id."' "; + $query = $this->db->query($sql); + $inv_med_item_result= $query->result_array(); + + $user = $this->ion_auth->user()->row(); + $user_update_info = $user->first_name.''. $user->last_name.'['.$user->id.']'.date('d-m-Y H:i:s'); + + $update=0; + $msg_box=""; + + if(count($inv_med_item_result)>0) + { + $inv_med_item=$inv_med_item_result[0]; + + $CGST=$inv_med_item['CGST_per']; + $SGST=$inv_med_item['SGST_per']; + + $item_rate=$inv_med_item['price']; + $amount_value=$r_qty*$item_rate; + + $disc=$inv_med_item['disc_per']; + $disc_amount=$amount_value*$disc/100; + + $Tamount_value=$amount_value-$disc_amount; + + $inv_med_item['inv_item_id'] = $inv_med_item['id']; + unset($inv_med_item['id']); + $inv_med_item['r_qty'] =$r_qty; + + $inv_med_item['amount'] = $amount_value; + $inv_med_item['tamount'] = $Tamount_value; + + $inv_med_item['update_remark']=$user_update_info; + + $sql="select * from inv_med_item_return where return_status=0 and inv_item_id='".$item_id."' "; + $query = $this->db->query($sql); + $inv_med_item_return= $query->result_array(); + + if(count($inv_med_item_return)==0) + { + $update=$this->Medical_M->insert_inv_med_item_return_add( $inv_med_item); + $msg_box="Added in Pending Return list"; + }else{ + $update=1; + $this->Medical_M->delete_return_item($item_id); + $update=$this->Medical_M->insert_inv_med_item_return_add($inv_med_item); + $msg_box="Alerady in Pending Return list, Now Update Again "; + } + + }else{ + $update=0; + $msg_box="No item found"; + } + + $rvar=array( + 'update' =>$update, + 'msg_text'=>$msg_box + ); + + $encode_data = json_encode($rvar); + echo $encode_data; + } + + + public function undo_Return() + { + $this->load->model('Medical_M'); + + $item_id=$this->input->post('itemid'); + + $update=1; + $msg_box=""; + + $this->Medical_M->delete_return_item($item_id); + + $rvar=array( + 'update' =>$update, + 'msg_text'=>$msg_box + ); + + $encode_data = json_encode($rvar); + echo $encode_data; + } + + + public function pre_reurn_item_list($inv_type_id,$inv_type=0) + { + $data['inv_type_id']=$inv_type_id; + $data['inv_type']=$inv_type; + + $p_id=0; + + if($inv_type==0) + { + $sql="select * from ipd_master where id='".$inv_type_id."' "; + $query = $this->db->query($sql); + $data['ipd_master']= $query->result(); + + $sql_items="select m.id as inv_id,m.inv_med_code,date_format(inv_date,'%d-%m-%Y') as str_inv_date,m.ipd_id,m.patient_id,m.group_invoice_id,m.case_id, + t.id as item_id,t.item_Name,t.qty,t.batch_no,t.expiry,t.store_stock_id as ss_no,t.item_code,t.mrp,t.price, + t.amount,t.disc_amount,t.tamount,t.r_qty,t.id as return_id + from (invoice_med_master m join inv_med_item_return t on m.id=t.inv_med_id and t.return_status=0) + where m.ipd_id=".$inv_type_id. " order by t.item_Name,t.batch_no"; + + $p_id=$data['ipd_master'][0]->p_id; + + }elseif($inv_type==1){ + $sql="select * from organization_case_master where id='".$inv_type_id."' "; + $query = $this->db->query($sql); + $data['org_master']= $query->result(); + + $sql_items="select m.id as inv_id,m.inv_med_code,date_format(inv_date,'%d-%m-%Y') as str_inv_date,m.ipd_id,m.patient_id,m.group_invoice_id,m.case_id, + t.id as item_id,t.item_Name,t.qty,t.batch_no,t.expiry,t.store_stock_id as ss_no,t.item_code,t.mrp,t.price, + t.amount,t.disc_amount,t.tamount,t.r_qty,t.id as return_id + from (invoice_med_master m join inv_med_item_return t on m.id=t.inv_med_id and t.return_status=0) + where m.case_id=".$inv_type_id. " order by t.item_Name,t.batch_no"; + + $p_id=$data['org_master'][0]->p_id; + }else{ + $sql="select * from invoice_med_master where id='".$inv_type_id."' "; + $query = $this->db->query($sql); + $data['invoice_med_master']= $query->result(); + + $sql_items="select m.id as inv_id,m.inv_med_code,date_format(inv_date,'%d-%m-%Y') as str_inv_date,m.ipd_id,m.patient_id,m.group_invoice_id,m.case_id, + t.id as item_id,t.item_Name,t.qty,t.batch_no,t.expiry,t.store_stock_id as ss_no,t.item_code,t.mrp,t.price, + t.amount,t.disc_amount,t.tamount,t.r_qty,t.id as return_id + from (invoice_med_master m join inv_med_item_return t on m.id=t.inv_med_id and t.return_status=0) + where m.id=".$inv_type_id. " order by t.item_Name,t.batch_no"; + + $p_id=$data['invoice_med_master'][0]->patient_id; + } + + $sql="select * from patient_master_exten + where id='".$p_id."' "; + $query = $this->db->query($sql); + $data['person_info']= $query->result(); + + $query = $this->db->query($sql_items); + $data['inv_items']= $query->result(); + + $this->load->view('Medical/Medical_Invoice_Return_pre',$data); + } + + + public function Med_Return_final($inv_type_id,$inv_type=0) + { + $this->load->model('Medical_M'); + + $data['inv_type_id']=$inv_type_id; + $data['inv_type']=$inv_type; + + $p_id=0; + + if($inv_type==0) + { + $sql="select * from ipd_master where id='".$inv_type_id."' "; + $query = $this->db->query($sql); + $data['ipd_master']= $query->result(); + + $sql_items="select m.id as inv_id,m.inv_med_code,date_format(inv_date,'%d-%m-%Y') as str_inv_date,m.ipd_id,m.patient_id,m.group_invoice_id,m.case_id, + t.id as ritem_id,t.inv_item_id,t.item_Name,t.qty,t.batch_no,t.expiry,t.store_stock_id as ss_no,t.item_code,t.mrp,t.price, + t.amount,t.disc_per,t.disc_amount,t.tamount,t.r_qty,t.id as return_id + from (invoice_med_master m join inv_med_item_return t on m.id=t.inv_med_id and t.return_status=0) + where m.ipd_id=".$inv_type_id. " order by t.item_Name,t.batch_no"; + + $p_id=$data['ipd_master'][0]->p_id; + + }elseif($inv_type==1){ + $sql="select * from organization_case_master where id='".$inv_type_id."' "; + $query = $this->db->query($sql); + $data['org_master']= $query->result(); + + $sql_items="select m.id as inv_id,m.inv_med_code,date_format(inv_date,'%d-%m-%Y') as str_inv_date,m.ipd_id,m.patient_id,m.group_invoice_id,m.case_id, + t.id as ritem_id,t.inv_item_id,t.item_Name,t.qty,t.batch_no,t.expiry,t.store_stock_id as ss_no,t.item_code,t.mrp,t.price, + t.amount,t.disc_per,t.disc_amount,t.tamount,t.r_qty,t.id as return_id + from (invoice_med_master m join inv_med_item_return t on m.id=t.inv_med_id and t.return_status=0) + where m.case_id=".$inv_type_id. " order by t.item_Name,t.batch_no"; + + $p_id=$data['org_master'][0]->p_id; + }else{ + $sql="select * from invoice_med_master where id='".$inv_type_id."' "; + $query = $this->db->query($sql); + $data['invoice_med_master']= $query->result(); + + $sql_items="select m.id as inv_id,m.inv_med_code,date_format(inv_date,'%d-%m-%Y') as str_inv_date,m.ipd_id,m.patient_id,m.group_invoice_id,m.case_id, + t.id as ritem_id,t.inv_item_id,t.item_Name,t.qty,t.batch_no,t.expiry,t.store_stock_id as ss_no,t.item_code,t.mrp,t.price, + t.amount,t.disc_per,t.disc_amount,t.tamount,t.r_qty,t.id as return_id + from (invoice_med_master m join inv_med_item_return t on m.id=t.inv_med_id and t.return_status=0) + where m.id=".$inv_type_id. " order by t.item_Name,t.batch_no"; + + $p_id=$data['invoice_med_master'][0]->patient_id; + } + + $sql="select * from patient_master_exten + where id='".$p_id."' "; + $query = $this->db->query($sql); + $data['person_info']= $query->result(); + + $query = $this->db->query($sql_items); + $data['inv_items']= $query->result(); + + foreach($data['inv_items'] as $row) + { + $ritem_id=$row->ritem_id; + + $itemid=$row->inv_item_id; + + $item_rate=$row->price; + + $current_qty=$row->qty-$row->r_qty; + + $inv_id=$row->inv_id; + + $amount_value=$current_qty*$item_rate; + + $disc_per=$row->disc_per; + + $disc_amount=$amount_value*$disc_per/100; + + $Tamount_value=$amount_value-$disc_amount; + + $data['update_inv_med_item'] = array( + 'qty' => $current_qty, + 'disc_amount' => $disc_amount, + 'amount' => $amount_value, + 'tamount' => $Tamount_value + ); + + $update_return_item = array( + 'return_status' => '1', + ); + + $this->Medical_M->update_return_item($update_return_item,$ritem_id); + + $this->Medical_M->update_invoiceitem($data['update_inv_med_item'],$itemid); + + $this->Medical_M->update_invoice_final($inv_id); + } + + redirect('/Medical/pre_reurn_item_list/'.$inv_type_id.'/'.$inv_type=0); + } + + + public function Med_Return_print($inv_type_id,$inv_type=0) + { + $this->load->model('Medical_M'); + + $data['inv_type_id']=$inv_type_id; + $data['inv_type']=$inv_type; + + $p_id=0; + + if($inv_type==0) + { + $sql="select * from v_ipd_list where id='".$inv_type_id."' "; + $query = $this->db->query($sql); + $data['ipd_master']= $query->result(); + + $sql_items="select m.id as inv_id,m.inv_med_code,date_format(inv_date,'%d-%m-%Y') as str_inv_date,m.ipd_id,m.patient_id,m.group_invoice_id,m.case_id, + t.id as ritem_id,t.inv_item_id,t.item_Name,t.qty,t.batch_no,t.expiry,t.store_stock_id as ss_no,t.item_code,t.mrp,t.price,t.update_remark,t.return_date_time, + t.amount,t.disc_per,t.disc_amount,t.tamount,t.r_qty,t.id as return_id + from (invoice_med_master m join inv_med_item_return t on m.id=t.inv_med_id and t.return_status=1) + where m.ipd_id=".$inv_type_id. " order by t.item_Name,t.batch_no"; + + $p_id=$data['ipd_master'][0]->p_id; + + }elseif($inv_type==1){ + $sql="select * from organization_case_master where id='".$inv_type_id."' "; + $query = $this->db->query($sql); + $data['org_master']= $query->result(); + + $sql_items="select m.id as inv_id,m.inv_med_code,date_format(inv_date,'%d-%m-%Y') as str_inv_date,m.ipd_id,m.patient_id,m.group_invoice_id,m.case_id, + t.id as ritem_id,t.inv_item_id,t.item_Name,t.qty,t.batch_no,t.expiry,t.store_stock_id as ss_no,t.item_code,t.mrp,t.price,t.update_remark,t.return_date_time, + t.amount,t.disc_per,t.disc_amount,t.tamount,t.r_qty,t.id as return_id + from (invoice_med_master m join inv_med_item_return t on m.id=t.inv_med_id and t.return_status=1) + where m.case_id=".$inv_type_id. " order by t.item_Name,t.batch_no"; + + $p_id=$data['org_master'][0]->p_id; + }else{ + $sql="select * from invoice_med_master where id='".$inv_type_id."' "; + $query = $this->db->query($sql); + $data['invoice_med_master']= $query->result(); + + $sql_items="select m.id as inv_id,m.inv_med_code,date_format(inv_date,'%d-%m-%Y') as str_inv_date,m.ipd_id,m.patient_id,m.group_invoice_id,m.case_id, + t.id as ritem_id,t.inv_item_id,t.item_Name,t.qty,t.batch_no,t.expiry,t.store_stock_id as ss_no,t.item_code,t.mrp,t.price,t.update_remark,t.return_date_time, + t.amount,t.disc_per,t.disc_amount,t.tamount,t.r_qty,t.id as return_id + from (invoice_med_master m join inv_med_item_return t on m.id=t.inv_med_id and t.return_status=1) + where m.id=".$inv_type_id. " order by t.item_Name,t.batch_no"; + + $p_id=$data['invoice_med_master'][0]->patient_id; + } + + $sql="select * from patient_master_exten + where id='".$p_id."' "; + $query = $this->db->query($sql); + $data['person_info']= $query->result(); + + $query = $this->db->query($sql_items); + $data['inv_items']= $query->result(); + + + $this->load->view('Medical/Medical_Invoice_Return_print',$data); + } + + + + + +} \ No newline at end of file diff --git a/old_code_ci3/controllers/Medical_Print.php b/old_code_ci3/controllers/Medical_Print.php index 67e3915..b379748 100644 --- a/old_code_ci3/controllers/Medical_Print.php +++ b/old_code_ci3/controllers/Medical_Print.php @@ -1074,7 +1074,8 @@ class Medical_Print extends MY_Controller { $sql = "select p.*,r.purchase_inv_id,r.qty as r_qty,Round(r.qty/p.packing,2) AS qty_pak,r.id as r_id, if(r.batch_no_r='',p.batch_no,r.batch_no_r) as batch_no_r_s, - date_format(p.expiry_date,'%m/%y') as exp_date_str ,p.purchase_unit_rate*r.qty AS r_amount,p.purchase_unit_rate + date_format(p.expiry_date,'%m/%y') as exp_date_str ,p.purchase_unit_rate*r.qty AS r_amount,p.purchase_unit_rate, + if(p.CGST_per_old IS NULL,CGST_per,CGST_per_old)*2 AS gst_per from purchase_return_invoice_item r join purchase_invoice_item p on r.purchase_item_id=p.id where purchase_inv_id=" . $inv_id; $query = $this->db->query($sql); diff --git a/old_code_ci3/controllers/Medical_Report.php b/old_code_ci3/controllers/Medical_Report.php index 1eb3b52..ca0a961 100644 --- a/old_code_ci3/controllers/Medical_Report.php +++ b/old_code_ci3/controllers/Medical_Report.php @@ -283,7 +283,7 @@ class Medical_Report extends MY_Controller FROM purchase_invoice_item t GROUP BY t.item_code) AS q ON q.item_code=i.item_code) LEFT JOIN doctor_master d ON m.doc_id=d.id - Where $sql_where and m.ipd_id=0 + Where $sql_where GROUP BY m.doc_id,i.item_code ORDER BY i.item_Name"; @@ -365,118 +365,6 @@ class Medical_Report extends MY_Controller } } - public function Report_daily_med_sale_doc_data_ipd($sale_date_range, $doc_id, $output = 0) - { - $sql_where = " 1=1 "; - - $rangeArray = explode("S", $sale_date_range); - $minRange = $rangeArray[0]; - $maxRange = $rangeArray[1]; - - if ($doc_id <> 0) { - //$doc_id_list = str_replace('S', ',', $doc_id); - - $sql_where .= " and FIND_IN_SET($doc_id,ipd.doc_list)>0"; - } - - $sql_where .= " and ipd.discharge_date between '" . $minRange . "' and '" . $maxRange . "'"; - - if (!$this->ion_auth->in_group('MedOLDRec')) { - $sql_where .= " and ipd.discharge_date >=date_add(sysdate(),interval -2 month)"; - } - - $sql = "SELECT ipd.doc_name,ipd.doc_list, i.item_code,i.item_Name, - SUM(if(m.sale_return=0,i.qty,i.qty*-1)) AS Sale_Qty, - SUM(if(m.sale_return=0,i.twdisc_amount,i.twdisc_amount*-1)) AS Sale_Amount, - SUM(if(m.sale_return=0,i.qty*p.purchase_unit_rate,i.qty*p.purchase_unit_rate*-1)) AS Purchase_Amount, - q.cur_qty,i.CGST_per, - SUM(if(m.sale_return=0,(i.CGST+i.SGST),(i.CGST+i.SGST)*-1)) AS Sale_GST - FROM ((((invoice_med_master m JOIN inv_med_item i ON m.id=i.inv_med_id AND m.ipd_id>0) JOIN v_ipd_list ipd ON m.ipd_id=ipd.id) - LEFT JOIN purchase_invoice_item p ON i.store_stock_id=p.id ) - - JOIN (SELECT t.item_code,SUM(t.total_unit-total_sale_unit-total_return_unit-total_lost_unit) AS cur_qty - FROM purchase_invoice_item t - GROUP BY t.item_code) AS q ON q.item_code=i.item_code) - Where $sql_where and m.ipd_id>0 - GROUP BY m.doc_id,i.item_code ORDER BY i.item_Name"; - - $query = $this->db->query($sql); - $med_inv_total = $query->result(); - - $content = 'Date Between ' . $minRange . ' and ' . $maxRange . '
- - '; - - $content .= ' - - - - - - - - - - '; - $sr_no = 0; - $tot_sale_amt = 0; - $tot_sale_gst = 0; - $tot_pur_amt = 0; - $tot_pur_return_amt = 0; - - foreach ($med_inv_total as $row) { - $sr_no = $sr_no + 1; - - $tot_sale_amt = $tot_sale_amt + $row->Sale_Amount; - - $tot_pur_amt += $row->Purchase_Amount; - - $tot_sale_gst += $row->Sale_GST; - - $content .= ' - - - - - - - - - - '; - } - - $content .= ' - - - - - - - - - - '; - - $content .= '
#Doc. NameItem CodeItem NameSale QtySale AmtPur. AmtSale GSTCur.Qty
' . $sr_no . '' . $row->doc_name . '' . $row->item_code . '' . $row->item_Name . '' . $row->Sale_Qty . '' . $row->Sale_Amount . '' . $row->Purchase_Amount . '' . $row->Sale_GST . '' . $row->cur_qty . '
#Total Sale' . $tot_sale_amt . '' . $tot_pur_amt . '' . $tot_sale_gst . '
'; - - $Tot_Margin = ($tot_sale_amt - $tot_pur_amt - $tot_sale_gst); - - $content .= "Total Margin (Sale - Purchase - SaleGST): Rs. " . $Tot_Margin; - - if ($output == 0) { - - $this->load->library('m_pdf'); - $file_name = "Report-MedicalSale-" . date('Ymdhis') . ".pdf"; - $filepath = $file_name; - $this->m_pdf->pdf->WriteHTML($content); - $this->m_pdf->pdf->Output($filepath, "I"); - } else { - $file_name = "Report-MedicalSale-" . date('Ymdhis') . ".pdf"; - - ExportExcel($content, $file_name); - } - } //Company Wise Medicine Sale Report public function Report_company_med_sale() { @@ -1537,7 +1425,7 @@ class Medical_Report extends MY_Controller $sql_where .= " and m.inv_date between '" . $minRange . "' and '" . $maxRange . "'"; - //$sql_where .= " and m.net_amount>0 "; + $sql_where .= " and m.net_amount>0 "; if (!$this->ion_auth->in_group('MedOLDRec')) { $sql_where .= " and m.inv_date >=date_add(sysdate(),interval -1 day)"; @@ -2629,8 +2517,6 @@ class Medical_Report extends MY_Controller ExportExcel($content, 'Report_Medical_gst_invoice'); } - - public function Report_5_HSNdata($sale_date_range, $output = 0) { $rangeArray = explode("S", $sale_date_range); @@ -2639,7 +2525,7 @@ class Medical_Report extends MY_Controller $where = " m.inv_date between '" . $minRange . "' and '" . $maxRange . "'"; - //$where .= " and m.net_amount>0 "; + $where .= " and m.net_amount>0 "; if (!$this->ion_auth->in_group('MedOLDRec')) { $where .= " and date(m.inv_date) >=date(date_add(sysdate(),interval -2 day))"; diff --git a/old_code_ci3/controllers/Medical_Report_09032022.php b/old_code_ci3/controllers/Medical_Report_09032022.php new file mode 100644 index 0000000..032f82e --- /dev/null +++ b/old_code_ci3/controllers/Medical_Report_09032022.php @@ -0,0 +1,2261 @@ +load->library("Pdf"); + } + + //Sale Report + + public function Report_1() + { + + $this->load->view('Medical/Report/Med_Report_1'); + } + + public function Report_1_data($sale_date_range,$output=0) + { + $sql_where=" 1=1 "; + + $rangeArray = explode("S",$sale_date_range); + $minRange = $rangeArray[0]; + $maxRange = $rangeArray[1]; + + $sql_where.=" and m.inv_date between '".$minRange."' and '".$maxRange. "'"; + + $sql="select count(DISTINCT m.id) as No_invoice, + count( DISTINCT m.patient_id) as No_Patients, + m.inv_date,Date_Format(m.inv_date,'%d-%m-%Y') as inv_date_str, + Sum(i.twdisc_amount) as tnet_amount, + sum(if(m.ipd_id=0 and m.case_id=0,i.twdisc_amount,0)) as OPD_Cash_Bill_amount, + sum(if(m.ipd_id=0 and m.case_id>1,i.twdisc_amount,0)) as OPD_Org_Bill_amount, + + sum(if(m.ipd_id>0 and m.ipd_credit=0,i.twdisc_amount,0)) as IPD_Cash_Bill_amount, + sum(if(m.ipd_id>0 and m.ipd_credit=1 and m.ipd_credit_type=1,i.twdisc_amount,0)) as IPD_Credit_Bill_amount, + sum(if(m.ipd_id>0 and m.ipd_credit=1 and m.ipd_credit_type=0,i.twdisc_amount,0)) as IPD_Package_Bill_amount + + from ((invoice_med_master m join inv_med_item i on m.id=i.inv_med_id) + left join patient_master p on m.patient_id=p.id) + left join organization_case_master o on m.case_id=o.id + + where ".$sql_where." group by m.inv_date with Rollup"; + + $query = $this->db->query($sql); + $med_inv_total= $query->result(); + + $content=''; + + $content.=' + + + + + + + + + + + + '; + $sr_no=0; + $cr_Amt_row=0; + $cr_Amt_total=0; + + foreach($med_inv_total as $row) + { + $sr_no=$sr_no+1; + + $cr_Amt_row=$row->OPD_Org_Bill_amount+$row->IPD_Credit_Bill_amount+$row->IPD_Package_Bill_amount; + + if($row->inv_date=='') + { + $content.=' + + + + + + + + + + + + '; + }else{ + $content.=' + + + + + + + + + + + + '; + $cr_Amt_total+=$cr_Amt_row; + } + } + + $content.='
#DateNo. PatientsNo. Inv.Net Amt.OPD CashOPD Org.IPD Cash AmountIPD Cr HospitalIPD Cr Pkg. HospitalTot. Cr. Amt.
#Total'.$row->No_Patients.''.$row->No_invoice.''.$row->tnet_amount.''.$row->OPD_Cash_Bill_amount.''.$row->OPD_Org_Bill_amount.''.$row->IPD_Cash_Bill_amount.''.$row->IPD_Credit_Bill_amount.''.$row->IPD_Package_Bill_amount.''.$cr_Amt_total.'
'.$sr_no.''.$row->inv_date_str.''.$row->No_Patients.''.$row->No_invoice.''.$row->tnet_amount.''.$row->OPD_Cash_Bill_amount.''.$row->OPD_Org_Bill_amount.''.$row->IPD_Cash_Bill_amount.''.$row->IPD_Credit_Bill_amount.''.$row->IPD_Package_Bill_amount.''.$cr_Amt_row.'
'; + + + $this->load->library('m_pdf'); + + $file_name="Report-MedicalBill-".date('Ymdhis').".pdf"; + + $filepath=$file_name; + + + $this->m_pdf->pdf->WriteHTML($content); + + $this->m_pdf->pdf->Output($filepath,"I"); + + + } + + + //Daily Medicine Sale Report + public function Report_daily_med_sale() + { + + $this->load->view('Medical/Report/Med_Report_daily_med_sale'); + } + + public function Report_daily_med_sale_data($sale_date_range,$output=0) + { + $sql_where=" 1=1 "; + + $rangeArray = explode("S",$sale_date_range); + $minRange = $rangeArray[0]; + $maxRange = $rangeArray[1]; + + $sql_where.=" and m.inv_date between '".$minRange."' and '".$maxRange. "'"; + + $sql="SELECT i.item_code,i.item_Name, + SUM(if(m.sale_return=0,i.qty,0)) AS Sale_Qty, + SUM(if(m.sale_return=0,i.twdisc_amount,0)) AS Sale_Amount, + SUM(if(m.sale_return=0,i.qty*p.purchase_unit_rate,0)) AS Purchase_Amount, + SUM(if(m.sale_return=1,i.qty,0)) AS Return_Qty, + SUM(if(m.sale_return=1,i.twdisc_amount,0)) AS Return_Amount, + SUM(if(m.sale_return=1,i.qty*p.purchase_unit_rate,0)) AS return_Purchase_Amount, + q.cur_qty + FROM (invoice_med_master m JOIN inv_med_item i ON m.id=i.inv_med_id) + LEFT JOIN purchase_invoice_item p ON i.store_stock_id=p.id + JOIN (SELECT t.item_code,SUM(t.total_unit-total_sale_unit-total_return_unit-total_lost_unit) AS cur_qty + FROM purchase_invoice_item t + GROUP BY t.item_code) AS q ON q.item_code=i.item_code + Where ".$sql_where." GROUP BY i.item_code ORDER BY i.item_Name"; + + $query = $this->db->query($sql); + $med_inv_total= $query->result(); + + $content=''; + + $content.=' + + + + + + + + + + + '; + $sr_no=0; + $tot_sale_amt=0; + $tot_return_amt=0; + $tot_pur_amt=0; + $tot_pur_return_amt=0; + + foreach($med_inv_total as $row) + { + $sr_no=$sr_no+1; + + $tot_sale_amt=$tot_sale_amt+$row->Sale_Amount; + $tot_return_amt=$tot_return_amt+$row->Return_Amount; + + $tot_pur_amt+=$row->Purchase_Amount; + $tot_pur_return_amt+=$row->return_Purchase_Amount; + + $content.=' + + + + + + + + + + + '; + } + + $content.=' + + + + + + + + + + + '; + + $content.='
#Item CodeItem NameSale QtySale AmtPur. AmtReturn QtyReturn AmtReturn Pur. AmtCur.Qty
'.$sr_no.''.$row->item_code.''.$row->item_Name.''.$row->Sale_Qty.''.$row->Sale_Amount.''.$row->Purchase_Amount.''.$row->Return_Qty.''.$row->Return_Amount.''.$row->return_Purchase_Amount.''.$row->cur_qty.'
#Total Sale'.$tot_sale_amt.''.$tot_pur_amt.'Total Return'.$tot_return_amt.''.$tot_pur_return_amt.'
'; + + $Tot_Margin=($tot_sale_amt-$tot_pur_amt)-($tot_return_amt-$tot_pur_return_amt); + + $content.="Total Margin : Rs.".$Tot_Margin; + + if($output==0) + { + + $this->load->library('m_pdf'); + + $file_name="Report-MedicalSale-".date('Ymdhis').".pdf"; + + $filepath=$file_name; + + $this->m_pdf->pdf->WriteHTML($content); + + $this->m_pdf->pdf->Output($filepath,"I"); + + + }else{ + $file_name="Report-MedicalSale-".date('Ymdhis').".pdf"; + + ExportExcel($content,$file_name); + } + + } + + //Company Wise Medicine Sale Report + public function Report_company_med_sale() + { + $sql="Select * from med_company order by company_name"; + $query = $this->db->query($sql); + $data['med_company']= $query->result(); + + $this->load->view('Medical/Report/Med_Report_company_med_sale',$data); + } + + public function Report_company_med_sale_data($sale_date_range,$comp_id,$output=0) + { + $sql_where=" c.company_id= ".$comp_id; + + $rangeArray = explode("S",$sale_date_range); + $minRange = $rangeArray[0]; + $maxRange = $rangeArray[1]; + + $sql_where.=" and m.inv_date between '".$minRange."' and '".$maxRange. "'"; + + $sql="SELECT i.item_code,i.item_Name,c.company_name, + SUM(if(m.sale_return=0,i.qty,0)) AS Sale_Qty, + SUM(if(m.sale_return=0,i.twdisc_amount,0)) AS Sale_Amount, + SUM(if(m.sale_return=0,i.qty*p.purchase_unit_rate,0)) AS Purchase_Amount, + SUM(if(m.sale_return=1,i.qty,0)) AS Return_Qty, + SUM(if(m.sale_return=1,i.twdisc_amount,0)) AS Return_Amount, + SUM(if(m.sale_return=1,i.qty*p.purchase_unit_rate,0)) AS return_Purchase_Amount + FROM ((invoice_med_master m JOIN inv_med_item i ON m.id=i.inv_med_id) + JOIN purchase_invoice_item p ON i.store_stock_id=p.id ) + JOIN med_product_master c ON i.item_code=c.id + Where ".$sql_where." GROUP BY i.item_code ORDER BY i.item_Name"; + + $query = $this->db->query($sql); + $med_inv_total= $query->result(); + + $content=''; + + $content.=' + + + + + + + + + + '; + $sr_no=0; + $tot_sale_amt=0; + $tot_return_amt=0; + $tot_pur_amt=0; + $tot_pur_return_amt=0; + + foreach($med_inv_total as $row) + { + $sr_no=$sr_no+1; + + $tot_sale_amt=$tot_sale_amt+$row->Sale_Amount; + $tot_return_amt=$tot_return_amt+$row->Return_Amount; + + $tot_pur_amt+=$row->Purchase_Amount; + $tot_pur_return_amt+=$row->return_Purchase_Amount; + + $content.=' + + + + + + + + + + '; + } + + $content.=' + + + + + + + + + + '; + + $content.='
#Item CodeItem NameSale QtySale AmtPur. AmtReturn QtyReturn AmtReturn Pur. Amt
'.$sr_no.''.$row->item_code.''.$row->item_Name.''.$row->Sale_Qty.''.$row->Sale_Amount.''.$row->Purchase_Amount.''.$row->Return_Qty.''.$row->Return_Amount.''.$row->return_Purchase_Amount.'
#Total Sale'.$tot_sale_amt.''.$tot_pur_amt.'Total Return'.$tot_return_amt.''.$tot_pur_return_amt.'
'; + + $Tot_Margin=($tot_sale_amt-$tot_pur_amt)-($tot_return_amt-$tot_pur_return_amt); + + $content.="Total Margin : Rs.".$Tot_Margin; + + if($output==0) + { + + $this->load->library('m_pdf'); + + $file_name="Report-MedicalSale-".date('Ymdhis').".pdf"; + + $filepath=$file_name; + + $this->m_pdf->pdf->WriteHTML($content); + + $this->m_pdf->pdf->Output($filepath,"I"); + + + }else{ + $file_name="Report-MedicalSale-".date('Ymdhis').".pdf"; + + ExportExcel($content,$file_name); + } + + } + + public function Report_company_med_purchase_data($sale_date_range,$comp_id,$output=0) + { + $sql_where=" p.company_id= ".$comp_id; + + $rangeArray = explode("S",$sale_date_range); + $minRange = $rangeArray[0]; + $maxRange = $rangeArray[1]; + + $sql_where.=" and m.date_of_invoice between '".$minRange."' and '".$maxRange. "'"; + + $sql="SELECT i.item_code,i.Item_name,i.packing, + sum(i.qty) as qty,sum(i.taxable_amount) AS taxable_amount, + sum(i.net_amount) AS net_amount ,c.company_name + FROM ((purchase_invoice_item i JOIN purchase_invoice m on i.purchase_id=m.id) + JOIN med_product_master p ON i.item_code=p.id) JOIN med_company c ON p.company_id=c.id + Where ".$sql_where." GROUP BY i.item_code ORDER BY i.Item_name"; + + echo $sql; + $query = $this->db->query($sql); + $med_inv_total= $query->result(); + + $content=''; + + $content.=' + + + + + + + '; + $sr_no=0; + $tot_taxable_amount=0; + $tot_net_amount=0; + + foreach($med_inv_total as $row) + { + $sr_no=$sr_no+1; + + $tot_taxable_amount=$tot_taxable_amount+$row->taxable_amount; + $tot_net_amount=$tot_net_amount+$row->net_amount; + + $content.=' + + + + + + + '; + } + + $content.=' + + + + + + + '; + + $content.='
#Company NameItem NamePurchase QtyPur. Tax. AmtPur. Net Amt
'.$sr_no.''.$row->company_name.''.$row->Item_name.''.$row->qty.''.$row->taxable_amount.''.$row->net_amount.'
#Total '.$tot_taxable_amount.''.$tot_net_amount.'
'; + + //echo $content; + if($output==0) + { + + $this->load->library('m_pdf'); + + $file_name="Report-MedicalCompanyWisePurcase-".date('Ymdhis').".pdf"; + + $filepath=$file_name; + + $this->m_pdf->pdf->WriteHTML($content); + + $this->m_pdf->pdf->Output($filepath,"I"); + + + }else{ + $file_name="Report-MedicalCompanyWisePurcase-".date('Ymdhis').".pdf"; + + ExportExcel($content,$file_name); + } + + } + + // Pending Invoice Report + + public function Report_2_OPD_Pending() + { + + $this->load->view('Medical/Report/Med_Report_2_Pending'); + } + + public function Report_2_Bal_pending_data($sale_date_range,$output=0) + { + $sql_where=" 1=1 "; + + $rangeArray = explode("S",$sale_date_range); + $minRange = $rangeArray[0]; + $maxRange = $rangeArray[1]; + + $sql_where.=" and m.inv_date between '".$minRange."' and '".$maxRange."'"; + + $Report_Heading="Date (YYYY-MM-DD) From :".$minRange." To ".$maxRange." / Data Filter : Pending Balance Invoice"; + + $sql="Select m.id,m.inv_med_code, m.patient_id,m.inv_name,m.patient_code, + m.inv_date,Date_Format(m.inv_date,'%d-%m-%Y') as inv_date_str, + Sum(m.net_amount) as tnet_amount , + Sum(m.payment_received) as payment_received, + Sum(m.payment_balance) as payment_balance + FROM invoice_med_master m + where ".$sql_where." + and (m.payment_balance >1 OR m.payment_balance <-1) + AND m.ipd_id=0 and m.case_id=0 + group by inv_date,m.id with ROLLUP"; + + $query = $this->db->query($sql); + $med_inv_total= $query->result(); + + //echo $sql; + + $content='

'.$Report_Heading.'

'; + $content.=''; + + $content.=' + + + + + + + + '; + $sr_no=0; + + foreach($med_inv_total as $row) + { + $sr_no=$sr_no+1; + + if($row->inv_date=='') + { + $content.=' + + + + + + '; + }elseif($row->id=='') + { + $content.=' + + + + + + '; + + }else{ + + $content.=' + + + + + + + + '; + } + } + + $content.=' + + + + + + + + + + + +
#DateInvoice IDPatients NameNet Amt.Amt. Rec.Amt. Bal.
#Grand Total : '.$row->tnet_amount.''.$row->payment_received.''.$row->payment_balance.'
#Total Date : '.$row->inv_date_str.''.$row->tnet_amount.''.$row->payment_received.''.$row->payment_balance.'
'.$sr_no.''.$row->inv_date_str.''.$row->inv_med_code.''.$row->inv_name.'
'.$row->patient_code.'
'.$row->tnet_amount.''.$row->payment_received.''.$row->payment_balance.'
#DateInvoice IDPatients NameNet Amt.Amt. Rec.Amt. Bal.
'; + + if($output==0) + { + //load mPDF library + $this->load->library('m_pdf'); + + //$this->m_pdf->pdf->SetProtection(array(), '1234567', '277395'); + + $this->m_pdf->pdf->SetWatermarkText(M_store); + $this->m_pdf->pdf->showWatermarkText = true; + + + + $file_name='Report-MedicalBill_Pending-'.date('Ymdhis').".pdf"; + + $filepath=$file_name; + + //generate the PDF from the given html + $this->m_pdf->pdf->WriteHTML($content); + + //download it. + $this->m_pdf->pdf->Output($filepath,"I"); + + }else{ + ExportExcel($content,'Med_Sale_day0001'); + } + + //echo $content; + + + } + + + + + // OPD Pending Balance Paid or OLD Payment Received + + public function Report_2_OPD_Pending_Paid() + { + + $this->load->view('Medical/Report/Med_Report_2_Pending_paid'); + } + + public function Report_2_Bal_pending_payment($sale_date_range,$output=0) + { + $sql_where=" 1=1 "; + + $rangeArray = explode("S",$sale_date_range); + $minRange = $rangeArray[0]; + $maxRange = $rangeArray[1]; + + $sql_where.=" and Date(h.payment_date)= '".$minRange."' and m.inv_date < '".$minRange."'"; + + $Report_Heading="Date (YYYY-MM-DD) :".$minRange." / Data Filter : Payment of OLD OPD Invoice"; + + $sql="Select m.id,m.inv_med_code, m.patient_id,m.inv_name,m.patient_code, m.inv_date, + Date_Format(m.inv_date,'%d-%m-%Y') as inv_date_str, + (m.net_amount) as tnet_amount , + (m.payment_received) as payment_received, + (m.payment_balance) as payment_balance, + if(h.credit_debit=0, h.amount,h.amount*-1) AS tran_amt + FROM (invoice_med_master m join payment_history_medical h on m.id=h.Medical_invoice_id ) + where ".$sql_where." "; + + $query = $this->db->query($sql); + $med_inv_total= $query->result(); + + //echo $sql; + + $content='

'.$Report_Heading.'

'; + $content.=''; + + $content.=' + + + + + + + + + '; + $sr_no=0; + + $tot_payment=0; + + foreach($med_inv_total as $row) + { + $sr_no=$sr_no+1; + $content.=' + + + + + + + + + '; + $tot_payment+=$row->tran_amt; + } + + $content.=' + + + + + + + + + + + + +
#DateInvoice IDPatients NameNet Amt.Amt. Rec.Amt. Bal.Payment Amt.
'.$sr_no.''.$row->inv_date_str.''.$row->inv_med_code.''.$row->inv_name.'
'.$row->patient_code.'
'.$row->tnet_amount.''.$row->payment_received.''.$row->payment_balance.''.$row->tran_amt.'
#Total'.$tot_payment.'
'; + + if($output==0) + { + //load mPDF library + $this->load->library('m_pdf'); + + //$this->m_pdf->pdf->SetProtection(array(), '1234567', '277395'); + + $this->m_pdf->pdf->SetWatermarkText(M_store); + $this->m_pdf->pdf->showWatermarkText = true; + + + $file_name='Report-MedicalBill_Pending-'.date('Ymdhis').".pdf"; + + $filepath=$file_name; + + //generate the PDF from the given html + $this->m_pdf->pdf->WriteHTML($content); + + //download it. + $this->m_pdf->pdf->Output($filepath,"I"); + + }else{ + ExportExcel($content,'Med_Sale_day0001'); + } + + //echo $content; + + } + //Daily Cash Received List + + public function Report_2() + { + + $this->load->view('Medical/Report/Med_Report_2'); + } + + + public function Report_2_data($sale_date_range,$bill_type,$output=0) + { + $sql_where=" 1=1 "; + + $minRange = $sale_date_range; + + $sql_where.=" and m.inv_date = '".$minRange."' "; + + $Filter_type="ALL"; + + if($bill_type==1){ + $sql_where.=" and (m.ipd_id=0 and m.case_id=0 )"; + $Filter_type="OPD CASH"; + }elseif($bill_type==2){ + $sql_where.=" and (m.ipd_id>0 and m.ipd_credit=0 )"; + $Filter_type="IPD CASH"; + }elseif($bill_type==3){ + $sql_where.=" and (m.ipd_id=0 and m.case_id>1 )"; + $Filter_type="OPD Org."; + }elseif($bill_type==4){ + $sql_where.=" and (m.ipd_id>0 and m.ipd_credit=1 and m.ipd_credit_type=1 )"; + $Filter_type="IPD Cr"; + }elseif($bill_type==5){ + $sql_where.=" and (m.ipd_id>0 and m.ipd_credit=1 and m.ipd_credit_type=0 )"; + $Filter_type="IPD Pkg Cr"; + }elseif($bill_type==6){ + $sql_where.=" and ((m.ipd_id>0 and m.ipd_credit=1) or (m.ipd_id=0 and m.case_id>1 ))"; + $Filter_type="Hospital Cr"; + } + + $Report_Heading="Date (YYYY-MM-DD) :".$minRange." / Data Filter :".$Filter_type; + + $sql="Select m.id,m.inv_med_code,m.ipd_code, m.patient_id,m.inv_name,m.patient_code, + m.inv_date,Date_Format(m.inv_date,'%d-%m-%Y') as inv_date_str, + Sum(i.twdisc_amount) as tnet_amount, + sum(if(m.ipd_id=0 and m.case_id=0,i.twdisc_amount,0)) as OPD_Cash_Bill_amount, + sum(if(m.ipd_id=0 and m.case_id>1,i.twdisc_amount,0)) as OPD_Org_Bill_amount, + + if(o1.short_name IS null, o2.short_name, o1.short_name) AS Ins_name, + sum(if(m.ipd_id>0 and m.ipd_credit=0,i.twdisc_amount,0)) as IPD_Cash_Bill_amount, + sum(if(m.ipd_id>0 and m.ipd_credit=1 and m.ipd_credit_type=1,i.twdisc_amount,0)) as IPD_Credit_Bill_amount, + sum(if(m.ipd_id>0 and m.ipd_credit=1 and m.ipd_credit_type=0,i.twdisc_amount,0)) as IPD_Package_Bill_amount + + FROM (((invoice_med_master m join inv_med_item i on m.id=i.inv_med_id) + left join patient_master p on m.patient_id=p.id) + left join (Select org.id,ins.short_name,org.ipd_id ,org.case_type + from organization_case_master org join hc_insurance ins + on org.insurance_id=ins.id) o1 ON m.ipd_id=o1.ipd_id AND o1.case_type=1 and m.ipd_id>0) + left join (Select org.id,ins.short_name,org.ipd_id ,org.case_type + from organization_case_master org join hc_insurance ins + on org.insurance_id=ins.id) o2 ON m.case_id=o2.id AND o2.case_type=0 and m.ipd_id=0 + where ".$sql_where." group by inv_date,m.id with ROLLUP"; + + $query = $this->db->query($sql); + $med_inv_total= $query->result(); + + //echo $sql; + + $content='

'.$Report_Heading.'

'; + $content.=''; + + $content.=' + + + + + + + + + + + + + '; + $sr_no=0; + $grand_date_tot_row=0; + $grand_tot_row=0; + foreach($med_inv_total as $row) + { + $sr_no=$sr_no+1; + + if($row->inv_date=='') + { + $content.=' + + + + + + + + + + + '; + }elseif($row->id=='') + { + $content.=' + + + + + + + + + + + '; + $grand_date_tot_row+=$grand_tot_row; + $grand_tot_row=0; + }else{ + $tot_row=$row->OPD_Org_Bill_amount+$row->IPD_Credit_Bill_amount+$row->IPD_Package_Bill_amount; + $grand_tot_row+=$tot_row; + + $content.=' + + + + + + + + + + + + + '; + } + } + + $content.=' + + + + + + + + + + + + + + + + +
#DateInvoice IDPatients NameNet Amt.OPD CashIPD Cash AmountOrg.NameOPD Org.IPD Cr HospitalIPD Cr Pkg. HospitalTot. Cr Hospital
#Grand Total : '.$row->tnet_amount.''.$row->OPD_Cash_Bill_amount.''.$row->IPD_Cash_Bill_amount.' '.$row->OPD_Org_Bill_amount.''.$row->IPD_Credit_Bill_amount.''.$row->IPD_Package_Bill_amount.''.$grand_date_tot_row.'
#Total Date : '.$row->inv_date_str.''.$row->tnet_amount.''.$row->OPD_Cash_Bill_amount.''.$row->IPD_Cash_Bill_amount.' '.$row->OPD_Org_Bill_amount.''.$row->IPD_Credit_Bill_amount.''.$row->IPD_Package_Bill_amount.''.$grand_tot_row.'
'.$sr_no.''.$row->inv_date_str.''.$row->inv_med_code.''.$row->inv_name.'
'.$row->patient_code.'
'.$row->ipd_code.'
'.$row->tnet_amount.''.$row->OPD_Cash_Bill_amount.''.$row->IPD_Cash_Bill_amount.''.$row->Ins_name.''.$row->OPD_Org_Bill_amount.''.$row->IPD_Credit_Bill_amount.''.$row->IPD_Package_Bill_amount.''.$tot_row.'
#DateInvoice IDPatients NameNet Amt.OPD CashIPD Cash AmountOrg.NameOPD Org.IPD Cr HospitalIPD Cr Pkg. HospitalTot. Cr Hospital
'; + + if($output==0) + { + //load mPDF library + $this->load->library('m_pdf'); + + //$this->m_pdf->pdf->SetProtection(array(), '1234567', '277395'); + + $this->m_pdf->pdf->SetWatermarkText(M_store); + $this->m_pdf->pdf->showWatermarkText = true; + + + + $file_name='Report-MedicalBill-'.date('Ymdhis').".pdf"; + + $filepath=$file_name; + + //generate the PDF from the given html + $this->m_pdf->pdf->WriteHTML($content); + + //download it. + $this->m_pdf->pdf->Output($filepath,"I"); + + }else{ + ExportExcel($content,'Med_Sale_day0001'); + } + + //echo $content; + + + } + + public function Report_2_short_data($sale_date_range,$bill_type) + { + $sql_where=" m.net_amount is not null "; + + $minRange = $sale_date_range; + + $sql_where.=" and m.inv_date = '".$minRange."' "; + + $Filter_type="ALL"; + + if($bill_type==1){ + $sql_where.=" and (m.ipd_id=0 and m.case_id=0 )"; + $Filter_type="OPD CASH"; + }elseif($bill_type==2){ + $sql_where.=" and (m.ipd_id>0 and m.ipd_credit=0 )"; + $Filter_type="IPD CASH"; + }elseif($bill_type==3){ + $sql_where.=" and (m.ipd_id=0 and m.case_id>1 )"; + $Filter_type="OPD Org."; + }elseif($bill_type==4){ + $sql_where.=" and (m.ipd_id>0 and m.ipd_credit=1 and m.ipd_credit_type=1 )"; + $Filter_type="IPD Cr"; + }elseif($bill_type==5){ + $sql_where.=" and (m.ipd_id>0 and m.ipd_credit=1 and m.ipd_credit_type=0 )"; + $Filter_type="IPD Pkg Cr"; + }elseif($bill_type==6){ + $sql_where.=" and ((m.ipd_id>0 and m.ipd_credit=1) or (m.ipd_id=0 and m.case_id>1 ))"; + $Filter_type="Hospital Cr"; + } + + $Report_Heading="Date (YYYY-MM-DD) :".$minRange." / Data Filter :".$Filter_type; + + $sql="select count(DISTINCT m.id) as No_invoice, + count( DISTINCT m.patient_id) as No_Patients, + m.inv_date,Date_Format(m.inv_date,'%d-%m-%Y') as inv_date_str, + Sum(m.net_amount) as tnet_amount, + sum(if(m.ipd_id=0 and m.case_id=0,m.net_amount,0)) as OPD_Cash_Bill_amount, + sum(if(m.ipd_id=0 and m.case_id>1,m.net_amount,0)) as OPD_Org_Bill_amount, + + sum(if(m.ipd_id>0 and m.ipd_credit=0,m.net_amount,0)) as IPD_Cash_Bill_amount, + sum(if(m.ipd_id>0 and m.ipd_credit=1 and m.ipd_credit_type=1,m.net_amount,0)) as IPD_Credit_Bill_amount, + sum(if(m.ipd_id>0 and m.ipd_credit=1 and m.ipd_credit_type=0,m.net_amount,0)) as IPD_Package_Bill_amount, + + sum(if(m.ipd_id=0 and m.case_id=0,1,0)) as OPD_Cash_Bill_invoice, + sum(if(m.ipd_id=0 and m.case_id>1,1,0)) as OPD_Org_Bill_invoice, + + sum(if(m.ipd_id>0 and m.ipd_credit=0,1,0)) as IPD_Cash_Bill_invoice, + sum(if(m.ipd_id>0 and m.ipd_credit=1 and m.ipd_credit_type=1,1,0)) as IPD_Credit_Bill_invoice, + sum(if(m.ipd_id>0 and m.ipd_credit=1 and m.ipd_credit_type=0,1,0)) as IPD_Package_Bill_invoice + + from invoice_med_master m + + where ".$sql_where." group by m.inv_date "; + + $query = $this->db->query($sql); + $med_inv_total= $query->result(); + + //echo $sql; + + $content='

'.$Report_Heading.'

'; + $content.=''; + + $content.=' + + + + + + + '; + + foreach($med_inv_total as $row) + { + $content.=' + + + + + + + '; + + $content.=' + + + + + + + '; + + $content.=' + + + + + + + '; + + $content.=' + + + + + + + '; + + $content.=' + + + + + + + '; + + $total_Cash_Bill_amount=$row->OPD_Cash_Bill_amount+$row->IPD_Cash_Bill_amount; + $total_Credit_Bill_amount=$row->OPD_Org_Bill_amount+$row->IPD_Credit_Bill_amount+$row->IPD_Package_Bill_amount; + + $content.=' + + + + + + '; + + } + + $content.=' +
Sr.No.DateNo. of InvoiceInvoice TypeCASH/DirectCredit to Hospital
1'.$row->inv_date_str.''.$row->OPD_Cash_Bill_invoice.'OPD CASH'.$row->OPD_Cash_Bill_amount.'
2'.$row->inv_date_str.''.$row->IPD_Cash_Bill_invoice.'IPD CASH'.$row->IPD_Cash_Bill_amount.'
3'.$row->inv_date_str.''.$row->OPD_Org_Bill_invoice.'OPD Org.'.$row->OPD_Org_Bill_amount.'
4'.$row->inv_date_str.''.$row->IPD_Credit_Bill_invoice.'IPD Credit'.$row->IPD_Credit_Bill_amount.'
5'.$row->inv_date_str.''.$row->IPD_Package_Bill_invoice.'IPD Credit Pkg.'.$row->IPD_Package_Bill_amount.'
Total'.$row->No_invoice.''.$total_Cash_Bill_amount.''.$total_Credit_Bill_amount.'
'; + + //load mPDF library + $this->load->library('m_pdf'); + + //$this->m_pdf->pdf->SetProtection(array(), '1234567', '277395'); + + $this->m_pdf->pdf->SetWatermarkText(M_store); + $this->m_pdf->pdf->showWatermarkText = true; + + + + $file_name='Report-MedicalBill-'.date('Ymdhis').".pdf"; + + $filepath=$file_name; + + //generate the PDF from the given html + $this->m_pdf->pdf->WriteHTML($content); + + //download it. + $this->m_pdf->pdf->Output($filepath,"I"); + //echo $content; + + + } + + //IPD Discharge Report + + public function ipd_discharge() + { + $this->load->view('Medical/Report/IPD_Discharge_Report'); + } + + + public function Report_6_data($sale_date_range,$output=0) + { + $rangeArray = explode("S",$sale_date_range); + $minRange = $rangeArray[0]; + $maxRange = $rangeArray[1]; + + $where=" m.ipd_id>0 and p.ipd_status=1 " ; + + $where.=" and p.discharge_date between '".$minRange."' and '".$maxRange. "'"; + + $sql=" SELECT p.ipd_code,p.p_code,p.p_fname, + DATE_FORMAT(p.register_date,'%d-%m-%Y') as ipd_admit_date_str, + DATE_FORMAT(p.discharge_date,'%d-%m-%Y') as ipd_discharge_date_str, + p.admit_type, + sum(if(m.ipd_credit=1 and m.ipd_credit_type=1,m.net_amount,0)) as IPD_Credit_Amount, + sum(if(m.ipd_credit=1 and m.ipd_credit_type=0,m.net_amount,0)) as IPD_Package_Amount, + sum(if(m.ipd_credit=0,m.net_amount,0)) as IPD_CASH_Amount, + pay_his.Total_Paid_Amount as Paid_Amount + FROM (invoice_med_master m join v_ipd_list p on m.ipd_id=p.id ) + LEFT JOIN + (SELECT SUM(if(h.credit_debit=0,h.amount,h.amount*-1)) AS Total_Paid_Amount, + h.ipd_id FROM payment_history_medical h WHERE h.Customerof_type=2 + GROUP BY h.ipd_id) AS pay_his ON p.id=pay_his.ipd_id + where ".$where." group by m.ipd_id "; + $query = $this->db->query($sql); + $stock_list= $query->result(); + + //echo $sql; + + $content=""; + + $content.=' + + + + + + + + + + + + '; + + $Head_Content=""; + foreach ($stock_list as $row) + { + $content.= ''; + $content.= ' '; + $content.= ' '; + $content.= ' '; + $content.= ' '; + $content.= ' '; + $content.= ' '; + $content.= ' '; + $content.= ' '; + $content.= ' '; + $content.= ' '; + $content.= ''; + + } + + $content.= '
IPD CodePatient CodePatient NameAdmit dt.Discharge Dt.TPA NameCashCreditPackagePaid Amt.
'.$row->ipd_code.''.$row->p_code.''.$row->p_fname.''.$row->ipd_admit_date_str.''.$row->ipd_discharge_date_str.''.$row->admit_type.''.$row->IPD_CASH_Amount.''.$row->IPD_Credit_Amount.''.$row->IPD_Package_Amount.''.$row->Paid_Amount.'
'; + + if($output==0) + { + //load mPDF library + $this->load->library('m_pdf'); + + //$this->m_pdf->pdf->SetProtection(array(), '1234567', '277395'); + + $this->m_pdf->pdf->SetWatermarkText(M_store); + $this->m_pdf->pdf->showWatermarkText = true; + + + $file_name='Report-MedicalBill-'.date('Ymdhis').".pdf"; + + $filepath=$file_name; + + //generate the PDF from the given html + $this->m_pdf->pdf->WriteHTML($content); + + //download it. + $this->m_pdf->pdf->Output($filepath,"I"); + }else{ + ExportExcel($content,'Report_Medical'); + } + + } + + + //Daily Cash Received List + + public function Report_Payment_Recieved() + { + + $sql="select * from users where active=1 order by first_name"; + $query = $this->db->query($sql); + $data['emplist']= $query->result(); + + $sql="select * from payment_mode where id in (1,2) "; + $query = $this->db->query($sql); + $data['paymodelist']= $query->result(); + + $this->load->view('Medical/Report/Med_Payment_Recevie',$data); + } + + public function Report_Payment_Recieved_data($sale_date_range,$emp_name_id=0,$output=0) + { + $sql_where=" 1=1 "; + + $rangeArray = explode("S",$sale_date_range); + $minRange = str_replace('T',' ',$rangeArray[0]); + $maxRange = str_replace('T',' ',$rangeArray[1]); + + + if($minRange==$maxRange) + { + $sql_where.=" and Date(p.payment_date) between Date('".$minRange."') and Date('".$maxRange. "')"; + }else{ + $sql_where.=" and p.payment_date between '".$minRange."' and '".$maxRange. "'"; + } + + $data_show='

Date(YYYY-MM-DD h:m) between '.$minRange.' and '.$maxRange.'

'; + + if($emp_name_id<>0) + { + $emp_name_id=str_replace('S',',',$emp_name_id); + + $sql_where.=" and p.update_by_id in (".$emp_name_id.")"; + } + + $sql="SELECT p.id, + if(p.Customerof_type=1,u.p_code,if(p.Customerof_type =3,m.inv_med_code,i.ipd_code)) AS UHID_IPD, + if(p.Customerof_type=1,u.p_fname,if(p.Customerof_type =3,m.inv_name,i.p_fname)) AS NAME_PERSON, + + if(p.Customerof_type IN (1,3) AND p.payment_mode=1 ,if(p.credit_debit=0,p.amount,p.amount*-1),0) AS OPD_Amt_CASH, + if(p.Customerof_type IN (1,3) AND p.payment_mode=2,if(p.credit_debit=0,p.amount,p.amount*-1),0) AS OPD_Amt_BANK, + + if(p.Customerof_type IN (2) AND p.payment_mode=1,if(p.credit_debit=0,p.amount,p.amount*-1),0) AS IPD_Amt_CASH, + if(p.Customerof_type IN (2) AND p.payment_mode=2,if(p.credit_debit=0,p.amount,p.amount*-1),0) AS IPD_Amt_BANK, + p.payment_date,p.credit_debit,p.update_by,p.update_by_id + FROM ((payment_history_medical p Left JOIN patient_master u ON p.Customerof_id=u.id AND p.Customerof_type=1) + Left JOIN + (SELECT ipd_master.id,ipd_master.ipd_code,patient_master.p_fname + from ipd_master JOIN patient_master ON ipd_master.p_id=patient_master.id ) i ON p.ipd_id=i.id AND p.Customerof_type=2) + LEFT JOIN invoice_med_master m ON p.Medical_invoice_id=m.id + where ".$sql_where." order by p.id"; + + $query = $this->db->query($sql); + $med_inv_total= $query->result(); + + $content=''; + + $content.=''; + + $content.=' + + + + + + + + + + '; + + $sr_no=0; + $OPD_Amt_CASH=0; + $OPD_Amt_BANK=0; + $IPD_Amt_CASH=0; + $IPD_Amt_BANK=0; + $Total_Amt=0; + + foreach($med_inv_total as $row) + { + $sr_no=$sr_no+1; + + $OPD_Amt_CASH+=$row->OPD_Amt_CASH; + $OPD_Amt_BANK+=$row->OPD_Amt_BANK; + $IPD_Amt_CASH+=$row->IPD_Amt_CASH; + $IPD_Amt_BANK+=$row->IPD_Amt_BANK; + + $content.=' + + + + + + + + + + '; + } + + $content.=' + + + + + + + + + + '; + $content.='
#Payment DateUHID/IPD/Inv.IDName of PersonOPD CashOPD BankIPD CashIPD BANKUpdate By
'.$row->id.''.$row->payment_date.''.$row->UHID_IPD.''.$row->NAME_PERSON.''.$row->OPD_Amt_CASH.''.$row->OPD_Amt_BANK.''.$row->IPD_Amt_CASH.''.$row->IPD_Amt_BANK.''.$row->update_by.'
# Total Amt.'.$OPD_Amt_CASH.''.$OPD_Amt_BANK.''.$IPD_Amt_CASH.''.$IPD_Amt_BANK.'
'; + + $GTotal=$OPD_Amt_CASH+$OPD_Amt_BANK+$IPD_Amt_CASH+$IPD_Amt_BANK; + + $content.='Total Amount : '.$GTotal; + + + if($output==0) + { + //load mPDF library + $this->load->library('m_pdf'); + + //$this->m_pdf->pdf->SetProtection(array(), '1234567', '277395'); + + $this->m_pdf->pdf->SetWatermarkText(M_store); + $this->m_pdf->pdf->showWatermarkText = true; + + + + $file_name='Report-MedicalBill-'.date('Ymdhis').".pdf"; + + $filepath=$file_name; + + //generate the PDF from the given html + $this->m_pdf->pdf->WriteHTML($content); + + //download it. + $this->m_pdf->pdf->Output($filepath,"I"); + + }else{ + ExportExcel($content,'Med_Sale_day0001'); + } + + //echo $content; + + } + + public function Report_3() + { + $this->load->view('Medical/Report/Med_Report_3'); + } + + public function Report_3_data($sale_date_range,$output=0) + { + $sql_where=" 1=1 "; + + $rangeArray = explode("S",$sale_date_range); + $minRange = $rangeArray[0]; + $maxRange = $rangeArray[1]; + + $sql_where.=" and m.inv_date between '".$minRange."' and '".$maxRange. "'"; + + $sql="Select t.CGST_per,sum(t.qty) as t_qty, + sum(t.CGST) as TCGST, + t.SGST_per, + sum(t.SGST) as TSGST, + sum(t.CGST+t.SGST) as TGST, + sum(t.TaxableAmount) as TaxableAmount, + sum(t.twdisc_amount) as Amount + from invoice_med_master m join inv_med_item t + on m.id=t.inv_med_id + where ".$sql_where." group by t.CGST_per with ROLLUP"; + + $query = $this->db->query($sql); + $med_inv_total= $query->result(); + //echo $sql; + + $content=''; + + $content.=' + + + + + + + + + + '; + + $sr_no=0; + foreach($med_inv_total as $row) + { + $sr_no=$sr_no+1; + + if($row->CGST_per=='') + { + $content.=' + + + + + + + + + + '; + }else{ + $content.=' + + + + + + + + + + '; + } + } + + $content.='
#CGST PerT. CGSTSGST PerT. SGSTTotal GSTTaxable AmountAmountItem Qty
#Grand Total : '.$row->TCGST.''.$row->TSGST.''.$row->TGST.''.$row->TaxableAmount.''.$row->Amount.''.$row->t_qty.'
'.$sr_no.''.$row->CGST_per.''.$row->TCGST.''.$row->SGST_per.''.$row->TSGST.''.$row->TGST.''.$row->TaxableAmount.''.$row->Amount.''.$row->t_qty.'
'; + + if($output==0) + { + //load mPDF library + $this->load->library('m_pdf'); + + //$this->m_pdf->pdf->SetProtection(array(), '1234567', '277395'); + + $this->m_pdf->pdf->SetWatermarkText(M_store); + $this->m_pdf->pdf->showWatermarkText = true; + + + $file_name='Report-MedicalBill-'.date('Ymdhis').".pdf"; + + $filepath=$file_name; + + //generate the PDF from the given html + $this->m_pdf->pdf->WriteHTML($content); + + //download it. + $this->m_pdf->pdf->Output($filepath,"I"); + }else{ + ExportExcel($content,'Med_Sale_day0001'); + } + + //echo $content; + + } + + + public function Report_4() + { + $this->load->view('Medical/Report/Med_Report_4'); + } + + public function Report_4_data($sale_date_range,$output=0) + { + $rangeArray = explode("S",$sale_date_range); + $minRange = $rangeArray[0]; + $maxRange = $rangeArray[1]; + + $where=" m.ipd_id>0 and p.ipd_status=1 " ; + + $where.=" and p.discharge_date between '".$minRange."' and '".$maxRange. "'"; + + $sql="select m.id,m.ipd_id,m.inv_med_code,m.ipd_code, m.patient_id,m.inv_name,m.patient_code, + m.inv_date,Date_Format(m.inv_date,'%d-%m-%Y') as inv_date_str,p.ins_company_name, + + sum(if(m.ipd_credit=1 and m.ipd_credit_type=1,m.net_amount,0)) as IPD_Credit_Amount, + sum(if(m.ipd_credit=1 and m.ipd_credit_type=0,m.net_amount,0)) as IPD_Package_Amount, + sum(if(m.ipd_credit=0,m.net_amount,0)) as IPD_CASH_Amount, + + sum(m.net_amount) as IPD_Total_Amount + from invoice_med_master m join v_ipd_list p on m.ipd_id=p.id + where ".$where." group by m.ipd_id,m.id with ROLLUP"; + $query = $this->db->query($sql); + $stock_list= $query->result(); + + //echo $sql; + + $content=' + + + + + + + + + + + + + + + '; + + $Head_Content=""; + foreach ($stock_list as $row) + { + if($row->id=='') + { + $content.= ''; + $content.= ''; + $content.= ' '; + $content.= ' '; + $content.= ' '; + $content.= ' '; + $content.= ''; + }else{ + if($Head_Content<>$row->ipd_code) + { + $content.= ''; + + $content.= ''; + $content.= ''; + $content.= ' '; + $content.= ' '; + $content.= ' '; + $content.= ' '; + $content.= ''; + $Head_Content=$row->ipd_code; + } + + $content.= ''; + $content.= ''; + $content.= ' '; + $content.= ' '; + $content.= ' '; + $content.= ' '; + $content.= ' '; + $content.= ' '; + $content.= ''; + + } + + } + + $content.= '
IPD CodePatient CodePatient NameTPA Name
Inv.No.Inv.DateCashCreditPackageTotal
IPD Total'.$row->IPD_CASH_Amount.''.$row->IPD_Credit_Amount.''.$row->IPD_Package_Amount.''.$row->IPD_Total_Amount.'
'.$row->ipd_code.''.$row->patient_code.''.$row->inv_name.''.$row->ins_company_name.'
'.$row->inv_med_code.''.$row->inv_date_str.''.$row->IPD_CASH_Amount.''.$row->IPD_Credit_Amount.''.$row->IPD_Package_Amount.''.$row->IPD_Total_Amount.'
'; + + if($output==0) + { + //load mPDF library + $this->load->library('m_pdf'); + + //$this->m_pdf->pdf->SetProtection(array(), '1234567', '277395'); + + $this->m_pdf->pdf->SetWatermarkText(M_store); + $this->m_pdf->pdf->showWatermarkText = true; + + + $file_name='Report-MedicalBill-'.date('Ymdhis').".pdf"; + + $filepath=$file_name; + + //generate the PDF from the given html + $this->m_pdf->pdf->WriteHTML($content); + + //download it. + $this->m_pdf->pdf->Output($filepath,"I"); + }else{ + ExportExcel($content,'Report_Medical'); + } + + } + + //IPD Credit Bills + + public function Report_IPD_Credit_data($sale_date_range,$billtype=0,$output=0) + { + $rangeArray = explode("S",$sale_date_range); + $minRange = $rangeArray[0]; + $maxRange = $rangeArray[1]; + + $where=" m.ipd_id>0 and p.ipd_status=1 " ; + + $where.=" and p.discharge_date between '".$minRange."' and '".$maxRange. "'"; + + if($billtype==0) + { + + }elseif($billtype==1) + { + $where.=" and m.ipd_credit=0 "; + }elseif($billtype==2) + { + $where.=" and m.ipd_credit=1 and m.ipd_credit_type=1 "; + }elseif($billtype==3) + { + $where.=" and m.ipd_credit=1 and m.ipd_credit_type=0 "; + }else{ + $where.=" 1<>1"; + } + + $sql="select m.id,m.ipd_id,m.inv_med_code,m.ipd_code, m.patient_id,m.inv_name,m.patient_code, + m.inv_date,Date_Format(m.inv_date,'%d-%m-%Y') as inv_date_str,p.ins_company_name, + if(m.ipd_credit=0,'CASH',if(m.ipd_credit_type=1,'Credit','Package')) bill_type, + sum(m.net_amount) as IPD_Total_Amount + from invoice_med_master m join v_ipd_list p on m.ipd_id=p.id + where ".$where." group by m.ipd_id,m.id with ROLLUP"; + $query = $this->db->query($sql); + $stock_list= $query->result(); + + echo $sql; + + $content=' + + + + + + + + + + + + '; + + $Head_Content=""; + + $stock_list_count=count($stock_list); + $i=0; + foreach ($stock_list as $row) + { + + if($row->id=='') + { + if($stock_list_count==$i+1) { + $content.= ''; + $content.= ''; + $content.= ''; + $content.= ''; + $content.= ''; + $content.= ''; + }else{ + $content.= ''; + $content.= ''; + $content.= ''; + $content.= ''; + $content.= ''; + } + + }else{ + if($Head_Content<>$row->ipd_code) + { + $content.= ''; + $content.= ''; + $content.= ' '; + $content.= ' '; + $content.= ' '; + $content.= ' '; + $content.= ''; + $Head_Content=$row->ipd_code; + } + + $content.= ''; + $content.= ' '; + $content.= ' '; + $content.= ' '; + $content.= ''; + $content.= ''; + + } + + $i=$i+1; + } + + $content.= '
IPD CodePatient CodePatient NameTPA Name
Inv.No.Inv.DateAmountType
Grand Total'.$row->IPD_Total_Amount.'
Total'.$row->IPD_Total_Amount.'
'.$row->ipd_code.''.$row->patient_code.''.$row->inv_name.''.$row->ins_company_name.'
'.$row->inv_med_code.''.$row->inv_date_str.''.$row->IPD_Total_Amount.''.$row->bill_type.'
'; + + if($output==0) + { + //load mPDF library + $this->load->library('m_pdf'); + + //$this->m_pdf->pdf->SetProtection(array(), '1234567', '277395'); + + $this->m_pdf->pdf->SetWatermarkText(M_store); + $this->m_pdf->pdf->showWatermarkText = true; + + $file_name='Report-MedicalBill-'.date('Ymdhis').".pdf"; + + $filepath=$file_name; + + //generate the PDF from the given html + $this->m_pdf->pdf->WriteHTML($content); + + //download it. + $this->m_pdf->pdf->Output($filepath,"I"); + }else{ + ExportExcel($content,'Report_Medical'); + } + } + + + + public function purchase_invoice_report() + { + $sql="select * from med_supplier order by name_supplier"; + $query = $this->db->query($sql); + $data['supplier_data']= $query->result(); + + $this->load->view('Medical/Report/Purchase_Invoice',$data); + } + + public function purchase_invoice_data($sale_date_range,$supplier_id,$output=0) + { + $sql_where=" 1=1 "; + + $rangeArray = explode("S",$sale_date_range); + $minRange = $rangeArray[0]; + $maxRange = $rangeArray[1]; + + $sql_where.=" and p.date_of_invoice between '".$minRange."' and '".$maxRange. "'"; + + if($supplier_id>0) + { + $sql_where.=" and s.sid= '".$supplier_id."' "; + } + + $sql="select p.id,p.Invoice_no,p.date_of_invoice,p.sid,s.name_supplier,s.short_name,s.gst_no, + sum(if(item_return=0,t.net_amount,t.net_amount*-1)) as tamount,count(t.id) as no_item, + p.Taxable_Amt,(p.CGST_Amt+p.SGST_Amt) as gst, + + SUM(if(t.CGST_per=0,t.CGST,0)) AS CGST_per_0, + SUM(if(t.SGST_per=0,t.SGST,0)) AS SGST_per_0, + SUM(if(t.SGST_per=0,t.taxable_amount,0)) AS TotGST_per_0, + + SUM(if(t.CGST_per=2.5,t.CGST,0)) AS CGST_per_2_5, + SUM(if(t.SGST_per=2.5,t.SGST,0)) AS SGST_per_2_5, + SUM(if(t.SGST_per=2.5,t.taxable_amount,0)) AS TotGST_per_5, + + SUM(if(t.CGST_per=6,t.CGST,0)) AS CGST_per_6, + SUM(if(t.SGST_per=6,t.SGST,0)) AS SGST_per_6, + SUM(if(t.SGST_per=6,t.taxable_amount,0)) AS TotGST_per_12, + + SUM(if(t.CGST_per=9,t.CGST,0)) AS CGST_per_9, + SUM(if(t.SGST_per=9,t.SGST,0)) AS SGST_per_9, + SUM(if(t.SGST_per=9,t.taxable_amount,0)) AS TotGST_per_18, + + SUM(if(t.CGST_per=14,t.CGST,0)) AS CGST_per_14, + SUM(if(t.SGST_per=14,t.SGST,0)) AS SGST_per_14, + SUM(if(t.SGST_per=14,t.taxable_amount,0)) AS TotGST_per_28 + + from (purchase_invoice p join med_supplier s on p.sid=s.sid) + left join purchase_invoice_item t on p.id=t.purchase_id + where ".$sql_where." group by p.id order by p.id"; + + $query = $this->db->query($sql); + $pur_inv_total= $query->result(); + + $content=''; + + $xcontent_head=''; + + if($output==1) + { + $xcontent_head=' + + + + + + + + + + + + + + '; + + } + + $content.=' + + + + + + + + '.$xcontent_head.' + '; + $sr_no=0; + $tamt=0; + $tramt=0; + $tgst=0; + + foreach($pur_inv_total as $row) + { + $sr_no=$sr_no+1; + $tamt=$tamt+$row->tamount; + $tramt=$tramt+round($row->tamount); + $tgst=$tgst+round($row->gst); + + $xcontent=''; + + if($output==1) + { + $xcontent=' + + + + + + + + + + + + + + '; + } + + $content.=' + + + + + + + + '.$xcontent.' + + '; + } + + if($output==1) + { + $xcontent_total=' + + + + + + + + + + + + + + '; + } + + $content.=' + + + + + + + + + + '.$xcontent_total.' + + +
TotGST_per_0CGST_per_0SGST_per_0TotGST_per_5CGST_per_2_5SGST_per_2_5TotGST_per_12CGST_per_6SGST_per_6TotGST_per_18CGST_per_9SGST_per_9TotGST_per_28CGST_per_14SGST_per_14
#Invoice IDSupplierDateAmountR AmountGST
'.round($row->TotGST_per_0).''.round($row->CGST_per_0).''.round($row->SGST_per_0).''.round($row->TotGST_per_5).''.round($row->CGST_per_2_5).''.round($row->SGST_per_2_5).''.round($row->TotGST_per_12).''.round($row->CGST_per_6).''.round($row->SGST_per_6).''.round($row->TotGST_per_18).''.round($row->CGST_per_9).''.round($row->SGST_per_9).''.round($row->TotGST_per_28).''.round($row->CGST_per_14).''.round($row->SGST_per_14).'
'.$sr_no.''.$row->Invoice_no.''.$row->name_supplier.''.$row->date_of_invoice.''.$row->tamount.''.round($row->tamount).''.round($row->gst).'
#'.$tamt.''.$tramt.''.$tgst.'
'; + + //echo $content; + if($output==0) + { + create_report_pdf_landscape($content,'Med_Invoice'); + }else{ + ExportExcel($content,'Report_Medical'); + } + + } + + public function purchase_invoice_data_pdf($sale_date_range,$supplier_id,$output=0) + { + $sql_where=" 1=1 "; + + $rangeArray = explode("S",$sale_date_range); + $minRange = $rangeArray[0]; + $maxRange = $rangeArray[1]; + + $sql_where.=" and p.date_of_invoice between '".$minRange."' and '".$maxRange. "'"; + + if($supplier_id>0) + { + $sql_where.=" and s.sid= '".$supplier_id."' "; + } + + $sql="select p.id,trim(s.name_supplier) AS name_supplier,p.sid,p.Invoice_no, + date_format(p.date_of_invoice,'%d-%m-%Y')AS str_date_of_invoice, + p.date_of_invoice, s.short_name,s.gst_no, + SUM(round(p.T_Net_Amount)) as tamount, + sum(p.Taxable_Amt) AS Taxable_Amt, + SUM(p.CGST_Amt+p.SGST_Amt) as gst + from (purchase_invoice p join med_supplier s on p.sid=s.sid) + where ".$sql_where." group by trim(s.name_supplier),p.date_of_invoice,p.id WITH rollup"; + + $query = $this->db->query($sql); + $pur_inv_total= $query->result(); + $content=''; + + //$content=$sql; + + $content.=''; + + $xcontent_head=''; + + $head_content=""; + $Total_Amount_Round=0; + $Total_Grand_Amount_Round=0; + + foreach($pur_inv_total as $row) + { + + if($row->id!='' && $row->name_supplier!='' && $row->date_of_invoice!='') + { + if($head_content!=$row->name_supplier) + { + $sr_no=0; + $Total_Amount_Round=0; + $content.=' + + '; + $content.=' + + '; + $content.=' + + + + + + + + '; + } + $sr_no=$sr_no+1; + + $content.=' + + + + + + + + '; + + }elseif($row->id=='' && $row->name_supplier=='' && $row->date_of_invoice==''){ + $content.=' + + + + + + + + '; + }elseif($row->id=='' && $row->date_of_invoice==''){ + $content.=' + + + + + + + '; + + } + + $head_content=$row->name_supplier; + } + + $content.='
_
'.$row->name_supplier.' / GST No. '.$row->gst_no.'
#Purchase. Inv. IDInv. DateTaxable AmtTax AmtInv. Amount
'.$sr_no.''.$row->Invoice_no.''.$row->str_date_of_invoice.''.$row->Taxable_Amt.''.$row->gst.''.$row->tamount.'
#Grand Total'.$row->Taxable_Amt.''.$row->gst.''.$row->tamount.'
#Total of : '.$row->name_supplier.''.$row->Taxable_Amt.''.$row->gst.''.$row->tamount.'
'; + + //echo $content; + if($output==0) + { + $this->load->library('m_pdf'); + + $file_name='Report-MedicalBill-'.date('Ymdhis').".pdf"; + $filepath=$file_name; + $this->m_pdf->pdf->WriteHTML($content); + $this->m_pdf->pdf->Output($filepath,"I"); + }else{ + ExportExcel($content,'Report_Medical'); + } + + } + + + //GST Report + + public function Report_5() + { + $this->load->view('Medical/Report/Med_Report_5'); + } + + public function Report_5_data($sale_date_range,$output=0) + { + $rangeArray = explode("S",$sale_date_range); + $minRange = $rangeArray[0]; + $maxRange = $rangeArray[1]; + + $where=" m.inv_date between '".$minRange."' and '".$maxRange. "'"; + + $sql="select m.inv_med_code,Date_Format(m.inv_date,'%d-%m-%Y') as Inv_Date,m.inv_name, + get_med_type(m.ipd_id,m.ipd_credit,m.ipd_credit_type,m.case_id,m.case_credit) as Invoice_type, + m.ipd_code,p.p_code,o.case_id_code, + count(i.id) as No_of_Items, + sum(i.qty) as No_of_Qty, + + round(sum(i.twdisc_amount),0) as Total_Amount, + + round(sum(if(i.CGST_per=2.5,i.TaxableAmount,0)),0) as Sale_5_Amount, + sum(if(i.CGST_per=2.5,i.CGST,0)) as CGST_2_5, + sum(if(i.CGST_per=2.5,i.SGST,0)) as SGST_2_5, + + round(sum(if(i.CGST_per=5,i.TaxableAmount,0)),0) as Sale_10_Amount, + sum(if(i.CGST_per=5,i.CGST,0)) as CGST_5, + sum(if(i.CGST_per=5,i.SGST,0)) as SGST_5, + + round(sum(if(i.CGST_per=6,i.TaxableAmount,0)),0) as Sale_12_Amount, + sum(if(i.CGST_per=6,i.CGST,0)) as CGST_6, + sum(if(i.CGST_per=6,i.SGST,0)) as SGST_6, + + round(sum(if(i.CGST_per=9,i.TaxableAmount,0)),0) as Sale_18_Amount, + sum(if(i.CGST_per=9,i.CGST,0)) as CGST_9, + sum(if(i.CGST_per=9,i.SGST,0)) as SGST_9, + + round(sum(if(i.CGST_per=14,i.TaxableAmount,0)),0) as Sale_28_Amount, + sum(if(i.CGST_per=14,i.CGST,0)) as CGST_14, + sum(if(i.CGST_per=14,i.SGST,0)) as SGST_14, + + round(sum(if(i.CGST_per=0,i.TaxableAmount,0)),0) as Sale_0_Amount, + + round(sum(i.TaxableAmount),0) as Total_TaxableAmount + + from ((invoice_med_master m join inv_med_item i on m.id=i.inv_med_id) + left join patient_master p on m.patient_id=p.id) + left join organization_case_master o on m.case_id=o.id + where ".$where." group by m.id "; + + $query = $this->db->query($sql); + $stock_list= $query->result(); + + //echo $sql; + + $content=' + + + + + + + + + + + + + + + + + + + + + '; + + $Head_Content=""; + foreach ($stock_list as $row) + { + $content.= ''; + $content.= ' '; + $content.= ' '; + $content.= ' '; + $content.= ' '; + $content.= ' '; + $content.= ' '; + $content.= ' '; + $content.= ' '; + $content.= ' '; + $content.= ' '; + $content.= ' '; + $content.= ' '; + $content.= ' '; + $content.= ' '; + $content.= ' '; + $content.= ' '; + $content.= ' '; + $content.= ' '; + $content.= ' '; + $content.= ''; + } + + $content.= '
Invoice IDInv.Dateinv.NameInvoice TypeTot.Amt.Tot.Tax.AmtTax.Amt.5%CGST 2.5%SCGT 2.5%Tax.Amt.12%CGST 6%SCGT 6%Tax.Amt.18%CGST 9%SCGT 9%Tax.Amt.28%CGST 14%SCGT 14%Tax.Amt.0%
'.$row->inv_med_code.''.$row->Inv_Date.''.$row->inv_name.''.$row->Invoice_type.''.$row->Total_Amount.''.$row->Total_TaxableAmount.''.$row->Sale_5_Amount.''.$row->CGST_2_5.''.$row->SGST_2_5.''.$row->Sale_12_Amount.''.$row->CGST_6.''.$row->SGST_6.''.$row->Sale_18_Amount.''.$row->CGST_9.''.$row->SGST_9.''.$row->Sale_28_Amount.''.$row->CGST_14.''.$row->SGST_14.''.$row->Sale_0_Amount.'
'; + + ExportExcel($content,'Report_Medical_gst_invoice'); + + + } + + //Bank Ledger Account + + public function Report_7() + { + $sql="select * from med_supplier"; + $query = $this->db->query($sql); + $data['supplier_data']= $query->result(); + + $sql="select * from bank_account_master"; + $query = $this->db->query($sql); + $data['bank_account_data']= $query->result(); + + $this->load->view('Medical/Report/Med_Report_7',$data); + } + + public function Report_7_data($sale_date_range,$supplier_id,$account_id,$output=0) + { + $rangeArray = explode("S",$sale_date_range); + $minRange = $rangeArray[0]; + $maxRange = $rangeArray[1]; + + $where=" l.tran_date between '".$minRange."' and '".$maxRange. "'"; + + if($supplier_id>0) + { + $where.=" and m.sid=$supplier_id "; + } + + if($account_id>0) + { + $where.=" and b.bank_id=$account_id "; + } + + $sql="SELECT b.bank_account_name,m.name_supplier, + l.tran_date,l.credit_debit,l.tran_desc, + Date_Format(l.tran_date,'%d-%m-%Y') as tran_date_str, + if(l.credit_debit=0,l.amount,0) AS cr_amt, + if(l.credit_debit=1,l.amount,0) AS dr_amt,l.id + FROM (bank_account_master b JOIN med_supplier_ledger l + ON l.bank_id=b.bank_id AND b.bank_id>1) + JOIN med_supplier m ON l.supplier_id=m.sid + where ".$where." order by l.tran_date, l.id "; + + $query = $this->db->query($sql); + $stock_list= $query->result(); + + //echo $sql; + + $content=' + + + + + + + + '; + + $Head_Content=""; + $total_cr_amt=0; + $total_dr_amt=0; + + foreach ($stock_list as $row) + { + $content.= ''; + $content.= ' '; + $content.= ' '; + $content.= ' '; + $content.= ' '; + $content.= ' '; + $content.= ' '; + $content.= ''; + $total_cr_amt+=$row->cr_amt; + $total_dr_amt+=$row->dr_amt; + } + + $content.= ''; + $content.= ' '; + $content.= ' '; + $content.= ' '; + $content.= ' '; + $content.= ' '; + $content.= ' '; + $content.= ''; + + $content.= '
Led. IDDateBank/CashLedgerCr.Amt.Dr.Amt
'.$row->id.''.$row->tran_date_str.''.$row->bank_account_name.''.$row->name_supplier.''.$row->cr_amt.''.$row->dr_amt.'
Total'.$total_cr_amt.''.$total_dr_amt.'
'; + + if($output==0) + { + //load mPDF library + $this->load->library('m_pdf'); + + $file_name='Report_Medical_Ledger_'.date('Ymdhis').".pdf"; + + $filepath=$file_name; + + //generate the PDF from the given html + $this->m_pdf->pdf->WriteHTML($content); + + //download it. + $this->m_pdf->pdf->Output($filepath,"I"); + }else{ + ExportExcel($content,'Report_Medical_Ledger_'.date('d-m-Y')); + } + + + + } + + //Lost Medicine Data + + public function Lost_medicine() + { + $this->load->view('Medical/Stock/Lost_medicine'); + } + + public function Lost_medicine_data($sale_date_range,$output=0) + { + $rangeArray = explode("S",$sale_date_range); + $minRange = $rangeArray[0]; + $maxRange = $rangeArray[1]; + + $where=" a.date_of_adjust between '".$minRange."' and '".$maxRange. "'"; + + + $sql="SELECT a.id,Date_Format(a.date_of_adjust,'%d-%m-%Y') as adjust_date_str,a.update_by, + i.item_code,i.Item_name,a.qty, + i.packing,i.purchase_price,i.purchase_unit_rate,(i.purchase_unit_rate*a.qty) AS cost, + (i.selling_unit_rate*a.qty) AS sale_value + FROM purchase_item_stock_adjust a JOIN purchase_invoice_item i ON a.item_id=i.id + where ".$where." order by a.date_of_adjust, a.id "; + + $query = $this->db->query($sql); + $stock_list= $query->result(); + + //echo $sql; + + $content=' + + + + + + + + '; + + $Head_Content=""; + $total_cost=0; + $total_sale_value=0; + + foreach ($stock_list as $row) + { + $content.= ''; + $content.= ' '; + $content.= ' '; + $content.= ' '; + $content.= ' '; + $content.= ' '; + $content.= ' '; + $content.= ''; + $total_cost+=$row->cost; + $total_sale_value+=$row->sale_value; + } + + $content.= ''; + $content.= ' '; + $content.= ' '; + $content.= ' '; + $content.= ' '; + $content.= ' '; + $content.= ' '; + $content.= ''; + + $content.= '
IDDateItem NameQtyCostSale Value
'.$row->id.''.$row->adjust_date_str.''.$row->Item_name.''.$row->qty.''.$row->cost.''.$row->sale_value.'
Total'.$total_cost.''.$total_sale_value.'
'; + + if($output==0) + { + //load mPDF library + $this->load->library('m_pdf'); + + $file_name='Report_Medicine_Lost_'.date('Ymdhis').".pdf"; + + $filepath=$file_name; + + //generate the PDF from the given html + $this->m_pdf->pdf->WriteHTML($content); + + //download it. + $this->m_pdf->pdf->Output($filepath,"I"); + }else{ + ExportExcel($content,'Report_Medicine_Lost_'.date('d-m-Y')); + } + + + + } + + +} \ No newline at end of file diff --git a/old_code_ci3/controllers/Medical_backpanel.php b/old_code_ci3/controllers/Medical_backpanel.php index d5f854a..a664327 100644 --- a/old_code_ci3/controllers/Medical_backpanel.php +++ b/old_code_ci3/controllers/Medical_backpanel.php @@ -1532,7 +1532,7 @@ class Medical_backpanel extends MY_Controller $data['purchase_return_invoice'] = $query->result(); $sql = "select p.*,r.purchase_inv_id,r.qty as r_qty,Round(r.qty/p.packing,2) AS qty_pak,r.id as r_id,if(r.batch_no_r='',p.batch_no,r.batch_no_r) as batch_no_r_s, - date_format(p.expiry_date,'%m/%y') as exp_date_str ,p.purchase_unit_rate*r.qty AS r_amount,p.purchase_unit_rate + date_format(p.expiry_date,'%m/%y') as exp_date_str ,p.purchase_unit_rate*r.qty AS r_amount,p.purchase_unit_rate,if(p.CGST_per_old IS NULL,CGST_per,CGST_per_old)*2 AS gst_per from purchase_return_invoice_item r join purchase_invoice_item p on r.purchase_item_id=p.id where purchase_inv_id=" . $inv_id; $query = $this->db->query($sql); @@ -1669,7 +1669,7 @@ class Medical_backpanel extends MY_Controller } $sql = "select p.*,r.purchase_inv_id,r.qty as r_qty,Round(r.qty/p.packing,2) AS qty_pak,r.id as r_id,if(r.batch_no_r='',p.batch_no,r.batch_no_r) as batch_no_r_s, - date_format(p.expiry_date,'%m/%y') as exp_date_str ,p.purchase_unit_rate*r.qty AS r_amount,p.purchase_unit_rate + date_format(p.expiry_date,'%m/%y') as exp_date_str ,p.purchase_unit_rate*r.qty AS r_amount,p.purchase_unit_rate,if(p.CGST_per_old IS NULL,CGST_per,CGST_per_old)*2 AS gst_per from purchase_return_invoice_item r join purchase_invoice_item p on r.purchase_item_id=p.id where purchase_inv_id=" . $inv_id; $query = $this->db->query($sql); @@ -1798,7 +1798,7 @@ class Medical_backpanel extends MY_Controller $msg_box = "Item Removed"; $sql = "select p.*,r.purchase_inv_id,r.qty as r_qty,Round(r.qty/p.packing,2) AS qty_pak,r.id as r_id,if(r.batch_no_r='',p.batch_no,r.batch_no_r) as batch_no_r_s, - date_format(p.expiry_date,'%m/%y') as exp_date_str ,p.purchase_unit_rate*r.qty AS r_amount,p.purchase_unit_rate + date_format(p.expiry_date,'%m/%y') as exp_date_str ,p.purchase_unit_rate*r.qty AS r_amount,p.purchase_unit_rate,if(p.CGST_per_old IS NULL,CGST_per,CGST_per_old)*2 AS gst_per from purchase_return_invoice_item r join purchase_invoice_item p on r.purchase_item_id=p.id where purchase_inv_id=" . $inv_id; $query = $this->db->query($sql); diff --git a/old_code_ci3/controllers/OcasePathLap.php b/old_code_ci3/controllers/OcasePathLap.php index 6d5fb69..023887d 100644 --- a/old_code_ci3/controllers/OcasePathLap.php +++ b/old_code_ci3/controllers/OcasePathLap.php @@ -276,7 +276,7 @@ class OcasePathLap extends MY_Controller { public function addPathTest($pno,$ins_id=0) { $sql="select *,if(gender=1,'Male','Female') as xgender, - IFNULL(GET_AGE_BY_DOB(dob),age) AS age from patient_master where id='".$pno."' "; + GET_AGE_1(dob,age,age_in_month,estimate_dob) AS age from patient_master where id='".$pno."' "; $query = $this->db->query($sql); $data['person_info']= $query->result(); @@ -447,7 +447,7 @@ class OcasePathLap extends MY_Controller { $data['invoice_master']= $query->result(); $sql="select *,if(gender=1,'Male','Female') as xgender, - IFNULL(GET_AGE_BY_DOB(dob),age) AS age from patient_master where id=".$data['invoice_master'][0]->attach_id; + GET_AGE_1(dob,age,age_in_month,estimate_dob) AS age from patient_master where id=".$data['invoice_master'][0]->attach_id; $query = $this->db->query($sql); $data['patient_master']= $query->result(); @@ -621,7 +621,7 @@ class OcasePathLap extends MY_Controller { $data['invoice_master']= $query->result(); $sql="select *,if(gender=1,'Male','Female') as xgender, - IFNULL(GET_AGE_BY_DOB(dob),age) AS age from patient_master where id=".$data['invoice_master'][0]->attach_id; + GET_AGE_1(dob,age,age_in_month,estimate_dob) AS age from patient_master where id=".$data['invoice_master'][0]->attach_id; $query = $this->db->query($sql); $data['patient_master']= $query->result(); diff --git a/old_code_ci3/controllers/Ocasemaster.php b/old_code_ci3/controllers/Ocasemaster.php index 477e4bf..d5c6084 100644 --- a/old_code_ci3/controllers/Ocasemaster.php +++ b/old_code_ci3/controllers/Ocasemaster.php @@ -15,7 +15,7 @@ class Ocasemaster extends MY_Controller { $data['or_case_master']= $query->result(); $sql="select *,if(gender=1,'Male','Female') as xgender, - IFNULL(GET_AGE_BY_DOB(dob),age) AS age from patient_master where id='".$data['or_case_master'][0]->p_id."' "; + GET_AGE_1(dob,age,age_in_month,estimate_dob) AS age from patient_master where id='".$data['or_case_master'][0]->p_id."' "; $query = $this->db->query($sql); $data['person_info']= $query->result(); @@ -191,7 +191,7 @@ class Ocasemaster extends MY_Controller { $data['or_case_master']= $query->result(); $sql="select *,if(gender=1,'Male','Female') as xgender, - IFNULL(GET_AGE_BY_DOB(dob),age) AS age from patient_master where id='".$data['or_case_master'][0]->p_id."' "; + GET_AGE_1(dob,age,age_in_month,estimate_dob) AS age from patient_master where id='".$data['or_case_master'][0]->p_id."' "; $query = $this->db->query($sql); $data['data']= $query->result(); @@ -577,7 +577,7 @@ class Ocasemaster extends MY_Controller { $data['invoice_master']= $query->result(); $sql="select *,if(gender=1,'Male','Female') as xgender, - IFNULL(GET_AGE_BY_DOB(dob),age) AS age from patient_master where id=".$data['invoice_master'][0]->attach_id; + GET_AGE_1(dob,age,age_in_month,estimate_dob) AS age from patient_master where id=".$data['invoice_master'][0]->attach_id; $query = $this->db->query($sql); $data['patient_master']= $query->result(); diff --git a/old_code_ci3/controllers/Opd.php b/old_code_ci3/controllers/Opd.php index 4816383..7917c9c 100644 --- a/old_code_ci3/controllers/Opd.php +++ b/old_code_ci3/controllers/Opd.php @@ -1718,7 +1718,7 @@ class Opd extends MY_Controller { $query = $this->db->query($sql); $data['doc_master']= $query->result(); - $sql="SELECT o.opd_id,o.opd_code,p.id,p.p_code,p.p_fname as P_name,m.queue_no,o.opd_fee_desc,o.payment_status,p.p_rname,o.opd_no, + $sql="SELECT o.opd_id,o.opd_code,p.id,p.p_code,p.p_fname as P_name,m.queue_no,o.opd_fee_desc,o.payment_status,p.p_rname, group_concat('ID:',`h`.`id`,'/M:',(case `h`.`payment_mode` when 1 then 'Cash' when 2 then 'BANK ' when 0 then 'Pending' else 'Other' end) separator ',') AS `Paymode` FROM ((opd_master o JOIN patient_master p ON o.p_id=p.id) LEFT JOIN opd_prescription m ON o.opd_id=m.opd_id) diff --git a/old_code_ci3/controllers/Opd2.php b/old_code_ci3/controllers/Opd2.php index bb2b4a6..ef7d5c7 100644 --- a/old_code_ci3/controllers/Opd2.php +++ b/old_code_ci3/controllers/Opd2.php @@ -12,7 +12,7 @@ class Opd extends MY_Controller { public function addopd($pno) { $sql="select *,if(gender=1,'Male','Female') as xgender, - IFNULL(GET_AGE_BY_DOB(dob),age) AS age from patient_master where id='".$pno."' "; + GET_AGE_1(dob,age,age_in_month,estimate_dob) AS age from patient_master where id='".$pno."' "; $query = $this->db->query($sql); $data['person_info']= $query->result(); @@ -157,7 +157,7 @@ class Opd extends MY_Controller { $data['opd_master']= $query->result(); $sql="select *,if(gender=1,'Male','Female') as xgender, - IFNULL(GET_AGE_BY_DOB(dob),age) AS age from patient_master where id='".$data['opd_master'][0]->p_id."' "; + GET_AGE_1(dob,age,age_in_month,estimate_dob) AS age from patient_master where id='".$data['opd_master'][0]->p_id."' "; $query = $this->db->query($sql); $data['patient_master']= $query->result(); diff --git a/old_code_ci3/controllers/Opd_prescription.php b/old_code_ci3/controllers/Opd_prescription.php index 24c372e..9dabb6b 100644 --- a/old_code_ci3/controllers/Opd_prescription.php +++ b/old_code_ci3/controllers/Opd_prescription.php @@ -360,7 +360,7 @@ class Opd_prescription extends MY_Controller{ { $data['p_id']=$p_id; - $sql="select *,IFNULL(GET_AGE_BY_DOB(dob),age) as str_age, + $sql="select *,GET_AGE_1(dob,age,age_in_month,estimate_dob) as str_age, Date_Format(insert_date,'%Y-%m-%d') as str_regdate, if(gender=1,'Male','Female') as xgender , if(date_add(insert_date,interval 12 hour)>sysdate(),1,0) as p_edit @@ -882,104 +882,6 @@ class Opd_prescription extends MY_Controller{ echo json_encode($row_set); //format the array into json data } } - - // Enhanced medicine autocomplete API - public function get_medicine_autocomplete() - { - $this->load->helper('url'); - - // Get search parameters - $query = $this->input->get('query') ?: $this->input->get('term'); - $category = $this->input->get('category') ?: 'medicine_name'; - $limit = (int)($this->input->get('limit') ?: 10); - - if (empty($query) || strlen($query) < 1) { - echo json_encode(['success' => false, 'data' => []]); - return; - } - - $user = $this->ion_auth->user()->row(); - $doc_id = $user->id; - - $response_data = []; - - switch($category) { - case 'medicine_name': - $sql = "SELECT DISTINCT item_name as text, 'global' as scope, id as med_id, formulation, genericname - FROM opd_med_master - WHERE item_name LIKE ? - ORDER BY item_name - LIMIT ?"; - $result = $this->db->query($sql, ['%' . $query . '%', $limit]); - - foreach($result->result() as $row) { - $response_data[] = [ - 'text' => $row->text, - 'scope' => $row->scope, - 'med_id' => $row->med_id, - 'formulation' => $row->formulation, - 'genericname' => $row->genericname - ]; - } - break; - - case 'dosage': - $dosage_patterns = [ - '1-0-1', '1-1-1', '0-1-0', '1-0-0', '0-0-1', '2-1-1', '1-1-2', - '1/2-0-1/2', '1/2-1/2-1/2', '2-0-2', '1-2-1', '3-2-1', '1-1-1-1', - '2-2-2', '1/4-1/4-1/4', '3/4-3/4-3/4', 'As required', 'SOS' - ]; - foreach($dosage_patterns as $pattern) { - if (stripos($pattern, $query) !== false) { - $response_data[] = ['text' => $pattern, 'scope' => 'global']; - } - } - break; - - case 'dosage_when': - $when_options = [ - 'Before meal', 'After meal', 'With meal', 'Empty stomach', - 'At bedtime', 'Morning', 'Evening', 'As directed' - ]; - foreach($when_options as $option) { - if (stripos($option, $query) !== false) { - $response_data[] = ['text' => $option, 'scope' => 'global']; - } - } - break; - - case 'dosage_frequency': - $frequency_options = [ - 'Daily', 'Twice daily', 'Thrice daily', 'Four times daily', - 'Once weekly', 'Twice weekly', 'Every other day', 'As needed', - 'Every 4 hours', 'Every 6 hours', 'Every 8 hours', 'Every 12 hours' - ]; - foreach($frequency_options as $option) { - if (stripos($option, $query) !== false) { - $response_data[] = ['text' => $option, 'scope' => 'global']; - } - } - break; - - case 'dosage_duration': - $duration_options = [ - '3 days', '5 days', '7 days', '10 days', '14 days', '21 days', '30 days', - '1 week', '2 weeks', '3 weeks', '1 month', '2 months', '3 months', - 'Till symptoms subside', 'Continue as advised' - ]; - foreach($duration_options as $option) { - if (stripos($option, $query) !== false) { - $response_data[] = ['text' => $option, 'scope' => 'global']; - } - } - break; - } - - echo json_encode([ - 'success' => true, - 'data' => array_slice($response_data, 0, $limit) - ]); - } public function opd_prescription_save() { diff --git a/old_code_ci3/controllers/Opd_print_1.php b/old_code_ci3/controllers/Opd_print_1.php new file mode 100644 index 0000000..aa70a0d --- /dev/null +++ b/old_code_ci3/controllers/Opd_print_1.php @@ -0,0 +1,302 @@ +db->query($sql); + $opd_master= $query->result(); + + $data['opd_master']=$opd_master; + + $sql="select *,if(gender=1,'M','F') as xgender, + GET_AGE_2(dob,age,age_in_month,estimate_dob,'".$opd_master[0]->apointment_date."') AS age from patient_master where id='".$opd_master[0]->p_id."' "; + $query = $this->db->query($sql); + $patient_master= $query->result(); + + $data['patient_master']=$patient_master; + + $sql="select *,date_format(date_add(apointment_date,interval 4 day),'%d-%m-%Y') as opd_Exp_Date , + date_format(apointment_date,'%d-%m-%Y') as s_opd_date + from opd_master where p_id=".$opd_master[0]->p_id." and opd_id < ".$opdid." + order by opd_id desc limit 1"; + $query = $this->db->query($sql); + $old_opd= $query->result(); + + $data['old_opd']=$old_opd; + + $sql="select * from hc_insurance where id=".$opd_master[0]->insurance_id; + $query = $this->db->query($sql); + $insurance= $query->result(); + + $data['insurance']=$insurance; + + if($opd_master[0]->insurance_case_id>0) + { + $sql="select * from organization_case_master where id=".$opd_master[0]->insurance_case_id; + $query = $this->db->query($sql); + $case_master= $query->result(); + + $data['case_master']=$case_master; + } + + $old_uhid=''; + if($patient_master[0]->udai<>"") + { + $old_uhid= ' /'.$patient_master[0]->udai; + } + $data['old_uhid']=$old_uhid; + + $exp_date=""; + + if($opd_master[0]->opd_fee_type=='3'){ + if(count($old_opd)>0){ + $exp_date= 'OPD Start Date : '.$old_opd[0]->s_opd_date.'
Valid Upto :'.$old_opd[0]->opd_Exp_Date.'
'; + } + }else{ + $exp_date="Valid Upto : ".$opd_master[0]->opd_Exp_Date .""; + } + + $data['exp_date']=$exp_date; + + $content=' + + + + + + +
+ Name : '.$patient_master[0]->title .' '.strtoupper($patient_master[0]->p_fname).'
+ '.$patient_master[0]->p_relative.' '.strtoupper($patient_master[0]->p_rname).'
+ Gender/Age : '.$patient_master[0]->xgender.' / '.$patient_master[0]->age.'
+ P.No. :'.$patient_master[0]->mphone1 .'
+ Address :'.$patient_master[0]->add1.','.$patient_master[0]->add2.' ,'.$patient_master[0]->city.' +
+ UHID : '.$patient_master[0]->p_code.' '.$old_uhid.'
+ Sr No.: '.$opd_master[0]->opd_no .'
+ OPD No.: '.$opd_master[0]->opd_code.'
+ OPD Fee: '.$opd_master[0]->opd_fee_amount .' ['.$opd_master[0]->opd_fee_desc .']
+ Date: '.$opd_master[0]->str_apointment_date .'
'.$exp_date.' +
+ Consultant : Dr. '.$opd_master[0]->doc_name .'
+
+
'; + //echo $content; + create_OPD_Letter_pdf($content,'opd_parchi-'.$opdid.'-'.date('Yms')); + + } + + + + public function opd_Cont_print($opdid) + { + $sql="select *,date_format(apointment_date,'%d-%m-%Y') as str_apointment_date, + date_format(date_add(apointment_date,interval 4 day),'%d-%m-%Y') as opd_Exp_Date, + (case payment_status when 1 Then 'Cash' when 2 then 'Bank Card' when 3 then 'Org. Credit' else 'Pending' end) as Payment_type_str + from opd_master where opd_id=".$opdid; + $query = $this->db->query($sql); + $opd_master= $query->result(); + + $sql="select *,if(gender=1,'M','F') as xgender, + GET_AGE_2(dob,age,age_in_month,estimate_dob,'".$opd_master[0]->apointment_date."') AS age from patient_master where id='".$opd_master[0]->p_id."' "; + $query = $this->db->query($sql); + $patient_master= $query->result(); + + $sql="select *,date_format(date_add(apointment_date,interval 4 day),'%d-%m-%Y') as opd_Exp_Date , + date_format(apointment_date,'%d-%m-%Y') as s_opd_date + from opd_master where p_id=".$opd_master[0]->p_id." and opd_id < ".$opdid." + order by opd_id desc limit 1"; + $query = $this->db->query($sql); + $old_opd= $query->result(); + + $sql="select * from hc_insurance where id=".$opd_master[0]->insurance_id; + $query = $this->db->query($sql); + $insurance= $query->result(); + + if($opd_master[0]->insurance_case_id>0) + { + $sql="select * from organization_case_master where id=".$opd_master[0]->insurance_case_id; + $query = $this->db->query($sql); + $case_master= $query->result(); + } + + $old_uhid=''; + if($patient_master[0]->udai<>"") + { + $old_uhid= ' /'.$patient_master[0]->udai; + } + + $exp_date=""; + + if($opd_master[0]->opd_fee_type=='3'){ + if(count($old_opd)>0){ + $exp_date= 'OPD Start Date : '.$old_opd[0]->s_opd_date.'
Valid Upto :'.$old_opd[0]->opd_Exp_Date.'
'; + } + }else{ + $exp_date="Valid Upto : ".$opd_master[0]->opd_Exp_Date .""; + } + + $content='
+
+ + + + + +
+ UHID : '.$patient_master[0]->p_code.' '.$old_uhid.'
+ Name : '.$patient_master[0]->title .' '.strtoupper($patient_master[0]->p_fname).'
+ '.$patient_master[0]->p_relative.' '.strtoupper($patient_master[0]->p_rname).'
+ Sex : '.$patient_master[0]->xgender.' '.$patient_master[0]->age.'
+
+ OPD No.: '.$opd_master[0]->opd_code.'
+ OPD Fee: '.$opd_master[0]->opd_fee_amount .' ['.$opd_master[0]->opd_fee_desc .']
+ Date: '.$opd_master[0]->str_apointment_date .'
'.$exp_date.' +
+ Sr No.: '.$opd_master[0]->opd_no .'
+ P.No. :'.$patient_master[0]->mphone1 .'
+ Address : '.$patient_master[0]->add1.','.$patient_master[0]->city.'
+

'; + + //echo $content; + create_OPD_cont_pdf($content,'opd_parchi-'.$opdid.'-'.date('Yms')); + + } + + public function invoice_print_pdf($opdid) + { + $sql="select *,date_format(apointment_date,'%d-%m-%Y') as str_apointment_date, + (case payment_status when 1 Then 'Cash' when 2 then 'Bank Card' when 3 then 'Org. Credit' else 'Pending' end) as Payment_type_str + from opd_master where opd_id=".$opdid; + $query = $this->db->query($sql); + $opd_master= $query->result(); + + $sql="select *,if(gender=1,'Male','Female') as xgender, + GET_AGE_2(dob,age,age_in_month,estimate_dob,'".$opd_master[0]->apointment_date."') AS age + from patient_master where id='".$opd_master[0]->p_id."' "; + + $query = $this->db->query($sql); + $patient_master= $query->result(); + + $sql="select * from hc_insurance where id=".$opd_master[0]->insurance_id; + $query = $this->db->query($sql); + $insurance= $query->result(); + + if($opd_master[0]->insurance_case_id>0) + { + $sql="select * from organization_case_master where id=".$opd_master[0]->insurance_case_id; + $query = $this->db->query($sql); + $case_master= $query->result(); + } + + // Content Start From here + + $content='

OPD Charges Invoice

'; + + $itemlist='Items:'; + + $content.=' + + + + + +
+ To
+ UHID : '.$patient_master[0]->p_code.'
+ Name : '.$patient_master[0]->title .' '.strtoupper($patient_master[0]->p_fname).'
+ '.$patient_master[0]->p_relative.' '.strtoupper($patient_master[0]->p_rname).'
+ Sex : '.$patient_master[0]->xgender.' '.$patient_master[0]->age.' P.No. :'.$patient_master[0]->mphone1 .'
+ Address : '.$patient_master[0]->add1.','.$patient_master[0]->city.'
+
+ Invoice No. : '.$opd_master[0]->opd_code.'
+ Date : '.$opd_master[0]->str_apointment_date.'
+
+ +
'; + $content.='
+ + + + + + + '; + + $content.= ''; + $content.= ''; + $content.= ''; + $content.= ''; + $content.= ''; + $content.= ''; + $content.= ''; + + if($opd_master[0]->opd_discount>0 ) + { + $content.= ''; + $content.= ''; + $content.= ''; + $content.= ''; + $content.= ''; + $content.= ''; + + } + + $content.= ''; + $content.= ''; + $content.= ''; + $content.= ''; + $content.= ''; + $content.= ''; + + $content.='
Date Charge NameDoctor NameDescriptionAmount
'.$opd_master[0]->str_apointment_date.'Consultation FeeDr.'.$opd_master[0]->doc_name.''.$opd_master[0]->opd_fee_desc.'Rs.'.$opd_master[0]->opd_fee_gross_amount.'
# Deduction '.$opd_master[0]->opd_disc_remark.' Rs.'.$opd_master[0]->opd_discount.'
# Net Amount Rs.'.$opd_master[0]->opd_fee_amount.'
'; + + // Content End Here + + if($opd_master[0]->payment_id>0 ) + { + $content.='Payment No. :'.$opd_master[0]->payment_id.'
'; + } + + $content.=' +
+ + + + + + + + + +
+ Amount in Words : Rs. '.number_to_word($opd_master[0]->opd_fee_amount).' + + +
+ Prepared By :'.$opd_master[0]->prepared_by.' + + Signature +
'; + + + $bar_content=$patient_master[0]->p_code.':OPD-'.$opd_master[0]->opd_code.':T'.date('dmYhms'); + //echo $content; + $this->load->library("Pdf"); + create_Invoice_pdf($content,$bar_content,'opd_invoice-'.$opdid.'-'.date('Yms')); + } + +} diff --git a/old_code_ci3/controllers/Opdcase.php b/old_code_ci3/controllers/Opdcase.php index 29359b0..633115c 100644 --- a/old_code_ci3/controllers/Opdcase.php +++ b/old_code_ci3/controllers/Opdcase.php @@ -14,7 +14,7 @@ class Opdcase extends MY_Controller { $sql="select p.*,if(p.gender=1,'Male','Female') as xgender, i.ins_company_name,i.short_name,i.opd_rate_direct,i.charge_rate_direct, i.opd_credit,i.charge_credit,i.opd_allowed,i.charge_cash,i.id as ins_id, - IFNULL(GET_AGE_BY_DOB(dob),age) AS age + GET_AGE_1(dob,age,age_in_month,estimate_dob) AS age from patient_master p left join hc_insurance i on p.insurance_id=i.id where p.id=".$pno; $query = $this->db->query($sql); $data['person_info']= $query->result(); @@ -83,7 +83,7 @@ class Opdcase extends MY_Controller { $data['opd_master']= $query->result(); $sql="select *,if(gender=1,'Male','Female') as xgender, - IFNULL(GET_AGE_BY_DOB(dob),age) AS age from patient_master where id='".$data['opd_master'][0]->p_id."' "; + GET_AGE_1(dob,age,age_in_month,estimate_dob) AS age from patient_master where id='".$data['opd_master'][0]->p_id."' "; $query = $this->db->query($sql); $data['patient_master']= $query->result(); @@ -145,7 +145,7 @@ class Opdcase extends MY_Controller { $data['opd_master']= $query->result(); $sql="select *,if(gender=1,'Male','Female') as xgender, - IFNULL(GET_AGE_BY_DOB(dob),age) AS age from patient_master where id='".$data['opd_master'][0]->p_id."' "; + GET_AGE_1(dob,age,age_in_month,estimate_dob) AS age from patient_master where id='".$data['opd_master'][0]->p_id."' "; $query = $this->db->query($sql); $data['patient_master']= $query->result(); diff --git a/old_code_ci3/controllers/OrganizationInvoice.php b/old_code_ci3/controllers/OrganizationInvoice.php index 2ee9759..b648666 100644 --- a/old_code_ci3/controllers/OrganizationInvoice.php +++ b/old_code_ci3/controllers/OrganizationInvoice.php @@ -131,7 +131,7 @@ class PathLab extends MY_Controller { public function addPathTest($pno,$ins_id=0) { $sql="select *,if(gender=1,'Male','Female') as xgender, - IFNULL(GET_AGE_BY_DOB(dob),age) AS age from patient_master where id='".$pno."' "; + GET_AGE_1(dob,age,age_in_month,estimate_dob) AS age from patient_master where id='".$pno."' "; $query = $this->db->query($sql); $data['person_info']= $query->result(); @@ -257,7 +257,7 @@ class PathLab extends MY_Controller { $data['invoice_master']= $query->result(); $sql="select *,if(gender=1,'Male','Female') as xgender, - IFNULL(GET_AGE_BY_DOB(dob),age) AS age from patient_master where id=".$data['invoice_master'][0]->attach_id; + GET_AGE_1(dob,age,age_in_month,estimate_dob) AS age from patient_master where id=".$data['invoice_master'][0]->attach_id; $query = $this->db->query($sql); $data['patient_master']= $query->result(); diff --git a/old_code_ci3/controllers/Orgcase.php b/old_code_ci3/controllers/Orgcase.php index 89c05ae..3064d03 100644 --- a/old_code_ci3/controllers/Orgcase.php +++ b/old_code_ci3/controllers/Orgcase.php @@ -65,7 +65,7 @@ class Orgcase extends MY_Controller { $this->db->query("CALL p_org_update(".$caseid.")"); $sql="select *,if(gender=1,'Male','Female') as xgender, - IFNULL(GET_AGE_BY_DOB(dob),age) AS age from patient_master where id='".$pno."' "; + GET_AGE_1(dob,age,age_in_month,estimate_dob) AS age from patient_master where id='".$pno."' "; $query = $this->db->query($sql); $data['person_info']= $query->result(); @@ -178,7 +178,7 @@ class Orgcase extends MY_Controller { $this->db->query("CALL p_org_update(".$caseid.")"); $sql="select *,if(gender=1,'Male','Female') as xgender, - IFNULL(GET_AGE_BY_DOB(dob),age) AS age from patient_master where id='".$pno."' "; + GET_AGE_1(dob,age,age_in_month,estimate_dob) AS age from patient_master where id='".$pno."' "; $query = $this->db->query($sql); $data['person_info']= $query->result(); @@ -299,12 +299,12 @@ class Orgcase extends MY_Controller { 'code' => $orgcode ); - + /* $sql="select * from hc_items_insurance where hc_items_id=".$master_item_id." and hc_insurance_id=".$insurance_id; $query = $this->db->query($sql); $chkitem= $query->result(); - if($insurance_id==2) + if($insurance_id>2) { if(count($chkitem)>0 ) { @@ -313,7 +313,7 @@ class Orgcase extends MY_Controller { $insDone=$this->item_M->insert_in_item( $data['update_insurance_item']); } } - + */ $sql="select * from invoice_item where id=".$item_id; $query = $this->db->query($sql); @@ -431,7 +431,7 @@ class Orgcase extends MY_Controller { $pno=$data['orgcase'][0]->p_id; $sql="select *,if(gender=1,'Male','Female') as xgender, - IFNULL(GET_AGE_BY_DOB(dob),age) AS age from patient_master where id='".$pno."' "; + GET_AGE_1(dob,age,age_in_month,estimate_dob) AS age from patient_master where id='".$pno."' "; $query = $this->db->query($sql); $data['person_info']= $query->result(); @@ -599,7 +599,7 @@ class Orgcase extends MY_Controller { $claim_id=$data['orgcase'][0]->insurance_no_1; $sql="select *,if(gender=1,'Male','Female') as xgender, - IFNULL(GET_AGE_BY_DOB(dob),age) AS age from patient_master where id='".$pno."' "; + GET_AGE_1(dob,age,age_in_month,estimate_dob) AS age from patient_master where id='".$pno."' "; $query = $this->db->query($sql); $data['person_info']= $query->result(); @@ -653,7 +653,7 @@ class Orgcase extends MY_Controller { $claim_id=$data['orgcase'][0]->insurance_no_1; $sql="select *,if(gender=1,'Male','Female') as xgender, - IFNULL(GET_AGE_BY_DOB(dob),age) AS age from patient_master where id='".$pno."' "; + GET_AGE_1(dob,age,age_in_month,estimate_dob) AS age from patient_master where id='".$pno."' "; $query = $this->db->query($sql); $data['person_info']= $query->result(); @@ -1102,7 +1102,7 @@ class Orgcase extends MY_Controller { $data['ipd_info']= $query->result(); $sql="select *,if(gender=1,'Male','Female') as xgender, - IFNULL(GET_AGE_BY_DOB(dob),age) as str_age from patient_master where id='".$data['org_info'][0]->p_id."' "; + GET_AGE_1(dob,age,age_in_month,estimate_dob) as str_age from patient_master where id='".$data['org_info'][0]->p_id."' "; $query = $this->db->query($sql); $data['person_info']= $query->result(); @@ -1120,7 +1120,7 @@ class Orgcase extends MY_Controller { $data['ipd_info']= $query->result(); $sql="select *,if(gender=1,'Male','Female') as xgender, - IFNULL(GET_AGE_BY_DOB(dob),age) as str_age from patient_master where id='".$data['org_info'][0]->p_id."' "; + GET_AGE_1(dob,age,age_in_month,estimate_dob) as str_age from patient_master where id='".$data['org_info'][0]->p_id."' "; $query = $this->db->query($sql); $data['person_info']= $query->result(); @@ -1153,7 +1153,7 @@ class Orgcase extends MY_Controller { $patient_id=$org_info[0]->p_id; $sql="select *,if(gender=1,'Male','Female') as xgender, - IFNULL(GET_AGE_BY_DOB(dob),age) as str_age from patient_master where id='".$patient_id."' "; + GET_AGE_1(dob,age,age_in_month,estimate_dob) as str_age from patient_master where id='".$patient_id."' "; $query = $this->db->query($sql); $person_info= $query->result(); @@ -1216,7 +1216,7 @@ class Orgcase extends MY_Controller { $patient_id=$org_info[0]->p_id; $sql="select *,if(gender=1,'Male','Female') as xgender, - IFNULL(GET_AGE_BY_DOB(dob),age) as str_age from patient_master where id='".$patient_id."' "; + GET_AGE_1(dob,age,age_in_month,estimate_dob) as str_age from patient_master where id='".$patient_id."' "; $query = $this->db->query($sql); $person_info= $query->result(); diff --git a/old_code_ci3/controllers/Package.php b/old_code_ci3/controllers/Package.php index d186a93..7d7b3bf 100644 --- a/old_code_ci3/controllers/Package.php +++ b/old_code_ci3/controllers/Package.php @@ -67,7 +67,7 @@ class Package extends MY_Controller $query = $this->db->query($sql); $data['package_group'] = $query->result(); - $sql = "SELECT * FROM package where pakage_group_id=1"; + $sql = "SELECT * FROM Package where pakage_group_id=1"; $query = $this->db->query($sql); $data['data'] = $query->result(); diff --git a/old_code_ci3/controllers/PathLab.php b/old_code_ci3/controllers/PathLab.php index a60011e..e034fd1 100644 --- a/old_code_ci3/controllers/PathLab.php +++ b/old_code_ci3/controllers/PathLab.php @@ -292,7 +292,7 @@ class PathLab extends MY_Controller { $ins_id=$data['invoiceMaster'][0]->insurance_card_id; $sql="select *,if(gender=1,'Male','Female') as xgender, - IFNULL(GET_AGE_BY_DOB(dob),age) AS age from patient_master where id='".$pno."' "; + GET_AGE_1(dob,age,age_in_month,estimate_dob) AS age from patient_master where id='".$pno."' "; $query = $this->db->query($sql); $data['person_info']= $query->result(); @@ -386,7 +386,7 @@ class PathLab extends MY_Controller { public function addPathTest($pno,$ins_id=0,$opd_id=0) { $sql="select *,if(gender=1,'Male','Female') as xgender, - IFNULL(GET_AGE_BY_DOB(dob),age) AS age from patient_master where id='".$pno."' "; + GET_AGE_1(dob,age,age_in_month,estimate_dob) AS age from patient_master where id='".$pno."' "; $query = $this->db->query($sql); $data['person_info']= $query->result(); diff --git a/old_code_ci3/controllers/PathLab1.php b/old_code_ci3/controllers/PathLab1.php new file mode 100644 index 0000000..c797ce2 --- /dev/null +++ b/old_code_ci3/controllers/PathLab1.php @@ -0,0 +1,1335 @@ +input->is_ajax_request()) { exit('no valid req.'); } + + $this->load->model('Invoice_M'); + $this->load->model('Payment_M'); + + $invoice_id=$this->input->post('invoice_id'); + + $sql="select * from invoice_master where id='".$invoice_id."'"; + $query = $this->db->query($sql); + $inv_master= $query->result(); + + $sql="select sum(if(credit_debit=0,amount,amount*-1)) as tPayment + from payment_history where payof_type=2 and payof_id='".$invoice_id."'"; + $query = $this->db->query($sql); + $payment_history= $query->result(); + + $TotPaymentR=0; + + if(count($payment_history)>0) + { + $TotPaymentR=$payment_history[0]->tPayment; + } + + $user = $this->ion_auth->user()->row(); + $user_id = $user->id; + $user_name = $user->first_name.''. $user->last_name; + + $pay_remark=''; + + if($inv_master[0]->discount_amount>0) + { + $pay_remark='Dis.Amt.:'.$inv_master[0]->discount_desc.' /Amount: '. $inv_master[0]->discount_amount.'/Update:'.$inv_master[0]->disc_update_by; + } + + $amountpaid=$this->input->post('input_amount_paid'); + + if($amountpaid<0){ + $amountpaid=$amountpaid*-1; + } + + $amountbalanace=0.00; + + if($amountpaid < $inv_master[0]->net_amount ); + { + $amountbalanace=$inv_master[0]->net_amount-$TotPaymentR; + } + + if($this->input->post('mode')==1) + { + $paydata = array( + 'payment_mode'=> '1', + 'payof_type'=>'2', + 'payof_id'=>$invoice_id, + 'payof_code'=>$inv_master[0]->invoice_code, + 'credit_debit'=>'0', + 'amount'=>$amountpaid, + 'payment_date'=>date('Y-m-d H:i:s'), + 'remark'=>$pay_remark, + 'update_by'=>$user_name.'['.$user_id.']', + 'update_by_id'=>$user_id + ); + + if($amountpaid<=$amountbalanace) + { + $insert_id=$this->Payment_M->insert($paydata); + + $data = array( + 'payment_mode'=> '1', + 'payment_status'=>'1', + 'invoice_status'=>'1', + 'payment_id'=>$insert_id, + 'payment_mode_desc'=>'Cash', + 'confirm_invoice'=>date('Y-m-d H:i:s'), + 'prepared_by'=>$user_name.'['.$user_id.']', + 'prepared_by_id'=>$user_id + ); + + $this->Invoice_M->update( $data,$invoice_id); + } + + $status='CASH'; + $showcontent=$status; + + $rvar=array( + 'update' =>1, + 'showcontent'=>$showcontent + ); + + $encode_data = json_encode($rvar); + } + + if($this->input->post('mode')==2) + { + $FormRules = array( + array( + 'field' => 'input_card_mac', + 'label' => 'Card Bank Name', + 'rules' => 'required|min_length[3]|max_length[30]' + ) + ); + + $this->form_validation->set_rules($FormRules); + + if ($this->form_validation->run() == TRUE) + { + $paydata = array( + 'payment_mode'=> '2', + 'payof_type'=>'2', + 'payof_id'=>$invoice_id, + 'payof_code'=>$inv_master[0]->invoice_code, + 'credit_debit'=>'0', + 'amount'=>$amountpaid, + 'payment_date'=>date('Y-m-d H:i:s'), + 'remark'=>$pay_remark, + 'update_by'=>$user_name.'['.$user_id.']', + 'card_bank'=>$this->input->post('input_card_mac'), + 'cust_card'=>$this->input->post('input_card_bank'), + 'card_remark'=>$this->input->post('input_card_digit'), + 'card_tran_id'=>$this->input->post('input_card_tran'), + 'update_by_id'=>$user_id + ); + + if($amountpaid<=$amountbalanace) + { + $insert_id=$this->Payment_M->insert($paydata); + + $data = array( + 'payment_mode'=> '2', + 'payment_status'=>'1', + 'invoice_status'=>'1', + 'payment_mode_desc'=>'Bank Card', + 'confirm_invoice'=>date('Y-m-d H:i:s'), + 'payment_id'=>$insert_id, + 'card_bank'=>$this->input->post('input_card_mac'), + 'card_remark'=>$this->input->post('input_card_digit'), + 'cust_card'=>$this->input->post('input_card_bank'), + 'card_tran_id'=>$this->input->post('input_card_tran'), + 'prepared_by'=>$user_name.'['.$user_id.']', + 'prepared_by_id'=>$user_id + ); + + $this->Invoice_M->update( $data,$invoice_id); + } + + + + $status='Bank Card'; + $showcontent=$status; + + $rvar=array( + 'update' =>1, + 'showcontent'=>$showcontent + ); + $encode_data = json_encode($rvar); + + } + else{ + $send_error=validation_errors(); + $rvar=array( + 'update' =>0, + 'error_text'=>$send_error + ); + + $encode_data = json_encode($rvar); + } + } + + if($this->input->post('mode')==3) + { + $data = array( + 'payment_mode'=> '3', + 'payment_status'=>'1', + 'invoice_status'=>'1', + 'confirm_invoice'=>date('Y-m-d H:i:s'), + 'payment_mode_desc'=>'IPD Credit', + 'ipd_id'=>$this->input->post('ipd_id'), + 'prepared_by'=>$user_name.'['.$user_id.']', + 'prepared_by_id'=>$user_id + ); + + $this->Invoice_M->update( $data,$invoice_id); + + $sql="select * from ipd_master where id=".$this->input->post('ipd_id'); + $query = $this->db->query($sql); + $ipd_master= $query->result(); + + if(count($ipd_master)>0) + { + $data = array( + 'insurance_case_id'=>$ipd_master[0]->case_id + ); + + $this->Invoice_M->update( $data,$invoice_id); + + } + $status='IPD Credit'; + + $rvar=array( + 'update' =>1 + ); + + $encode_data = json_encode($rvar); + } + + if($this->input->post('mode')==4) + { + $data = array( + 'payment_mode'=> '4', + 'payment_status'=>'1', + 'invoice_status'=>'1', + 'payment_mode_desc'=>'Org.Case Credit', + 'confirm_invoice'=>date('Y-m-d H:i:s'), + 'insurance_case_id'=>$this->input->post('case_id'), + 'prepared_by'=>$user_name.'['.$user_id.']', + 'prepared_by_id'=>$user_id + ); + + $this->Invoice_M->update($data,$invoice_id); + + $status='Org. Credit'; + + + $rvar=array( + 'update' =>1, + 'showcontent'=>$status + ); + + $encode_data = json_encode($rvar); + + } + + if($this->input->post('mode')==5) + { + $data = array( + 'payment_mode'=> '1', + 'payment_status'=>'1', + 'invoice_status'=>'1', + 'payment_id'=>'0', + 'payment_mode_desc'=>'Zero Amount', + 'confirm_invoice'=>date('Y-m-d H:i:s'), + 'prepared_by'=>$user_name.'['.$user_id.']', + 'prepared_by_id'=>$user_id + ); + + $this->Invoice_M->update( $data,$invoice_id); + + $status='Zero Amount'; + $showcontent=$status; + + $rvar=array( + 'update' =>1, + 'showcontent'=>$showcontent + ); + + $encode_data = json_encode($rvar); + + } + + $this->load->model('Invoice_M'); + $this->Invoice_M->update_invoice_final($invoice_id); + + + echo $encode_data; + } + + public function IPD_Invoice_Edit($Invoice_ID) + { + $sql="select * from invoice_master where id=".$Invoice_ID; + $query = $this->db->query($sql); + $data['invoiceMaster']= $query->result(); + + $sql="select i.*,t.group_desc from invoice_item i join hc_item_type t on i.item_type=t.itype_id where i.inv_master_id=".$Invoice_ID; + $query = $this->db->query($sql); + $data['invoiceDetails']= $query->result(); + + $sql="select sum(item_amount) as Gtotal from invoice_item where inv_master_id=".$Invoice_ID; + $query = $this->db->query($sql); + $data['invoiceGtotal']= $query->result(); + + $pno=$data['invoiceMaster'][0]->attach_id; + $ipd_no=$data['invoiceMaster'][0]->ipd_id; + $ins_id=$data['invoiceMaster'][0]->insurance_card_id; + + $sql="select *,if(gender=1,'Male','Female') as xgender, + GET_AGE_1(dob,age,age_in_month,estimate_dob) AS age from patient_master where id='".$pno."' "; + $query = $this->db->query($sql); + $data['person_info']= $query->result(); + + if($ins_id>0) + { + $sql="select * from hc_item_type order by group_desc"; + }else{ + $sql="select * from hc_item_type where itype_id<>33 order by group_desc "; + } + $query = $this->db->query($sql); + $data['labitemtype']= $query->result(); + + $path_cash=1; + $path_credit=1; + + $ins_comp_id=0; + if($ins_id>0) + { + $sql="select * from hc_insurance_card where id=".$ins_id; + $query = $this->db->query($sql); + $data['hc_insurance_card']= $query->result(); + + $ins_comp_id=$data['hc_insurance_card'][0]->insurance_id; + + $sql="select * from hc_insurance where id=".$ins_comp_id; + $query = $this->db->query($sql); + $data['insurance']= $query->result(); + + $path_cash=$data['insurance'][0]->path_cash; + $path_credit=$data['insurance'][0]->path_credit; + } + + $data['pdata']=$ins_comp_id; + + $sql="select * from doctor_master where active=1 order by p_fname"; + $query = $this->db->query($sql); + $data['doclist']= $query->result(); + + if($ins_comp_id<2) + { + $sql="select id,Concat(idesc,' : {',amount,'}') as sdesc from hc_items where itype=1 order by idesc "; + }else{ + $sql="select m.id,m.itype,m.idesc,m.amount,t.itype_id,t.is_ipd_opd,t.group_desc, + i.hc_insurance_id ,if(i.hc_insurance_id is null,m.amount,i.amount1) as amount1, + Concat(m.idesc,'{',if(i.hc_insurance_id is null,m.amount,i.amount1),'}',if(i.id is null,'',concat('[',i.code,']'))) as sdesc + from (hc_items m join hc_item_type t on m.itype=t.itype_id) + left join + (select * from hc_items_insurance where hc_insurance_id=".$ins_comp_id." and isdelete=0 ) as i on m.id=i.hc_items_id + where itype_id=1 order by m.idesc"; + } + + $query = $this->db->query($sql); + $data['labitem']= $query->result(); + + $this->load->model('invoice_M'); + + $today = date("Y-m-d"); + $expire = $data['invoiceMaster'][0]->inv_date; //from db + + $today_dt = new DateTime($today); + $inv_dt = new DateTime($expire); + + $sql="select *,if(ipd_status=0,DATEDIFF(sysdate(),register_date),DATEDIFF(discharge_date,register_date)) as no_days + from ipd_master where id=".$data['invoiceMaster'][0]->ipd_id; + $query = $this->db->query($sql); + $data['ipd_master']= $query->result(); + + if(count($data['ipd_master'])>0) + { + if($data['ipd_master'][0]->ipd_status==0) + { + $ipd_status=0; + }else{ + $ipd_status=1; + } + }else{ + $ipd_status=1; + } + + if($this->ion_auth->in_group('ChargeInvoiceUpdate') || ($ipd_status==0 && $this->ion_auth->in_group('IPDPayment') )) + { + $this->load->view('Invoice_PathLab',$data); + }else{ + + } + + //$this->load->view('Invoice_ipd_credit',$data); + } + + + public function addPathTest($pno,$ins_id=0,$opd_id=0) + { + $sql="select *,if(gender=1,'Male','Female') as xgender, + GET_AGE_1(dob,age,age_in_month,estimate_dob) AS age from patient_master where id='".$pno."' "; + $query = $this->db->query($sql); + $data['person_info']= $query->result(); + + if($opd_id>0) + { + $sql="select * from opd_master where p_id='".$pno."' and opd_id=".$opd_id." order by opd_id desc limit 1"; + }else{ + $sql="select * from opd_master where p_id='".$pno."' order by opd_id desc limit 1"; + } + $query = $this->db->query($sql); + $data['opd_master']= $query->result(); + + if(count($data['opd_master'])>0) + { + $select_doc=$data['opd_master'][0]->doc_id; + $opd_code=$data['opd_master'][0]->opd_code; + }else{ + $select_doc=0; + $opd_code=''; + } + + $sql="select l.doc_id from ipd_master p join ipd_master_doc_list l on p.id=l.ipd_id + where p.ipd_status=0 and p.p_id=".$pno." "; + $query = $this->db->query($sql); + $data['ipd_master_docid']= $query->result(); + + if(count($data['ipd_master_docid'])>0) + { + $select_doc=$data['ipd_master_docid'][0]->doc_id; + } + + if($ins_id>0) + { + $sql="select * from hc_item_type order by group_desc"; + }else{ + $sql="select * from hc_item_type where itype_id<>33 order by group_desc"; + } + + $query = $this->db->query($sql); + $data['labitemtype']= $query->result(); + + $path_cash=1; + $path_credit=1; + + + $ins_comp_id=0; + if($ins_id>0) + { + $sql="select * from hc_insurance_card where id=".$ins_id; + $query = $this->db->query($sql); + $data['hc_insurance_card']= $query->result(); + + $ins_comp_id=$data['hc_insurance_card'][0]->insurance_id; + + $sql="select * from hc_insurance where id=".$ins_comp_id; + $query = $this->db->query($sql); + $data['insurance']= $query->result(); + + $path_cash=$data['insurance'][0]->path_cash; + $path_credit=$data['insurance'][0]->path_credit; + } + + $data['pdata']=$ins_comp_id; + + $sql="select * from doctor_master where active=1 order by p_fname"; + $query = $this->db->query($sql); + $data['doclist']= $query->result(); + + + + + if($ins_comp_id<2) + { + $sql="select id,Concat(idesc,' : {',amount,'}') as sdesc from hc_items where itype=1 order by idesc "; + }else{ + $sql="select m.id,m.itype,m.idesc,m.amount,t.itype_id,t.is_ipd_opd,t.group_desc, + i.hc_insurance_id ,if(i.hc_insurance_id is null,m.amount,i.amount1) as amount1, + Concat(m.idesc,'{',if(i.hc_insurance_id is null,m.amount,i.amount1),'}',if(i.id is null,'',concat('[',i.code,']'))) as sdesc + from (hc_items m join hc_item_type t on m.itype=t.itype_id) + left join + (select * from hc_items_insurance where hc_insurance_id=".$ins_comp_id." and isdelete=0 ) as i on m.id=i.hc_items_id + where itype_id=1 order by m.idesc"; + } + + $query = $this->db->query($sql); + $data['labitem']= $query->result(); + + $this->load->model('invoice_M'); + + if($ins_id>0) + { + $sql="select * from invoice_master where invoice_status=0 and insurance_card_id>0 and attach_id=".$pno; + }else{ + $sql="select * from invoice_master where invoice_status=0 and insurance_card_id=0 and attach_id=".$pno; + } + + $query = $this->db->query($sql); + $data['chk_draft_invoice']= $query->result(); + + if(count($data['chk_draft_invoice'])<1) + { + $data['insert_invoice'] = array( + 'attach_type' => '0', + 'opd_code' => $opd_code, + 'attach_id' => $pno, + 'refer_by_id' => $select_doc, + 'inv_date' => date('Y-m-d H:i:s'), + 'inv_name' => $data['person_info'][0]->p_fname, + 'insurance_id' => $ins_comp_id, + 'insurance_card_id' => $ins_id, + 'insurance_cash' => $path_cash, + 'insurance_credit' => $path_credit, + 'inv_a_code' => $data['person_info'][0]->p_code + ); + $inser_id=$this->invoice_M->create_invoice( $data['insert_invoice']); + }else{ + $today = date("Y-m-d"); + $expire = $data['chk_draft_invoice'][0]->inv_date; //from db + + $today_dt = new DateTime($today); + $inv_dt = new DateTime($expire); + + if ($inv_dt < $today_dt) { + + //$this->db->delete("invoice_master", "id=".$data['chk_draft_invoice'][0]->id); + //$this->db->delete("invoice_item", "inv_master_id=".$data['chk_draft_invoice'][0]->id); + + $data['insert_invoice'] = array( + 'attach_type' => '0', + 'attach_id' => $pno, + 'opd_code' => $opd_code, + 'refer_by_id' => $select_doc, + 'inv_date' => date('Y-m-d H:i:s'), + 'inv_name' => $data['person_info'][0]->p_fname, + 'insurance_id' => $ins_comp_id, + 'insurance_card_id' => $ins_id, + 'insurance_cash' => $path_cash, + 'insurance_credit' => $path_credit, + 'inv_a_code' => $data['person_info'][0]->p_code + ); + //$inser_id=$data['chk_draft_invoice'][0]->id; + $inser_id=$this->invoice_M->create_invoice( $data['insert_invoice']); + }else{ + $inser_id=$data['chk_draft_invoice'][0]->id; + } + } + + if($inser_id) + { + $sql="select * from invoice_master where id=".$inser_id; + $query = $this->db->query($sql); + $data['invoiceMaster']= $query->result(); + + $sql="select i.*,t.group_desc from invoice_item i join hc_item_type t on i.item_type=t.itype_id where i.inv_master_id=".$inser_id; + $query = $this->db->query($sql); + $data['invoiceDetails']= $query->result(); + + $sql="select sum(item_amount) as Gtotal from invoice_item where inv_master_id=".$inser_id; + $query = $this->db->query($sql); + $data['invoiceGtotal']= $query->result(); + } + + $sql="select *,if(ipd_status=0,DATEDIFF(sysdate(),register_date),DATEDIFF(discharge_date,register_date)) as no_days from ipd_master where ipd_status=0 and p_id=".$data['invoiceMaster'][0]->attach_id; + $query = $this->db->query($sql); + $data['ipd_master']= $query->result(); + + $this->load->view('Invoice_PathLab',$data); + //$this->load->view('Invoice_ipd_credit',$data); + } + + public function list_pathtest_bytype() + { + $tid=$this->input->post('itype_idv'); + $ins_id=$this->input->post('ins_id'); + + $sql="select id,Concat(idesc,' : {',amount,'}') as sdesc from hc_items where itype=".$tid; + + if($ins_id>1) + { + $sql="select m.id,m.itype,m.idesc,m.amount,t.itype_id,t.is_ipd_opd,t.group_desc, + i.hc_insurance_id ,if(i.hc_insurance_id is null,m.amount,i.amount1) as amount1, + Concat(m.idesc,'{',if(i.hc_insurance_id is null,m.amount,i.amount1),'}',if(i.id is null,'',concat('[',i.code,']'))) as sdesc + from (hc_items m join hc_item_type t on m.itype=t.itype_id) + left join + (select * from hc_items_insurance where hc_insurance_id=".$ins_id." and isdelete=0 ) as i on m.id=i.hc_items_id + where itype_id=".$tid." order by m.idesc "; + }else{ + $sql="select id,Concat(idesc,' : [',amount,']') as sdesc from hc_items where itype=".$tid." order by idesc "; + } + + $query = $this->db->query($sql); + $data['labitem']= $query->result(); + + echo '
+ +
'; + + } + + public function update_refer_doc() + { + $invoice_id=$this->input->post('inv_id'); + $doc_id=$this->input->post('doc_id'); + $inv_date=$this->input->post('inv_date'); + + if($doc_id<1) + { + $refername=$this->input->post('refername'); + }else{ + $sql="select * from doctor_master where id=".$doc_id; + $query = $this->db->query($sql); + $data['doc_master']= $query->result(); + $refername=$data['doc_master'][0]->p_fname; + } + + if($this->ion_auth->in_group('InvoiceDateChanged')) + { + $inv_date=str_to_MysqlDate($inv_date); + }else{ + $inv_date=$data['invoice_master'][0]->inv_date; + } + + $dataupdate = array( + 'refer_by_id' => $doc_id, + 'inv_date' => $inv_date, + 'refer_by_other' => $refername, + 'invoice_status' =>'1', + ); + + $this->load->model('Invoice_M'); + $this->Invoice_M->update($dataupdate,$invoice_id); + + } + + public function get_echs_id() + { + $itype_name_id_srno=$this->input->post('input_charge_code'); + $tid=$this->input->post('itype_idv'); + + $sql="select * from hc_items where itype=".$tid." and echs_sr_no='".$itype_name_id_srno."'"; + //echo $sql; + $query = $this->db->query($sql); + $data['echs_data']= $query->result(); + + if($query->num_rows()>0) + { + echo $data['echs_data'][0]->id; + }else{ + echo '0'; + } + } + + + + public function showinvoice($invoice_id) + { + $this->load->model('Invoice_M'); + $this->Invoice_M->update_invoice_final($invoice_id); + + $sql="select i.*,t.group_desc + from invoice_item i join hc_item_type t on i.item_type=t.itype_id + where i.inv_master_id=".$invoice_id; + $query = $this->db->query($sql); + $data['invoiceDetails']= $query->result(); + + $sql="select *, + (case payment_mode + when 1 Then 'Cash' + when 2 then 'Bank Card' + when 3 then 'IPD Credit' + when 4 then 'Org. Credit' + else 'Pending' end) as Payment_type_str + from invoice_master + where id=".$invoice_id; + $query = $this->db->query($sql); + $data['invoice_master']= $query->result(); + + $ins_comp_id=$data['invoice_master'][0]->insurance_id; + $ins_id=$data['invoice_master'][0]->insurance_card_id; + + $sql="select * from hc_insurance_card where id=".$ins_id; + $query = $this->db->query($sql); + $data['hc_insurance_card']= $query->result(); + + $sql="select * from hc_insurance where id=".$ins_comp_id; + $query = $this->db->query($sql); + $data['insurance']= $query->result(); + + $sql="select * from patient_master_exten + where id=".$data['invoice_master'][0]->attach_id; + $query = $this->db->query($sql); + $data['patient_master']= $query->result(); + + $sql="select * from ipd_master + where ipd_status=0 and p_id=".$data['invoice_master'][0]->attach_id; + + if($data['invoice_master'][0]->ipd_id >0) + { + $sql="select * from ipd_master where id=".$data['invoice_master'][0]->ipd_id; + } + $query = $this->db->query($sql); + $data['ipd_master']= $query->result(); + + $sql="select * from invoice_item i join hc_item_type t on i.item_type=t.itype_id + where t.is_ipd_opd=2 and i.inv_master_id=".$invoice_id; + $query = $this->db->query($sql); + $IPD_Credit= $query->result(); + + if(count($IPD_Credit)>0) + { + $data['IPD_Credit']="1"; + }else{ + $data['IPD_Credit']="0"; + } + + $sql="select * + from organization_case_master + where case_type=0 and status=0 and p_id=".$data['invoice_master'][0]->attach_id; + + if($data['invoice_master'][0]->insurance_case_id>0) + { + $sql="select * from organization_case_master + where id=".$data['invoice_master'][0]->insurance_case_id; + }elseif(count($data['ipd_master'])>0){ + if($data['ipd_master'][0]->case_id>0) + { + $sql="select * from organization_case_master where id=".$data['ipd_master'][0]->case_id; + } + } + + $query = $this->db->query($sql); + $data['case_master']= $query->result(); + + $this->load->view('Invoice_PathLab_final_V',$data); + } + + public function update_discount() + { + $invoice_id=$this->input->post('invoice_id'); + + $user = $this->ion_auth->user()->row(); + $user_id = $user->id; + $user_name = $user->first_name.''. $user->last_name; + + $dataupdate = array( + 'discount_amount' => $this->input->post('input_dis_amt'), + 'discount_desc' => $this->input->post('input_dis_desc'), + 'disc_update_by'=>$user_name.'['.$user_id.']' + ); + $this->load->model('Invoice_M'); + $this->Invoice_M->update($dataupdate,$invoice_id); + + $sql="select sum(item_amount) as Gtotal from invoice_item where inv_master_id=".$invoice_id; + $query = $this->db->query($sql); + $data['invoiceGtotal']= $query->result(); + + $sql="select sum(if(credit_debit>0,amount*-1,amount)) as paid_amount from payment_history where payof_type=2 and payof_id=".$invoice_id; + $query = $this->db->query($sql); + $data['payment_history']= $query->result(); + + $sql="select * from invoice_master where id=".$invoice_id; + $query = $this->db->query($sql); + $data['invoice_master']= $query->result(); + + $discount_amount=$data['invoice_master'][0]->discount_amount ; + $correction_amount=$data['invoice_master'][0]->correction_amount ; + + $total_amount=$data['invoiceGtotal'][0]->Gtotal; + $net_amount=$total_amount-$discount_amount; + $net_amount=$net_amount-$correction_amount; + $paid_amount=$data['payment_history'][0]->paid_amount; + $balance_amount=$net_amount-$paid_amount; + + if($balance_amount>0 && $paid_amount>0) + { + $payment_part=1; + }else{ + $payment_part=0; + } + + $dataupdate = array( + 'total_amount' => $total_amount, + 'net_amount' => $net_amount, + 'payment_part_received' => $paid_amount, + 'payment_part_balance' => $balance_amount, + 'payment_part' => $payment_part, + ); + + $this->load->model('Invoice_M'); + $this->Invoice_M->update($dataupdate,$invoice_id); + + } + + + public function showitem($type) + { + $this->load->model('invoice_M'); + + if($type==1) + { + $ins_id=$this->input->post('ins_id'); + + $sql="select * from hc_items where id=".$this->input->post('itype_name_id'); + if($ins_id>1) + { + $sql="select m.id,m.itype,m.idesc as sdesc,m.amount,t.itype_id,t.is_ipd_opd,t.group_desc,i.isdelete, + if(i.hc_insurance_id is null,0,i.hc_insurance_id) as hc_insurance_id ,if(i.hc_insurance_id is null, + m.amount,i.amount1) as amount1, + if(i.hc_insurance_id is null,'',i.code) as org_code + from (hc_items m left join hc_items_insurance i on m.id=i.hc_items_id and i.isdelete=0 and i.hc_insurance_id=".$ins_id." ) + join hc_item_type t on m.itype=t.itype_id where m.id=".$this->input->post('itype_name_id'); + + $query = $this->db->query($sql); + $data['itemlist']= $query->result(); + + $item_rate=$data['itemlist'][0]->amount1; + $org_code=$data['itemlist'][0]->org_code; + + $item_custom_rate=$this->input->post('input_rate'); + + if($item_custom_rate>0) + { + $item_rate=$item_custom_rate; + } + + $amount_value=$this->input->post('input_qty')*$item_rate; + + } + else + { + $sql="select id,idesc as sdesc,amount from hc_items where id=".$this->input->post('itype_name_id'); + + $query = $this->db->query($sql); + $data['itemlist']= $query->result(); + + $item_rate=$data['itemlist'][0]->amount; + + $org_code=''; + + $item_custom_rate=$this->input->post('input_rate'); + + if($item_custom_rate>0) + { + $item_rate=$item_custom_rate; + } + $amount_value=$this->input->post('input_qty')*$item_rate; + } + + $data['insert_invoice_item'] = array( + 'inv_master_id' => $this->input->post('lab_invoice_id'), + 'item_type' => $this->input->post('itype_idv'), + 'item_id' => $this->input->post('itype_name_id'), + 'item_name' => $data['itemlist'][0]->sdesc, + 'item_rate' => $item_rate, + 'item_added_date' => str_to_MysqlDate(date('d/m/Y')), + 'item_qty' => $this->input->post('input_qty'), + 'item_amount' => $amount_value, + 'ins_id' => $ins_id, + 'org_code' => $org_code + ); + + $sql="select * from invoice_item where inv_master_id=".$this->input->post('lab_invoice_id')." and item_id=".$this->input->post('itype_name_id'); + $query = $this->db->query($sql); + + $itemcheck= $query->result(); + + if(count($itemcheck)<1) + { + $inser_id=$this->invoice_M->addinvoiceitem( $data['insert_invoice_item']); + } + + }if($type==2) + { + $amount_value=$this->input->post('update_qty') * $this->input->post('item_rate'); + + $data['update_invoice_item'] = array( + 'item_added_date' => str_to_MysqlDate(date('d/m/Y')), + 'item_qty' => $this->input->post('update_qty'), + 'item_amount' => $amount_value + ); + + $inser_id=$this->invoice_M->update_item( $data['update_invoice_item'],$this->input->post('itemid')); + + }else{ + $this->invoice_M->deleteinvoiceitem($this->input->post('itemid')); + echo 'DataDelete '.$this->input->post('itemid'); + //$this->db->delete("invoice_item", "id=".$this->input->post('itemid')); + } + + $sql="select i.*,t.group_desc from invoice_item i join hc_item_type t on i.item_type=t.itype_id where i.inv_master_id=".$this->input->post('lab_invoice_id')." Order by i.id"; + $query = $this->db->query($sql); + $data['invoiceDetails']= $query->result(); + + $invoice_id=$this->input->post('lab_invoice_id'); + + $sql="select * from invoice_master where id=".$invoice_id; + $query = $this->db->query($sql); + $data['invoice_master']= $query->result(); + + $sql="select sum(item_amount) as Gtotal from invoice_item where inv_master_id=".$this->input->post('lab_invoice_id'); + $query = $this->db->query($sql); + $data['invoiceGtotal']= $query->result(); + + $total_amount=$data['invoiceGtotal'][0]->Gtotal; + $discount_amount=$data['invoice_master'][0]->discount_amount ; + $total_amount=$data['invoiceGtotal'][0]->Gtotal; + $net_amount=$total_amount-$discount_amount; + + $dataupdate = array( + 'total_amount' => $total_amount, + 'net_amount' => $net_amount + ); + + $this->load->model('Invoice_M'); + $this->Invoice_M->update($dataupdate,$invoice_id); + + + echo '
+ + + + + + + + + + '; + + $srno=0; + + foreach($data['invoiceDetails'] as $row) + { + $srno=$srno+1; + echo ''; + echo ''; + echo ''; + echo ''; + if(in_array($row->item_type, array(1,2,3,4,5))) + { + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + } + + echo ''; + + echo ' + + + + + + + + + +
#Charge TypeCharge NameRateQtyUpdated QtyAmount
'.$srno.''.$row->group_desc.''.$row->item_name.''.$row->item_rate.''.$row->item_qty.''.$row->item_amount.''; + }else{ + echo ''.$row->item_rate.''.$row->item_amount.''; + echo ''; + } + + $sql="select * from lab_request where charge_item_id=".$row->id; + $query = $this->db->query($sql); + $lab_request= $query->result(); + + if(count($lab_request)<1) + { + echo ''; + } + + echo '
#Gross Total'.$data['invoiceGtotal'][0]->Gtotal.'
'; + } + + public function invoice_print($invoice_id) + { + $sql="select i.*,t.group_desc from invoice_item i join hc_item_type t on i.item_type=t.itype_id where i.inv_master_id=".$invoice_id." order by i.id"; + $query = $this->db->query($sql); + $data['invoiceDetails']= $query->result(); + + $sql="select sum(item_amount) as Gtotal from invoice_item where inv_master_id=".$invoice_id; + $query = $this->db->query($sql); + $data['invoiceGtotal']= $query->result(); + + $sql="select *,(case invoice_status when 0 then 'Pending' when 1 then '' when 2 then 'Cancelled Invoice' else 'Other' end) as Invoice_status_str, + (case payment_mode when 1 Then 'Cash' when 2 then 'Bank Card' + when 3 then 'IPD Credit' when 4 then 'Org. Credit' else 'Pending' end) as Payment_type_str + from invoice_master where id=".$invoice_id; + $query = $this->db->query($sql); + $data['invoice_master']= $query->result(); + + $sql="select *,if(gender=1,'Male','Female') as xgender, + GET_AGE_2(dob,age,age_in_month,estimate_dob,'".$data['invoice_master'][0]->inv_date."') AS age from patient_master + where id=".$data['invoice_master'][0]->attach_id; + $query = $this->db->query($sql); + $data['patient_master']= $query->result(); + + $sql="select *,get_payment_type(payment_mode,credit_debit) as Payment_type_str from payment_history where payof_type=2 and payof_id=".$invoice_id; + $query = $this->db->query($sql); + $data['payment_history']= $query->result(); + + $ins_comp_id=$data['invoice_master'][0]->insurance_id; + $ins_id=$data['invoice_master'][0]->insurance_card_id; + + $sql="select * from hc_insurance_card where id=".$ins_id; + $query = $this->db->query($sql); + $data['hc_insurance_card']= $query->result(); + + $sql="select * from hc_insurance where id=".$ins_comp_id; + $query = $this->db->query($sql); + $data['insurance']= $query->result(); + + + + $sql="select * from organization_case_master where id=".$data['invoice_master'][0]->insurance_case_id; + $query = $this->db->query($sql); + $data['case_master']= $query->result(); + + $this->load->view('invoice_pathlab_print_V',$data); + + } + + public function charge_crorg($inv_id,$org_code_id) + { + $user = $this->ion_auth->user()->row(); + $user_id = $user->id; + $user_name = $user->first_name.''. $user->last_name.'['.$user->id.']:T-'.date('d-m-Y h:m:s'); + + $status_str=""; + + $opd_status_remark=$status_str.' Update By:'.$user_name; + + $sql="select sum(if(credit_debit>0,amount*-1,amount)) as paid_amount from payment_history where payof_type=2 and payof_id=".$inv_id; + $query = $this->db->query($sql); + $payment_history= $query->result(); + + $sql="select * from invoice_master where id=".$inv_id; + $query = $this->db->query($sql); + $invoice_master= $query->result(); + + $sql="select * from refund_order where refund_process=0 and refund_type=2 and refund_type_id=".$inv_id; + $query = $this->db->query($sql); + $refund_order= $query->result(); + + if(count($payment_history)>0 && count($refund_order)<1) + { + if($payment_history[0]->paid_amount>0 && $invoice_master[0]->invoice_status==1) + { + $RefundRequest = array( + 'refund_type' => 2, + 'refund_type_id' => $inv_id, + 'refund_type_code' => $invoice_master[0]->invoice_code, + 'refund_type_reason' => 'Cr. to Org.', + 'approved_by_id' => $user_id, + 'approved_by' => $user_name, + 'refund_amount' => $payment_history[0]->paid_amount, + 'patient_id' => $invoice_master[0]->attach_id, + 'patient_name' =>strtoupper($invoice_master[0]->inv_name) + ); + + $this->load->model('Payment_M'); + $this->Payment_M->insert_refundorder($RefundRequest); + } + } + + $dataupdate = array( + 'payment_mode' => 4, + 'payment_mode_desc' => 'Org. Credit', + 'payment_id' => 0, + 'insurance_case_id' => $org_code_id, + 'payment_status'=>1 + ); + + $this->load->model('Invoice_M'); + $this->Invoice_M->update($dataupdate,$inv_id); + } + + public function invoice_PDF_print($invoice_id,$page_size=0) + { + $this->load->model('Invoice_M'); + $this->Invoice_M->update_invoice_final($invoice_id); + + + $sql="select i.*,t.group_desc + from invoice_item i join hc_item_type t on i.item_type=t.itype_id + where i.inv_master_id=".$invoice_id." order by t.group_desc,i.id"; + $query = $this->db->query($sql); + $data['invoiceDetails']= $query->result(); + + + $sql="select *,(case invoice_status when 0 then 'Pending' when 1 then '' when 2 then 'Cancelled Invoice' else 'Other' end) as Invoice_status_str, + (case payment_mode when 1 Then 'Cash' when 2 then 'Bank Card' + when 3 then 'IPD Credit' when 4 then 'Org. Credit' else 'Pending' end) as Payment_type_str , + date_format(confirm_invoice,'%d-%m-%Y %H:%i:%s') as confirm_invoice_datetime + from invoice_master where id=".$invoice_id; + $query = $this->db->query($sql); + $data['invoice_master']= $query->result(); + + $sql="select *,if(gender=1,'M','F') as xgender, + GET_AGE_2(dob,age,age_in_month,estimate_dob,'".$data['invoice_master'][0]->inv_date."') AS age from patient_master + where id='".$data['invoice_master'][0]->attach_id."' "; + $query = $this->db->query($sql); + $data['patient_master']= $query->result(); + + $sql="select *,get_payment_type(payment_mode,credit_debit) as Payment_type_str + from payment_history where payof_type=2 and payof_id=".$invoice_id; + $query = $this->db->query($sql); + $data['payment_history']= $query->result(); + + $ins_comp_id=$data['invoice_master'][0]->insurance_id; + $ins_id=$data['invoice_master'][0]->insurance_card_id; + + $sql="select * from hc_insurance_card where id=".$ins_id; + $query = $this->db->query($sql); + $hc_insurance_card= $query->result(); + + $sql="select * from hc_insurance where id=".$ins_comp_id; + $query = $this->db->query($sql); + $insurance= $query->result(); + + $sql="select *,i.short_name + from organization_case_master o join hc_insurance i on o.insurance_id=i.id + where o.id=".$data['invoice_master'][0]->insurance_case_id; + $query = $this->db->query($sql); + $data['case_master']= $query->result(); + + //load mPDF library + + $this->load->library('m_pdf'); + + $this->m_pdf->pdf->SetWatermarkText(H_Name); + $this->m_pdf->pdf->showWatermarkText = true; + + $file_name='Charge_Invoice-'.date('Ymdhis').".pdf"; + + $filepath=$file_name; + + if($page_size==0) + { + $content=$this->load->view('Invoice/invoice_print',$data,TRUE); + }elseif($page_size==1){ + $content=$this->load->view('Invoice/invoice_print_a5',$data,TRUE); + }elseif($page_size==2){ + $content=$this->load->view('Invoice/invoice_print_a4_double',$data,TRUE); + } + + //echo $content; + + //generate the PDF from the given html + $this->m_pdf->pdf->WriteHTML($content); + + //download it. + $this->m_pdf->pdf->Output("TEST.pdf","I"); + + } + + + + public function charge_crIPD($inv_id,$ipd_id) + { + $user = $this->ion_auth->user()->row(); + $user_id = $user->id; + $user_name = $user->first_name.''. $user->last_name.'['.$user->id.']:T-'.date('d-m-Y h:m:s'); + + $status_str=""; + + $opd_status_remark=$status_str.' Update By:'.$user_name; + + $sql="select sum(if(credit_debit>0,amount*-1,amount)) as paid_amount + from payment_history where payof_type=2 and payof_id=".$inv_id; + $query = $this->db->query($sql); + $payment_history= $query->result(); + + $sql="select * from invoice_master where id=".$inv_id; + $query = $this->db->query($sql); + $invoice_master= $query->result(); + + $sql="select * from ipd_master where id=".$ipd_id; + $query = $this->db->query($sql); + $ipd_master= $query->result(); + + $sql="select * from refund_order where refund_process=0 and refund_type=2 and refund_type_id=".$inv_id; + $query = $this->db->query($sql); + $refund_order= $query->result(); + + if(count($payment_history)>0 && count($refund_order)<1) + { + if($payment_history[0]->paid_amount>0 && $invoice_master[0]->invoice_status==1) + { + $RefundRequest = array( + 'refund_type' => 2, + 'refund_type_id' => $inv_id, + 'refund_type_code' => $invoice_master[0]->invoice_code, + 'refund_type_reason' => 'Cr. to IPD.', + 'approved_by_id' => $user_id, + 'approved_by' => $user_name, + 'refund_amount' => $payment_history[0]->paid_amount, + 'patient_id' => $invoice_master[0]->attach_id, + 'patient_name' =>strtoupper($invoice_master[0]->inv_name) + ); + + $this->load->model('Payment_M'); + $this->Payment_M->insert_refundorder($RefundRequest); + } + } + + $dataupdate = array( + 'payment_mode' => 3, + 'payment_mode_desc' => 'IPD Credit', + 'payment_id' => 0, + 'insurance_case_id' => $ipd_master[0]->case_id, + 'ipd_id' => $ipd_id, + 'payment_status' => 1, + ); + + $this->load->model('Invoice_M'); + $this->Invoice_M->update($dataupdate,$inv_id); + } + + + public function cancel_inv($inv_id) + { + $user = $this->ion_auth->user()->row(); + $user_id = $user->id; + $user_name = $user->first_name.''. $user->last_name.'['.$user->id.']:T-'.date('d-m-Y h:m:s'); + + $status_str=""; + + $opd_status_remark=$status_str.' Update By:'.$user_name; + + $sql="select sum(if(credit_debit>0,amount*-1,amount)) as paid_amount from payment_history where payof_type=2 and payof_id=".$inv_id; + $query = $this->db->query($sql); + $payment_history= $query->result(); + + $sql="select * from invoice_master where id=".$inv_id; + $query = $this->db->query($sql); + $invoice_master= $query->result(); + + $sql="select * from refund_order + where refund_process=0 and refund_type=2 and refund_type_id=".$inv_id; + $query = $this->db->query($sql); + $refund_order= $query->result(); + + if(count($payment_history)>0 && count($refund_order)<1) + { + if($payment_history[0]->paid_amount>0 && $invoice_master[0]->invoice_status==1) + { + $RefundRequest = array( + 'refund_type' => 2, + 'refund_type_id' => $inv_id, + 'refund_type_code' => $invoice_master[0]->invoice_code, + 'refund_type_reason' => 'Cancel Invoice', + 'approved_by_id' => $user_id, + 'approved_by' => $user_name, + 'refund_amount' => $payment_history[0]->paid_amount, + 'patient_id' => $invoice_master[0]->attach_id, + 'patient_name' =>strtoupper($invoice_master[0]->inv_name) + ); + + $this->load->model('Payment_M'); + $this->Payment_M->insert_refundorder($RefundRequest); + } + + $dataupdate = array( + 'payment_id' => 0, + 'invoice_status' => 2 + ); + + $this->load->model('Invoice_M'); + $this->Invoice_M->update($dataupdate,$inv_id); + }else{ + + } + + + } + + public function charge_refund($inv_id,$inv_refund_amount) + { + $user = $this->ion_auth->user()->row(); + $user_id = $user->id; + $user_name = $user->first_name.''. $user->last_name.'['.$user->id.']:T-'.date('d-m-Y h:m:s'); + + $status_str=""; + + $opd_status_remark=$status_str.' Update By:'.$user_name; + + $sql="select sum(if(credit_debit>0,amount*-1,amount)) as paid_amount from payment_history where payof_type=2 and payof_id=".$inv_id; + $query = $this->db->query($sql); + $payment_history= $query->result(); + + $sql="select * from invoice_master where id=".$inv_id; + $query = $this->db->query($sql); + $invoice_master= $query->result(); + + $sql="select * from refund_order where refund_process=0 and refund_type=2 and refund_type_id=".$inv_id; + $query = $this->db->query($sql); + $refund_order= $query->result(); + + if(count($payment_history)>0 && count($refund_order)<1) + { + if($payment_history[0]->paid_amount>0 && $invoice_master[0]->invoice_status==1 && $inv_refund_amount<=$payment_history[0]->paid_amount) + { + if($inv_refund_amount<0) + { + $inv_refund_amount=$inv_refund_amount*-1; + } + + $RefundRequest = array( + 'refund_type' => 2, + 'refund_type_id' => $inv_id, + 'refund_type_code' => $invoice_master[0]->invoice_code, + 'refund_type_reason' => 'Return Extra Charge', + 'approved_by_id' => $user_id, + 'approved_by' => $user_name, + 'refund_amount' => $inv_refund_amount, + 'patient_id' => $invoice_master[0]->attach_id, + 'patient_name' =>strtoupper($invoice_master[0]->inv_name) + ); + + $this->load->model('Payment_M'); + $this->Payment_M->insert_refundorder($RefundRequest); + } + } + + } + + public function deleteinvoice() + { + $inv_id=$this->input->post('inv_id'); + $this->db->delete("invoice_master", "id=".$inv_id); + $this->db->delete("invoice_item", "inv_master_id=".$inv_id); + } + +} \ No newline at end of file diff --git a/old_code_ci3/controllers/PathLab_17042021.php b/old_code_ci3/controllers/PathLab_17042021.php new file mode 100644 index 0000000..46b7398 --- /dev/null +++ b/old_code_ci3/controllers/PathLab_17042021.php @@ -0,0 +1,1750 @@ +input->is_ajax_request()) { exit('no valid req.'); } + + $this->load->model('Invoice_M'); + $this->load->model('Payment_M'); + + $invoice_id=$this->input->post('invoice_id'); + + $sql="select * from invoice_master where id='".$invoice_id."'"; + $query = $this->db->query($sql); + $inv_master= $query->result(); + + $sql="select sum(if(credit_debit=0,amount,amount*-1)) as tPayment from payment_history where payof_type=2 and payof_id='".$invoice_id."'"; + $query = $this->db->query($sql); + $payment_history= $query->result(); + + $TotPaymentR=0; + + if(count($payment_history)>0) + { + $TotPaymentR=$payment_history[0]->tPayment; + } + + $user = $this->ion_auth->user()->row(); + $user_id = $user->id; + $user_name = $user->first_name.''. $user->last_name; + + $showcontent1='
+
+ Print +
+
+ Payment Method by : '; + + $showcontent2='
'; + + $pay_remark=''; + + if($inv_master[0]->discount_amount>0) + { + $pay_remark='Dis.Amt.:'.$inv_master[0]->discount_desc.' /Amount: '. $inv_master[0]->discount_amount.'/Update:'.$inv_master[0]->disc_update_by; + } + + $amountpaid=$this->input->post('input_amount_paid'); + + if($amountpaid<0){ + $amountpaid=$amountpaid*-1; + } + + $amountbalanace=0.00; + + if($amountpaid < $inv_master[0]->net_amount ); + { + $amountbalanace=$inv_master[0]->net_amount-$TotPaymentR; + } + + if($this->input->post('mode')==1) + { + $paydata = array( + 'payment_mode'=> '1', + 'payof_type'=>'2', + 'payof_id'=>$invoice_id, + 'payof_code'=>$inv_master[0]->invoice_code, + 'credit_debit'=>'0', + 'amount'=>$amountpaid, + 'payment_date'=>date('Y-m-d H:i:s'), + 'remark'=>$pay_remark, + 'update_by'=>$user_name.'['.$user_id.']', + 'update_by_id'=>$user_id + ); + + if($amountpaid<=$amountbalanace) + { + $insert_id=$this->Payment_M->insert($paydata); + + $data = array( + 'payment_mode'=> '1', + 'payment_status'=>'1', + 'invoice_status'=>'1', + 'payment_id'=>$insert_id, + 'payment_mode_desc'=>'Cash', + 'confirm_invoice'=>date('Y-m-d H:i:s'), + 'prepared_by'=>$user_name.'['.$user_id.']', + 'prepared_by_id'=>$user_id + ); + + $this->Invoice_M->update( $data,$invoice_id); + } + + $status='CASH'; + $showcontent=$showcontent1.$status.$showcontent2; + + $rvar=array( + 'update' =>1, + 'showcontent'=>$showcontent + ); + + $encode_data = json_encode($rvar); + } + + if($this->input->post('mode')==2) + { + $FormRules = array( + array( + 'field' => 'input_card_mac', + 'label' => 'Card Bank Name', + 'rules' => 'required|min_length[3]|max_length[30]' + ) + ); + + $this->form_validation->set_rules($FormRules); + + if ($this->form_validation->run() == TRUE) + { + $paydata = array( + 'payment_mode'=> '2', + 'payof_type'=>'2', + 'payof_id'=>$invoice_id, + 'payof_code'=>$inv_master[0]->invoice_code, + 'credit_debit'=>'0', + 'amount'=>$amountpaid, + 'payment_date'=>date('Y-m-d H:i:s'), + 'remark'=>$pay_remark, + 'update_by'=>$user_name.'['.$user_id.']', + 'card_bank'=>$this->input->post('input_card_mac'), + 'cust_card'=>$this->input->post('input_card_bank'), + 'card_remark'=>$this->input->post('input_card_digit'), + 'card_tran_id'=>$this->input->post('input_card_tran'), + 'update_by_id'=>$user_id + ); + + if($amountpaid<=$amountbalanace) + { + $insert_id=$this->Payment_M->insert($paydata); + + $data = array( + 'payment_mode'=> '2', + 'payment_status'=>'1', + 'invoice_status'=>'1', + 'payment_mode_desc'=>'Bank Card', + 'confirm_invoice'=>date('Y-m-d H:i:s'), + 'payment_id'=>$insert_id, + 'card_bank'=>$this->input->post('input_card_mac'), + 'card_remark'=>$this->input->post('input_card_digit'), + 'cust_card'=>$this->input->post('input_card_bank'), + 'card_tran_id'=>$this->input->post('input_card_tran'), + 'prepared_by'=>$user_name.'['.$user_id.']', + 'prepared_by_id'=>$user_id + ); + + $this->Invoice_M->update( $data,$invoice_id); + } + + + + $status='Bank Card'; + $showcontent=$showcontent1.$status.$showcontent2; + + $rvar=array( + 'update' =>1, + 'showcontent'=>$showcontent + ); + $encode_data = json_encode($rvar); + + } + else{ + $send_error=validation_errors(); + $rvar=array( + 'update' =>0, + 'error_text'=>$send_error + ); + + $encode_data = json_encode($rvar); + } + } + + if($this->input->post('mode')==3) + { + $data = array( + 'payment_mode'=> '3', + 'payment_status'=>'1', + 'invoice_status'=>'1', + 'confirm_invoice'=>date('Y-m-d H:i:s'), + 'payment_mode_desc'=>'IPD Credit', + 'ipd_id'=>$this->input->post('ipd_id'), + 'prepared_by'=>$user_name.'['.$user_id.']', + 'prepared_by_id'=>$user_id + ); + + $this->Invoice_M->update( $data,$invoice_id); + + $sql="select * from ipd_master where id=".$this->input->post('ipd_id'); + $query = $this->db->query($sql); + $ipd_master= $query->result(); + + if(count($ipd_master)>0) + { + $data = array( + 'insurance_case_id'=>$ipd_master[0]->case_id + ); + + $this->Invoice_M->update( $data,$invoice_id); + + } + $status='IPD Credit'; + + $rvar=array( + 'update' =>1 + ); + + $encode_data = json_encode($rvar); + } + + if($this->input->post('mode')==4) + { + $data = array( + 'payment_mode'=> '4', + 'payment_status'=>'1', + 'invoice_status'=>'1', + 'payment_mode_desc'=>'Org.Case Credit', + 'confirm_invoice'=>date('Y-m-d H:i:s'), + 'insurance_case_id'=>$this->input->post('case_id'), + 'prepared_by'=>$user_name.'['.$user_id.']', + 'prepared_by_id'=>$user_id + ); + + $this->Invoice_M->update($data,$invoice_id); + + $status='Org. Credit'; + + + $rvar=array( + 'update' =>1, + 'showcontent'=>$status + ); + + $encode_data = json_encode($rvar); + + } + + if($this->input->post('mode')==5) + { + $paydata = array( + 'payment_mode'=> '1', + 'payof_type'=>'2', + 'payof_id'=>$invoice_id, + 'payof_code'=>$inv_master[0]->invoice_code, + 'credit_debit'=>'1', + 'amount'=>$amountpaid, + 'payment_date'=>date('Y-m-d H:i:s'), + 'remark'=>$pay_remark, + 'update_by'=>$user_name.'['.$user_id.']', + 'update_by_id'=>$user_id + ); + + $insert_id=$this->Payment_M->insert($paydata); + + $data = array( + 'payment_mode'=> '1', + 'payment_status'=>'1', + 'invoice_status'=>'1', + 'payment_id'=>$insert_id, + 'payment_mode_desc'=>'Cash Return', + 'confirm_invoice'=>date('Y-m-d H:i:s'), + 'prepared_by'=>$user_name.'['.$user_id.']', + 'prepared_by_id'=>$user_id + ); + + $this->Invoice_M->update( $data,$invoice_id); + + $status='CASH'; + $showcontent=$showcontent1.$status.$showcontent2; + + $rvar=array( + 'update' =>1, + 'showcontent'=>$showcontent + ); + + $encode_data = json_encode($rvar); + + } + + $sql="select sum(item_amount) as Gtotal from invoice_item where inv_master_id=".$invoice_id; + $query = $this->db->query($sql); + $data['invoiceGtotal']= $query->result(); + + $sql="select sum(if(credit_debit>0,amount*-1,amount)) as paid_amount from payment_history where payof_type=2 and payof_id=".$invoice_id; + $query = $this->db->query($sql); + $data['payment_history']= $query->result(); + + $sql="select * from invoice_master where id=".$invoice_id; + $query = $this->db->query($sql); + $data['invoice_master']= $query->result(); + + $discount_amount=$data['invoice_master'][0]->discount_amount ; + $correction_amount=$data['invoice_master'][0]->correction_amount ; + + $total_amount=$data['invoiceGtotal'][0]->Gtotal; + $net_amount=$total_amount-$discount_amount; + $net_amount=$net_amount-$correction_amount; + $paid_amount=$data['payment_history'][0]->paid_amount; + $balance_amount=$net_amount-$paid_amount; + + if($balance_amount>0 && $paid_amount>0) + { + $payment_part=1; + }else{ + $payment_part=0; + } + + $dataupdate = array( + 'total_amount' => $total_amount, + 'net_amount' => $net_amount, + 'payment_part_received' => $paid_amount, + 'payment_part_balance' => $balance_amount, + 'payment_part' => $payment_part, + ); + + $this->load->model('Invoice_M'); + $this->Invoice_M->update($dataupdate,$invoice_id); + + echo $encode_data; + } + + + + public function confirm_payment1() + { + if (!$this->input->is_ajax_request()) { exit('no valid req.'); } + + $this->load->model('Invoice_M'); + $this->load->model('Payment_M'); + + $invoice_id=$this->input->post('invoice_id'); + + $sql="select * from invoice_master where id='".$invoice_id."'"; + $query = $this->db->query($sql); + $inv_master= $query->result(); + + $user = $this->ion_auth->user()->row(); + $user_id = $user->id; + $user_name = $user->first_name.''. $user->last_name; + + $showcontent1='
+
+ Print +
+
+ Payment Method by : '; + + $showcontent2='
'; + + $pay_remark=''; + + if($inv_master[0]->discount_amount>0) + { + $pay_remark='Dis.Amt.:'.$inv_master[0]->discount_desc.' /Amount: '. $inv_master[0]->discount_amount.'/Update:'.$inv_master[0]->disc_update_by; + } + + $amountpaid=$this->input->post('input_amount_paid'); + + if($amountpaid<0){ + $amountpaid=$amountpaid*-1; + } + + $amountbalanace=0.00; + + if($amountpaid < $inv_master[0]->net_amount ); + { + $amountbalanace=$inv_master[0]->net_amount-$amountpaid; + } + + if($this->input->post('mode')==1) + { + $paydata = array( + 'payment_mode'=> '1', + 'payof_type'=>'2', + 'payof_id'=>$invoice_id, + 'payof_code'=>$inv_master[0]->invoice_code, + 'credit_debit'=>'0', + 'amount'=>$amountpaid, + 'payment_date'=>date('Y-m-d H:i:s'), + 'remark'=>$pay_remark, + 'update_by'=>$user_name.'['.$user_id.']', + 'update_by_id'=>$user_id + ); + + $insert_id=$this->Payment_M->insert($paydata); + + $data = array( + + 'payment_mode'=> '1', + 'payment_status'=>'1', + 'invoice_status'=>'1', + 'payment_id'=>$insert_id, + 'payment_mode_desc'=>'Cash', + 'confirm_invoice'=>date('Y-m-d H:i:s'), + 'prepared_by'=>$user_name.'['.$user_id.']', + 'prepared_by_id'=>$user_id + ); + + $this->Invoice_M->update( $data,$invoice_id); + + $status='CASH'; + $showcontent=$showcontent1.$status.$showcontent2; + + $rvar=array( + 'update' =>1, + 'showcontent'=>$showcontent + ); + + $encode_data = json_encode($rvar); + } + + if($this->input->post('mode')==2) + { + $FormRules = array( + array( + 'field' => 'input_card_mac', + 'label' => 'Card Bank Name', + 'rules' => 'required|min_length[3]|max_length[30]' + ) + ); + + $this->form_validation->set_rules($FormRules); + + if ($this->form_validation->run() == TRUE) + { + $paydata = array( + 'payment_mode'=> '2', + 'payof_type'=>'2', + 'payof_id'=>$invoice_id, + 'payof_code'=>$inv_master[0]->invoice_code, + 'credit_debit'=>'0', + 'amount'=>$amountpaid, + 'payment_date'=>date('Y-m-d H:i:s'), + 'remark'=>$pay_remark, + 'update_by'=>$user_name.'['.$user_id.']', + 'card_bank'=>$this->input->post('input_card_mac'), + 'cust_card'=>$this->input->post('input_card_bank'), + 'card_remark'=>$this->input->post('input_card_digit'), + 'card_tran_id'=>$this->input->post('input_card_tran'), + 'update_by_id'=>$user_id + ); + + $insert_id=$this->Payment_M->insert($paydata); + + $data = array( + 'payment_mode'=> '2', + 'payment_status'=>'1', + 'invoice_status'=>'1', + 'payment_mode_desc'=>'Bank Card', + 'confirm_invoice'=>date('Y-m-d H:i:s'), + 'payment_id'=>$insert_id, + 'card_bank'=>$this->input->post('input_card_mac'), + 'card_remark'=>$this->input->post('input_card_digit'), + 'cust_card'=>$this->input->post('input_card_bank'), + 'card_tran_id'=>$this->input->post('input_card_tran'), + 'prepared_by'=>$user_name.'['.$user_id.']', + 'prepared_by_id'=>$user_id + ); + + $this->Invoice_M->update( $data,$invoice_id); + + $status='Bank Card'; + $showcontent=$showcontent1.$status.$showcontent2; + + $rvar=array( + 'update' =>1, + 'showcontent'=>$showcontent + ); + $encode_data = json_encode($rvar); + + } + else{ + $send_error=validation_errors(); + $rvar=array( + 'update' =>0, + 'error_text'=>$send_error + ); + + $encode_data = json_encode($rvar); + } + } + + if($this->input->post('mode')==3) + { + $data = array( + 'payment_mode'=> '3', + 'payment_status'=>'1', + 'invoice_status'=>'1', + 'confirm_invoice'=>date('Y-m-d H:i:s'), + 'payment_mode_desc'=>'IPD Credit', + 'ipd_id'=>$this->input->post('ipd_id'), + 'prepared_by'=>$user_name.'['.$user_id.']', + 'prepared_by_id'=>$user_id + ); + + $this->Invoice_M->update( $data,$invoice_id); + + $sql="select * from ipd_master where id=".$this->input->post('ipd_id'); + $query = $this->db->query($sql); + $ipd_master= $query->result(); + + if(count($ipd_master)>0) + { + $data = array( + 'insurance_case_id'=>$ipd_master[0]->case_id + ); + + $this->Invoice_M->update( $data,$invoice_id); + + } + $status='IPD Credit'; + + $rvar=array( + 'update' =>1 + ); + + $encode_data = json_encode($rvar); + } + + if($this->input->post('mode')==4) + { + $data = array( + 'payment_mode'=> '4', + 'payment_status'=>'1', + 'invoice_status'=>'1', + 'payment_mode_desc'=>'Org.Case Credit', + 'confirm_invoice'=>date('Y-m-d H:i:s'), + 'insurance_case_id'=>$this->input->post('case_id'), + 'prepared_by'=>$user_name.'['.$user_id.']', + 'prepared_by_id'=>$user_id + ); + + $this->Invoice_M->update($data,$invoice_id); + + $status='Org. Credit'; + + + $rvar=array( + 'update' =>1, + 'showcontent'=>$status + ); + + $encode_data = json_encode($rvar); + + } + + if($this->input->post('mode')==5) + { + $paydata = array( + 'payment_mode'=> '1', + 'payof_type'=>'2', + 'payof_id'=>$invoice_id, + 'payof_code'=>$inv_master[0]->invoice_code, + 'credit_debit'=>'1', + 'amount'=>$amountpaid, + 'payment_date'=>date('Y-m-d H:i:s'), + 'remark'=>$pay_remark, + 'update_by'=>$user_name.'['.$user_id.']', + 'update_by_id'=>$user_id + ); + + $insert_id=$this->Payment_M->insert($paydata); + + $data = array( + 'payment_mode'=> '1', + 'payment_status'=>'1', + 'invoice_status'=>'1', + 'payment_id'=>$insert_id, + 'payment_mode_desc'=>'Cash Return', + 'confirm_invoice'=>date('Y-m-d H:i:s'), + 'prepared_by'=>$user_name.'['.$user_id.']', + 'prepared_by_id'=>$user_id + ); + + $this->Invoice_M->update( $data,$invoice_id); + + $status='CASH'; + $showcontent=$showcontent1.$status.$showcontent2; + + $rvar=array( + 'update' =>1, + 'showcontent'=>$showcontent + ); + + $encode_data = json_encode($rvar); + + } + + $sql="select sum(item_amount) as Gtotal from invoice_item where inv_master_id=".$invoice_id; + $query = $this->db->query($sql); + $data['invoiceGtotal']= $query->result(); + + $sql="select sum(if(credit_debit>0,amount*-1,amount)) as paid_amount from payment_history where payof_type=2 and payof_id=".$invoice_id; + $query = $this->db->query($sql); + $data['payment_history']= $query->result(); + + $sql="select * from invoice_master where id=".$invoice_id; + $query = $this->db->query($sql); + $data['invoice_master']= $query->result(); + + $discount_amount=$data['invoice_master'][0]->discount_amount ; + $correction_amount=$data['invoice_master'][0]->correction_amount ; + + $total_amount=$data['invoiceGtotal'][0]->Gtotal; + $net_amount=$total_amount-$discount_amount; + $net_amount=$net_amount-$correction_amount; + $paid_amount=$data['payment_history'][0]->paid_amount; + $balance_amount=$net_amount-$paid_amount; + + if($balance_amount>0 && $paid_amount>0) + { + $payment_part=1; + }else{ + $payment_part=0; + } + + $dataupdate = array( + 'total_amount' => $total_amount, + 'net_amount' => $net_amount, + 'payment_part_received' => $paid_amount, + 'payment_part_balance' => $balance_amount, + 'payment_part' => $payment_part, + ); + + $this->load->model('Invoice_M'); + $this->Invoice_M->update($dataupdate,$invoice_id); + + echo $encode_data; + } + + public function IPD_Invoice_Edit($Invoice_ID) + { + $sql="select * from invoice_master where id=".$Invoice_ID; + $query = $this->db->query($sql); + $data['invoiceMaster']= $query->result(); + + $sql="select i.*,t.group_desc from invoice_item i join hc_item_type t on i.item_type=t.itype_id where i.inv_master_id=".$Invoice_ID; + $query = $this->db->query($sql); + $data['invoiceDetails']= $query->result(); + + $sql="select sum(item_amount) as Gtotal from invoice_item where inv_master_id=".$Invoice_ID; + $query = $this->db->query($sql); + $data['invoiceGtotal']= $query->result(); + + $pno=$data['invoiceMaster'][0]->attach_id; + $ipd_no=$data['invoiceMaster'][0]->ipd_id; + $ins_id=$data['invoiceMaster'][0]->insurance_card_id; + + $sql="select *,if(gender=1,'Male','Female') as xgender, + GET_AGE_1(dob,age,age_in_month,estimate_dob) AS age from patient_master where id='".$pno."' "; + $query = $this->db->query($sql); + $data['person_info']= $query->result(); + + if($ins_id>0) + { + $sql="select * from hc_item_type order by group_desc"; + }else{ + $sql="select * from hc_item_type where itype_id<>33 order by group_desc "; + } + $query = $this->db->query($sql); + $data['labitemtype']= $query->result(); + + $path_cash=1; + $path_credit=1; + + $ins_comp_id=0; + if($ins_id>0) + { + $sql="select * from hc_insurance_card where id=".$ins_id; + $query = $this->db->query($sql); + $data['hc_insurance_card']= $query->result(); + + $ins_comp_id=$data['hc_insurance_card'][0]->insurance_id; + + $sql="select * from hc_insurance where id=".$ins_comp_id; + $query = $this->db->query($sql); + $data['insurance']= $query->result(); + + $path_cash=$data['insurance'][0]->path_cash; + $path_credit=$data['insurance'][0]->path_credit; + } + + $data['pdata']=$ins_comp_id; + + $sql="select * from doctor_master where active=1 order by p_fname"; + $query = $this->db->query($sql); + $data['doclist']= $query->result(); + + + if($ins_comp_id<2) + { + $sql="select id,Concat(idesc,' : {',amount,'}') as sdesc from hc_items where itype=1 order by idesc "; + }else{ + $sql="select m.id,m.itype,m.idesc,m.amount,t.itype_id,t.is_ipd_opd,t.group_desc, + i.hc_insurance_id ,if(i.hc_insurance_id is null,m.amount,i.amount1) as amount1, + Concat(m.idesc,'{',if(i.hc_insurance_id is null,m.amount,i.amount1),'}',if(i.id is null,'',concat('[',i.code,']'))) as sdesc + from (hc_items m join hc_item_type t on m.itype=t.itype_id) + left join + (select * from hc_items_insurance where hc_insurance_id=".$ins_comp_id." and isdelete=0 ) as i on m.id=i.hc_items_id + where itype_id=1 order by m.idesc"; + } + + $query = $this->db->query($sql); + $data['labitem']= $query->result(); + + $this->load->model('invoice_M'); + + $today = date("Y-m-d"); + $expire = $data['invoiceMaster'][0]->inv_date; //from db + + $today_dt = new DateTime($today); + $inv_dt = new DateTime($expire); + + $sql="select *,if(ipd_status=0,DATEDIFF(sysdate(),register_date),DATEDIFF(discharge_date,register_date)) as no_days from ipd_master where id=".$data['invoiceMaster'][0]->ipd_id; + $query = $this->db->query($sql); + $data['ipd_master']= $query->result(); + + if(count($data['ipd_master'])>0) + { + if($data['ipd_master'][0]->ipd_status==0) + { + $ipd_status=0; + }else{ + $ipd_status=1; + } + }else{ + $ipd_status=1; + } + + if($this->ion_auth->in_group('ChargeInvoiceUpdate') || ($ipd_status==0 && $this->ion_auth->in_group('IPDPayment') )) + { + $this->load->view('Invoice_PathLab',$data); + }else{ + + } + + //$this->load->view('Invoice_ipd_credit',$data); + } + + + public function addPathTest($pno,$ins_id=0,$opd_id=0) + { + $sql="select *,if(gender=1,'Male','Female') as xgender, + GET_AGE_1(dob,age,age_in_month,estimate_dob) AS age from patient_master where id='".$pno."' "; + $query = $this->db->query($sql); + $data['person_info']= $query->result(); + + if($opd_id>0) + { + $sql="select * from opd_master where p_id='".$pno."' and opd_id=".$opd_id." order by opd_id desc limit 1"; + }else{ + $sql="select * from opd_master where p_id='".$pno."' order by opd_id desc limit 1"; + } + $query = $this->db->query($sql); + $data['opd_master']= $query->result(); + + if(count($data['opd_master'])>0) + { + $select_doc=$data['opd_master'][0]->doc_id; + $opd_code=$data['opd_master'][0]->opd_code; + }else{ + $select_doc=0; + $opd_code=''; + } + + $sql="select l.doc_id from ipd_master p join ipd_master_doc_list l on p.id=l.ipd_id + where p.ipd_status=0 and p.p_id=".$pno." "; + $query = $this->db->query($sql); + $data['ipd_master_docid']= $query->result(); + + if(count($data['ipd_master_docid'])>0) + { + $select_doc=$data['ipd_master_docid'][0]->doc_id; + } + + if($ins_id>0) + { + $sql="select * from hc_item_type order by group_desc"; + }else{ + $sql="select * from hc_item_type where itype_id<>33 order by group_desc"; + } + + $query = $this->db->query($sql); + $data['labitemtype']= $query->result(); + + $path_cash=1; + $path_credit=1; + + + $ins_comp_id=0; + if($ins_id>0) + { + $sql="select * from hc_insurance_card where id=".$ins_id; + $query = $this->db->query($sql); + $data['hc_insurance_card']= $query->result(); + + $ins_comp_id=$data['hc_insurance_card'][0]->insurance_id; + + $sql="select * from hc_insurance where id=".$ins_comp_id; + $query = $this->db->query($sql); + $data['insurance']= $query->result(); + + $path_cash=$data['insurance'][0]->path_cash; + $path_credit=$data['insurance'][0]->path_credit; + } + + $data['pdata']=$ins_comp_id; + + $sql="select * from doctor_master where active=1 order by p_fname"; + $query = $this->db->query($sql); + $data['doclist']= $query->result(); + + + + + if($ins_comp_id<2) + { + $sql="select id,Concat(idesc,' : {',amount,'}') as sdesc from hc_items where itype=1 order by idesc "; + }else{ + $sql="select m.id,m.itype,m.idesc,m.amount,t.itype_id,t.is_ipd_opd,t.group_desc, + i.hc_insurance_id ,if(i.hc_insurance_id is null,m.amount,i.amount1) as amount1, + Concat(m.idesc,'{',if(i.hc_insurance_id is null,m.amount,i.amount1),'}',if(i.id is null,'',concat('[',i.code,']'))) as sdesc + from (hc_items m join hc_item_type t on m.itype=t.itype_id) + left join + (select * from hc_items_insurance where hc_insurance_id=".$ins_comp_id." and isdelete=0 ) as i on m.id=i.hc_items_id + where itype_id=1 order by m.idesc"; + } + + $query = $this->db->query($sql); + $data['labitem']= $query->result(); + + $this->load->model('invoice_M'); + + if($ins_id>0) + { + $sql="select * from invoice_master where invoice_status=0 and insurance_card_id>0 and attach_id=".$pno; + }else{ + $sql="select * from invoice_master where invoice_status=0 and insurance_card_id=0 and attach_id=".$pno; + } + + $query = $this->db->query($sql); + $data['chk_draft_invoice']= $query->result(); + + if(count($data['chk_draft_invoice'])<1) + { + $data['insert_invoice'] = array( + 'attach_type' => '0', + 'opd_code' => $opd_code, + 'attach_id' => $pno, + 'refer_by_id' => $select_doc, + 'inv_date' => date('Y-m-d H:i:s'), + 'inv_name' => $data['person_info'][0]->p_fname, + 'insurance_id' => $ins_comp_id, + 'insurance_card_id' => $ins_id, + 'insurance_cash' => $path_cash, + 'insurance_credit' => $path_credit, + 'inv_a_code' => $data['person_info'][0]->p_code + ); + $inser_id=$this->invoice_M->create_invoice( $data['insert_invoice']); + }else{ + $today = date("Y-m-d"); + $expire = $data['chk_draft_invoice'][0]->inv_date; //from db + + $today_dt = new DateTime($today); + $inv_dt = new DateTime($expire); + + if ($inv_dt < $today_dt) { + + //$this->db->delete("invoice_master", "id=".$data['chk_draft_invoice'][0]->id); + //$this->db->delete("invoice_item", "inv_master_id=".$data['chk_draft_invoice'][0]->id); + + $data['insert_invoice'] = array( + 'attach_type' => '0', + 'attach_id' => $pno, + 'opd_code' => $opd_code, + 'refer_by_id' => $select_doc, + 'inv_date' => date('Y-m-d H:i:s'), + 'inv_name' => $data['person_info'][0]->p_fname, + 'insurance_id' => $ins_comp_id, + 'insurance_card_id' => $ins_id, + 'insurance_cash' => $path_cash, + 'insurance_credit' => $path_credit, + 'inv_a_code' => $data['person_info'][0]->p_code + ); + //$inser_id=$data['chk_draft_invoice'][0]->id; + $inser_id=$this->invoice_M->create_invoice( $data['insert_invoice']); + }else{ + $inser_id=$data['chk_draft_invoice'][0]->id; + } + } + + if($inser_id) + { + $sql="select * from invoice_master where id=".$inser_id; + $query = $this->db->query($sql); + $data['invoiceMaster']= $query->result(); + + $sql="select i.*,t.group_desc from invoice_item i join hc_item_type t on i.item_type=t.itype_id where i.inv_master_id=".$inser_id; + $query = $this->db->query($sql); + $data['invoiceDetails']= $query->result(); + + $sql="select sum(item_amount) as Gtotal from invoice_item where inv_master_id=".$inser_id; + $query = $this->db->query($sql); + $data['invoiceGtotal']= $query->result(); + } + + $sql="select *,if(ipd_status=0,DATEDIFF(sysdate(),register_date),DATEDIFF(discharge_date,register_date)) as no_days from ipd_master where ipd_status=0 and p_id=".$data['invoiceMaster'][0]->attach_id; + $query = $this->db->query($sql); + $data['ipd_master']= $query->result(); + + $this->load->view('Invoice_PathLab',$data); + //$this->load->view('Invoice_ipd_credit',$data); + } + + public function list_pathtest_bytype() + { + $tid=$this->input->post('itype_idv'); + $ins_id=$this->input->post('ins_id'); + + $sql="select id,Concat(idesc,' : {',amount,'}') as sdesc from hc_items where itype=".$tid; + + if($ins_id>1) + { + $sql="select m.id,m.itype,m.idesc,m.amount,t.itype_id,t.is_ipd_opd,t.group_desc, + i.hc_insurance_id ,if(i.hc_insurance_id is null,m.amount,i.amount1) as amount1, + Concat(m.idesc,'{',if(i.hc_insurance_id is null,m.amount,i.amount1),'}',if(i.id is null,'',concat('[',i.code,']'))) as sdesc + from (hc_items m join hc_item_type t on m.itype=t.itype_id) + left join + (select * from hc_items_insurance where hc_insurance_id=".$ins_id." and isdelete=0 ) as i on m.id=i.hc_items_id + where itype_id=".$tid." order by m.idesc "; + }else{ + $sql="select id,Concat(idesc,' : [',amount,']') as sdesc from hc_items where itype=".$tid." order by idesc "; + } + + $query = $this->db->query($sql); + $data['labitem']= $query->result(); + + echo '
+ +
'; + + } + + public function update_refer_doc() + { + $invoice_id=$this->input->post('inv_id'); + $doc_id=$this->input->post('doc_id'); + $inv_date=$this->input->post('inv_date'); + + $sql="select sum(item_amount) as Gtotal from invoice_item where inv_master_id=".$invoice_id; + $query = $this->db->query($sql); + $data['invoiceGtotal']= $query->result(); + + $sql="select sum(if(credit_debit>0,amount*-1,amount)) as paid_amount from payment_history where payof_type=2 and payof_id=".$invoice_id; + $query = $this->db->query($sql); + $data['payment_history']= $query->result(); + + $sql="select * from invoice_master where id=".$invoice_id; + $query = $this->db->query($sql); + $data['invoice_master']= $query->result(); + + $discount_amount=$data['invoice_master'][0]->discount_amount ; + $correction_amount=$data['invoice_master'][0]->correction_amount ; + + $total_amount=$data['invoiceGtotal'][0]->Gtotal; + $net_amount=$total_amount-$discount_amount; + $net_amount=$net_amount-$correction_amount; + $paid_amount=$data['payment_history'][0]->paid_amount; + $balance_amount=$net_amount-$paid_amount; + + if($balance_amount>0 && $paid_amount>0) + { + $payment_part=1; + }else{ + $payment_part=0; + } + + if($doc_id<1) + { + $refername=$this->input->post('refername'); + }else{ + $sql="select * from doctor_master where id=".$doc_id; + $query = $this->db->query($sql); + $data['doc_master']= $query->result(); + $refername=$data['doc_master'][0]->p_fname; + } + + + + if($this->ion_auth->in_group('InvoiceDateChanged')) + { + $inv_date=str_to_MysqlDate($inv_date); + }else{ + $inv_date=$data['invoice_master'][0]->inv_date; + } + + $dataupdate = array( + 'total_amount' => $total_amount, + 'net_amount' => $net_amount, + 'payment_part_received' => $paid_amount, + 'payment_part_balance' => $balance_amount, + 'payment_part' => $payment_part, + 'refer_by_id' => $doc_id, + 'inv_date' => $inv_date, + 'refer_by_other' => $refername, + 'invoice_status' =>'1', + ); + + $this->load->model('Invoice_M'); + $this->Invoice_M->update($dataupdate,$invoice_id); + + } + + public function get_echs_id() + { + $itype_name_id_srno=$this->input->post('input_charge_code'); + $tid=$this->input->post('itype_idv'); + + $sql="select * from hc_items where itype=".$tid." and echs_sr_no='".$itype_name_id_srno."'"; + //echo $sql; + $query = $this->db->query($sql); + $data['echs_data']= $query->result(); + + if($query->num_rows()>0) + { + echo $data['echs_data'][0]->id; + }else{ + echo '0'; + } + } + + + + public function showinvoice($invoice_id) + { + $sql="select i.*,t.group_desc from invoice_item i join hc_item_type t on i.item_type=t.itype_id where i.inv_master_id=".$invoice_id; + $query = $this->db->query($sql); + $data['invoiceDetails']= $query->result(); + + $sql="select sum(item_amount) as Gtotal from invoice_item where inv_master_id=".$invoice_id; + $query = $this->db->query($sql); + $data['invoiceGtotal']= $query->result(); + + $sql="select * from invoice_master where id=".$invoice_id; + $query = $this->db->query($sql); + $data['invoice_master']= $query->result(); + + $ins_comp_id=$data['invoice_master'][0]->insurance_id; + $ins_id=$data['invoice_master'][0]->insurance_card_id; + + $sql="select * from hc_insurance_card where id=".$ins_id; + $query = $this->db->query($sql); + $data['hc_insurance_card']= $query->result(); + + $sql="select * from hc_insurance where id=".$ins_comp_id; + $query = $this->db->query($sql); + $data['insurance']= $query->result(); + + $sql="select sum(if(credit_debit>0,amount*-1,amount)) as paid_amount + from payment_history where payof_type=2 and payof_id=".$invoice_id; + $query = $this->db->query($sql); + $data['payment_history']= $query->result(); + + $sql="select *,(case payment_mode when 1 Then 'Cash' when 2 then 'Bank Card' when 3 then 'IPD Credit' when 4 then 'Org. Credit' else 'Pending' end) as Payment_type_str from invoice_master where id=".$invoice_id; + $query = $this->db->query($sql); + $data['invoice_master']= $query->result(); + + $discount_amount=$data['invoice_master'][0]->discount_amount ; + $correction_amount=$data['invoice_master'][0]->correction_amount ; + + $total_amount=$data['invoiceGtotal'][0]->Gtotal; + $net_amount=$total_amount-$discount_amount; + $net_amount=$net_amount-$correction_amount; + $paid_amount=$data['payment_history'][0]->paid_amount; + $balance_amount=$net_amount-$paid_amount; + + if($balance_amount>0 && $paid_amount>0) + { + $payment_part=1; + }else{ + $payment_part=0; + } + + $dataupdate = array( + 'total_amount' => $total_amount, + 'net_amount' => $net_amount, + 'payment_part_received' => $paid_amount, + 'payment_part_balance' => $balance_amount, + 'payment_part' => $payment_part + ); + + $this->load->model('Invoice_M'); + $this->Invoice_M->update($dataupdate,$invoice_id); + + $sql="select *,if(gender=1,'Male','Female') as xgender, + GET_AGE_1(dob,age,age_in_month,estimate_dob) AS age from patient_master where id=".$data['invoice_master'][0]->attach_id; + $query = $this->db->query($sql); + $data['patient_master']= $query->result(); + + $sql="select * from ipd_master where ipd_status=0 and p_id=".$data['invoice_master'][0]->attach_id; + + if($data['invoice_master'][0]->ipd_id >0) + { + $sql="select * from ipd_master where id=".$data['invoice_master'][0]->ipd_id; + } + $query = $this->db->query($sql); + $data['ipd_master']= $query->result(); + + $sql="select * from invoice_item i join hc_item_type t on i.item_type=t.itype_id where t.is_ipd_opd=2 and i.inv_master_id=".$invoice_id; + $query = $this->db->query($sql); + $IPD_Credit= $query->result(); + + if(count($IPD_Credit)>0) + { + $data['IPD_Credit']="1"; + }else{ + $data['IPD_Credit']="0"; + } + + $sql="select * from organization_case_master where status=0 and p_id=".$data['invoice_master'][0]->attach_id; + + + if($data['invoice_master'][0]->insurance_case_id>0) + { + $sql="select * from organization_case_master where id=".$data['invoice_master'][0]->insurance_case_id; + }elseif(count($data['ipd_master'])>0){ + if($data['ipd_master'][0]->case_id>0) + { + $sql="select * from organization_case_master where id=".$data['ipd_master'][0]->case_id; + } + } + + $query = $this->db->query($sql); + $data['case_master']= $query->result(); + + $this->load->view('Invoice_PathLab_final_V',$data); + } + + public function update_discount() + { + $invoice_id=$this->input->post('invoice_id'); + + $user = $this->ion_auth->user()->row(); + $user_id = $user->id; + $user_name = $user->first_name.''. $user->last_name; + + $dataupdate = array( + 'discount_amount' => $this->input->post('input_dis_amt'), + 'discount_desc' => $this->input->post('input_dis_desc'), + 'disc_update_by'=>$user_name.'['.$user_id.']' + ); + $this->load->model('Invoice_M'); + $this->Invoice_M->update($dataupdate,$invoice_id); + + $sql="select sum(item_amount) as Gtotal from invoice_item where inv_master_id=".$invoice_id; + $query = $this->db->query($sql); + $data['invoiceGtotal']= $query->result(); + + $sql="select sum(if(credit_debit>0,amount*-1,amount)) as paid_amount from payment_history where payof_type=2 and payof_id=".$invoice_id; + $query = $this->db->query($sql); + $data['payment_history']= $query->result(); + + $sql="select * from invoice_master where id=".$invoice_id; + $query = $this->db->query($sql); + $data['invoice_master']= $query->result(); + + $discount_amount=$data['invoice_master'][0]->discount_amount ; + $correction_amount=$data['invoice_master'][0]->correction_amount ; + + $total_amount=$data['invoiceGtotal'][0]->Gtotal; + $net_amount=$total_amount-$discount_amount; + $net_amount=$net_amount-$correction_amount; + $paid_amount=$data['payment_history'][0]->paid_amount; + $balance_amount=$net_amount-$paid_amount; + + if($balance_amount>0 && $paid_amount>0) + { + $payment_part=1; + }else{ + $payment_part=0; + } + + $dataupdate = array( + 'total_amount' => $total_amount, + 'net_amount' => $net_amount, + 'payment_part_received' => $paid_amount, + 'payment_part_balance' => $balance_amount, + 'payment_part' => $payment_part, + ); + + $this->load->model('Invoice_M'); + $this->Invoice_M->update($dataupdate,$invoice_id); + + } + + + public function showitem($type) + { + $this->load->model('invoice_M'); + + if($type==1) + { + $ins_id=$this->input->post('ins_id'); + + $sql="select * from hc_items where id=".$this->input->post('itype_name_id'); + if($ins_id>1) + { + $sql="select m.id,m.itype,m.idesc as sdesc,m.amount,t.itype_id,t.is_ipd_opd,t.group_desc,i.isdelete, + if(i.hc_insurance_id is null,0,i.hc_insurance_id) as hc_insurance_id ,if(i.hc_insurance_id is null, + m.amount,i.amount1) as amount1, + if(i.hc_insurance_id is null,'',i.code) as org_code + from (hc_items m left join hc_items_insurance i on m.id=i.hc_items_id and i.isdelete=0 and i.hc_insurance_id=".$ins_id." ) + join hc_item_type t on m.itype=t.itype_id where m.id=".$this->input->post('itype_name_id'); + + $query = $this->db->query($sql); + $data['itemlist']= $query->result(); + + $item_rate=$data['itemlist'][0]->amount1; + $org_code=$data['itemlist'][0]->org_code; + + $item_custom_rate=$this->input->post('input_rate'); + + if($item_custom_rate>0) + { + $item_rate=$item_custom_rate; + } + + $amount_value=$this->input->post('input_qty')*$item_rate; + + } + else + { + $sql="select id,idesc as sdesc,amount from hc_items where id=".$this->input->post('itype_name_id'); + + $query = $this->db->query($sql); + $data['itemlist']= $query->result(); + + $item_rate=$data['itemlist'][0]->amount; + + $org_code=''; + + $item_custom_rate=$this->input->post('input_rate'); + + if($item_custom_rate>0) + { + $item_rate=$item_custom_rate; + } + $amount_value=$this->input->post('input_qty')*$item_rate; + } + + $data['insert_invoice_item'] = array( + 'inv_master_id' => $this->input->post('lab_invoice_id'), + 'item_type' => $this->input->post('itype_idv'), + 'item_id' => $this->input->post('itype_name_id'), + 'item_name' => $data['itemlist'][0]->sdesc, + 'item_rate' => $item_rate, + 'item_added_date' => str_to_MysqlDate(date('d/m/Y')), + 'item_qty' => $this->input->post('input_qty'), + 'item_amount' => $amount_value, + 'ins_id' => $ins_id, + 'org_code' => $org_code + ); + + $sql="select * from invoice_item where inv_master_id=".$this->input->post('lab_invoice_id')." and item_id=".$this->input->post('itype_name_id'); + $query = $this->db->query($sql); + + $itemcheck= $query->result(); + + if(count($itemcheck)<1) + { + $inser_id=$this->invoice_M->addinvoiceitem( $data['insert_invoice_item']); + } + + }if($type==2) + { + $amount_value=$this->input->post('update_qty') * $this->input->post('item_rate'); + + $data['update_invoice_item'] = array( + 'item_added_date' => str_to_MysqlDate(date('d/m/Y')), + 'item_qty' => $this->input->post('update_qty'), + 'item_amount' => $amount_value + ); + + $inser_id=$this->invoice_M->update_item( $data['update_invoice_item'],$this->input->post('itemid')); + + }else{ + $this->invoice_M->deleteinvoiceitem($this->input->post('itemid')); + echo 'DataDelete '.$this->input->post('itemid'); + //$this->db->delete("invoice_item", "id=".$this->input->post('itemid')); + } + + $sql="select i.*,t.group_desc from invoice_item i join hc_item_type t on i.item_type=t.itype_id where i.inv_master_id=".$this->input->post('lab_invoice_id')." Order by i.id"; + $query = $this->db->query($sql); + $data['invoiceDetails']= $query->result(); + + $invoice_id=$this->input->post('lab_invoice_id'); + + $sql="select * from invoice_master where id=".$invoice_id; + $query = $this->db->query($sql); + $data['invoice_master']= $query->result(); + + $sql="select sum(item_amount) as Gtotal from invoice_item where inv_master_id=".$this->input->post('lab_invoice_id'); + $query = $this->db->query($sql); + $data['invoiceGtotal']= $query->result(); + + $total_amount=$data['invoiceGtotal'][0]->Gtotal; + $discount_amount=$data['invoice_master'][0]->discount_amount ; + $total_amount=$data['invoiceGtotal'][0]->Gtotal; + $net_amount=$total_amount-$discount_amount; + + $dataupdate = array( + 'total_amount' => $total_amount, + 'net_amount' => $net_amount + ); + + $this->load->model('Invoice_M'); + $this->Invoice_M->update($dataupdate,$invoice_id); + + + echo ' + + + + + + + + + + '; + + $srno=0; + + foreach($data['invoiceDetails'] as $row) + { + $srno=$srno+1; + echo ''; + echo ''; + echo ''; + echo ''; + if(in_array($row->item_type, array(1,2,3,4,5))) + { + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + } + + echo ''; + + echo ' + + + + + + + + + +
#Charge TypeCharge NameRateQtyUpdated QtyAmount
'.$srno.''.$row->group_desc.''.$row->item_name.''.$row->item_rate.''.$row->item_qty.''.$row->item_amount.''; + }else{ + echo ''.$row->item_rate.''.$row->item_amount.''; + echo ''; + } + + $sql="select * from lab_request where charge_item_id=".$row->id; + $query = $this->db->query($sql); + $lab_request= $query->result(); + + if(count($lab_request)<1) + { + echo ''; + } + + echo '
#Gross Total'.$data['invoiceGtotal'][0]->Gtotal.'
'; + } + + public function invoice_print($invoice_id) + { + $sql="select i.*,t.group_desc from invoice_item i join hc_item_type t on i.item_type=t.itype_id where i.inv_master_id=".$invoice_id." order by i.id"; + $query = $this->db->query($sql); + $data['invoiceDetails']= $query->result(); + + $sql="select sum(item_amount) as Gtotal from invoice_item where inv_master_id=".$invoice_id; + $query = $this->db->query($sql); + $data['invoiceGtotal']= $query->result(); + + $sql="select *,(case invoice_status when 0 then 'Pending' when 1 then '' when 2 then 'Cancelled Invoice' else 'Other' end) as Invoice_status_str, + (case payment_mode when 1 Then 'Cash' when 2 then 'Bank Card' + when 3 then 'IPD Credit' when 4 then 'Org. Credit' else 'Pending' end) as Payment_type_str + from invoice_master where id=".$invoice_id; + $query = $this->db->query($sql); + $data['invoice_master']= $query->result(); + + $sql="select *,if(gender=1,'Male','Female') as xgender, + GET_AGE_2(dob,age,age_in_month,estimate_dob,'".$data['invoice_master'][0]->inv_date."') AS age from patient_master + where id=".$data['invoice_master'][0]->attach_id; + $query = $this->db->query($sql); + $data['patient_master']= $query->result(); + + $sql="select *,get_payment_type(payment_mode,credit_debit) as Payment_type_str from payment_history where payof_type=2 and payof_id=".$invoice_id; + $query = $this->db->query($sql); + $data['payment_history']= $query->result(); + + $ins_comp_id=$data['invoice_master'][0]->insurance_id; + $ins_id=$data['invoice_master'][0]->insurance_card_id; + + $sql="select * from hc_insurance_card where id=".$ins_id; + $query = $this->db->query($sql); + $data['hc_insurance_card']= $query->result(); + + $sql="select * from hc_insurance where id=".$ins_comp_id; + $query = $this->db->query($sql); + $data['insurance']= $query->result(); + + + + $sql="select * from organization_case_master where id=".$data['invoice_master'][0]->insurance_case_id; + $query = $this->db->query($sql); + $data['case_master']= $query->result(); + + $this->load->view('invoice_pathlab_print_V',$data); + + } + + public function charge_crorg($inv_id,$org_code_id) + { + $user = $this->ion_auth->user()->row(); + $user_id = $user->id; + $user_name = $user->first_name.''. $user->last_name.'['.$user->id.']:T-'.date('d-m-Y h:m:s'); + + $status_str=""; + + $opd_status_remark=$status_str.' Update By:'.$user_name; + + $sql="select sum(if(credit_debit>0,amount*-1,amount)) as paid_amount from payment_history where payof_type=2 and payof_id=".$inv_id; + $query = $this->db->query($sql); + $payment_history= $query->result(); + + $sql="select * from invoice_master where id=".$inv_id; + $query = $this->db->query($sql); + $invoice_master= $query->result(); + + $sql="select * from refund_order where refund_process=0 and refund_type=2 and refund_type_id=".$inv_id; + $query = $this->db->query($sql); + $refund_order= $query->result(); + + if(count($payment_history)>0 && count($refund_order)<1) + { + if($payment_history[0]->paid_amount>0 && $invoice_master[0]->invoice_status==1) + { + $RefundRequest = array( + 'refund_type' => 2, + 'refund_type_id' => $inv_id, + 'refund_type_code' => $invoice_master[0]->invoice_code, + 'refund_type_reason' => 'Cr. to Org.', + 'approved_by_id' => $user_id, + 'approved_by' => $user_name, + 'refund_amount' => $payment_history[0]->paid_amount, + 'patient_id' => $invoice_master[0]->attach_id, + 'patient_name' =>strtoupper($invoice_master[0]->inv_name) + ); + + $this->load->model('Payment_M'); + $this->Payment_M->insert_refundorder($RefundRequest); + } + } + + $dataupdate = array( + 'payment_mode' => 4, + 'payment_mode_desc' => 'Org. Credit', + 'payment_id' => 0, + 'insurance_case_id' => $org_code_id, + ); + + $this->load->model('Invoice_M'); + $this->Invoice_M->update($dataupdate,$inv_id); + } + + public function invoice_PDF_print($invoice_id,$page_size=0) + { + $sql="select i.*,t.group_desc + from invoice_item i join hc_item_type t on i.item_type=t.itype_id + where i.inv_master_id=".$invoice_id." order by t.group_desc,i.id"; + $query = $this->db->query($sql); + $data['invoiceDetails']= $query->result(); + + $sql="select sum(item_amount) as Gtotal from invoice_item where inv_master_id=".$invoice_id; + $query = $this->db->query($sql); + $data['invoiceGtotal']= $query->result(); + + $sql="select *,(case invoice_status when 0 then 'Pending' when 1 then '' when 2 then 'Cancelled Invoice' else 'Other' end) as Invoice_status_str, + (case payment_mode when 1 Then 'Cash' when 2 then 'Bank Card' + when 3 then 'IPD Credit' when 4 then 'Org. Credit' else 'Pending' end) as Payment_type_str , + date_format(confirm_invoice,'%d-%m-%Y %H:%i:%s') as confirm_invoice_datetime + from invoice_master where id=".$invoice_id; + $query = $this->db->query($sql); + $data['invoice_master']= $query->result(); + + $sql="select *,if(gender=1,'M','F') as xgender, + GET_AGE_2(dob,age,age_in_month,estimate_dob,'".$data['invoice_master'][0]->inv_date."') AS age from patient_master + where id='".$data['invoice_master'][0]->attach_id."' "; + $query = $this->db->query($sql); + $data['patient_master']= $query->result(); + + $sql="select *,get_payment_type(payment_mode,credit_debit) as Payment_type_str + from payment_history where payof_type=2 and payof_id=".$invoice_id; + $query = $this->db->query($sql); + $data['payment_history']= $query->result(); + + $ins_comp_id=$data['invoice_master'][0]->insurance_id; + $ins_id=$data['invoice_master'][0]->insurance_card_id; + + $sql="select * from hc_insurance_card where id=".$ins_id; + $query = $this->db->query($sql); + $hc_insurance_card= $query->result(); + + $sql="select * from hc_insurance where id=".$ins_comp_id; + $query = $this->db->query($sql); + $insurance= $query->result(); + + $sql="select * from organization_case_master where id=".$data['invoice_master'][0]->insurance_case_id; + $query = $this->db->query($sql); + $case_master= $query->result(); + + //load mPDF library + + $this->load->library('m_pdf'); + + $this->m_pdf->pdf->SetWatermarkText(H_Name); + $this->m_pdf->pdf->showWatermarkText = true; + + $file_name='Charge_Invoice-'.date('Ymdhis').".pdf"; + + $filepath=$file_name; + + if($page_size==0) + { + $content=$this->load->view('Invoice/invoice_print',$data,TRUE); + }elseif($page_size==1){ + $content=$this->load->view('Invoice/invoice_print_a5',$data,TRUE); + }elseif($page_size==2){ + $content=$this->load->view('Invoice/invoice_print_a4_double',$data,TRUE); + } + + //echo $content; + + //generate the PDF from the given html + $this->m_pdf->pdf->WriteHTML($content); + + //download it. + $this->m_pdf->pdf->Output("TEST.pdf","I"); + + } + + + + public function charge_crIPD($inv_id,$ipd_id) + { + $user = $this->ion_auth->user()->row(); + $user_id = $user->id; + $user_name = $user->first_name.''. $user->last_name.'['.$user->id.']:T-'.date('d-m-Y h:m:s'); + + $status_str=""; + + $opd_status_remark=$status_str.' Update By:'.$user_name; + + $sql="select sum(if(credit_debit>0,amount*-1,amount)) as paid_amount + from payment_history where payof_type=2 and payof_id=".$inv_id; + $query = $this->db->query($sql); + $payment_history= $query->result(); + + $sql="select * from invoice_master where id=".$inv_id; + $query = $this->db->query($sql); + $invoice_master= $query->result(); + + $sql="select * from ipd_master where id=".$ipd_id; + $query = $this->db->query($sql); + $ipd_master= $query->result(); + + $sql="select * from refund_order where refund_process=0 and refund_type=2 and refund_type_id=".$inv_id; + $query = $this->db->query($sql); + $refund_order= $query->result(); + + if(count($payment_history)>0 && count($refund_order)<1) + { + if($payment_history[0]->paid_amount>0 && $invoice_master[0]->invoice_status==1) + { + $RefundRequest = array( + 'refund_type' => 2, + 'refund_type_id' => $inv_id, + 'refund_type_code' => $invoice_master[0]->invoice_code, + 'refund_type_reason' => 'Cr. to IPD.', + 'approved_by_id' => $user_id, + 'approved_by' => $user_name, + 'refund_amount' => $payment_history[0]->paid_amount, + 'patient_id' => $invoice_master[0]->attach_id, + 'patient_name' =>strtoupper($invoice_master[0]->inv_name) + ); + + $this->load->model('Payment_M'); + $this->Payment_M->insert_refundorder($RefundRequest); + } + } + + $dataupdate = array( + 'payment_mode' => 3, + 'payment_mode_desc' => 'IPD Credit', + 'payment_id' => 0, + 'insurance_case_id' => $ipd_master[0]->case_id, + 'ipd_id' => $ipd_id + ); + + $this->load->model('Invoice_M'); + $this->Invoice_M->update($dataupdate,$inv_id); + } + + + public function cancel_inv($inv_id) + { + $user = $this->ion_auth->user()->row(); + $user_id = $user->id; + $user_name = $user->first_name.''. $user->last_name.'['.$user->id.']:T-'.date('d-m-Y h:m:s'); + + $status_str=""; + + $opd_status_remark=$status_str.' Update By:'.$user_name; + + $sql="select sum(if(credit_debit>0,amount*-1,amount)) as paid_amount from payment_history where payof_type=2 and payof_id=".$inv_id; + $query = $this->db->query($sql); + $payment_history= $query->result(); + + $sql="select * from invoice_master where id=".$inv_id; + $query = $this->db->query($sql); + $invoice_master= $query->result(); + + $sql="select * from refund_order where refund_process=0 and refund_type=2 and refund_type_id=".$inv_id; + $query = $this->db->query($sql); + $refund_order= $query->result(); + + if(count($payment_history)>0 && count($refund_order)<1) + { + if($payment_history[0]->paid_amount>0 && $invoice_master[0]->invoice_status==1) + { + $RefundRequest = array( + 'refund_type' => 2, + 'refund_type_id' => $inv_id, + 'refund_type_code' => $invoice_master[0]->invoice_code, + 'refund_type_reason' => 'Cancel Invoice', + 'approved_by_id' => $user_id, + 'approved_by' => $user_name, + 'refund_amount' => $payment_history[0]->paid_amount, + 'patient_id' => $invoice_master[0]->attach_id, + 'patient_name' =>strtoupper($invoice_master[0]->inv_name) + ); + + $this->load->model('Payment_M'); + $this->Payment_M->insert_refundorder($RefundRequest); + } + } + + $dataupdate = array( + 'payment_id' => 0, + 'invoice_status' => 2 + ); + + $this->load->model('Invoice_M'); + $this->Invoice_M->update($dataupdate,$inv_id); + } + + public function charge_refund($inv_id,$inv_refund_amount) + { + $user = $this->ion_auth->user()->row(); + $user_id = $user->id; + $user_name = $user->first_name.''. $user->last_name.'['.$user->id.']:T-'.date('d-m-Y h:m:s'); + + $status_str=""; + + $opd_status_remark=$status_str.' Update By:'.$user_name; + + $sql="select sum(if(credit_debit>0,amount*-1,amount)) as paid_amount from payment_history where payof_type=2 and payof_id=".$inv_id; + $query = $this->db->query($sql); + $payment_history= $query->result(); + + $sql="select * from invoice_master where id=".$inv_id; + $query = $this->db->query($sql); + $invoice_master= $query->result(); + + $sql="select * from refund_order where refund_process=0 and refund_type=2 and refund_type_id=".$inv_id; + $query = $this->db->query($sql); + $refund_order= $query->result(); + + if(count($payment_history)>0 && count($refund_order)<1) + { + if($payment_history[0]->paid_amount>0 && $invoice_master[0]->invoice_status==1 && $inv_refund_amount<=$payment_history[0]->paid_amount) + { + if($inv_refund_amount<0) + { + $inv_refund_amount=$inv_refund_amount*-1; + } + + $RefundRequest = array( + 'refund_type' => 2, + 'refund_type_id' => $inv_id, + 'refund_type_code' => $invoice_master[0]->invoice_code, + 'refund_type_reason' => 'Return Extra Charge', + 'approved_by_id' => $user_id, + 'approved_by' => $user_name, + 'refund_amount' => $inv_refund_amount, + 'patient_id' => $invoice_master[0]->attach_id, + 'patient_name' =>strtoupper($invoice_master[0]->inv_name) + ); + + $this->load->model('Payment_M'); + $this->Payment_M->insert_refundorder($RefundRequest); + } + } + + } + + public function deleteinvoice() + { + $inv_id=$this->input->post('inv_id'); + $this->db->delete("invoice_master", "id=".$inv_id); + $this->db->delete("invoice_item", "inv_master_id=".$inv_id); + } + +} \ No newline at end of file diff --git a/old_code_ci3/controllers/Patient.php b/old_code_ci3/controllers/Patient.php index 09da2a8..a40f6ac 100644 --- a/old_code_ci3/controllers/Patient.php +++ b/old_code_ci3/controllers/Patient.php @@ -1,89 +1,108 @@ load->model('Patient_M'); } - public function index() + public function index() { - $sql = "select * from hc_insurance"; - $query = $this->db->query($sql); - $data['data_insurance'] = $query->result(); + $sql="select * from hc_insurance"; + $query = $this->db->query($sql); + $data['data_insurance']= $query->result(); - $sql = "select * from blood_group order by id"; - $query = $this->db->query($sql); - $data['blood_group'] = $query->result(); - - $this->load->view('Patient_V', $data); + $sql="select * from blood_group order by id"; + $query = $this->db->query($sql); + $data['blood_group']= $query->result(); + + $this->load->view('Patient_V',$data); } - public function search_adv() - { - $sdata = ""; - - $input_mphone1 = $this->input->post('input_mphone1'); - $input_Aadhar = $this->input->post('input_udai'); - $input_relative_name = $this->input->post('input_relative_name'); - $input_name = $this->input->post('input_name'); - - if (strlen($input_mphone1) > 0) { - $sdata = $sdata . " or mphone1 = '" . $input_mphone1 . "'"; + public function search_adv() + { + $sdata=""; + + $input_mphone1=$this->input->post('input_mphone1'); + $input_Aadhar=$this->input->post('input_udai'); + $input_relative_name=$this->input->post('input_relative_name'); + $input_name=$this->input->post('input_name'); + + if(strlen($input_mphone1)>0) + { + $sdata=$sdata." or mphone1 = '".$input_mphone1."'"; + } + + if(strlen($input_Aadhar)>0) + { + $sdata=$sdata." or udai = '".$input_Aadhar."'"; } - if (strlen($input_Aadhar) > 0) { - $sdata = $sdata . " or udai = '" . $input_Aadhar . "'"; + if(strlen($input_relative_name)>0) + { + $sdata=$sdata." or (trim(p_rname) = '".trim($input_relative_name)."' and Trim(p_fname)='".trim($input_name)."') "; } - - if (strlen($input_relative_name) > 0) { - $sdata = $sdata . " or (trim(p_rname) = '" . trim($input_relative_name) . "' and Trim(p_fname)='" . trim($input_name) . "') "; - } - - $sql = "SELECT id,Concat(p_fname,'/',if(gender=1,'M','F'),'/',p_relative,' ',p_rname) as Sresult - FROM patient_master WHERE 1<>1 " . $sdata . " order by id desc"; + + $sql = "SELECT id,Concat(p_fname,'/',if(gender=1,'M','F'),'/',p_relative,' ',p_rname) as Sresult + FROM patient_master WHERE 1<>1 ".$sdata." order by id desc"; $query = $this->db->query($sql); - $search_result = $query->result(); + $search_result= $query->result(); - $data['search_result'] = $search_result; - - - $this->load->view('search_adv_data', $data); + if(count($search_result)>0) + { + echo ''; + } + + for($i=0;$i + + '; + } + + if(count($search_result)>0) + { + echo '
Name of Person/Sex/Relative Name
+ '.$search_result[$i]->Sresult.' +
'; + } } - + public function search() { - $sdata = $this->input->post('txtsearch'); - + $sdata=$this->input->post('txtsearch'); + $sdata = preg_replace('/[^A-Za-z0-9 _.@\-]/', '', trim($sdata)); - if (strlen($sdata) == 0) { + if(strlen($sdata)==0) + { $sql = "SELECT p.*,GET_AGE_1(dob,age,age_in_month,estimate_dob) AS age , Date_Format(p.last_visit,'%d-%m-%Y') AS Last_Visit FROM patient_master p group BY p.id order BY p.last_visit DESC LIMIT 100 "; - } else { + }else{ - $sdate_array = explode(" ", $sdata); - $search_string = " 1=1 "; + $sdate_array=explode(" ",$sdata); + $search_string=" 1=1 " ; - foreach ($sdate_array as $row_data) { - if (is_numeric($row_data)) { - $search_string .= " and (p.p_code like '%$row_data' + foreach($sdate_array as $row_data) + { + if(is_numeric($row_data)) + { + $search_string.=" and (p.p_code like '%$row_data' or p.mphone1 = '$row_data' or p.udai='$row_data' )"; - } elseif (ctype_alpha($row_data)) { - $search_string .= " and (p.p_fname like '%$row_data%' + }elseif(ctype_alpha($row_data)){ + $search_string.=" and (p.p_fname like '%$row_data%' or p.email1 = '$row_data' - or SUBSTRING_INDEX(p.p_fname,' ',1) sounds like '" . $row_data . "')"; - } else { - $search_string .= " and (p.p_code like '$row_data' + or SUBSTRING_INDEX(p.p_fname,' ',1) sounds like '".$row_data."')"; + }else{ + $search_string.=" and (p.p_code like '$row_data' or p.email1 = '$row_data' )"; } } @@ -95,13 +114,13 @@ class Patient extends MY_Controller group BY p.id order BY p.last_visit DESC "; } - + $query = $this->db->query($sql); - $data['data'] = $query->result(); - - $this->load->view('Patient_Search_V', $data); + $data['data']= $query->result(); + + $this->load->view('Patient_Search_V',$data); } - + public function search_opd() { @@ -112,630 +131,656 @@ class Patient extends MY_Controller order BY o.opd_id DESC LIMIT 100 "; $query = $this->db->query($sql); - $data['data'] = $query->result(); - - $content = $this->load->view('Patient_Search_opd', $data, true); + $data['data']= $query->result(); + + $content=$this->load->view('Patient_Search_opd',$data,true); echo $content; } - - function person_record($pno, $edit = 0) - { - $sql = "select *,GET_AGE_1(dob,age,age_in_month,estimate_dob) as str_age, + + function person_record($pno,$edit=0) + { + $sql="select *,GET_AGE_1(dob,age,age_in_month,estimate_dob) as str_age, Date_Format(insert_date,'%Y-%m-%d') as str_regdate, if(gender=1,'Male','Female') as xgender , if(date_add(insert_date,interval 12 hour)>sysdate(),1,0) as p_edit - from patient_master where id=" . $pno; + from patient_master where id=".$pno; $query = $this->db->query($sql); - $data['data'] = $query->result(); + $data['data']= $query->result(); - $required_age = $data['data'][0]->age; - $required_age_in_month = $data['data'][0]->age_in_month; - $required_dob = $data['data'][0]->dob; - $estimate_dob = $data['data'][0]->estimate_dob; - - if ($required_age == '' && $estimate_dob == 1) { - if ($required_age == '0') { - if ($required_age_in_month == 0 || $required_age_in_month == '') { - $edit = 1; + $required_age=$data['data'][0]->age; + $required_age_in_month=$data['data'][0]->age_in_month; + $required_dob=$data['data'][0]->dob; + $estimate_dob=$data['data'][0]->estimate_dob; + + if($required_age=='' && $estimate_dob==1) + { + if($required_age=='0') + { + if($required_age_in_month==0 || $required_age_in_month=='') + { + $edit=1; } } - } + } - if ($required_dob == '' && $estimate_dob == 0) { - $edit = 1; - } + if($required_dob=='' && $estimate_dob==0 ) + { + $edit=1; + } - $sql = "select *,p.p_fname,if(apointment_date=curdate(),1,0) as new_opd, + $sql="select *,p.p_fname,if(apointment_date=curdate(),1,0) as new_opd, date_format(apointment_date,'%d-%m-%Y') as str_apointment_date from opd_master o join patient_master p on o.p_id=p.id where p_id=$pno Order by opd_code desc"; $query = $this->db->query($sql); - $data['opd_List'] = $query->result(); - - $sql = "select m.id,m.invoice_code,Date_Format(m.inv_date,'%d-%m-%y') as str_inv_date,m.inv_name, + $data['opd_List']= $query->result(); + + $sql="select m.id,m.invoice_code,Date_Format(m.inv_date,'%d-%m-%y') as str_inv_date,m.inv_name, if(count(t.id)>0,group_concat(t.item_name SEPARATOR ' / '),'No-Item') as Item_List, m.net_amount,m.invoice_status from invoice_master m left join invoice_item t on m.id=t.inv_master_id - where attach_type=0 and attach_id=" . $pno . " group by m.id order by m.id desc"; - $query = $this->db->query($sql); - $data['invoice_list'] = $query->result(); - - $sql = "select i.*,m.ins_company_name,m.opd_allowed,m.charge_cash + where attach_type=0 and attach_id=".$pno." group by m.id order by m.id desc"; + $query = $this->db->query($sql); + $data['invoice_list']= $query->result(); + + $sql="select i.*,m.ins_company_name,m.opd_allowed,m.charge_cash from hc_insurance_card i join hc_insurance m on i.insurance_id=m.id - where i.p_id=" . $pno; - $query = $this->db->query($sql); - $data['data_insurance_card'] = $query->result(); + where i.p_id=".$pno; + $query = $this->db->query($sql); + $data['data_insurance_card']= $query->result(); + + $sql="select *,Date_Format(date_registration,'%d-%m-%Y') as str_date_registration + from organization_case_master where status=0 and case_type=0 and p_id=".$pno; + $query = $this->db->query($sql); + $data['case_master_opd']= $query->result(); - $sql = "select *,Date_Format(date_registration,'%d-%m-%Y') as str_date_registration - from organization_case_master where status=0 and case_type=0 and p_id=" . $pno; - $query = $this->db->query($sql); - $data['case_master_opd'] = $query->result(); - - $sql = "SELECT o.*,DATE_FORMAT(o.date_registration,'%d-%m-%Y') as str_date_registration , + $sql="SELECT o.*,DATE_FORMAT(o.date_registration,'%d-%m-%Y') as str_date_registration , i.ipd_code,i.register_date from organization_case_master o left JOIN ipd_master i ON o.ipd_id=i.id - WHERE o.status=0 AND o.case_type=1 and o.p_id=" . $pno; + WHERE o.status=0 AND o.case_type=1 and o.p_id=".$pno; + $query = $this->db->query($sql); + $data['case_master_ipd']= $query->result(); + + $sql="select * from file_upload_data where id=".$data['data'][0]->profile_file_id; + $query = $this->db->query($sql); + $file_data= $query->result(); + + $profile_file_path="/assets/images/no_image.jpg"; + + $sql="SELECT * from blood_group order by id"; + $query = $this->db->query($sql); + $data['blood_group']= $query->result(); + + $sql="select * from tag_master Order by tag_name"; $query = $this->db->query($sql); - $data['case_master_ipd'] = $query->result(); + $data['tag_master']= $query->result(); - $sql = "select * from file_upload_data where id=" . $data['data'][0]->profile_file_id; - $query = $this->db->query($sql); - $file_data = $query->result(); - - $profile_file_path = "/assets/images/no_image.jpg"; - - $sql = "SELECT * from blood_group order by id"; - $query = $this->db->query($sql); - $data['blood_group'] = $query->result(); - - $sql = "select * from tag_master Order by tag_name"; - $query = $this->db->query($sql); - $data['tag_master'] = $query->result(); - - $sql = "SELECT a.*,t.tag_name,t.tag_type_id + $sql="SELECT a.*,t.tag_name,t.tag_type_id FROM patient_tag_assign a JOIN tag_master t ON a.tag_id=t.id WHERE isdelete=0 and a.p_id=$pno"; $query = $this->db->query($sql); - $data['patient_tag_list'] = $query->result(); + $data['patient_tag_list']= $query->result(); - if (count($file_data) > 0) { - $pos = strpos($file_data[0]->full_path, '/uploads/', 1); - $profile_file_path = substr($file_data[0]->full_path, $pos); + if(count($file_data)>0) + { + $pos=strpos($file_data[0]->full_path,'/uploads/',1) ; + $profile_file_path=substr($file_data[0]->full_path,$pos); + } + + $data['profile_file_path']=$profile_file_path; + + if($edit==0) + { + $this->load->view('Person_profile_V',$data); + }else{ + $this->load->view('Person_Edit_V',$data); } + - $data['profile_file_path'] = $profile_file_path; - - if ($edit == 0) { - $this->load->view('Person_profile_V', $data); - } else { - $this->load->view('Person_Edit_V', $data); - } - } - + } + public function update_1() { - if (!$this->input->is_ajax_request()) { - exit('no valid req.'); - } - + if (!$this->input->is_ajax_request()) { exit('no valid req.'); } + $FormRules = array( - array( - 'field' => 'input_name', - 'label' => 'Name', - 'rules' => 'required|min_length[2]|max_length[30]' - ) - ); + array( + 'field' => 'input_name', + 'label' => 'Name', + 'rules' => 'required|min_length[2]|max_length[30]' + ) + ); - $this->form_validation->set_rules($FormRules); + $this->form_validation->set_rules($FormRules); + + if ($this->form_validation->run() == TRUE) + { - if ($this->form_validation->run() == TRUE) { + $data = array( + 'mphone1' => $this->input->post('input_mphone1'), + 'p_fname' => strtoupper($this->input->post('input_name')), + 'gender' => $this->input->post('optionsRadios_gender'), + 'dob' => str_to_MysqlDate($this->input->post('datepicker_dob')), + 'zip' => $this->input->post('input_zip'), + 'add1' => $this->input->post('input_address'), + 'city' => $this->input->post('input_city'), + 'district' => $this->input->post('input_district'), + 'state' => $this->input->post('input_state'), + 'age' => $this->input->post('input_age'), + 'title' => $this->input->post('cbo_title'), + 'p_relative' => strtoupper($this->input->post('cbo_relation')), + 'p_rname' => $this->input->post('input_relative_name'), + 'email1' => $this->input->post('input_email'), + 'age' => $this->input->post('input_age'), + 'age_in' => $this->input->post('cbo_age') + ); - $data = array( - 'mphone1' => $this->input->post('input_mphone1'), - 'p_fname' => strtoupper($this->input->post('input_name')), - 'gender' => $this->input->post('optionsRadios_gender'), - 'dob' => str_to_MysqlDate($this->input->post('datepicker_dob')), - 'zip' => $this->input->post('input_zip'), - 'add1' => $this->input->post('input_address'), - 'city' => $this->input->post('input_city'), - 'district' => $this->input->post('input_district'), - 'state' => $this->input->post('input_state'), - 'age' => $this->input->post('input_age'), - 'title' => $this->input->post('cbo_title'), - 'p_relative' => strtoupper($this->input->post('cbo_relation')), - 'p_rname' => $this->input->post('input_relative_name'), - 'email1' => $this->input->post('input_email'), - 'age' => $this->input->post('input_age'), - 'age_in' => $this->input->post('cbo_age') - ); - - $pid = $this->input->post('p_id'); - $this->Patient_M->update($data, $pid); - $rvar = array( - 'update' => 1, - 'showcontent' => 'Data Saved successfully' - ); - $encode_data = json_encode($rvar); - echo $encode_data; - } else { - $send_error = validation_errors(); - $rvar = array( - 'update' => 0, - 'error_text' => $send_error - ); - $encode_data = json_encode($rvar); - echo $encode_data; - } + $pid= $this->input->post('p_id'); + $this->Patient_M->update($data,$pid); + $rvar=array( + 'update' =>1, + 'showcontent'=> 'Data Saved successfully' + ); + $encode_data = json_encode($rvar); + echo $encode_data; + + } + else + { + $send_error=validation_errors(); + $rvar=array( + 'update' =>0, + 'error_text'=>$send_error + ); + $encode_data = json_encode($rvar); + echo $encode_data; + } } - + public function update() { - if (!$this->input->is_ajax_request()) { - exit('no valid req.'); - } + if (!$this->input->is_ajax_request()) { exit('no valid req.'); } + + $chk_age=$this->input->post('chk_age'); + + $FormRules = array( + array( + 'field' => 'input_name', + 'label' => 'Name of Patient', + 'rules' => 'required|min_length[1]|max_length[30]' + ) + + ); + + $age_month=$this->input->post('input_age_month'); + $age_year=$this->input->post('input_age_year'); - $chk_age = $this->input->post('chk_age'); - - $FormRules = array( - array( - 'field' => 'input_name', - 'label' => 'Name of Patient', - 'rules' => 'required|min_length[1]|max_length[30]' - ) - - ); - - $age_month = $this->input->post('input_age_month'); - $age_year = $this->input->post('input_age_year'); - - - if ($chk_age == 'on') { - $estimate_dob = 1; - - if ($age_year == '' && $age_month == '') { - array_push( - $FormRules, - array( - 'field' => 'input_age_year', - 'label' => 'Patient Age', - 'rules' => 'required|min_length[1]|max_length[4]' - ) + + if($chk_age=='on') + { + $estimate_dob=1; + + if($age_year=='' && $age_month=='') + { + array_push($FormRules, + array( + 'field' => 'input_age_year', + 'label' => 'Patient Age', + 'rules' => 'required|min_length[1]|max_length[4]' + ) ); } - } else { - $estimate_dob = 0; - array_push( - $FormRules, + }else{ + $estimate_dob=0; + array_push($FormRules, array( - 'field' => 'datepicker_dob', + 'field' => 'datepicker_dob', 'label' => 'Date of Birth', - 'rules' => 'required|min_length[1]|max_length[10]' - ) - ); - } + 'rules' => 'required|min_length[1]|max_length[10]' + ) + ); + } - $this->form_validation->set_rules($FormRules); + $this->form_validation->set_rules($FormRules); + + if ($this->form_validation->run() == TRUE) + { + + $data = array( + 'mphone1' => $this->input->post('input_mphone1'), + 'p_fname' => strtoupper($this->input->post('input_name')), + 'gender' => $this->input->post('optionsRadios_gender'), + 'zip' => $this->input->post('input_zip'), + 'add1' => strtoupper($this->input->post('input_address')), + 'city' => strtoupper($this->input->post('input_city')), + 'district' => strtoupper($this->input->post('input_district')), + 'state' => strtoupper($this->input->post('input_state')), + 'title' => $this->input->post('cbo_title'), + 'p_relative' => strtoupper($this->input->post('cbo_relation')), + 'p_rname' => strtoupper($this->input->post('input_relative_name')), + 'email1' => strtoupper($this->input->post('input_email')), + 'udai' => strtoupper($this->input->post('input_Aadhar')), + 'estimate_dob' => $estimate_dob, + 'blood_group' => $this->input->post('input_blood_group') + ); + + if($chk_age=='on') + { + $data['age'] = $age_year; + $data['age_in_month'] = $age_month; + + }else{ + $data['dob'] = str_to_MysqlDate($this->input->post('datepicker_dob')); + + } + + $pid= $this->input->post('p_id'); + $this->Patient_M->update($data,$pid); + $rvar=array( + 'update' =>1, + 'showcontent'=> 'Data Saved successfully' + ); + $encode_data = json_encode($rvar); + echo $encode_data; + + } + else + { + $send_error=validation_errors(); + $rvar=array( + 'update' =>0, + 'error_text'=>$send_error + ); + $encode_data = json_encode($rvar); + echo $encode_data; + } - if ($this->form_validation->run() == TRUE) { - - $data = array( - 'mphone1' => $this->input->post('input_mphone1'), - 'p_fname' => strtoupper($this->input->post('input_name')), - 'gender' => $this->input->post('optionsRadios_gender'), - 'zip' => $this->input->post('input_zip'), - 'add1' => strtoupper($this->input->post('input_address')), - 'city' => strtoupper($this->input->post('input_city')), - 'district' => strtoupper($this->input->post('input_district')), - 'state' => strtoupper($this->input->post('input_state')), - 'title' => $this->input->post('cbo_title'), - 'p_relative' => strtoupper($this->input->post('cbo_relation')), - 'p_rname' => strtoupper($this->input->post('input_relative_name')), - 'email1' => strtoupper($this->input->post('input_email')), - 'udai' => strtoupper($this->input->post('input_Aadhar')), - 'estimate_dob' => $estimate_dob, - 'blood_group' => $this->input->post('input_blood_group') - ); - - if ($chk_age == 'on') { - $data['age'] = $age_year; - $data['age_in_month'] = $age_month; - } else { - $data['dob'] = str_to_MysqlDate($this->input->post('datepicker_dob')); - } - - $pid = $this->input->post('p_id'); - $this->Patient_M->update($data, $pid); - $rvar = array( - 'update' => 1, - 'showcontent' => 'Data Saved successfully' - ); - $encode_data = json_encode($rvar); - echo $encode_data; - } else { - $send_error = validation_errors(); - $rvar = array( - 'update' => 0, - 'error_text' => $send_error - ); - $encode_data = json_encode($rvar); - echo $encode_data; - } } - + public function update_aadhar() { - if (!$this->input->is_ajax_request()) { - exit('no valid req.'); - } - - $data = array( + if (!$this->input->is_ajax_request()) { exit('no valid req.'); } + + $data = array( 'udai' => $this->input->post('udai'), - ); - - $pid = $this->input->post('p_id'); - $this->Patient_M->update($data, $pid); - $rvar = array( - 'update' => 1, - 'showcontent' => 'Data Saved successfully' + ); + + $pid= $this->input->post('p_id'); + $this->Patient_M->update($data,$pid); + $rvar=array( + 'update' =>1, + 'showcontent'=> 'Data Saved successfully' ); $encode_data = json_encode($rvar); echo $encode_data; + } - public function create() - { - if (!$this->input->is_ajax_request()) { - exit('no valid req.'); - } + public function create() { + if (!$this->input->is_ajax_request()) { exit('no valid req.'); } - $chk_age = $this->input->post('chk_age'); + $chk_age=$this->input->post('chk_age'); $FormRules = array( - array( - 'field' => 'input_name', - 'label' => 'Name of Patient', - 'rules' => 'required|min_length[1]|max_length[100]' - ), - array( - 'field' => 'input_relative_name', - 'rules' => 'required|min_length[1]|max_length[100]' - ), - array( - 'field' => 'input_mphone1', - 'rules' => 'required|min_length[10]|max_length[10]' - ) + array( + 'field' => 'input_name', + 'label' => 'Name of Patient', + 'rules' => 'required|min_length[1]|max_length[100]' + ), + array( + 'field' => 'input_relative_name', + 'rules' => 'required|min_length[1]|max_length[100]' + ), + array( + 'field' => 'input_mphone1', + 'rules' => 'required|min_length[10]|max_length[10]' + ) + + ); - ); + $age_month=$this->input->post('input_age_month'); + $age_year=$this->input->post('input_age_year'); - $age_month = $this->input->post('input_age_month'); - $age_year = $this->input->post('input_age_year'); - - - if ($chk_age == 'on') { - $estimate_dob = 1; - - if ($age_year == '' && $age_month == '') { - array_push( - $FormRules, - array( - 'field' => 'input_age_year', - 'label' => 'Patient Age', - 'rules' => 'required|min_length[1]|max_length[4]' - ) + + if($chk_age=='on') + { + $estimate_dob=1; + + if($age_year=='' && $age_month=='') + { + array_push($FormRules, + array( + 'field' => 'input_age_year', + 'label' => 'Patient Age', + 'rules' => 'required|min_length[1]|max_length[4]' + ) ); } - } else { - $estimate_dob = 0; - array_push( - $FormRules, + }else{ + $estimate_dob=0; + array_push($FormRules, array( - 'field' => 'datepicker_dob', + 'field' => 'datepicker_dob', 'label' => 'Date of Birth', - 'rules' => 'required|min_length[1]|max_length[10]' - ) + 'rules' => 'required|min_length[1]|max_length[10]' + ) ); } $this->form_validation->set_rules($FormRules); - if ($this->form_validation->run() == TRUE) { + if ($this->form_validation->run() == TRUE) + { - $data = array( - 'mphone1' => $this->input->post('input_mphone1'), - 'p_fname' => strtoupper($this->input->post('input_name')), - 'gender' => $this->input->post('optionsRadios_gender'), - 'zip' => $this->input->post('input_zip'), - 'add1' => strtoupper($this->input->post('input_address')), - 'city' => strtoupper($this->input->post('input_city')), - 'district' => strtoupper($this->input->post('input_district')), - 'state' => strtoupper($this->input->post('input_state')), - 'title' => $this->input->post('cbo_title'), - 'p_relative' => $this->input->post('cbo_relation'), - 'p_rname' => strtoupper($this->input->post('input_relative_name')), - 'blood_group' => strtoupper($this->input->post('input_blood_group')), - 'udai' => strtoupper($this->input->post('input_udai')), - 'estimate_dob' => $estimate_dob - ); + $data = array( + 'mphone1' => $this->input->post('input_mphone1'), + 'p_fname' => strtoupper($this->input->post('input_name')), + 'gender' => $this->input->post('optionsRadios_gender'), + 'zip' => $this->input->post('input_zip'), + 'add1' => strtoupper($this->input->post('input_address')), + 'city' => strtoupper($this->input->post('input_city')), + 'district' => strtoupper($this->input->post('input_district')), + 'state' => strtoupper($this->input->post('input_state')), + 'title' => $this->input->post('cbo_title'), + 'p_relative' => $this->input->post('cbo_relation'), + 'p_rname' => strtoupper($this->input->post('input_relative_name')), + 'blood_group' => strtoupper($this->input->post('input_blood_group')), + 'udai' => strtoupper($this->input->post('input_udai')), + 'estimate_dob' => $estimate_dob + ); + + if($chk_age=='on') + { + $data['age'] = $age_year; + $data['age_in_month'] = $age_month; + + }else{ + $data['dob'] = str_to_MysqlDate($this->input->post('datepicker_dob')); + + } + + $inser_id=$this->Patient_M->insert($data); + $rvar=array( + 'insertid' =>$inser_id + ); - if ($chk_age == 'on') { - $data['age'] = $age_year; - $data['age_in_month'] = $age_month; - } else { - $data['dob'] = str_to_MysqlDate($this->input->post('datepicker_dob')); - } + // Check Multiple UHID + $sdata=''; + //$sdata=$sdata." or udai = '".$this->input->post('input_udai')."'"; + $sdata=$sdata." or (trim(p_rname) = '".trim(strtoupper($this->input->post('input_relative_name')))."' and Trim(p_fname)='".trim(strtoupper($this->input->post('input_name')))."') "; + + $sql = "SELECT id,Concat(p_code,'/',p_fname,'/',if(gender=1,'M','F'),'/',p_relative,' ',p_rname) as Sresult + FROM patient_master WHERE 1<>1 ".$sdata." and id<>$inser_id order by id desc"; + $query = $this->db->query($sql); + $search_result= $query->result(); - $inser_id = $this->Patient_M->insert($data); - $rvar = array( - 'insertid' => $inser_id - ); + $user = $this->ion_auth->user()->row(); + $user_name = $user->first_name.''. $user->last_name.'[Date:'.date('d-m-Y h:i:s').']-'.$user->id; - // Check Multiple UHID - $sdata = ''; - //$sdata=$sdata." or udai = '".$this->input->post('input_udai')."'"; - $sdata = $sdata . " or (trim(p_rname) = '" . trim(strtoupper($this->input->post('input_relative_name'))) . "' and Trim(p_fname)='" . trim(strtoupper($this->input->post('input_name'))) . "') "; + $log_text=''; - $sql = "SELECT id,Concat(p_code,'/',p_fname,'/',if(gender=1,'M','F'),'/',p_relative,' ',p_rname) as Sresult - FROM patient_master WHERE 1<>1 " . $sdata . " and id<>$inser_id order by id desc"; - $query = $this->db->query($sql); - $search_result = $query->result(); + foreach($search_result as $row) + { + $log_text.=$row->Sresult.PHP_EOL; + } - $user = $this->ion_auth->user()->row(); - $user_name = $user->first_name . '' . $user->last_name . '[Date:' . date('d-m-Y h:i:s') . ']-' . $user->id; + if(count($search_result)>0) + { + $data = array( + 'new_uhid' => $inser_id, + 'name_of_person' => strtoupper($this->input->post('input_name')), + 'new_patient_code' => '', + 'date_of_registration' => date('Y-m-d h:i:s'), + 'update_by' => $user_name, + 'remark_duplicate' => $log_text, + ); - $log_text = ''; + $inser_id=$this->Patient_M->insert_log_patient_multiple($data); + } - foreach ($search_result as $row) { - $log_text .= $row->Sresult . PHP_EOL; - } - - if (count($search_result) > 0) { - $data = array( - 'new_uhid' => $inser_id, - 'name_of_person' => strtoupper($this->input->post('input_name')), - 'new_patient_code' => '', - 'date_of_registration' => date('Y-m-d h:i:s'), - 'update_by' => $user_name, - 'remark_duplicate' => $log_text, - ); - - $inser_id = $this->Patient_M->insert_log_patient_multiple($data); - } - - //End of Chking Multiple UHID - $encode_data = json_encode($rvar); - echo $encode_data; - } else { - $send_error = validation_errors(); - $rvar = array( - 'insertid' => 0, - 'error_text' => $send_error - ); - $encode_data = json_encode($rvar); - echo $encode_data; - } + //End of Chking Multiple UHID + $encode_data = json_encode($rvar); + echo $encode_data; + } + else + { + $send_error=validation_errors(); + $rvar=array( + 'insertid' =>0, + 'error_text'=>$send_error + ); + $encode_data = json_encode($rvar); + echo $encode_data; + } + } - - public function show_cards($pno, $card_no = 0) + + public function show_cards($pno,$card_no=0) { + + $sql="select * from patient_master where id=".$pno; + $query = $this->db->query($sql); + $data['pdata']= $query->result(); + + $inc_card_no=$data['pdata'][0]->insurance_card_id; + + $sql="select * from hc_insurance_card where id>1 and id=".$inc_card_no; + $query = $this->db->query($sql); + $data['data_insurance_card']= $query->result(); - $sql = "select * from patient_master where id=" . $pno; - $query = $this->db->query($sql); - $data['pdata'] = $query->result(); + $sql="select * from hc_insurance where id>1 and active=1 order by ins_company_name "; + $query = $this->db->query($sql); + $data['data_insurance']= $query->result(); - $inc_card_no = $data['pdata'][0]->insurance_card_id; - - $sql = "select * from hc_insurance_card where id>1 and id=" . $inc_card_no; - $query = $this->db->query($sql); - $data['data_insurance_card'] = $query->result(); - - $sql = "select * from hc_insurance where id>1 and active=1 order by ins_company_name "; - $query = $this->db->query($sql); - $data['data_insurance'] = $query->result(); - - $this->load->view('insurance/insurance_card', $data); + $this->load->view('insurance/insurance_card',$data); } - - public function city() - { + + public function city(){ $this->load->model('Patient_M'); - if (isset($_GET['term'])) { + if (isset($_GET['term'])){ $q = strtolower($_GET['term']); $this->Patient_M->get_city($q); } } - public function P_info() - { - + public function P_info(){ + $UHID = $this->input->post('input_uhid'); + + $sql="select * from patient_master_exten where p_code='$UHID' "; + $query = $this->db->query($sql); + $data= $query->result(); + + if(count($data)>0) + { + $Patient_id=$data[0]->id; + $Patient_info=$data[0]->p_fname.' '.$data[0]->p_relative.' '.$data[0]->p_rname.' /Age :'.$data[0]->str_age; - $sql = "select * from patient_master_exten where p_code='$UHID' "; - $query = $this->db->query($sql); - $data = $query->result(); - - if (count($data) > 0) { - $Patient_id = $data[0]->id; - $Patient_info = $data[0]->p_fname . ' ' . $data[0]->p_relative . ' ' . $data[0]->p_rname . ' /Age :' . $data[0]->str_age; - } else { - $Patient_id = 0; - $Patient_info = ''; + }else{ + $Patient_id=0; + $Patient_info=''; } - $rvar = array( - 'Patient_id' => $Patient_id, - 'Patient_info' => $Patient_info - ); + $rvar=array( + 'Patient_id' =>$Patient_id, + 'Patient_info'=>$Patient_info + ); $encode_data = json_encode($rvar); echo $encode_data; - } + } + public function update_card() { - if (!$this->input->is_ajax_request()) { - exit('no valid req.'); - } + if (!$this->input->is_ajax_request()) { exit('no valid req.'); } $FormRules = array( - array( - 'field' => 'input_insurance_id', - 'label' => 'Insurance No', - 'rules' => 'required|min_length[2]|max_length[30]' - ), - array( - 'field' => 'input_card_holder_name', - 'label' => 'Insurance Card Holder Name', - 'rules' => 'required|min_length[1]|max_length[30]' - ) - ); + array( + 'field' => 'input_insurance_id', + 'label' => 'Insurance No', + 'rules' => 'required|min_length[2]|max_length[30]' + ), + array( + 'field' => 'input_card_holder_name', + 'label' => 'Insurance Card Holder Name', + 'rules' => 'required|min_length[1]|max_length[30]' + ) + ); $this->form_validation->set_rules($FormRules); - if ($this->form_validation->run() == TRUE) { + if ($this->form_validation->run() == TRUE) + { + + $data = array( + 'insurance_id' => $this->input->post('Insurance_id'), + 'p_id' => $this->input->post('p_id'), + 'insurance_no' => $this->input->post('input_insurance_id'), + 'card_holder_name' => strtoupper($this->input->post('input_card_holder_name')), + 'issue_date' => str_to_MysqlDate($this->input->post('datepicker_issue_date')), + 'expiry_date' => str_to_MysqlDate($this->input->post('datepicker_expiry_date')), + 'relation_patient_cardholder' => strtoupper($this->input->post('input_Relation')) + ); + + $card_no=$this->input->post('inscard_id'); + $inser_id=$card_no; + + if($card_no=="0") + { + $inser_id=$this->Patient_M->insert_card($data); + }else{ + $this->Patient_M->update_card($data,$card_no); + } - $data = array( - 'insurance_id' => $this->input->post('Insurance_id'), - 'p_id' => $this->input->post('p_id'), - 'insurance_no' => $this->input->post('input_insurance_id'), - 'card_holder_name' => strtoupper($this->input->post('input_card_holder_name')), - 'issue_date' => str_to_MysqlDate($this->input->post('datepicker_issue_date')), - 'expiry_date' => str_to_MysqlDate($this->input->post('datepicker_expiry_date')), - 'relation_patient_cardholder' => strtoupper($this->input->post('input_Relation')) - ); + $data = array( + 'insurance_card_id' => $inser_id, + 'insurance_id' => $this->input->post('Insurance_id'), + 'insurance_no' => $this->input->post('input_insurance_id'), + 'card_holder_name' => strtoupper($this->input->post('input_card_holder_name')), + 'issue_date' => str_to_MysqlDate($this->input->post('datepicker_issue_date')), + 'expiry_date' => str_to_MysqlDate($this->input->post('datepicker_expiry_date')), + 'relation_patient_cardholder' => strtoupper($this->input->post('input_Relation')) + ); + + $this->Patient_M->update($data,$this->input->post('p_id')); - $card_no = $this->input->post('inscard_id'); - $inser_id = $card_no; - - if ($card_no == "0") { - $inser_id = $this->Patient_M->insert_card($data); - } else { - $this->Patient_M->update_card($data, $card_no); - } - - $data = array( - 'insurance_card_id' => $inser_id, - 'insurance_id' => $this->input->post('Insurance_id'), - 'insurance_no' => $this->input->post('input_insurance_id'), - 'card_holder_name' => strtoupper($this->input->post('input_card_holder_name')), - 'issue_date' => str_to_MysqlDate($this->input->post('datepicker_issue_date')), - 'expiry_date' => str_to_MysqlDate($this->input->post('datepicker_expiry_date')), - 'relation_patient_cardholder' => strtoupper($this->input->post('input_Relation')) - ); - - $this->Patient_M->update($data, $this->input->post('p_id')); - - $rvar = array( - 'insertid' => $inser_id - ); - - $encode_data = json_encode($rvar); - echo $encode_data; - } else { - $send_error = validation_errors(); - $rvar = array( - 'insertid' => 0, - 'error_text' => $send_error - ); - $encode_data = json_encode($rvar); - echo $encode_data; - } + $rvar=array( + 'insertid' =>$inser_id + ); + + $encode_data = json_encode($rvar); + echo $encode_data; + } + else + { + $send_error=validation_errors(); + $rvar=array( + 'insertid' =>0, + 'error_text'=>$send_error + ); + $encode_data = json_encode($rvar); + echo $encode_data; + } } public function show_profile_opd($p_id) { - $data['p_id'] = $p_id; + $data['p_id']=$p_id; - $sql = "select * from patient_master_exten where id=" . $p_id; - $query = $this->db->query($sql); - $data['data'] = $query->result(); + $sql="select * from patient_master_exten where id=".$p_id; + $query = $this->db->query($sql); + $data['data']= $query->result(); + + $sql="select o.* from opd_master o where o.p_id=$p_id order by o.opd_id desc"; + $query = $this->db->query($sql); + $data['opd_master']= $query->result(); - $sql = "select o.* from opd_master o where o.p_id=$p_id order by o.opd_id desc"; - $query = $this->db->query($sql); - $data['opd_master'] = $query->result(); - - $sql = "select o.* from opd_master o where o.p_id=$p_id and date(o.apointment_date)=curdate()"; - $query = $this->db->query($sql); - $data['opd_master_current'] = $query->result(); + $sql="select o.* from opd_master o where o.p_id=$p_id and date(o.apointment_date)=curdate()"; + $query = $this->db->query($sql); + $data['opd_master_current']= $query->result(); //$this->load->view('Person/person_file_show',$data); - $this->load->view('Person/Person_Profile', $data); + $this->load->view('Person/Person_Profile',$data); + } public function show_profile_image($p_id) { - $data['p_id'] = $p_id; + $data['p_id']=$p_id; - $sql = "select *,GET_AGE_1(dob,age,age_in_month,estimate_dob) as str_age, + $sql="select *,GET_AGE_1(dob,age,age_in_month,estimate_dob) as str_age, Date_Format(insert_date,'%Y-%m-%d') as str_regdate, if(gender=1,'Male','Female') as xgender , if(date_add(insert_date,interval 12 hour)>sysdate(),1,0) as p_edit - from patient_master where id=" . $p_id; + from patient_master where id=".$p_id; $query = $this->db->query($sql); - $data['data'] = $query->result(); - - - $this->load->view('Person/person_profile_photo', $data); + $data['data']= $query->result(); + + + $this->load->view('Person/person_profile_photo',$data); } public function save_profile_image($p_id) { - $filename = 'P-' . $p_id . '-' . time() . '.jpg'; - - $folder_name = 'uploads/' . date('Ymd'); + $filename = 'P-'.$p_id.'-'.time() . '.jpg'; + $folder_name='uploads/'.date('Ymd'); + if (!file_exists($folder_name)) { mkdir($folder_name, 0777, true); } - + $user = $this->ion_auth->user()->row(); $user_id = $user->id; - $user_name = $user->first_name . '' . $user->last_name; - + $user_name = $user->first_name.''. $user->last_name; + //echo $folder_name; - + $config['upload_path'] = $folder_name; $config['allowed_types'] = 'gif|jpg|png|jpeg'; - + //$new_name = time().$_FILES["webcam"]['name']; $config['file_name'] = $filename; $this->load->library('upload', $config); - + if (!$this->upload->do_upload('webcam')) { $error = array('error' => $this->upload->display_errors()); echo $error['error']; - } else { - $data = array('upload_data' => $this->upload->data()); - + }else{ + $data = array('upload_data' => $this->upload->data()); + $this->load->model('File_M'); + + $file_insert_id=$this->File_M->insert($data['upload_data']); + + $udata = array( + 'upload_by'=> $user_name, + 'pid'=>$p_id, + 'opd_id'=>'0', + 'ipd_id'=>'0', + 'case_id'=>'0', + 'upload_by_id'=>$user_id + ); - $file_insert_id = $this->File_M->insert($data['upload_data']); - - $udata = array( - 'upload_by' => $user_name, - 'pid' => $p_id, - 'opd_id' => '0', - 'ipd_id' => '0', - 'case_id' => '0', - 'upload_by_id' => $user_id - ); - - if ($file_insert_id > 0) { - $this->File_M->update($udata, $file_insert_id); - - $user_name = $user->first_name . '' . $user->last_name . ':T-' . date('d-m-Y h:m:s'); - - $dataupdate = array( - 'profile_file_id' => $file_insert_id, - 'profile_picture_update_by' => $user_name + if($file_insert_id>0) + { + $this->File_M->update($udata,$file_insert_id); + + $user_name = $user->first_name.''. $user->last_name.':T-'.date('d-m-Y h:m:s'); + + $dataupdate = array( + 'profile_file_id' => $file_insert_id, + 'profile_picture_update_by' => $user_name ); - $this->Patient_M->update($dataupdate, $p_id); + $this->Patient_M->update($dataupdate,$p_id); } - + echo $filename; } } @@ -743,108 +788,112 @@ class Patient extends MY_Controller //Patient Tag function add_comments($p_id) - { - if (!$this->input->is_ajax_request()) { - exit('no valid req.'); - } - + { + if (!$this->input->is_ajax_request()) { exit('no valid req.'); } + $user = $this->ion_auth->user()->row(); $user_id = $user->id; - $user_name = $user->first_name . '' . $user->last_name . ' [Date:' . date('d-m-Y h:i') . ']'; - - $comments_data = array( - 'p_id' => $p_id, - 'remark' => $this->input->post('add_notes'), - 'insert_by_id' => $user_id, - 'insert_by' => $user_name - ); - - $insert_id = $this->Patient_M->insert_remark($comments_data); - - if ($insert_id > 0) { - $rvar = array( - 'update' => $insert_id, - 'error_text' => 'Update Done ' . $insert_id + $user_name = $user->first_name.''. $user->last_name.' [Date:'.date('d-m-Y h:i').']'; + + $comments_data = array( + 'p_id' => $p_id, + 'remark' => $this->input->post('add_notes'), + 'insert_by_id' => $user_id, + 'insert_by' => $user_name ); - } else { - $rvar = array( - 'update' => 0, + + $insert_id=$this->Patient_M->insert_remark($comments_data); + + if($insert_id>0) + { + $rvar=array( + 'update' =>$insert_id, + 'error_text' => 'Update Done '.$insert_id + ); + }else{ + $rvar=array( + 'update' =>0, 'error_text' => 'Some Error', ); } - + $encode_data = json_encode($rvar); echo $encode_data; - } - + } + function patient_tag() { $this->load->model('Patienttag_M'); - $tag_id = $this->input->post('tag_id'); - $p_id = $this->input->post('p_id'); + $tag_id=$this->input->post('tag_id'); + $p_id=$this->input->post('p_id'); $user = $this->ion_auth->user()->row(); $user_id = $user->id; - $user_name = $user->first_name . '' . $user->last_name; - - if ($this->input->post('isadd') == 1) { - - $sql = "Select * + $user_name = $user->first_name.''. $user->last_name; + + if($this->input->post('isadd')==1) + { + + $sql="Select * from patient_tag_assign where isdelete=0 and p_id='$p_id' and tag_id='$tag_id'"; - $query = $this->db->query($sql); - $no_rec = $query->num_rows(); - - if ($no_rec == 0) { - $data = array( - 'p_id' => $p_id, + $query = $this->db->query($sql); + $no_rec= $query->num_rows(); + + if($no_rec==0) + { + $data = array( + 'p_id' => $p_id, 'tag_id' => $tag_id, 'assign_by_id' => $user_id, - 'assign_by' => $user_name . '[' . $user_id . ']' . date('d-m-Y H:i'), - ); - $inser_id = $this->Patienttag_M->insert_patient_tag_assign($data); - } - } else { - - $cust_tag_assign = $this->input->post('cust_tag_assign'); - - $data = array( - 'isdelete' => 1, - 'delete_by' => $this->session->userdata('username') . '[' . $this->session->userdata('agent_id') . ']' . date('d-m-Y H:i'), - ); - - $this->Patienttag_M->update_patient_tag_assign($data, $cust_tag_assign); - } - + 'assign_by' => $user_name.'['.$user_id.']'.date('d-m-Y H:i'), + ); + $inser_id=$this->Patienttag_M->insert_patient_tag_assign($data); + + } + }else{ + + $cust_tag_assign=$this->input->post('cust_tag_assign'); + + $data = array( + 'isdelete' => 1, + 'delete_by' => $this->session->userdata('username').'['.$this->session->userdata('agent_id').']'.date('d-m-Y H:i'), + ); + + $this->Patienttag_M->update_patient_tag_assign($data,$cust_tag_assign); + } + echo '1'; + } //AutoList of Person Names - - public function get_name() - { - - if (isset($_GET['term'])) { + + public function get_name(){ + + if (isset($_GET['term'])){ $q = strtolower($_GET['term']); - $sql = "select * from name_list where name like '" . $q . "%' "; + $sql="select * from name_list where name like '".$q."%' "; - $sql = $sql . "order by name limit 20"; + $sql=$sql."order by name limit 20"; $query = $this->db->query($sql); - - if ($query->num_rows() > 0) { - foreach ($query->result_array() as $row) { - $new_row['label'] = htmlentities(stripslashes($row['name'])); - $new_row['value'] = htmlentities(stripslashes($row['name'])); - + + if($query->num_rows() > 0){ + foreach ($query->result_array() as $row){ + $new_row['label']=htmlentities(stripslashes($row['name'])); + $new_row['value']=htmlentities(stripslashes($row['name'])); + $row_set[] = $new_row; //build an array } - echo json_encode($row_set); //format the array into json data + echo json_encode($row_set); //format the array into json data } } } + } + diff --git a/old_code_ci3/controllers/Payment_Medical.php b/old_code_ci3/controllers/Payment_Medical.php index 4926e5e..7e7243a 100644 --- a/old_code_ci3/controllers/Payment_Medical.php +++ b/old_code_ci3/controllers/Payment_Medical.php @@ -6,6 +6,7 @@ class Payment_Medical extends MY_Controller { public function __construct() { parent::__construct(); + } function index() @@ -259,33 +260,5 @@ class Payment_Medical extends MY_Controller { } - public function payment_log(){ - $this->load->view('Medical/payment_log'); - } - - public function payment_log_data(){ - - $opd_date_range=$this->input->post('opd_date_range'); - - $rangeArray = explode("S",$opd_date_range); - $minRange = str_replace('T',' ',$rangeArray[0]); - $maxRange = str_replace('T',' ',$rangeArray[1]); - - $sql="SELECT p.* , - (case p.Customerof_type when 1 then p.Medical_invoice_code when 2 then p.ipd_id when 3 then p.Medical_invoice_code ELSE 'Unknown' END) AS Inv_code, - (case p.Customerof_type when 1 then 'UHID' when 2 then 'IPD' when 3 then 'CASH' ELSE 'Unknown' END) AS Bill_type - ,l.update_by,l.insert_datetime AS log_insert,l.update_type,l.update_log, - (case update_type when 3 then 'Change Amount' when 2 then 'Cash to Bank' when 1 then 'Bank to Cash' ELSE 'Unknown' END ) AS LOG_type - FROM payment_history_medical p JOIN paymentmedical_history_log l ON p.id=l.pay_id - where date(l.insert_datetime) between '".$minRange."' and '".$maxRange."'"; - $query = $this->db->query($sql); - $data['paymentmedical_history_log']= $query->result(); - - //echo $sql; - $data['opd_date_range']=$opd_date_range; - - $this->load->view('Medical/payment_log_data',$data); - } - } diff --git a/old_code_ci3/controllers/Report.php b/old_code_ci3/controllers/Report.php index a1d4fe9..2d16308 100644 --- a/old_code_ci3/controllers/Report.php +++ b/old_code_ci3/controllers/Report.php @@ -153,7 +153,7 @@ class Report extends MY_Controller { o.doc_name ,if(o.insurance_id>1,'Org.','Direct') as 'Type', m.mode_desc as 'PayMode',o.opd_fee_gross_amount as 'GrossAmt', o.opd_discount as Discount, o.opd_fee_amount as 'FeeAmt', - o.prepared_by,IFNULL(GET_AGE_BY_DOB(dob),age) as Age "; + o.prepared_by,GET_AGE_1(dob,age,age_in_month,estimate_dob) as Age "; $sql_from=" from opd_master o join payment_mode m join patient_master p on o.payment_mode=m.id and p.id=o.p_id"; diff --git a/old_code_ci3/controllers/Report2.php b/old_code_ci3/controllers/Report2.php index 429fec5..95349eb 100644 --- a/old_code_ci3/controllers/Report2.php +++ b/old_code_ci3/controllers/Report2.php @@ -69,7 +69,7 @@ class Report2 extends MY_Controller { $discount=$ipdmaster[0]->Discount; $sql="select *,if(gender=1,'Male','Female') as xgender, - IFNULL(GET_AGE_BY_DOB(dob),age) AS age from patient_master where id='".$pno."' "; + GET_AGE_1(dob,age,age_in_month,estimate_dob) AS age from patient_master where id='".$pno."' "; $query = $this->db->query($sql); $person_info= $query->result(); @@ -309,14 +309,12 @@ class Report2 extends MY_Controller { $table_body=''; $table_Doctor_Total=0.00; - $table_qty_total=0.00; $table_Diagnosis_Head_Total=0.00; $table_Grand_Total=0.00; $table_Doctor_act_Total=0.00; $table_Diagnosis_act_Head_Total=0.00; $table_Grand_act_Total=0.00; - $table_grand_qty_total=0.00; //echo $sql_f_all.$sql_from.$sql_where.$gwhere.' '.$sql_order.'

'; $doc_name_head=''; @@ -357,12 +355,10 @@ class Report2 extends MY_Controller { $table_Doctor_Total=$table_Doctor_Total+$rowdata[$i]->Total_Amount; $table_Diagnosis_Head_Total=$table_Diagnosis_Head_Total+$rowdata[$i]->Total_Amount; $table_Grand_Total=$table_Grand_Total+$rowdata[$i]->Total_Amount; - $table_qty_total=$table_qty_total+$rowdata[$i]->No_qty; $table_Doctor_act_Total=$table_Doctor_act_Total+$rowdata[$i]->Total_Act_Amount; $table_Diagnosis_act_Head_Total=$table_Diagnosis_act_Head_Total+$rowdata[$i]->Total_Act_Amount; $table_Grand_act_Total=$table_Grand_act_Total+$rowdata[$i]->Total_Act_Amount; - $table_grand_qty_total=$table_grand_qty_total+$rowdata[$i]->No_qty; if($Diagnosis_id<1) { @@ -381,7 +377,6 @@ class Report2 extends MY_Controller { $table_Diagnosis_Head_Total=0.00; $table_Diagnosis_act_Head_Total=0.00; - $table_qty_total=0.00; } }else{ $table_body.=''; @@ -395,7 +390,6 @@ class Report2 extends MY_Controller { $table_Diagnosis_Head_Total=0.00; $table_Diagnosis_act_Head_Total=0.00; - $table_qty_total=0.00; } } @@ -407,30 +401,28 @@ class Report2 extends MY_Controller { $table_body.=''; $table_body.=''; $table_body.=''; + $table_body.=''; $table_body.='Total Doctor Head'; - $table_body.=''.$table_qty_total.''; $table_body.=''.$table_Doctor_Total.''; $table_body.=''.$table_Doctor_act_Total.''; $table_body.=''; $table_Doctor_Total=0.00; $table_Doctor_act_Total=0.00; - $table_qty_total=0.00; - + } }else{ $table_body.=''; $table_body.=''; $table_body.=''; + $table_body.=''; $table_body.='Total Doctor Head'; - $table_body.=''.$table_qty_total.''; $table_body.=''.$table_Doctor_Total.''; $table_body.=''.$table_Doctor_act_Total.''; $table_body.=''; $table_Doctor_Total=0.00; $table_Doctor_act_Total=0.00; - $table_qty_total=0.00; } } @@ -439,7 +431,7 @@ class Report2 extends MY_Controller { $table_footer.='Total'; $table_footer.=''; $table_footer.=''; - $table_footer.=''.$table_grand_qty_total.''; + $table_footer.=''; $table_footer.=''.$table_Grand_Total.''; $table_footer.=''.$table_Grand_act_Total.''; $table_footer.=''; @@ -849,7 +841,6 @@ class Report2 extends MY_Controller { } - public function report_Diagnosis_item_count($opd_date_range,$emp_name_id,$Diagnosis_id) { $sql_f_all = "select m.invoice_code,p.p_code,p.p_fname,y.group_desc,t.item_name,t.item_qty, diff --git a/old_code_ci3/controllers/Report4.php b/old_code_ci3/controllers/Report4.php index a307f9b..674340f 100644 --- a/old_code_ci3/controllers/Report4.php +++ b/old_code_ci3/controllers/Report4.php @@ -165,7 +165,7 @@ class Report4 extends MY_Controller { $where.=" and o.insurance_id=".($ipd_type*-1)." "; } - $sql="select o.id,o.case_id_code,Concat(o.insurance_no,'/',o.insurance_no_1) as case_info,p.p_fname, + $sql="select o.case_id_code,Concat(o.insurance_no,'/',o.insurance_no_1) as case_info,p.p_fname, `o`.`status`,p.p_code,p.p_fname, (case `o`.`status` when 0 then 'Pending' when 1 then 'Ready' when 2 then 'Submit' else 'Nothing' end) AS `org_submit_status`, (o.inv_opd_amt+o.inv_opd_charge_amt) as Charge_amount, @@ -176,7 +176,7 @@ class Report4 extends MY_Controller { where ".$where." and (o.inv_opd_amt+o.inv_opd_charge_amt+o.inv_opd_med_amt)>0 group by o.id order by o.id"; - //echo $sql; + echo $sql; $query = $this->db->query($sql); $dischargelist= $query->result(); @@ -188,38 +188,31 @@ class Report4 extends MY_Controller { $content.=' # - Bill No. - Case Info. + Case Info. Org. Code UHID Person Name Date Charge Amt. Med. Amt. - Net Amt. '; $sr_no=0; - $total_net_amount=0.00; foreach($dischargelist as $row) { $sr_no=$sr_no+1; - $net_amount=($row->Charge_amount+$row->med_net_amount); $content.=' '.$sr_no.' - '.$row->id.' - '.$row->case_info.' + '.$row->case_info.' '.$row->case_id_code.' '.$row->p_code.' '.$row->p_fname.' '.$row->str_date_registration.' '.$row->Charge_amount.' '.$row->med_net_amount.' - '.$net_amount.' '; $total_Payment+= $row->Charge_amount; $total_Med_Payment+= $row->med_net_amount; - $total_net_amount+= $net_amount; } $content.=' @@ -229,10 +222,8 @@ class Report4 extends MY_Controller { - - '.$total_Payment.' - '.$total_Med_Payment.' - '.$total_net_amount.' + '.$total_Payment.' + '.$total_Med_Payment.' '; $content.=""; diff --git a/old_code_ci3/controllers/Report5.php b/old_code_ci3/controllers/Report5.php index f27d3e9..b64e6e4 100644 --- a/old_code_ci3/controllers/Report5.php +++ b/old_code_ci3/controllers/Report5.php @@ -4,6 +4,7 @@ class Report5 extends MY_Controller { function __construct() { parent::__construct(); + $this->load->library("Pdf"); } function document_list() @@ -14,7 +15,9 @@ class Report5 extends MY_Controller { $this->load->view('Report5/Report_Document',$data); } - + + + function document_list_data($daterange,$dr_id,$output=0) { $rangeArray = explode("S",$daterange); @@ -22,7 +25,8 @@ class Report5 extends MY_Controller { $maxRange = $rangeArray[1]; $where =" 1=1 " ; - + + if($dr_id>0) { $where.=" and doc.id =".$dr_id; @@ -94,80 +98,6 @@ class Report5 extends MY_Controller { } - // Xray Chest List - public function Report_XRay_chest() - { - $this->load->view('Report5/Report_XRay_chest'); - } - - public function XRay_chest_data($daterange,$output=0){ - $rangeArray = explode("S",$daterange); - $minRange = $rangeArray[0]; - $maxRange = $rangeArray[1]; - - - $sql="SELECT p.p_code,p.p_fname,p.xgender,p.str_age,p.mphone1,p_address, - date_format(m.inv_date,'%d-%m-%Y') AS str_test_date,i.item_name,t.group_desc,i.item_id - FROM ((patient_master_exten p JOIN invoice_master m ON p.id=m.attach_id) - JOIN invoice_item i ON m.id=i.inv_master_id) - JOIN hc_item_type t ON i.item_type=t.itype_id - WHERE m.inv_date BETWEEN '".$minRange."' AND '".$maxRange."' - AND i.item_id=61 "; - - //echo $sql; - - $query = $this->db->query($sql); - $doclist= $query->result(); - - $content='

'.H_Name.'

'; - $content.='

'.H_address_1.'

'; - - $content.='

X-Ray Chest

'; - - $content.=''; - - $content.=' - - - - - - - - - - '; - $sr_no=0; - foreach($doclist as $row) - { - $sr_no=$sr_no+1; - $content.=' - - - - - - - - - - '; - } - $content.="
#PCode/UHIDPatient NameAgeGenderAddressPhone NumberTest DateTest Name
'.$sr_no.''.$row->p_code.''.$row->p_fname.''.$row->str_age.''.$row->xgender.''.$row->p_address.''.$row->mphone1.''.$row->str_test_date.''.$row->item_name.'
"; - - if($output==0) - { - $this->load->library('m_pdf'); - $file_name="Report-".date('Ymdhis').".pdf"; - $filepath=$file_name; - $this->m_pdf->pdf->WriteHTML($content); - $this->m_pdf->pdf->Output($filepath,"I"); - }else{ - ExportExcel($content,'XRay_chest_list'.date('Yms')); - } - } - - // Corona public function corona_suspected() { @@ -241,79 +171,6 @@ class Report5 extends MY_Controller { } } - // pregnancy - public function pregnancy_search() - { - $this->load->view('Report5/Report_pregnancy_suspected'); - } - - function pregnancy_data($daterange,$output=0) - { - $rangeArray = explode("S",$daterange); - $minRange = $rangeArray[0]; - $maxRange = $rangeArray[1]; - - $where =" " ; - - $where.=" and m.apointment_date between '".$minRange."' and '".$maxRange."' " ; - - $sql="SELECT p.p_code,p.p_fname,p.xgender,p.str_age,p.mphone1,p_address, - date_format(m.apointment_date,'%d-%m-%Y') AS str_apointment_date,o.complaints - FROM (opd_prescription o JOIN opd_master m ON m.opd_id=o.opd_id) - JOIN patient_master_exten p ON m.p_id=p.id - WHERE o.pregnancy=1 ".$where." "; - - //echo $sql; - - $query = $this->db->query($sql); - $doclist= $query->result(); - - $content='

'.H_Name.'

'; - $content.='

'.H_address_1.'

'; - - $content.='

Pregnancy Data

'; - - $content.=''; - - $content.=' - - - - - - - - - '; - $sr_no=0; - foreach($doclist as $row) - { - $sr_no=$sr_no+1; - $content.=' - - - - - - - - - '; - } - $content.="
#Patient NameAgeGenderAddressPhone NumberVisit DateSymptoms
'.$sr_no.''.$row->p_fname.''.$row->str_age.''.$row->xgender.''.$row->p_address.''.$row->mphone1.''.$row->str_apointment_date.''.$row->complaints.'
"; - - if($output==0) - { - $this->load->library('m_pdf'); - $file_name="Report-".date('Ymdhis').".pdf"; - $filepath=$file_name; - $this->m_pdf->pdf->WriteHTML($content); - $this->m_pdf->pdf->Output($filepath,"I"); - }else{ - ExportExcel($content,'pregnancy_data'.date('Yms')); - } - } - //Dengue public function dengue() diff --git a/old_code_ci3/controllers/ReportPanel2.php b/old_code_ci3/controllers/ReportPanel2.php index 58db238..9f866f3 100644 --- a/old_code_ci3/controllers/ReportPanel2.php +++ b/old_code_ci3/controllers/ReportPanel2.php @@ -226,7 +226,7 @@ EOD; o.opd_fee_gross_amount as 'GrossAmt', o.opd_discount as Discount, o.opd_fee_amount as 'FeeAmt', - o.prepared_by,IFNULL(GET_AGE_BY_DOB(dob),age) as Age "; + o.prepared_by,GET_AGE_1(dob,age,age_in_month,estimate_dob) as Age "; $sql_from=" from opd_master o join payment_mode m join patient_master p on o.payment_mode=m.id and p.id=o.p_id"; diff --git a/old_code_ci3/controllers/Report_bak.php b/old_code_ci3/controllers/Report_bak.php new file mode 100644 index 0000000..e8e1882 --- /dev/null +++ b/old_code_ci3/controllers/Report_bak.php @@ -0,0 +1,1978 @@ +load->library("Pdf"); + } + + public function opd() { + + $this->load->library('table'); + + $template = array( + 'table_open' => '', + 'thead_open' => '', + 'thead_close' => '', + + 'heading_row_start' => '', + 'heading_row_end' => '', + 'heading_cell_start' => '', + + 'tbody_open' => '', + 'tbody_close' => '', + + 'row_start' => '', + 'row_end' => '', + 'cell_start' => '', + + 'row_alt_start' => '', + 'row_alt_end' => '', + 'cell_alt_start' => '', + + 'table_close' => '
', + 'heading_cell_end' => '
', + 'cell_end' => '
', + 'cell_alt_end' => '
' + ); + + $this->table->set_template($template); + + $query = $this->db->query("select o.opd_code,o.P_name,o.apointment_date,o.doc_name + from opd_master o"); + + $table_show = $this->table->generate($query); + + //echo $table_show; + // create new PDF document + $pdf = new TCPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false); + + // set document information + $pdf->SetCreator(PDF_CREATOR); + $pdf->SetAuthor('IHC:D.S.Bisht'); + $pdf->SetTitle('IHC:OPD List'); + $pdf->SetSubject('IHC:OPD List'); + $pdf->SetKeywords('IHC:OPD List, PDF, OPD, List, guide'); + + // set default header data + $pdf->SetHeaderData(PDF_HEADER_LOGO, PDF_HEADER_LOGO_WIDTH, PDF_HEADER_TITLE, PDF_HEADER_STRING, array(0,64,255), array(0,64,128)); + $pdf->setFooterData(array(0,64,0), array(0,64,128)); + + // set header and footer fonts + $pdf->setHeaderFont(Array(PDF_FONT_NAME_MAIN, '', PDF_FONT_SIZE_MAIN)); + $pdf->setFooterFont(Array(PDF_FONT_NAME_DATA, '', PDF_FONT_SIZE_DATA)); + + // set default monospaced font + $pdf->SetDefaultMonospacedFont(PDF_FONT_MONOSPACED); + + // set margins + $pdf->SetMargins(PDF_MARGIN_LEFT, PDF_MARGIN_TOP, PDF_MARGIN_RIGHT); + $pdf->SetHeaderMargin(PDF_MARGIN_HEADER); + $pdf->SetFooterMargin(PDF_MARGIN_FOOTER); + + // set auto page breaks + $pdf->SetAutoPageBreak(TRUE, PDF_MARGIN_BOTTOM); + + // set image scale factor + $pdf->setImageScale(PDF_IMAGE_SCALE_RATIO); + + // set some language-dependent strings (optional) + if (@file_exists(dirname(__FILE__).'/lang/eng.php')) { + require_once(dirname(__FILE__).'/lang/eng.php'); + $pdf->setLanguageArray($l); + } + + // --------------------------------------------------------- + + // set default font subsetting mode + $pdf->setFontSubsetting(true); + + // Set font + // dejavusans is a UTF-8 Unicode font, if you only need to + // print standard ASCII chars, you can use core fonts like + // helvetica or times to reduce file size. + $pdf->SetFont('dejavusans', '', 14, '', true); + + // Add a page + // This method has several options, check the source code documentation for more information. + $pdf->AddPage(); + + // set text shadow effect + $pdf->setTextShadow(array('enabled'=>true, 'depth_w'=>0.2, 'depth_h'=>0.2, 'color'=>array(196,196,196), 'opacity'=>1, 'blend_mode'=>'Normal')); + + $test= '

Report Sample Page TEsted

'; + // Set some content to print + $html = <<writeHTMLCell(0, 0, '', '', $html, 0, 1, 0, true, '', true); + + // --------------------------------------------------------- + + // Close and output PDF document + // This method has several options, check the source code documentation for more information. + $pdf->Output('OPD_001.pdf', 'I'); + + //============================================================+ + // END OF FILE + //============================================================+ + } + + public function index() + { + $this->load->view('Report/ReportMain'); + } + public function report_opd_app() + { + + $sql="select * from doctor_master where active=1 order by p_fname"; + $query = $this->db->query($sql); + $data['doclist']= $query->result(); + + $sql="select * from users where active=1 order by first_name"; + $query = $this->db->query($sql); + $data['emplist']= $query->result(); + + $sql="select * from payment_mode "; + $query = $this->db->query($sql); + $data['paymodelist']= $query->result(); + + $this->load->view('Report/rep_opd_p',$data); + } + + + public function report_charge_app() + { + $sql="select * from doctor_master where active=1 order by p_fname"; + $query = $this->db->query($sql); + $data['doclist']= $query->result(); + + $sql="select * from users where active=1 order by first_name"; + $query = $this->db->query($sql); + $data['emplist']= $query->result(); + + $sql="select * from payment_mode "; + $query = $this->db->query($sql); + $data['paymodelist']= $query->result(); + + $this->load->view('Report/rep_other_charge',$data); + } + + public function report_ipdpayment_app() + { + $sql="select * from doctor_master where active=1 order by p_fname"; + $query = $this->db->query($sql); + $data['doclist']= $query->result(); + + $sql="select * from users where active=1 order by first_name"; + $query = $this->db->query($sql); + $data['emplist']= $query->result(); + + $sql="select * from payment_mode where id in (1,2) "; + $query = $this->db->query($sql); + $data['paymodelist']= $query->result(); + + $this->load->view('Report/ipd_payment_report',$data); + } + + public function report_totalpayment_app() + { + $sql="select * from doctor_master where active=1 order by p_fname"; + $query = $this->db->query($sql); + $data['doclist']= $query->result(); + + $sql="select * from users where active=1 order by first_name"; + $query = $this->db->query($sql); + $data['emplist']= $query->result(); + + $sql="select * from payment_mode where id in (1,2) "; + $query = $this->db->query($sql); + $data['paymodelist']= $query->result(); + + $this->load->view('Report/rep_total_payment',$data); + } + + public function report_emp_total_app() + { + $sql="select * from doctor_master where active=1 order by p_fname"; + $query = $this->db->query($sql); + $data['doclist']= $query->result(); + + $sql="select * from users where active=1 order by first_name"; + $query = $this->db->query($sql); + $data['emplist']= $query->result(); + + $sql="select * from payment_mode where id in (1,2) "; + $query = $this->db->query($sql); + $data['paymodelist']= $query->result(); + + $this->load->view('Report/rep_collocation_emp',$data); + } + + public function report_opd_app_show($opd_date_range, + $doc_name_id,$emp_name_id,$paymode_id,$order_1,$order_2,$group_by) + { + $sql_f_all = "select o.opd_code, + o.P_name ,p_code ,Date_Format(o.apointment_date,'%d-%m-%Y') as 'App_Date', + o.doc_name ,if(o.insurance_id>1,'Org.','Direct') as 'Type', + m.mode_desc as 'PayMode',o.opd_fee_gross_amount as 'GrossAmt', + o.opd_discount as Discount, o.opd_fee_amount as 'FeeAmt', + o.prepared_by,GET_AGE_1(dob,age,age_in_month,estimate_dob) as Age "; + + $sql_from=" from opd_master o join payment_mode m join patient_master p on o.payment_mode=m.id and p.id=o.p_id"; + + $sql_where=" Where 1=1 "; + + $rangeArray = explode("S",$opd_date_range); + $minRange = $rangeArray[0]; + $maxRange = $rangeArray[1]; + $sql_where.=" and o.apointment_date between '".$minRange."' and '".$maxRange. "'"; + + if($doc_name_id>0) + { + $sql_where.=" and o.doc_id='".$doc_name_id."'"; + } + + if($emp_name_id>0) + { + $sql_where.=" and o.prepared_by like '%[".$emp_name_id."]'"; + } + + if($paymode_id>0) + { + $sql_where.=" and o.payment_mode = '".$paymode_id."'"; + } + + $sql_order=" Order by o.apointment_date"; + + if($order_1==1) + { + $sql_order.=' ,o.doc_name'; + } + + if($order_1==2) + { + $sql_order.=' ,o.prepared_by'; + } + + if($order_1==3) + { + $sql_order.=' ,m.mode_desc'; + } + + if($order_2==1) + { + $sql_order.=' ,o.doc_name'; + } + + if($order_2==2) + { + $sql_order.=' ,o.prepared_by'; + } + + //echo $table_show; + // create new PDF document + $pdf = new TCPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false); + + // set document information + $pdf->SetCreator(PDF_CREATOR); + $pdf->SetAuthor('IHC:D.S.Bisht'); + $pdf->SetTitle('IHC:OPD List'); + $pdf->SetSubject('IHC:OPD List'); + $pdf->SetKeywords('IHC:OPD List, PDF, OPD, List, guide'); + + // set default header data + $pdf->SetHeaderData(PDF_HEADER_LOGO, PDF_HEADER_LOGO_WIDTH, PDF_HEADER_TITLE, PDF_HEADER_STRING, array(0,64,255), array(0,64,128)); + $pdf->setFooterData(array(0,64,0), array(0,64,128)); + + // set header and footer fonts + $pdf->setHeaderFont(Array(PDF_FONT_NAME_MAIN, '', PDF_FONT_SIZE_MAIN)); + $pdf->setFooterFont(Array(PDF_FONT_NAME_DATA, '', PDF_FONT_SIZE_DATA)); + + // set default monospaced font + $pdf->SetDefaultMonospacedFont(PDF_FONT_MONOSPACED); + + // set margins + $pdf->SetMargins(PDF_MARGIN_LEFT, PDF_MARGIN_TOP, PDF_MARGIN_RIGHT); + $pdf->SetHeaderMargin(PDF_MARGIN_HEADER); + $pdf->SetFooterMargin(PDF_MARGIN_FOOTER); + + // set auto page breaks + $pdf->SetAutoPageBreak(TRUE, PDF_MARGIN_BOTTOM); + + // set image scale factor + $pdf->setImageScale(PDF_IMAGE_SCALE_RATIO); + + // set some language-dependent strings (optional) + if (@file_exists(dirname(__FILE__).'/lang/eng.php')) { + require_once(dirname(__FILE__).'/lang/eng.php'); + $pdf->setLanguageArray($l); + } + + // --------------------------------------------------------- + + // set default font subsetting mode + $pdf->setFontSubsetting(true); + + // Set font + // dejavusans is a UTF-8 Unicode font, if you only need to + // print standard ASCII chars, you can use core fonts like + // helvetica or times to reduce file size. + $pdf->SetFont('dejavusans', '', 8, '', true); + + // Add a page + // This method has several options, check the source code documentation for more information. + + // set text shadow effect + //$pdf->setTextShadow(array('enabled'=>true, 'depth_w'=>0.2, 'depth_h'=>0.2, 'color'=>array(196,196,196), 'opacity'=>1, 'blend_mode'=>'Normal')); + + $table_start=''; + $table_end='
'; + + if($group_by==0) + { + $table_head=''; + $table_head.='OPD ID'; + $table_head.='Patient Name / Age'; + $table_head.='Patient Code'; + $table_head.='Doctor Name'; + $table_head.='Pay Mode'; + $table_head.='Employee'; + $table_head.='Fee Amt.'; + + $GroupSQL="select Date(o.apointment_date) as sdate,Date_Format(Date(o.apointment_date),'%d-%m-%Y') as strDate + from opd_master o where Date(o.apointment_date) between '".$minRange."' and '".$maxRange. "' + group by Date(o.apointment_date)"; + + $query = $this->db->query($GroupSQL); + $data['group_rec']= $query->result(); + + foreach($data['group_rec'] as $row) + { + // Add a page + // This method has several options, check the source code documentation for more information. + $pdf->AddPage(); + + $data_show='OPD Date : '.$row->strDate.'
'; + + $gwhere=" and Date(o.apointment_date)='".$row->sdate."'"; + + $query = $this->db->query($sql_f_all.$sql_from.$sql_where.$gwhere.$sql_order); + $data['gsub_rec']= $query->result(); + + $table_body=''; + $table_total_1=0.00; + + foreach($data['gsub_rec'] as $rowdata) + { + $table_body.=''; + $table_body.=''.$rowdata->opd_code.''; + $table_body.=''.$rowdata->P_name.'/'.$rowdata->Age.''; + $table_body.=''.$rowdata->p_code.''; + $table_body.=''.$rowdata->doc_name.''; + $table_body.=''.$rowdata->PayMode.''; + $table_body.=''.$rowdata->prepared_by.''; + $table_body.=''.$rowdata->FeeAmt.''; + $table_body.=''; + $table_total_1=$table_total_1+$rowdata->FeeAmt; + } + $table_footer=''; + $table_footer.='Total'; + $table_footer.=''.$table_total_1.''; + + $data_show.=$table_start.$table_head.$table_body.$table_footer.$table_end; + + // Set some content to print + $html = <<writeHTMLCell(0, 0, '', '', $html, 0, 1, 0, true, '', true); + + + } + } + + if($group_by==1) + { + $table_head=''; + $table_head.='OPD ID'; + $table_head.='Patient Name'; + $table_head.='Patient Code'; + $table_head.='Date'; + $table_head.='Pay Mode'; + $table_head.='Employee'; + $table_head.='Fee Amt.'; + + + $GroupSQL="select o.doc_id,doc_name + from opd_master o where Date(o.apointment_date) between '".$minRange."' and '".$maxRange. "' group by o.doc_id"; + + $query = $this->db->query($GroupSQL); + $data['group_rec']= $query->result(); + + foreach($data['group_rec'] as $row) + { + // Add a page + // This method has several options, check the source code documentation for more information. + $pdf->AddPage(); + + $data_show='Doctor Name : Dr.'.$row->doc_name.'
'; + + $gwhere=" and doc_id='".$row->doc_id."'"; + + $query = $this->db->query($sql_f_all.$sql_from.$sql_where.$gwhere.$sql_order); + $data['gsub_rec']= $query->result(); + + $table_body=''; + $table_total_1=0.00; + foreach($data['gsub_rec'] as $rowdata) + { + $table_body.=''; + $table_body.=''.$rowdata->opd_code.''; + $table_body.=''.$rowdata->P_name.'/'.$rowdata->Age.''; + $table_body.=''.$rowdata->p_code.''; + $table_body.=''.$rowdata->App_Date.''; + $table_body.=''.$rowdata->PayMode.''; + $table_body.=''.$rowdata->prepared_by.''; + $table_body.=''.$rowdata->FeeAmt.''; + $table_body.=''; + $table_total_1=$table_total_1+$rowdata->FeeAmt; + } + $table_footer=''; + $table_footer.='Total'; + $table_footer.=''.$table_total_1.''; + + $data_show.=$table_start.$table_head.$table_body.$table_footer.$table_end; + + // Set some content to print + $html = <<writeHTMLCell(0, 0, '', '', $html, 0, 1, 0, true, '', true); + + + } + } + + if($group_by==2) + { + $table_head=''; + $table_head.='OPD ID'; + $table_head.='Patient Name'; + $table_head.='Patient Code'; + $table_head.='App. Date'; + $table_head.='Doctor Name'; + $table_head.='Pay Mode'; + $table_head.='Fee Amt.'; + + $GroupSQL="select o.prepared_by + from opd_master o where Date(o.apointment_date) between'".$minRange."' and '".$maxRange. "' group by o.prepared_by"; + + $query = $this->db->query($GroupSQL); + $data['group_rec']= $query->result(); + + foreach($data['group_rec'] as $row) + { + // Add a page + // This method has several options, check the source code documentation for more information. + $pdf->AddPage(); + + $data_show='Prepared By : '.$row->prepared_by.'
'; + + $gwhere=" and o.prepared_by='".$row->prepared_by."'"; + + $query = $this->db->query($sql_f_all.$sql_from.$sql_where.$gwhere.$sql_order); + $data['gsub_rec']= $query->result(); + + $table_body=''; + $table_total_1=0.00; + foreach($data['gsub_rec'] as $rowdata) + { + $table_body.=''; + $table_body.=''.$rowdata->opd_code.''; + $table_body.=''.$rowdata->P_name.'/'.$rowdata->Age.''; + $table_body.=''.$rowdata->p_code.''; + $table_body.=''.$rowdata->App_Date.''; + $table_body.=''.$rowdata->doc_name.''; + $table_body.=''.$rowdata->PayMode.''; + $table_body.=''.$rowdata->FeeAmt.''; + $table_body.=''; + $table_total_1=$table_total_1+$rowdata->FeeAmt; + } + $table_footer=''; + $table_footer.='Total'; + $table_footer.=''.$table_total_1.''; + + $data_show.=$table_start.$table_head.$table_body.$table_footer.$table_end; + + // Set some content to print + $html = <<writeHTMLCell(0, 0, '', '', $html, 0, 1, 0, true, '', true); + + + } + } + + + if($group_by==3) + { + $table_head=''; + $table_head.='OPD ID'; + $table_head.='Patient Name'; + $table_head.='Patient Code'; + $table_head.='Date'; + $table_head.='Doctor Name'; + $table_head.='Employee'; + $table_head.='Fee Amt.'; + + $GroupSQL="select o.payment_mode,m.mode_desc as 'PayMode' + from opd_master o join payment_mode m on o.payment_mode=m.id where Date(o.apointment_date) between'".$minRange."' and '".$maxRange. "' group by o.payment_mode"; + + $query = $this->db->query($GroupSQL); + $data['group_rec']= $query->result(); + + foreach($data['group_rec'] as $row) + { + // Add a page + // This method has several options, check the source code documentation for more information. + $pdf->AddPage(); + + $data_show='Payment Mode : '.$row->PayMode.'
'; + + $gwhere=" and o.payment_mode='".$row->payment_mode."'"; + + $query = $this->db->query($sql_f_all.$sql_from.$sql_where.$gwhere.$sql_order); + $data['gsub_rec']= $query->result(); + + $table_body=''; + $table_total_1=0.00; + foreach($data['gsub_rec'] as $rowdata) + { + $table_body.=''; + $table_body.=''.$rowdata->opd_code.''; + $table_body.=''.$rowdata->P_name.'/'.$rowdata->Age.''; + $table_body.=''.$rowdata->p_code.''; + $table_body.=''.$rowdata->App_Date.''; + $table_body.=''.$rowdata->doc_name.''; + $table_body.=''.$rowdata->prepared_by.''; + $table_body.=''.$rowdata->FeeAmt.''; + $table_body.=''; + $table_total_1=$table_total_1+$rowdata->FeeAmt; + } + $table_footer=''; + $table_footer.='Total'; + $table_footer.=''.$table_total_1.''; + + $data_show.=$table_start.$table_head.$table_body.$table_footer.$table_end; + + // Set some content to print + $html = <<writeHTMLCell(0, 0, '', '', $html, 0, 1, 0, true, '', true); + + + } + } + + // --------------------------------------------------------- + + // Close and output PDF document + // This method has several options, check the source code documentation for more information. + // $pdf->Output('OPD_001.pdf', 'I'); + $folder_name='uploads/'.date('Ymd'); + + if (!file_exists($folder_name)) { + mkdir($folder_name, 0777, true); + chmod($folder_name, 0777); + } + + $filename="OPD_0001".date('Ymdhis').".pdf"; + $filepath=$folder_name.'/'.$filename; + + + $pdf->Output($filepath, 'F'); + $pdf->Output($filepath); + + //============================================================+ + // END OF FILE + //============================================================+ + } + + + public function report_charge_app_show($opd_date_range, + $doc_name_id,$emp_name_id,$paymode_id,$order_1,$order_2,$group_by) + { + $sql_f_all = "select i.id,i.invoice_code,p.p_fname,p.p_code,i.refer_by_other, + i.inv_date,Date_Format(i.inv_date,'%d-%m-%Y') as str_inv_date,i.invoice_status, + if(i.insurance_id>1,'Org.','Direct') as PType,i.prepared_by, + if(i.correction_amount>0,i.correction_net_amount,i.net_amount) as Amount,m.mode_desc , + group_concat(t.item_name) as test_list"; + + $sql_from=" from invoice_master i join patient_master p join payment_mode m join invoice_item t + on i.attach_id=p.id and i.attach_type=0 and i.payment_mode=m.id and i.id=t.inv_master_id"; + + $sql_where=" Where i.invoice_status>0 "; + + $rangeArray = explode("S",$opd_date_range); + $minRange = $rangeArray[0]; + $maxRange = $rangeArray[1]; + $sql_where.=" and Date(i.inv_date) between Date('".$minRange."') and Date('".$maxRange. "') "; + + if($doc_name_id>0) + { + $sql_where.=" and i.refer_by_id='".$doc_name_id."'"; + } + + if($emp_name_id>0) + { + $sql_where.=" and i.prepared_by like '%[".$emp_name_id."]' "; + } + + if($paymode_id>0) + { + $sql_where.=" and i.payment_mode = '".$paymode_id."'"; + } + + $sql_order=" Order by i.inv_date"; + + if($order_1==1) + { + $sql_order.=' ,i.refer_by_other'; + } + + if($order_1==2) + { + $sql_order.=' ,i.prepared_by'; + } + + if($order_1==3) + { + $sql_order.=' ,m.mode_desc'; + } + + if($order_2==1) + { + $sql_order.=' ,i.refer_by_other'; + } + + if($order_2==2) + { + $sql_order.=' ,i.prepared_by'; + } + + //echo $table_show; + // create new PDF document + $pdf = new TCPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false); + + // set document information + $pdf->SetCreator(PDF_CREATOR); + $pdf->SetAuthor('IHC:D.S.Bisht'); + $pdf->SetTitle('IHC:OPD List'); + $pdf->SetSubject('IHC:OPD List'); + $pdf->SetKeywords('IHC:OPD List, PDF, OPD, List, guide'); + + // set default header data + $pdf->SetHeaderData(PDF_HEADER_LOGO, PDF_HEADER_LOGO_WIDTH, PDF_HEADER_TITLE, PDF_HEADER_STRING, array(0,64,255), array(0,64,128)); + $pdf->setFooterData(array(0,64,0), array(0,64,128)); + + // set header and footer fonts + $pdf->setHeaderFont(Array(PDF_FONT_NAME_MAIN, '', PDF_FONT_SIZE_MAIN)); + $pdf->setFooterFont(Array(PDF_FONT_NAME_DATA, '', PDF_FONT_SIZE_DATA)); + + // set default monospaced font + $pdf->SetDefaultMonospacedFont(PDF_FONT_MONOSPACED); + + // set margins + $pdf->SetMargins(PDF_MARGIN_LEFT, PDF_MARGIN_TOP, PDF_MARGIN_RIGHT); + $pdf->SetHeaderMargin(PDF_MARGIN_HEADER); + $pdf->SetFooterMargin(PDF_MARGIN_FOOTER); + + // set auto page breaks + $pdf->SetAutoPageBreak(TRUE, PDF_MARGIN_BOTTOM); + + // set image scale factor + $pdf->setImageScale(PDF_IMAGE_SCALE_RATIO); + + // set some language-dependent strings (optional) + if (@file_exists(dirname(__FILE__).'/lang/eng.php')) { + require_once(dirname(__FILE__).'/lang/eng.php'); + $pdf->setLanguageArray($l); + } + + // --------------------------------------------------------- + + // set default font subsetting mode + $pdf->setFontSubsetting(true); + + // Set font + // dejavusans is a UTF-8 Unicode font, if you only need to + // print standard ASCII chars, you can use core fonts like + // helvetica or times to reduce file size. + $pdf->SetFont('dejavusans', '', 8, '', true); + + // Add a page + // This method has several options, check the source code documentation for more information. + + // set text shadow effect + //$pdf->setTextShadow(array('enabled'=>true, 'depth_w'=>0.2, 'depth_h'=>0.2, 'color'=>array(196,196,196), 'opacity'=>1, 'blend_mode'=>'Normal')); + + $table_start=''; + $table_end='
'; + + if($group_by==0) + { + $table_head=''; + $table_head.='Invoice ID'; + $table_head.='Patient Name'; + $table_head.='Patient Code'; + $table_head.='Doctor Name'; + $table_head.='Pay Mode'; + $table_head.='Employee'; + $table_head.='Inv. Amt.'; + + $GroupSQL="select Date(i.inv_date) as sdate,Date_Format(Date(i.inv_date),'%d-%m-%Y') as strDate + from invoice_master i where i.invoice_status>0 and Date(i.inv_date) between'".$minRange."' and '".$maxRange. "' + group by Date(i.inv_date)"; + + $query = $this->db->query($GroupSQL); + $data['group_rec']= $query->result(); + + foreach($data['group_rec'] as $row) + { + // Add a page + // This method has several options, check the source code documentation for more information. + $pdf->AddPage(); + + $data_show='Invoice Date : '.$row->strDate.'
'; + + $gwhere=" and Date(i.inv_date)='".$row->sdate."'"; + + $query = $this->db->query($sql_f_all.$sql_from.$sql_where.$gwhere.' group by i.id '.$sql_order); + $data['gsub_rec']= $query->result(); + + $table_body=''; + $table_total_1=0; + + foreach($data['gsub_rec'] as $rowdata) + { + $table_body.=''; + $table_body.=''.$rowdata->invoice_code.''; + $table_body.=''.$rowdata->p_fname.''; + $table_body.=''.$rowdata->p_code.''; + $table_body.=''.$rowdata->refer_by_other.''; + $table_body.=''.$rowdata->mode_desc.''; + $table_body.=''.$rowdata->prepared_by.''; + $table_body.=''.$rowdata->Amount.''; + $table_body.=''; + $table_body.=''.$rowdata->test_list.''; + $table_total_1=$table_total_1+$rowdata->Amount; + } + $table_footer=''; + $table_footer.='Total'; + $table_footer.=''.$table_total_1.''; + + $data_show.=$table_start.$table_head.$table_body.$table_footer.$table_end; + + // Set some content to print + $html = <<writeHTMLCell(0, 0, '', '', $html, 0, 1, 0, true, '', true); + + } + } + + if($group_by==1) + { + $table_head=''; + $table_head.='Invoice ID'; + $table_head.='Patient Name'; + $table_head.='Patient Code'; + $table_head.='Doctor Name'; + $table_head.='Pay Mode'; + $table_head.='Employee'; + $table_head.='Amount'; + + $GroupSQL="select i.refer_by_id,refer_by_other + from invoice_master i where i.invoice_status>0 and Date(i.inv_date) between'".$minRange."' and '".$maxRange. "' group by i.refer_by_id"; + + $query = $this->db->query($GroupSQL); + $data['group_rec']= $query->result(); + + foreach($data['group_rec'] as $row) + { + // Add a page + // This method has several options, check the source code documentation for more information. + $pdf->AddPage(); + + $data_show='Doctor Name : Dr.'.$row->refer_by_other.'
'; + + $gwhere=" and i.refer_by_id='".$row->refer_by_id."'"; + + $query = $this->db->query($sql_f_all.$sql_from.$sql_where.$gwhere.' group by i.id '.$sql_order); + $data['gsub_rec']= $query->result(); + + $table_body=''; + $table_total_1=0.00; + foreach($data['gsub_rec'] as $rowdata) + { + $table_body.=''; + $table_body.=''.$rowdata->invoice_code.''; + $table_body.=''.$rowdata->p_fname.''; + $table_body.=''.$rowdata->p_code.''; + $table_body.=''.$rowdata->inv_date.''; + $table_body.=''.$rowdata->mode_desc.''; + $table_body.=''.$rowdata->prepared_by.''; + $table_body.=''.$rowdata->Amount.''; + $table_body.=''; + $table_body.=''.$rowdata->test_list.''; + $table_total_1=$table_total_1+$rowdata->Amount; + } + $table_footer=''; + $table_footer.='Total'; + $table_footer.=''.$table_total_1.''; + + $data_show.=$table_start.$table_head.$table_body.$table_footer.$table_end; + + // Set some content to print + $html = <<writeHTMLCell(0, 0, '', '', $html, 0, 1, 0, true, '', true); + + + } + } + + if($group_by==2) + { + $table_head=''; + $table_head.='Invoice ID'; + $table_head.='Patient Name'; + $table_head.='Patient Code'; + $table_head.='Invoice Date'; + $table_head.='Doctor Name'; + $table_head.='Pay Mode'; + $table_head.='Amount'; + + $GroupSQL="select i.prepared_by + from opd_master i where i.invoice_status>0 and Date(i.apointment_date) between'".$minRange."' and '".$maxRange. "' group by i.prepared_by"; + + $query = $this->db->query($GroupSQL); + $data['group_rec']= $query->result(); + + foreach($data['group_rec'] as $row) + { + // Add a page + // This method has several options, check the source code documentation for more information. + $pdf->AddPage(); + + $data_show='Prepared By : '.$row->prepared_by.'
'; + + $gwhere=" and i.prepared_by='".$row->prepared_by."'"; + + $query = $this->db->query($sql_f_all.$sql_from.$sql_where.$gwhere.' group by i.id '.$sql_order); + $data['gsub_rec']= $query->result(); + + $table_body=''; + $table_total_1=0.00; + foreach($data['gsub_rec'] as $rowdata) + { + $table_body.=''; + $table_body.=''.$rowdata->invoice_code.''; + $table_body.=''.$rowdata->p_fname.''; + $table_body.=''.$rowdata->p_code.''; + $table_body.=''.$rowdata->inv_date.''; + $table_body.=''.$rowdata->refer_by_other.''; + $table_body.=''.$rowdata->mode_desc.''; + $table_body.=''.$rowdata->Amount.''; + $table_body.=''; + $table_body.=''.$rowdata->test_list.''; + $table_total_1=$table_total_1+$rowdata->Amount; + } + $table_footer=''; + $table_footer.='Total'; + $table_footer.=''.$table_total_1.''; + + $data_show.=$table_start.$table_head.$table_body.$table_footer.$table_end; + + // Set some content to print + $html = <<writeHTMLCell(0, 0, '', '', $html, 0, 1, 0, true, '', true); + + + } + } + + + if($group_by==3) + { + $table_head=''; + $table_head.='Invoice ID'; + $table_head.='Patient Name'; + $table_head.='Patient Code'; + $table_head.='Inv.Date'; + $table_head.='Ref. Doc. Name'; + $table_head.='Employee'; + $table_head.='Amount'; + + $GroupSQL="select i.payment_mode,m.mode_desc as 'PayMode' + from invoice_master i join payment_mode m on i.payment_mode=m.id + where i.invoice_status>0 and Date(i.inv_date) between'".$minRange."' and '".$maxRange. "' group by i.payment_mode"; + + $query = $this->db->query($GroupSQL); + $data['group_rec']= $query->result(); + + foreach($data['group_rec'] as $row) + { + // Add a page + // This method has several options, check the source code documentation for more information. + $pdf->AddPage(); + + $data_show='Payment Mode : '.$row->PayMode.'
'; + + $gwhere=" and i.payment_mode='".$row->payment_mode."'"; + + $query = $this->db->query($sql_f_all.$sql_from.$sql_where.$gwhere.' group by i.id '.$sql_order); + $data['gsub_rec']= $query->result(); + + $table_body=''; + $table_total_1=0.00; + foreach($data['gsub_rec'] as $rowdata) + { + $table_body.=''; + $table_body.=''.$rowdata->invoice_code.''; + $table_body.=''.$rowdata->p_fname.''; + $table_body.=''.$rowdata->p_code.''; + $table_body.=''.$rowdata->inv_date.''; + $table_body.=''.$rowdata->refer_by_other.''; + $table_body.=''.$rowdata->prepared_by.''; + $table_body.=''.$rowdata->Amount.''; + $table_body.=''; + $table_body.=''.$rowdata->test_list.''; + $table_total_1=$table_total_1+$rowdata->Amount; + } + $table_footer=''; + $table_footer.='Total'; + $table_footer.=''.$table_total_1.''; + + $data_show.=$table_start.$table_head.$table_body.$table_footer.$table_end; + + // Set some content to print + $html = <<writeHTMLCell(0, 0, '', '', $html, 0, 1, 0, true, '', true); + + + } + } + + + + // --------------------------------------------------------- + + // Close and output PDF document + // This method has several options, check the source code documentation for more information. + $pdf->Output('INV_001.pdf', 'I'); + + //============================================================+ + // END OF FILE + //============================================================+ + } + + + public function report_ipdpayment_app_show($opd_date_range, + $doc_name_id,$emp_name_id,$paymode_id,$order_1,$order_2,$group_by) + { + $sql_f_all = "select i.id,i.ipd_code,i.ipd_status,m.p_fname,m.p_code,contact_person_Name, + i.register_date,p.pay_date,p.enter_pay_date,p.payment_id, + if(Date(p.pay_date)=date(p.enter_pay_date),p.pay_date,Concat(p.pay_date,'
',p.enter_pay_date)) as strPayDate, + if(i.ipd_status=0,'Admit','Discharged') as IPD_Status, + if(credit_debit=0,p.amount,0) as C_Amount, + if(credit_debit=1,p.amount,0) as D_Amount,p.payment_mode_desc, + doc.doc_name,doc_list,p.prepared_by "; + + $sql_from=" from ipd_payment p join ipd_master i join patient_master m join + (select l.ipd_id,group_concat(d.p_fname) as doc_name,group_concat(d.id) as doc_list from ipd_master_doc_list l + join doctor_master d on l.doc_id=d.id group by l.ipd_id ) as doc + on i.id=p.ipd_id and i.p_id=m.id and i.id=doc.ipd_id"; + + $sql_where=" Where 1=1 "; + + $rangeArray = explode("S",$opd_date_range); + $minRange = $rangeArray[0]; + $maxRange = $rangeArray[1]; + $sql_where.=" and Date(p.pay_date) between '".$minRange."' and '".$maxRange. "'"; + + if($doc_name_id>0) + { + $sql_where.=" and FIND_IN_SET('".$doc_name_id."',doc_list) "; + } + + if($emp_name_id>0) + { + $sql_where.=" and p.prepared_by like '%[".$emp_name_id."]' "; + } + + if($paymode_id>0) + { + $sql_where.=" and p.payment_mode = '".$paymode_id."'"; + } + + $sql_order=" Order by p.pay_date"; + + if($order_1==1) + { + $sql_order.=' ,doc.doc_name'; + } + + if($order_1==2) + { + $sql_order.=' ,p.prepared_by'; + } + + if($order_1==3) + { + $sql_order.=' ,p.payment_mode_desc'; + } + + if($order_2==1) + { + $sql_order.=' ,doc.doc_name'; + } + + if($order_2==2) + { + $sql_order.=' ,p.prepared_by'; + } + + //echo $table_show; + // create new PDF document + $pdf = new TCPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false); + + // set document information + $pdf->SetCreator(PDF_CREATOR); + $pdf->SetAuthor('IHC:D.S.Bisht'); + $pdf->SetTitle('IHC:OPD List'); + $pdf->SetSubject('IHC:OPD List'); + $pdf->SetKeywords('IHC:OPD List, PDF, OPD, List, guide'); + + // set default header data + $pdf->SetHeaderData(PDF_HEADER_LOGO, PDF_HEADER_LOGO_WIDTH, PDF_HEADER_TITLE, PDF_HEADER_STRING, array(0,64,255), array(0,64,128)); + $pdf->setFooterData(array(0,64,0), array(0,64,128)); + + // set header and footer fonts + $pdf->setHeaderFont(Array(PDF_FONT_NAME_MAIN, '', PDF_FONT_SIZE_MAIN)); + $pdf->setFooterFont(Array(PDF_FONT_NAME_DATA, '', PDF_FONT_SIZE_DATA)); + + // set default monospaced font + $pdf->SetDefaultMonospacedFont(PDF_FONT_MONOSPACED); + + // set margins + //$pdf->SetMargins(PDF_MARGIN_LEFT, PDF_MARGIN_TOP, PDF_MARGIN_RIGHT); + $pdf->SetMargins(5, PDF_MARGIN_TOP, 0.25); + $pdf->SetHeaderMargin(PDF_MARGIN_HEADER); + $pdf->SetFooterMargin(PDF_MARGIN_FOOTER); + + // set auto page breaks + $pdf->SetAutoPageBreak(TRUE, PDF_MARGIN_BOTTOM); + + // set image scale factor + $pdf->setImageScale(PDF_IMAGE_SCALE_RATIO); + + // set some language-dependent strings (optional) + if (@file_exists(dirname(__FILE__).'/lang/eng.php')) { + require_once(dirname(__FILE__).'/lang/eng.php'); + $pdf->setLanguageArray($l); + } + + // --------------------------------------------------------- + + // set default font subsetting mode + $pdf->setFontSubsetting(true); + + // Set font + // dejavusans is a UTF-8 Unicode font, if you only need to + // print standard ASCII chars, you can use core fonts like + // helvetica or times to reduce file size. + $pdf->SetFont('dejavusans', '', 8, '', true); + + // Add a page + // This method has several options, check the source code documentation for more information. + + // set text shadow effect + //$pdf->setTextShadow(array('enabled'=>true, 'depth_w'=>0.2, 'depth_h'=>0.2, 'color'=>array(196,196,196), 'opacity'=>1, 'blend_mode'=>'Normal')); + + $table_start=''; + $table_end='
'; + + $table_head=''; + $table_head.='IPD No '; + $table_head.='Patient Name / Patient Code'; + $table_head.='Doctor Name'; + $table_head.='Pay Date'; + $table_head.='Pay Mode'; + $table_head.='Amount (Cr.)'; + $table_head.='Amount (Dr.)'; + $table_head.='Employee'; + + if($group_by==0) + { + + + $GroupSQL="select Date(p.pay_date) as sdate,Date_Format(Date(p.pay_date),'%d-%m-%Y') as strDate + from ipd_payment p join ipd_master i join patient_master m on i.id=p.ipd_id and i.p_id=m.id + where Date(p.pay_date) between'".$minRange."' and '".$maxRange. "' + group by Date(p.pay_date) "; + + $query = $this->db->query($GroupSQL); + $data['group_rec']= $query->result(); + + foreach($data['group_rec'] as $row) + { + // Add a page + // This method has several options, check the source code documentation for more information. + $pdf->AddPage(); + + $data_show='Payment Date : '.$row->strDate.'
'; + + $gwhere=" and Date(p.pay_date)='".$row->sdate."'"; + + $query = $this->db->query($sql_f_all.$sql_from.$sql_where.$gwhere.' '.$sql_order); + $data['gsub_rec']= $query->result(); + + $table_body=''; + $table_total_1=0.00; + $table_Dr_total_1=0.00; + + //echo $sql_f_all.$sql_from.$sql_where.$gwhere.' '.$sql_order.'

'; + + foreach($data['gsub_rec'] as $rowdata) + { + $table_body.=''; + $table_body.=''.$rowdata->ipd_code.''; + $table_body.='['.$rowdata->p_code.']
'.$rowdata->p_fname.'
{'.$rowdata->contact_person_Name.'}'; + $table_body.=''.$rowdata->doc_name.''; + $table_body.=''.$rowdata->strPayDate.''; + $table_body.=''.$rowdata->payment_mode_desc.''; + $table_body.=''.$rowdata->C_Amount.''; + $table_body.=''.$rowdata->D_Amount.''; + $table_body.=''.$rowdata->prepared_by.''; + $table_body.=''; + + $table_total_1=$table_total_1+$rowdata->C_Amount; + $table_Dr_total_1=$table_Dr_total_1+$rowdata->D_Amount; + } + + $table_footer=''; + $table_footer.='Total'; + $table_footer.=''.$table_total_1.''; + $table_footer.=''.$table_Dr_total_1.''; + $table_footer.=''; + $data_show.=$table_start.$table_head.$table_body.$table_footer.$table_end; + + + // Set some content to print + $html = <<writeHTMLCell(0, 0, '', '', $html, 0, 1, 0, true, '', true); + + + } + } + + if($group_by==1) + { + + + $GroupSQL="select doc.doc_name + from ipd_payment p join ipd_master i join patient_master m join + (select l.ipd_id,group_concat(d.p_fname) as doc_name,group_concat(d.id) as doc_list from ipd_master_doc_list l + join doctor_master d on l.doc_id=d.id group by l.ipd_id ) as doc + on i.id=p.ipd_id and i.p_id=m.id and i.id=doc.ipd_id + where Date(p.pay_date) between'".$minRange."' and '".$maxRange. "' group by doc.doc_name"; + + $query = $this->db->query($GroupSQL); + $data['group_rec']= $query->result(); + + foreach($data['group_rec'] as $row) + { + // Add a page + // This method has several options, check the source code documentation for more information. + $pdf->AddPage(); + + $data_show='Doctor Name : Dr.'.$row->doc_name.'
'; + + $gwhere=" and doc.doc_name='".$row->doc_name."'"; + + $query = $this->db->query($sql_f_all.$sql_from.$sql_where.$gwhere.' '.$sql_order); + $data['gsub_rec']= $query->result(); + + $table_body=''; + $table_total_1=0.00; + $table_Dr_total_1=0.00; + + foreach($data['gsub_rec'] as $rowdata) + { + $table_body.=''; + $table_body.=''.$rowdata->ipd_code.''; + $table_body.='['.$rowdata->p_code.']
'.$rowdata->p_fname.'
{'.$rowdata->contact_person_Name.'}'; + $table_body.=''.$rowdata->doc_name.''; + $table_body.=''.$rowdata->strPayDate.''; + $table_body.=''.$rowdata->payment_mode_desc.''; + $table_body.=''.$rowdata->C_Amount.''; + $table_body.=''.$rowdata->D_Amount.''; + $table_body.=''.$rowdata->prepared_by.''; + $table_body.=''; + + $table_total_1=$table_total_1+$rowdata->C_Amount; + $table_Dr_total_1=$table_Dr_total_1+$rowdata->D_Amount; + + } + + $table_footer=''; + $table_footer.='Total'; + $table_footer.=''.$table_total_1.''; + $table_footer.=''.$table_Dr_total_1.''; + $table_footer.=''; + + $data_show.=$table_start.$table_head.$table_body.$table_footer.$table_end; + + // Set some content to print + $html = <<writeHTMLCell(0, 0, '', '', $html, 0, 1, 0, true, '', true); + + + } + } + + if($group_by==2) + { + + + $GroupSQL="select p.prepared_by + from ipd_payment p join ipd_master i join patient_master m + on i.id=p.ipd_id and i.p_id=m.id + Where Date(p.pay_date) between'".$minRange."' and '".$maxRange. "' group by p.prepared_by"; + + $query = $this->db->query($GroupSQL); + $data['group_rec']= $query->result(); + + foreach($data['group_rec'] as $row) + { + // Add a page + // This method has several options, check the source code documentation for more information. + $pdf->AddPage(); + + $data_show='Prepared By : '.$row->prepared_by.'
'; + + $gwhere=" and p.prepared_by='".$row->prepared_by."'"; + + $query = $this->db->query($sql_f_all.$sql_from.$sql_where.$gwhere.' '.$sql_order); + $data['gsub_rec']= $query->result(); + + $table_body=''; + $table_total_1=0.00; + $table_Dr_total_1=0.00; + + foreach($data['gsub_rec'] as $rowdata) + { + $table_body.=''; + $table_body.=''.$rowdata->ipd_code.''; + $table_body.='['.$rowdata->p_code.']
'.$rowdata->p_fname.'
{'.$rowdata->contact_person_Name.'}'; + $table_body.=''.$rowdata->doc_name.''; + $table_body.=''.$rowdata->strPayDate.''; + $table_body.=''.$rowdata->payment_mode_desc.''; + $table_body.=''.$rowdata->C_Amount.''; + $table_body.=''.$rowdata->D_Amount.''; + $table_body.=''.$rowdata->prepared_by.''; + $table_body.=''; + + $table_total_1=$table_total_1+$rowdata->C_Amount; + $table_Dr_total_1=$table_Dr_total_1+$rowdata->D_Amount; + } + + $table_footer=''; + $table_footer.='Total'; + $table_footer.=''.$table_total_1.''; + $table_footer.=''.$table_Dr_total_1.''; + $table_footer.=''; + + $data_show.=$table_start.$table_head.$table_body.$table_footer.$table_end; + + // Set some content to print + $html = <<writeHTMLCell(0, 0, '', '', $html, 0, 1, 0, true, '', true); + + + } + } + + + if($group_by==3) + { + + $GroupSQL="select p.payment_mode,p.payment_mode_desc + from ipd_payment p join ipd_master i join patient_master m + on i.id=p.ipd_id and i.p_id=m.id + Where Date(p.pay_date) between'".$minRange."' and '".$maxRange. "' group by p.payment_mode "; + + $query = $this->db->query($GroupSQL); + $data['group_rec']= $query->result(); + + foreach($data['group_rec'] as $row) + { + // Add a page + // This method has several options, check the source code documentation for more information. + $pdf->AddPage(); + + $data_show='Payment Mode : '.$row->payment_mode_desc.'
'; + + $gwhere=" and p.payment_mode='".$row->payment_mode."'"; + + $query = $this->db->query($sql_f_all.$sql_from.$sql_where.$gwhere.' '.$sql_order); + $data['gsub_rec']= $query->result(); + + $table_body=''; + $table_total_1=0.00; + $table_Dr_total_1=0.00; + + + foreach($data['gsub_rec'] as $rowdata) + { + $table_body.=''; + $table_body.=''.$rowdata->ipd_code.''; + $table_body.='['.$rowdata->p_code.']
'.$rowdata->p_fname.'
{'.$rowdata->contact_person_Name.'}'; + $table_body.=''.$rowdata->doc_name.''; + $table_body.=''.$rowdata->strPayDate.''; + $table_body.=''.$rowdata->payment_mode_desc.''; + $table_body.=''.$rowdata->C_Amount.''; + $table_body.=''.$rowdata->D_Amount.''; + $table_body.=''.$rowdata->prepared_by.''; + $table_body.=''; + + $table_total_1=$table_total_1+$rowdata->C_Amount; + $table_Dr_total_1=$table_Dr_total_1+$rowdata->D_Amount; + } + + $table_footer=''; + $table_footer.='Total'; + $table_footer.=''.$table_total_1.''; + $table_footer.=''.$table_Dr_total_1.''; + $table_footer.=''; + + $data_show.=$table_start.$table_head.$table_body.$table_footer.$table_end; + + // Set some content to print + $html = <<writeHTMLCell(0, 0, '', '', $html, 0, 1, 0, true, '', true); + + + } + } + + // --------------------------------------------------------- + + // Close and output PDF document + // This method has several options, check the source code documentation for more information. + $pdf->Output('ipd_payment_list.pdf', 'I'); + + //============================================================+ + // END OF FILE + //============================================================+ + } + + public function report_total_payment_app_show($opd_date_range,$emp_name_id,$paymode_id,$order_1,$output=0) + { + $sql_f_all = "select p.id,p.payment_date,date_format(p.payment_date,'%d-%m-%Y %H:%m') as str_payment_date, + case p.payof_type when 1 then 'OPD' + when 2 then 'Charges' when 4 then 'IPD' else 'Other' end as PayType, + payof_id,p.payof_code, + if(credit_debit=0,amount,0) as Cr_Amount, + if(credit_debit=1,amount,0) as Dr_Amount, + p.remark,p.update_by,get_patientinfo(p.payof_type,payof_id) as P_Name, + case p.payment_mode when 1 then 'Cash' when 2 then 'Bank' end as Pay_Mode"; + + $sql_from=" from payment_history p "; + + $sql_where=" Where 1=1 "; + + $rangeArray = explode("S",$opd_date_range); + $minRange = str_replace('T',' ',$rangeArray[0]); + $maxRange = str_replace('T',' ',$rangeArray[1]); + + if($minRange==$maxRange) + { + $sql_where.=" and Date(p.payment_date) between Date('".$minRange."') and Date('".$maxRange. "')"; + }else{ + $sql_where.=" and p.payment_date between '".$minRange."' and '".$maxRange. "'"; + } + + $data_show='

Date(YYYY-MM-DD h:m) between '.$minRange.' and '.$maxRange.'

'; + + if($emp_name_id<>0) + { + $emp_name_id=str_replace('S',',',$emp_name_id); + + $sql_where.=" and p.update_by_id in (".$emp_name_id.")"; + } + + if($paymode_id<1) + { + $sql_where.=" and p.payment_mode in (1,2) "; + }else{ + $sql_where.=" and p.payment_mode = '".$paymode_id."'"; + } + + $sql_order=" Order by p.id"; + + if($order_1==1) + { + $sql_order.=' ,p.update_by'; + } + + if($order_1==2) + { + $sql_order.=' ,p.payment_mode'; + } + + + $table_start=''; + $table_end='
'; + + $table_head=''; + $table_head.='PayID '; + $table_head.='Date'; + $table_head.='Type of Payment'; + $table_head.='OPD/IPD/In. Code '; + $table_head.='Pay Mode'; + $table_head.='Amt (Cr.)'; + $table_head.='Amt (Dr.)'; + $table_head.='Remark'; + $table_head.='Employee'; + + $query = $this->db->query($sql_f_all.$sql_from.$sql_where.' '.$sql_order); + $data['gsub_rec']= $query->result(); + + //echo $sql_f_all.$sql_from.$sql_where.' '.$sql_order; + + $table_body=''; + $table_total_1=0.00; + $table_Dr_total_1=0.00; + + // $sql_f_all.$sql_from.$sql_where.$gwhere.' '.$sql_order.'

'; + + foreach($data['gsub_rec'] as $rowdata) + { + $table_body.=''; + $table_body.=''.$rowdata->id.''; + $table_body.=''.$rowdata->str_payment_date.''; + $table_body.=''.$rowdata->PayType.''; + $table_body.=''.$rowdata->payof_code.'
'.$rowdata->P_Name.''; + $table_body.=''.$rowdata->Pay_Mode.''; + $table_body.=''.$rowdata->Cr_Amount.''; + $table_body.=''.$rowdata->Dr_Amount.''; + $table_body.=''.$rowdata->remark.''; + $table_body.=''.$rowdata->update_by.''; + $table_body.=''; + + $table_total_1=$table_total_1+$rowdata->Cr_Amount; + $table_Dr_total_1=$table_Dr_total_1+$rowdata->Dr_Amount; + } + + $table_footer=''; + $table_footer.='Total'; + $table_footer.=''.$table_total_1.''; + $table_footer.=''.$table_Dr_total_1.''; + $table_footer.=''; + $data_show.=$table_start.$table_head.$table_body.$table_footer.$table_end; + + $Total_Amount=$table_total_1-$table_Dr_total_1; + + $data_show.='

Total Amount : '.$Total_Amount.'

'; + + if($output==0) + { + //echo $data_show; + create_report_pdf($data_show,'Payment.pdf'); + }else{ + + ExportExcel($data_show,'Payment'); + } + } + + public function report_charge_type($opd_date_range) + { + $sql_f_all = "select p.id,p.payment_date,date_format(p.payment_date,'%d-%m-%Y %H:%m') as str_payment_date, + case p.payof_type when 1 then 'OPD' + when 2 then 'Charges' when 4 then 'IPD' else 'Other' end as PayType, + payof_id,p.payof_code, + if(credit_debit=0,amount,0) as Cr_Amount, + if(credit_debit=1,amount,0) as Dr_Amount, + p.remark,p.update_by,get_patientinfo(p.payof_type,payof_id) as P_Name, + case p.payment_mode when 1 then 'Cash' when 2 then 'Bank' end as Pay_Mode"; + + $sql_from=" from payment_history p "; + + $sql_where=" Where 1=1 "; + + $rangeArray = explode("S",$opd_date_range); + $minRange = str_replace('T',' ',$rangeArray[0]); + $maxRange = str_replace('T',' ',$rangeArray[1]); + + if($minRange==$maxRange) + { + $sql_where.=" and Date(p.payment_date) between Date('".$minRange."') and Date('".$maxRange. "')"; + }else{ + $sql_where.=" and p.payment_date between '".$minRange."' and '".$maxRange. "'"; + } + + $data_show='

Date(YYYY-MM-DD h:m) between '.$minRange.' and '.$maxRange.'

'; + + + if($emp_name_id<>0) + { + $emp_name_id=str_replace('S',',',$emp_name_id); + + $sql_where.=" and p.update_by_id in (".$emp_name_id.")"; + } + + if($paymode_id<1) + { + $sql_where.=" and p.payment_mode in (1,2) "; + }else{ + $sql_where.=" and p.payment_mode = '".$paymode_id."'"; + } + + $sql_order=" Order by p.id"; + + if($order_1==1) + { + $sql_order.=' ,p.update_by'; + } + + if($order_1==2) + { + $sql_order.=' ,p.payment_mode'; + } + + //echo $table_show; + // create new PDF document + $pdf = new TCPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false); + + // set document information + $pdf->SetCreator(PDF_CREATOR); + $pdf->SetAuthor('IHC:D.S.Bisht'); + $pdf->SetTitle('IHC:OPD List'); + $pdf->SetSubject('IHC:OPD List'); + $pdf->SetKeywords('IHC:OPD List, PDF, OPD, List, guide'); + + // set default header data + $pdf->SetHeaderData(PDF_HEADER_LOGO, PDF_HEADER_LOGO_WIDTH, PDF_HEADER_TITLE, PDF_HEADER_STRING, array(0,64,255), array(0,64,128)); + $pdf->setFooterData(array(0,64,0), array(0,64,128)); + + // set header and footer fonts + $pdf->setHeaderFont(Array(PDF_FONT_NAME_MAIN, '', PDF_FONT_SIZE_MAIN)); + $pdf->setFooterFont(Array(PDF_FONT_NAME_DATA, '', PDF_FONT_SIZE_DATA)); + + // set default monospaced font + $pdf->SetDefaultMonospacedFont(PDF_FONT_MONOSPACED); + + // set margins + //$pdf->SetMargins(PDF_MARGIN_LEFT, PDF_MARGIN_TOP, PDF_MARGIN_RIGHT); + $pdf->SetMargins(5, PDF_MARGIN_TOP, 0.25); + $pdf->SetHeaderMargin(PDF_MARGIN_HEADER); + $pdf->SetFooterMargin(PDF_MARGIN_FOOTER); + + // set auto page breaks + $pdf->SetAutoPageBreak(TRUE, PDF_MARGIN_BOTTOM); + + // set image scale factor + $pdf->setImageScale(PDF_IMAGE_SCALE_RATIO); + + // set some language-dependent strings (optional) + if (@file_exists(dirname(__FILE__).'/lang/eng.php')) { + require_once(dirname(__FILE__).'/lang/eng.php'); + $pdf->setLanguageArray($l); + } + + // --------------------------------------------------------- + + // set default font subsetting mode + $pdf->setFontSubsetting(true); + + // Set font + // dejavusans is a UTF-8 Unicode font, if you only need to + // print standard ASCII chars, you can use core fonts like + // helvetica or times to reduce file size. + $pdf->SetFont('dejavusans', '', 9, '', true); + + // Add a page + // This method has several options, check the source code documentation for more information. + + // set text shadow effect + //$pdf->setTextShadow(array('enabled'=>true, 'depth_w'=>0.2, 'depth_h'=>0.2, 'color'=>array(196,196,196), 'opacity'=>1, 'blend_mode'=>'Normal')); + + $table_start=''; + $table_end='
'; + + $table_head=''; + $table_head.='PayID '; + $table_head.='Date'; + $table_head.='Type of Payment'; + $table_head.='OPD/IPD/In. Code '; + $table_head.='Pay Mode'; + $table_head.='Amt (Cr.)'; + $table_head.='Amt (Dr.)'; + $table_head.='Remark'; + $table_head.='Employee'; + + // Add a page + // This method has several options, check the source code documentation for more information. + $pdf->AddPage(); + + $query = $this->db->query($sql_f_all.$sql_from.$sql_where.' '.$sql_order); + $data['gsub_rec']= $query->result(); + + //echo $sql_f_all.$sql_from.$sql_where.' '.$sql_order; + + $table_body=''; + $table_total_1=0.00; + $table_Dr_total_1=0.00; + + //echo $sql_f_all.$sql_from.$sql_where.$gwhere.' '.$sql_order.'

'; + + foreach($data['gsub_rec'] as $rowdata) + { + $table_body.=''; + $table_body.=''.$rowdata->id.''; + $table_body.=''.$rowdata->str_payment_date.''; + $table_body.=''.$rowdata->PayType.''; + $table_body.=''.$rowdata->payof_code.'
'.$rowdata->P_Name.''; + $table_body.=''.$rowdata->Pay_Mode.''; + $table_body.=''.$rowdata->Cr_Amount.''; + $table_body.=''.$rowdata->Dr_Amount.''; + $table_body.=''.$rowdata->remark.''; + $table_body.=''.$rowdata->update_by.''; + $table_body.=''; + + $table_total_1=$table_total_1+$rowdata->Cr_Amount; + $table_Dr_total_1=$table_Dr_total_1+$rowdata->Dr_Amount; + } + + $table_footer=''; + $table_footer.='Total'; + $table_footer.=''.$table_total_1.''; + $table_footer.=''.$table_Dr_total_1.''; + $table_footer.=''; + $data_show.=$table_start.$table_head.$table_body.$table_footer.$table_end; + + $Total_Amount=$table_total_1-$table_Dr_total_1; + + $data_show.='

Total Amount : '.$Total_Amount.'

'; + + // Set some content to print + $html = <<writeHTMLCell(0, 0, '', '', $html, 0, 1, 0, true, '', true); + + // --------------------------------------------------------- + + // Close and output PDF document + // This method has several options, check the source code documentation for more information. + $pdf->Output('Total_payment_list.pdf', 'I'); + + //============================================================+ + // END OF FILE + //============================================================+ + } + + + public function report_emp_total($opd_date_range,$emp_name_id,$paymode_id,$order_1,$output=0) + { + $sql_f_all = "select p.update_by, + sum(if(p.payof_type=1,if(p.credit_debit=0,p.amount,0),0)) as OPD_Amount, + sum(if(p.payof_type=2,if(p.credit_debit=0,p.amount,0),0)) as Charge_Amount, + sum(if(p.payof_type=4,if(p.credit_debit=0,p.amount,0),0)) as IPD_Amount, + sum(if(p.credit_debit=1,p.amount,0)) as Return_Amount, + sum(if(p.credit_debit=0,p.amount,p.amount*-1)) as total_Amount "; + + $sql_from=" from payment_history p "; + + $sql_where=" Where 1=1 "; + + $sql_group_by=" group by p.update_by_id "; + + $rangeArray = explode("S",$opd_date_range); + $minRange = str_replace('T',' ',$rangeArray[0]); + $maxRange = str_replace('T',' ',$rangeArray[1]); + + if($minRange==$maxRange) + { + $sql_where.=" and Date(p.payment_date) between Date('".$minRange."') and Date('".$maxRange. "')"; + }else{ + $sql_where.=" and p.payment_date between '".$minRange."' and '".$maxRange. "'"; + } + + $data_show='

Date(YYYY-MM-DD h:m) between '.$minRange.' and '.$maxRange.'

'; + + if($emp_name_id<>0) + { + $emp_name_id=str_replace('S',',',$emp_name_id); + + $sql_where.=" and p.update_by_id in (".$emp_name_id.")"; + } + + if($paymode_id<1) + { + $sql_where.=" and p.payment_mode in (1,2) "; + }else{ + $sql_where.=" and p.payment_mode = '".$paymode_id."'"; + } + + $sql_order=" Order by p.update_by"; + + if($order_1==1) + { + $sql_order.=' ,p.update_by'; + } + + if($order_1==2) + { + $sql_order.=' ,p.payment_mode'; + } + + $table_start=''; + $table_end='
'; + + $table_head=''; + $table_head.='User ID'; + $table_head.='OPD Amount'; + $table_head.='Charge Amount'; + $table_head.='IPD Amount'; + $table_head.='Return Amount'; + $table_head.='Total'; + $table_head.=''; + + $table_footer=''; + + $query = $this->db->query($sql_f_all.$sql_from.$sql_where.' '.$sql_group_by.$sql_order); + $data['gsub_rec']= $query->result(); + + $table_body=''; + $table_total_opd=0.00; + $table_total_ipd=0.00; + $table_total_charge=0.00; + $table_total_return=0.00; + $table_total_all=0.00; + + //echo $sql_f_all.$sql_from.$sql_where.$gwhere.' '.$sql_order.'

'; + + foreach($data['gsub_rec'] as $rowdata) + { + $table_body.=''; + $table_body.=''.$rowdata->update_by.''; + $table_body.=''.$rowdata->OPD_Amount.''; + $table_body.=''.$rowdata->Charge_Amount.''; + $table_body.=''.$rowdata->IPD_Amount.''; + $table_body.=''.$rowdata->Return_Amount.''; + $table_body.=''.$rowdata->total_Amount.''; + $table_body.=''; + + + $table_total_opd=$table_total_opd+$rowdata->OPD_Amount; + $table_total_ipd=$table_total_ipd+$rowdata->IPD_Amount; + $table_total_charge=$table_total_charge+$rowdata->Charge_Amount; + $table_total_return=$table_total_return+$rowdata->Return_Amount; + $table_total_all=$table_total_all+$rowdata->total_Amount; + + } + + $table_footer=''; + $table_footer.='Total'; + $table_footer.=''.$table_total_opd.''; + $table_footer.=''.$table_total_charge.''; + $table_footer.=''.$table_total_ipd.''; + $table_footer.=''.$table_total_return.''; + $table_footer.=''.$table_total_all.''; + $table_footer.=''; + + $data_show.=$table_start.$table_head.$table_body.$table_footer.$table_end; + + if($output==0) + { + create_report_pdf($data_show,'Payment_Complie'); + }else{ + + ExportExcel($data_show,'Payment_Complie'); + } + } + + public function report_opd_page() + { + $sql="select * from doctor_master where active=1 order by p_fname"; + $query = $this->db->query($sql); + $data['doclist']= $query->result(); + + $sql="select * from users where active=1 order by first_name"; + $query = $this->db->query($sql); + $data['emplist']= $query->result(); + + $sql="select * from payment_mode "; + $query = $this->db->query($sql); + $data['paymodelist']= $query->result(); + + $this->load->view('Report/OPD_Report_Doctor',$data); + } + public function report_opd($opd_date_range,$doc_name_id,$output=0) + { + $sql_where=" 1=1 "; + + $rangeArray = explode("S",$opd_date_range); + $minRange = $rangeArray[0]; + $maxRange = $rangeArray[1]; + + $sql_where.=" and o.apointment_date between '".$minRange."' and '".$maxRange. "'"; + + if($doc_name_id>0) + { + $sql_where.=" and o.doc_id='".$doc_name_id."'"; + } + + + $sql="select o.doc_id,o.doc_name,o.apointment_date,count(o.opd_id) as no_opd,sum(o.opd_fee_amount) as OPD_Amount, + + sum(if(o.payment_mode in (1,2),'1',0)) as Cash_no, + sum(if(o.payment_mode in (1,2),o.opd_fee_amount,0)) as Cash_Amount, + + sum(if(o.payment_mode=4,'1',0)) as Org_Credit_no, + sum(if(o.payment_mode=4,o.opd_fee_amount,0)) as Org_Credit_Amount, + + sum(if(o.opd_correction_amount>0,1,0)) as No_Cancel, + sum(if(o.opd_correction_amount>0,o.opd_correction_amount,0)) as No_Cancel_Amount + + from opd_master o + where ".$sql_where." and o.payment_status=1 + group by o.doc_id,o.apointment_date with ROLLUP"; + + $query = $this->db->query($sql); + $opdlist= $query->result(); + + $srno=1; + + $tableHead=' + + + + + + + + + + + + + + + + '; + + $line=''; + $tablefooter='
Doctor NameDateTotalTotal.Amt.No.Cash OPDCash Amt.Org.OPD CreditOrg.Cr.Amt.No. CancelCancel Amt.Net OPDNet Amount
'; + $FooterHead=''; + foreach($opdlist as $row) + { + $net_opd=$row->no_opd - $row->No_Cancel; + $net_amount=$row->OPD_Amount + $row->Org_Credit_Amount - $row->No_Cancel_Amount ; + + if($row->doc_id=='') + { + + }elseif($row->apointment_date=='') + { + $line.=''; + $line.='Total of Dr.'.$row->doc_name.''.PHP_EOL; + $line.=''.$row->no_opd.''.PHP_EOL; + $line.=''.$row->OPD_Amount.''.PHP_EOL; + $line.=''.$row->Cash_no.''.PHP_EOL; + $line.=''.$row->Cash_Amount.''.PHP_EOL; + $line.=''.$row->Org_Credit_no.''.PHP_EOL; + $line.=''.$row->Org_Credit_Amount.''.PHP_EOL; + $line.=''.$row->No_Cancel.''.PHP_EOL; + $line.=''.$row->No_Cancel_Amount.''.PHP_EOL; + + $line.=''.$net_opd.''.PHP_EOL; + $line.=''.$net_amount.''.PHP_EOL; + + $line.=""; + + $FooterHead.='

Doctor :Dr. '.$row->doc_name.' / Total Net OPD : '.$net_opd.' / Total Amount : Rs.'.number_format($net_amount,2).'

'; + + + }else + { + $line.=''; + $line.=''.$row->doc_name.''.PHP_EOL; + $line.=''.$row->apointment_date.''.PHP_EOL; + $line.=''.$row->no_opd.''.PHP_EOL; + $line.=''.$row->OPD_Amount.''.PHP_EOL; + $line.=''.$row->Cash_no.''.PHP_EOL; + $line.=''.$row->Cash_Amount.''.PHP_EOL; + $line.=''.$row->Org_Credit_no.''.PHP_EOL; + $line.=''.$row->Org_Credit_Amount.''.PHP_EOL; + $line.=''.$row->No_Cancel.''.PHP_EOL; + $line.=''.$row->No_Cancel_Amount.''.PHP_EOL; + + $line.=''.$net_opd.''.PHP_EOL; + $line.=''.$net_amount.''.PHP_EOL; + + $line.=""; + } + } + + $print_data= $tableHead.$line.$tablefooter.'
'.$FooterHead; + if($output==0) + { + create_report_pdf_landscape($print_data,'OPDList'); + }else{ + + ExportExcel($print_data,'OPDList'); + } + + } +} + +/* End of file c_test.php */ +/* Location: ./application/controllers/c_test.php */ \ No newline at end of file diff --git a/old_code_ci3/controllers/opd_print_parcha_2.php b/old_code_ci3/controllers/opd_print_parcha_2.php new file mode 100644 index 0000000..d6ae79e --- /dev/null +++ b/old_code_ci3/controllers/opd_print_parcha_2.php @@ -0,0 +1,21 @@ + + + +

+
+ +

Print Time :

+
+ \ No newline at end of file diff --git a/old_code_ci3/models/Custtag_M.php b/old_code_ci3/models/Custtag_M.php new file mode 100644 index 0000000..ba00be6 --- /dev/null +++ b/old_code_ci3/models/Custtag_M.php @@ -0,0 +1,46 @@ +db->insert("tag_master", $data)) { + $insert_id = $this->db->insert_id(); + return $insert_id; + }else + return 0; + } + + public function update_tag_master($data,$old_id_no) { + $this->db->set($data); + $this->db->where("id", $old_id_no); + if ($this->db->update("tag_master", $data)) { + return 1; + }else + return 0; + } + + public function insert_patient_tag_assign($data) { + + if ($this->db->insert("patient_tag_assign", $data)) { + $insert_id = $this->db->insert_id(); + return $insert_id; + }else + return 0; + } + + public function update_patient_tag_assign($data,$old_id_no) { + $this->db->set($data); + $this->db->where("id", $old_id_no); + if ($this->db->update("cpatient_tag_assign", $data)) { + return 1; + }else + return 0; + } + +} +?> \ No newline at end of file diff --git a/old_code_ci3/models/Medical_M.php b/old_code_ci3/models/Medical_M.php index 054b491..80922c9 100644 --- a/old_code_ci3/models/Medical_M.php +++ b/old_code_ci3/models/Medical_M.php @@ -79,7 +79,6 @@ return 0; } - public function update_invoiceitem($data,$old_id_no) { $this->db->set($data); diff --git a/old_code_ci3/views/AdminMain.php b/old_code_ci3/views/AdminMain.php index e856e6b..0024970 100644 --- a/old_code_ci3/views/AdminMain.php +++ b/old_code_ci3/views/AdminMain.php @@ -1,7 +1,7 @@ -
+
-
+
diff --git a/old_code_ci3/views/IPD2/ipd_main_panel.php b/old_code_ci3/views/IPD2/ipd_main_panel.php index a4db372..7d65d52 100644 --- a/old_code_ci3/views/IPD2/ipd_main_panel.php +++ b/old_code_ci3/views/IPD2/ipd_main_panel.php @@ -293,11 +293,6 @@ Sticker [2 x 8]
-
- -
- 0) { ?>
diff --git a/old_code_ci3/views/IPD2/ipd_payment_receipt_print.php b/old_code_ci3/views/IPD2/ipd_payment_receipt_print.php index 91bcd9a..d582f20 100644 --- a/old_code_ci3/views/IPD2/ipd_payment_receipt_print.php +++ b/old_code_ci3/views/IPD2/ipd_payment_receipt_print.php @@ -20,7 +20,7 @@

-

,
+

, Uttarakhand
- +

-

,
+

, Uttarakhand
+ + + diff --git a/old_code_ci3/views/IPD_Discharge/ipd_discharge_edit.php b/old_code_ci3/views/IPD_Discharge/ipd_discharge_edit.php index 3701138..978e1d5 100644 --- a/old_code_ci3/views/IPD_Discharge/ipd_discharge_edit.php +++ b/old_code_ci3/views/IPD_Discharge/ipd_discharge_edit.php @@ -1312,10 +1312,9 @@

-

Other

@@ -1331,11 +1330,6 @@ -
@@ -1638,9 +1632,9 @@ function save_FOOD_DRUG_INTERACTION() { - var editor_data=CKEDITOR.instances['editor_FOOD_DRUG_INTERACTION_list'].getData(); + //var editor_data=CKEDITOR.instances['editor_FOOD_DRUG_INTERACTION_list'].getData(); - //var editor_data = $('#editor_FOOD_DRUG_INTERACTION_list').val(); + var editor_data = $('#editor_FOOD_DRUG_INTERACTION_list').val(); var chkArray = []; $(".chk_food:checked").each(function() { diff --git a/old_code_ci3/views/IPD_Format/ipd_sticker_print_2.php b/old_code_ci3/views/IPD_Format/ipd_sticker_print_2.php index 21c4e43..6a7fefd 100644 --- a/old_code_ci3/views/IPD_Format/ipd_sticker_print_2.php +++ b/old_code_ci3/views/IPD_Format/ipd_sticker_print_2.php @@ -3,7 +3,7 @@ .content_1 { position: absolute; overflow: visible; - top: 18mm; + top: 17mm; left: 10mm; width: 100mm; height: 33mm; @@ -17,7 +17,7 @@ .content_2 { position: absolute; overflow: visible; - top: 52mm; + top: 51mm; left: 10mm; width: 100mm; height: 33mm; @@ -31,7 +31,7 @@ .content_3 { position: absolute; overflow: visible; - top: 86mm; + top: 85mm; left: 10mm; width: 100mm; height: 33mm; @@ -46,7 +46,7 @@ .content_4 { position: absolute; overflow: visible; - top: 122mm; + top: 119mm; left: 10mm; width: 100mm; height: 33mm; @@ -61,7 +61,7 @@ .content_5 { position: absolute; overflow: visible; - top: 157mm; + top: 153mm; left: 10mm; width: 100mm; height: 33mm; @@ -76,7 +76,7 @@ .content_6 { position: absolute; overflow: visible; - top: 191mm; + top: 187mm; left: 10mm; width: 100mm; height: 33mm; @@ -91,7 +91,7 @@ .content_7 { position: absolute; overflow: visible; - top: 226mm; + top: 221mm; left: 10mm; width: 100mm; height: 33mm; @@ -105,7 +105,7 @@ .content_8 { position: absolute; overflow: visible; - top: 260mm; + top: 255mm; left: 10mm; width: 100mm; height: 33mm; @@ -119,7 +119,7 @@ .content_9 { position: absolute; overflow: visible; - top: 18mm; + top: 17mm; left: 110mm; width: 100mm; height: 33mm; @@ -133,7 +133,7 @@ .content_10 { position: absolute; overflow: visible; - top: 52mm; + top: 51mm; left: 110mm; width: 100mm; height: 33mm; @@ -147,7 +147,7 @@ .content_11 { position: absolute; overflow: visible; - top: 86mm; + top: 85mm; left: 110mm; width: 100mm; height: 33mm; @@ -162,7 +162,7 @@ .content_12 { position: absolute; overflow: visible; - top: 122mm; + top: 119mm; left: 110mm; width: 100mm; height: 33mm; @@ -177,7 +177,7 @@ .content_13 { position: absolute; overflow: visible; - top: 157mm; + top: 153mm; left: 110mm; width: 100mm; height: 33mm; @@ -192,7 +192,7 @@ .content_14 { position: absolute; overflow: visible; - top: 191mm; + top: 187mm; left: 110mm; width: 100mm; height: 33mm; @@ -206,7 +206,7 @@ .content_15 { position: absolute; overflow: visible; - top: 226mm; + top: 221mm; left: 110mm; width: 100mm; height: 33mm; @@ -220,7 +220,7 @@ .content_16 { position: absolute; overflow: visible; - top: 260mm; + top: 255mm; left: 110mm; width: 100mm; height: 33mm; diff --git a/old_code_ci3/views/Invoice/caseinvoice_print_V.php b/old_code_ci3/views/Invoice/caseinvoice_print_V.php index b03c087..edb2738 100644 --- a/old_code_ci3/views/Invoice/caseinvoice_print_V.php +++ b/old_code_ci3/views/Invoice/caseinvoice_print_V.php @@ -129,25 +129,14 @@ footer: html_myFooter; foreach($showinvoice2 as $row) { $srno=$srno+1; - if($row->discount_amount>0){ - $readonly = 'readonly'; - $disabled = 'disabled'; - $rate = $row->d_rate; - $discription = $row->Description.' (Discounted) Rate : '.$row->item_rate; - }else{ - $readonly = ''; - $disabled = ''; - $rate = $row->item_rate; - $discription = $row->Description; - } echo ''; echo ''.$srno.''; echo ''.$row->str_date.''; echo ''.$row->Charge_type.''; - echo ''.$discription.''; + echo ''.$row->Description.''; echo ''.$row->orgcode.''; echo ''.$row->item_qty.''; - echo ''.$rate.''; + echo ''.$row->item_rate.''; echo ''.$row->Code.''; echo ''.$row->Amount.''; echo ''; diff --git a/old_code_ci3/views/Invoice_PathLab_final_V - Copy.php b/old_code_ci3/views/Invoice_PathLab_final_V - Copy.php new file mode 100644 index 0000000..12ba0f3 --- /dev/null +++ b/old_code_ci3/views/Invoice_PathLab_final_V - Copy.php @@ -0,0 +1,544 @@ +
+

+ Invoice + #invoice_code ?> +

+ + +
+
+ +
+ +
+ To +
+ p_fname ?>
+ p_relative ?> : p_rname ?>
+ Gender : xgender ?>
+ Age : age ?>
+ Phone No : mphone1 ?> +
+
+ +
+ Invoice #invoice_code ?>
+ insurance_id>1) + { + echo ' Ins. Comp. :'.$insurance[0]->ins_company_name.'
'; + if($invoice_master[0]->insurance_case_id>0) + { + echo ' Org.Case No. :'.$case_master[0]->case_id_code.'
'; + } + } + ?> + Date : inv_date ?>
+ Patient ID : p_code ?>
+ Refer By : refer_by_other ?>
+ + +
+ +
+ + + +
+
+ + + + + + + + + + + '; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + $srno=$srno+1; + echo ''; + echo ''; + } + ?> + + + + + + + + + + + payment_status==0 ) { ?> + + + + + + + + + + + + + + + + + + ipd_id<1) { ?> + + + + + + + + + + + + + + + + + + +
#Charges GroupCharge NameRateQtyAmount
'.$srno.''.$row->group_desc.''.$row->item_name.''.$row->item_rate.''.$row->item_qty.''.$row->item_amount.'
#Gross TotalGtotal?>
#Deduction
#Deductiondiscount_desc ?>discount_amount ?>
#Amount received : payment_part_received?>Balance Amount : payment_part_balance?>Net Amountnet_amount?>
#Net Amountnet_amount?>
+
+ +
+ + ipd_id<1 && $invoice_master[0]->insurance_case_id<2 ) + { + if ($invoice_master[0]->payment_part_balance>0 || $invoice_master[0]->payment_part_balance < 0 ) { ?> +
+
+
+
+ + + +
+
+
+ +
+
+
+
+ +
+ 0 && $invoice_master[0]->payment_status==0 ) { ?> +
+ +
+
+
+
+
+ + ipd_code ?> autocomplete="off" readonly> + +
+
+
+
+ + +
+
+
+
+
+
+ 0 && $invoice_master[0]->payment_status==0 ){ ?> +
+ +
+
+ 0) { ?> +
+
+
+ + case_id_code ?> autocomplete="off" readonly> + +
+
+
+
+ + +
+
+
+ +
+
+ +
+
+ +
+
+
+ + + payment_part_balance>0) + { + ?> +
+
+

+ + Cash +

+
+
+
+ +
+
+
+
+ +
+
+
+
+
+ + +
+
+
+
+ + +
+
+
+
+ + +
+
+
+
+ + +
+
+
+
+ + +
+
+
+
+
+
+ payment_part_balance<0){ ?> +
+ +
+
+ +
+
+
+ + + +
+
+
+
+
+ + + + + + ion_auth->in_group('ChargeInvoiceUpdate') && ($invoice_master[0]->invoice_status==1 )) { ?> +
+
+
+ + + invoice_status==1) { + $credit_invoice=0; + if($invoice_master[0]->insurance_case_id==0 && $invoice_master[0]->ipd_id==0) + { + ?> + + + insurance_case_id==0) { + if(count($case_master)>0) + { + $credit_invoice=1; + ?> + + + ipd_id==0) { + if(count($ipd_master)>0) + { + $credit_invoice=1; + ?> + + + + + + + + +
+
+
+
+
+ payment_part_received>1) + { + ?> + + + + + + + + +
#Deduction
+ +
+
+ + +
+ +
+ + \ No newline at end of file diff --git a/old_code_ci3/views/June19.xlsx b/old_code_ci3/views/June19.xlsx new file mode 100644 index 0000000000000000000000000000000000000000..0baa17ec3f50e61143468c77acce712dc982b63c GIT binary patch literal 183984 zcmeFYgLfod+b^8S#1q@LZQHhO+nLy&cw%c}+sVYXZFih}nH%SM-u3};J)Y@PL#J?u@K zbZFgetnu>}zL4ht0e_zV|Bn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gl9F&^m2GWXkJm$4ZO7P|k2gBwGrwtIUq0!t9jVrQDNRrPDwT}-rs_7hP=PHQjV-mRU z%%@xBe4?h!433IZL*o}5R2$)w(JSE+R(ncn8yqj}TBRISTn=Wj&brIa$Qs2iHtpd6?>usg~2{nAhE5cjpEj_CAoDj?P7VC;BFN zn%mCJF6yJA+J5<2-{xc_S2M`Tzay&n(L_M8{`Z z>gZ#NiX5EaWcJl?I`Y?G?wA>(g8Ui07hF%mCc4`g#qbt{j_F&-6}}|Qjjo3Tlu6oc z1gf~Qng{;4EvUQnFrZMrV_vy9uVtXO|X6aWkmPt^u$jT5k4}z8y;q)$U6DZ?j*0IWGZh7 z-uc4<92AGEypm~oW0Ayu_mP|%4o~SLq&z$<$UZu~mGEPOT382NoZUK2S9atq9R9^V z!&_Ir5f^U8Jdro-`MwAJF3HKCjuOFHTRsw-r-eDu?8R4TmDcC}?L%*rw^`|(vllfn z-hRndI?%G@qr7r4{Es7_NA7QMykSN0S9Q#trPm&PeIWZ$w+@l91Fy2=ZgLfLzYh&| z9vE;>E-WlhF#I^MUx=orq%*I%R%NilzxZGvS3YxR{Pf25(I!_x8PWcmu8`igr9W{R z3!5MKlU(wR3>(#9ri2XmpXBn76a2a}SAt_gl#|=N+uqJFSIb{>L{IZ?fEptq)?Lg` zwJ?kMul)5-X~oR4dkC0=tDwNI>v=(*_B8`lOv?=T0C4q>6y~lJlk8%W+<#;};Rt&u z9B%)s?F(^sB)~bN7@Q1DbEJRah+%ZX;QSlmd?#LBZ|Ql+3;?@X06_bfusBAU{|dX> z!eDN$g1-<;%?+WfYjUq6d`vSj}xCrI^&e9*NZZ=^5LOH+B zbbd_E^ZY*m1?b-Zf3g1a(&stxAL-iG-_qw8@r4ZeJm}x#@(&~cw6 0) { - $datetimepicker1 = $lab_invoice_request[0]->collected_time; - $datetimepicker2 = $lab_invoice_request[0]->reported_time; -} else { - $datetimepicker1 = ""; - $datetimepicker2 = ""; +0) +{ + $datetimepicker1=$lab_invoice_request[0]->collected_time; + $datetimepicker2=$lab_invoice_request[0]->reported_time; +}else{ + $datetimepicker1=""; + $datetimepicker2=""; } ?> -
-
-

Lab Collection and Report Time

+
+
+ +
+ + + + + +
-
-
-
- -
- - - - - -
+
+ +
+ + + +
-
- -
- - - - -
-
-
- -
- -
-
+
+ +
+ +
\ No newline at end of file diff --git a/old_code_ci3/views/Lab_Panel/lab_invoice_main.php b/old_code_ci3/views/Lab_Panel/lab_invoice_main.php index 18c16ee..5d6b1b9 100644 --- a/old_code_ci3/views/Lab_Panel/lab_invoice_main.php +++ b/old_code_ci3/views/Lab_Panel/lab_invoice_main.php @@ -79,8 +79,6 @@ accesskey="E">Edit --> - -
+
+
-

Test List : [Invoice Code : ]

+

Test List : [Invoice Code : ]

+
@@ -492,14 +493,5 @@ refresh_data(); Webcam.reset(); }); - - function report_letter_head(inv_id,labtype) - { - - - var Get_Query='/index.php/Lab_Admin/print_pdf_create/'+inv_id+'/'+labtype+'/1'; - - window.open(Get_Query, "_blank"); - } \ No newline at end of file diff --git a/old_code_ci3/views/Lab_Panel/lab_invoice_xray.php b/old_code_ci3/views/Lab_Panel/lab_invoice_xray.php index c864743..3d35213 100644 --- a/old_code_ci3/views/Lab_Panel/lab_invoice_xray.php +++ b/old_code_ci3/views/Lab_Panel/lab_invoice_xray.php @@ -64,9 +64,6 @@
-
-
-
@@ -126,7 +123,6 @@ $(document).ready(function() { var lab_type = $('#lab_type').val(); var inv_id = $('#inv_id').val(); - load_form_div('/Lab_Report/lab_date_show/'+inv_id+'/'+lab_type,'date_show'); load_form_div('/Lab_Report/xray_test_list/' + inv_id + '/' + lab_type, 'test_list'); //load_form_div('/Lab_Report/report_file_list/'+inv_id+'/'+lab_type,'file_show'); }); diff --git a/old_code_ci3/views/Lab_Panel/lab_main.php b/old_code_ci3/views/Lab_Panel/lab_main.php index 39c5641..1aaf04b 100644 --- a/old_code_ci3/views/Lab_Panel/lab_main.php +++ b/old_code_ci3/views/Lab_Panel/lab_main.php @@ -78,18 +78,5 @@
- ion_auth->in_group('DiagnosisIVF')) { ?> - - - \ No newline at end of file diff --git a/old_code_ci3/views/Lab_Panel/pathlab_request_list.php b/old_code_ci3/views/Lab_Panel/pathlab_request_list.php index 58c0e4d..dfe8e3b 100644 --- a/old_code_ci3/views/Lab_Panel/pathlab_request_list.php +++ b/old_code_ci3/views/Lab_Panel/pathlab_request_list.php @@ -2,7 +2,7 @@ 'form','class'=>'form2')); ?>
-
+
@@ -10,7 +10,7 @@
-
+
@@ -18,7 +18,7 @@
-
+
@@ -26,15 +26,6 @@
-
-
- - Template - - Template - -
-
diff --git a/old_code_ci3/views/Lab_Panel/patient_lab_report_svh.php b/old_code_ci3/views/Lab_Panel/patient_lab_report_svh.php index 9801e3f..b84687d 100644 --- a/old_code_ci3/views/Lab_Panel/patient_lab_report_svh.php +++ b/old_code_ci3/views/Lab_Panel/patient_lab_report_svh.php @@ -1,11 +1,11 @@ - + - +
Page : {PAGENO}/{nbpg}
- - - - - - - - - - - - - - -
- - -
- - -
- -
-
-
-
-
-
-

###################### END OF REPORT ######################

- +
+
+
+ + + + + + + + + + + +
+ + + +
+ Lab Technologist + + + Dr. Preeti Singh
+ M.B.B.S. , MD +
+ diff --git a/old_code_ci3/views/Lab_Panel/patient_lab_xray_report.php b/old_code_ci3/views/Lab_Panel/patient_lab_xray_report.php new file mode 100644 index 0000000..a76ce61 --- /dev/null +++ b/old_code_ci3/views/Lab_Panel/patient_lab_xray_report.php @@ -0,0 +1,102 @@ + + + + + + + + + + +
+ + +

+

, Uttarakhand
+ +

+ +
+ +
+ + + + + + + + + +
---- Page Continue.. ----
Page : {PAGENO}/{nbpg}
+
+ + + + + + + + + + + + + + +
+ + + +
+ + +
+ +
+
+
+
+
+
+

Note : Impression is a professional opinion. All modern machines/ Procedures have their limitations. If there is variance clinically this examination may be repeated of re-evaluated by other investigations. Not valid for medico-legal purpose.
+ Any typing & technical error should be corrected within seven days. No compensation liability stands.

+
+ +

###################### END OF REPORT ######################

+ \ No newline at end of file diff --git a/old_code_ci3/views/Medical/Med_Model_Payment.php b/old_code_ci3/views/Medical/Med_Model_Payment.php index 0c18aef..8da3759 100644 --- a/old_code_ci3/views/Medical/Med_Model_Payment.php +++ b/old_code_ci3/views/Medical/Med_Model_Payment.php @@ -167,7 +167,7 @@ Total Amount Paid : Rs. payment_received ?>
Balance Amount: - Rs. payment_balance) ?>
+ Rs. payment_balance ?>
Print Cash

diff --git a/old_code_ci3/views/Medical/Med_Payment_Receipt.php b/old_code_ci3/views/Medical/Med_Payment_Receipt.php index 9002247..2095cdb 100644 --- a/old_code_ci3/views/Medical/Med_Payment_Receipt.php +++ b/old_code_ci3/views/Medical/Med_Payment_Receipt.php @@ -1,3 +1,9 @@ + + + + + + + + + + + +

+

, Uttarakhand
+ '; + + if($pharmacyGst!='') + { + echo 'GST: '.$pharmacyGst .''; + } + + if($pharmacyLicense!='') + { + echo ' L.No: '.$pharmacyLicense; + } + ?> +

+

+ Invoice To : + Supplier : name_supplier?>
+ Purchase Return Invoice No.: Invoice_no?>
+ Invoice Date : str_date_of_invoice ?>
+

+
+

Purchase Return

+
+ + + + + + +
Page : {PAGENO}/{nbpg}Invoice No.:Invoice_no ?> / Name : name_supplier ?>
+
+ + + + + + + + + + + + + + '; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + } + echo ''; + ?> + + + + + + + + + + + + + +
#RecNoItem NameBatch NoExp.MRPQty.Rate
'.$srno.''.$row->r_id.''.$row->Item_name.''.$row->batch_no.''.$row->exp_date_str.''.$row->mrp.''.floatval($row->r_qty).''.$row->purchase_price.''; + if(1==1) + { + echo ''; + } + echo '
#
\ No newline at end of file diff --git a/old_code_ci3/views/Medical/Stock/purchase_return_invoice_item.php b/old_code_ci3/views/Medical/Stock/purchase_return_invoice_item.php index 3b33071..edd6a12 100644 --- a/old_code_ci3/views/Medical/Stock/purchase_return_invoice_item.php +++ b/old_code_ci3/views/Medical/Stock/purchase_return_invoice_item.php @@ -7,7 +7,10 @@ Exp. MRP / P. Rate/Unit Qty.(Unit / Pack) - Rate + GST % + Amount + GST Amount + Net Amount '.$row->exp_date_str.''; echo ''.$row->mrp.' / '.$row->purchase_unit_rate.''; echo ''.floatval($row->r_qty).' / '.floatval($row->qty_pak).''; + echo ''.$row->gst_per.''; echo ''.$row->r_amount.''; + echo ''.(($row->gst_per*$row->r_amount)/100).''; + echo ''.($row->r_amount + (($row->gst_per*$row->r_amount)/100)).''; echo ''; if(1==1) { diff --git a/old_code_ci3/views/Medical/Stock/purchase_return_invoice_item_print.php b/old_code_ci3/views/Medical/Stock/purchase_return_invoice_item_print.php index 550b6b2..b02e10f 100644 --- a/old_code_ci3/views/Medical/Stock/purchase_return_invoice_item_print.php +++ b/old_code_ci3/views/Medical/Stock/purchase_return_invoice_item_print.php @@ -1,3 +1,11 @@ + + + + + + + + +
+

+

, Uttarakhand
+ '; + + if(H_Med_GST!='') + { + echo 'GST: '.H_Med_GST .''; + } + + if(M_LIC!='') + { + echo ' L.No: '.M_LIC; + } + ?> +

+ p_fname.':IPD-'.$ipd_master[0]->ipd_code .':P-'.date('Y-m-d H:i:s'); + ?> + + +
+

Payment Receipt

+
+ + + + + + +
Page : {PAGENO}/{nbpg}IPD-ID:ipd_code ?> / UHID:p_code ?> /Name : p_fname ?>
+
+

+ To : + p_fname ?>
+ Patient Info. as per Hospital Records
+ UHID ID : p_code ?>
+ IPD Code : ipd_code ?>
+ Refer By : doc_name ?>
+ org_id>0) { ?> + Org. Code : case_id_code ?>
+ Org. Name : insurance_company_name ?>
+ +

+ + + + + + + + '; + + } + ?> +
Pay.No.ModeDate Amount
'.$row->id.''.$row->Payment_type_str.''.$row->str_payment_date.''.$row->amount.'
+
+
+0) { ?> + Pharmacy Bill Amount at the Time of Print Receipt : + Rs. net_amount ?>
+ Total Amount Paid : Rs. payment_received ?>
+ Balance Amount : Rs. net_amount-$inv_med_group[0]->payment_received ?> + +
+
+
+
+
+
+

+ For +

\ No newline at end of file diff --git a/old_code_ci3/views/Medical1/Med_Return_Invoice_search.php b/old_code_ci3/views/Medical1/Med_Return_Invoice_search.php new file mode 100644 index 0000000..5e10f8b --- /dev/null +++ b/old_code_ci3/views/Medical1/Med_Return_Invoice_search.php @@ -0,0 +1,67 @@ + +

Search By Phone No. (Complete 10 Digit Phone No.)

+
+ + + + +
+
+

Search By UHID (Type Last 5 to 6 Digit of UHID/Patient ID)

+
+ + + + +
+
+

Search By Invoice Code (Type Last 5 to 6 Digit of invoice)

+
+ + + + +
+
+

Search By Product

+
+ + + + +
+ + \ No newline at end of file diff --git a/old_code_ci3/views/Medical1/Med_back_Panel.php b/old_code_ci3/views/Medical1/Med_back_Panel.php new file mode 100644 index 0000000..b0f9e9b --- /dev/null +++ b/old_code_ci3/views/Medical1/Med_back_Panel.php @@ -0,0 +1,123 @@ +
+

+ Back + Panel +

+
+
+
diff --git a/old_code_ci3/views/Medical1/Med_old_invoice_list.php b/old_code_ci3/views/Medical1/Med_old_invoice_list.php new file mode 100644 index 0000000..f841dc8 --- /dev/null +++ b/old_code_ci3/views/Medical1/Med_old_invoice_list.php @@ -0,0 +1,67 @@ + + $row->inv_id) + { + $srno=0; + + echo ''; + echo ''; + echo ''; + + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + } + + $srno=$srno+1; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + if($row->sale_return==0){ + echo ''; + }else{ + echo ''; + } + echo ''; + + $inv_id=$row->inv_id; + } + ?> +
#'.$row->inv_med_code.''.$row->inv_date.''.$row->net_amount.'
#ItemBat./Exp.DtRateQtyN.Amt.R.Qty
'.$srno.''.$row->item_Name.''.$row->batch_no.'
'.$row->exp_date.'
'.$row->price.''.$row->qty.''.$row->twdisc_amount.' +
+ + + + +
'; + echo '
diff --git a/old_code_ci3/views/Medical1/Medical_Final_Invoice.php b/old_code_ci3/views/Medical1/Medical_Final_Invoice.php new file mode 100644 index 0000000..b8faae3 --- /dev/null +++ b/old_code_ci3/views/Medical1/Medical_Final_Invoice.php @@ -0,0 +1,394 @@ +
+
+

+ Medical Invoice + +

+
+
+'form','class'=>'form1')); ?> +
+
+
+ + +
+

Name : + inv_name?> + / P Code :patient_code?> + / Invoice No. :inv_med_code?> + / Date : inv_date)?> + ipd_id > 0) { ?> + IPD Code : + + ipd_code?> + + Admit Date : str_register_date ?> reg_time ?> + / Doctor :doc_name?> + / TPA-Org. :admit_type?> + / Bill Type :ipd_credit)?'Credit To Hospital':'CASH/Direct'?> + case_id > 0){ ?> + / Org. Case ID : + case_id_code ?> + + + med_group_id==0){ ?> + + +

+
+
+
+
+
+
+ + + + + + + + + + + + + + + + + + '; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + } + echo ''; + ?> + + + + + + + + + + + + + + + + + +
#Item codeItem NameFormulationBatch NoExp.RateQty.PriceDisc.HSNCODE/C-SGSTCGSTSGSTAmount
'.$srno.''.$row->item_code.''.$row->item_Name.''.$row->formulation.''.$row->batch_no.''.$row->expiry.''.$row->price.''.$row->qty.''.$row->amount.''.$row->disc_amount.''.$row->HSNCODE.''.$row->CGST.''.$row->SGST.''.$row->tamount.'
#Gross Totalgross_amount ?>inv_disc_total?>CGST_Tamount?>SGST_Tamount?>net_amount?>
+
+ group_invoice_id==0) { ?> +
+ + + + + + + + +
#Deduction
+
+ +
+ + + + + + + + + +
#Amount received : payment_received?>Balance Amount : payment_balance?>Net Amount : net_amount?>
+
+
+ + payment_balance<>0) { ?> +
+ +
+
+
+ + +
+
+
+
+
+ +
+ ipd_credit==0 || $invoiceMaster[0]->ipd_credit=='')&& $invoiceMaster[0]->case_credit==0 && $invoiceMaster[0]->group_invoice_id==0) { ?> + payment_balance>0) { ?> +
+
+

+ + Cash +

+
+
+
+ +
+
+
+
+ +
+
+
+
+
+ + +
+
+ +
+
+ + +
+
+
+
+ + +
+
+
+
+ + +
+
+
+
+ + +
+
+
+
+
+
+ payment_balance<0) { ?> +
+ +
+
+ +
+
+
+ +
+
+
+
+
+ +
+ +
+ +
+
+ +
+ + + +
\ No newline at end of file diff --git a/old_code_ci3/views/Medical1/Medical_Invoice_Return.php b/old_code_ci3/views/Medical1/Medical_Invoice_Return.php new file mode 100644 index 0000000..382edc2 --- /dev/null +++ b/old_code_ci3/views/Medical1/Medical_Invoice_Return.php @@ -0,0 +1,212 @@ +
+

+ Medical Return Items + +

+
+
+'form','class'=>'form1')); ?> +
+
+
+ +
+
+ + +
+
+
+
+ + +
+
+ 0) { ?> +
+
+ + +
+
+ 0){ ?> +
+
+ + +
+
+ +
+
+
+
+ + + + + + + + + + + + + + + + + + + item_id.'">'; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + + if($row->r_qty=='') + { + echo ''; + $visible_return=''; + $visible_undo='style="display:none;"'; + + }else{ + echo ''; + $visible_return='style="display:none;"'; + $visible_undo=''; + } + echo ''; + echo ''; + } + ?> + + +
#Inv-DateItem NameBatch NoExp.RateSaved Qty.PriceDisc.AmountReturn Qty.Update
'.$srno.''.$row->str_inv_date.''.$row->item_Name.''.$row->batch_no.''.$row->expiry.''.$row->price.''.$row->qty.''.$row->amount.''.$row->disc_amount.''.$row->tamount.' + + + + + + + +
+ '; + echo ''; + ?> +
+
+ +
+ + + + \ No newline at end of file diff --git a/old_code_ci3/views/Medical1/Medical_Invoice_Return_V.php b/old_code_ci3/views/Medical1/Medical_Invoice_Return_V.php new file mode 100644 index 0000000..b02b1fc --- /dev/null +++ b/old_code_ci3/views/Medical1/Medical_Invoice_Return_V.php @@ -0,0 +1,294 @@ +
+

+ Medical Return Invoice No. inv_med_code?> + + Edit + +

+
+
+'form','class'=>'form1')); ?> +
+
+
+ + + patient_id==0) { ?> +
+
+ +
+ +
+
+
+
+
+ +
+ +
+
+
+
+
+ + +
+
+ +
+

Name : + inv_name?> + / P Code :patient_code?> + / Invoice No. :inv_med_code?> + / Date : inv_date)?> + ipd_id > 0) { ?> + IPD Code : + + ipd_code?> + + Admit Date : str_register_date ?> reg_time ?> + / Doctor :doc_name?> + / TPA-Org. :admit_type?> + / Bill Type :ipd_credit)?'Credit To Hospital':'CASH/Direct'?> + case_id > 0){ ?> + / Org. Case ID : + case_id_code ?> + + +

+
+ +
+
+
+
+
+
+ +
+
+
+ +
+
+
+
+

Sale Medicine Within Last 2 months

+
+ +
+
+ + +
+ +
+ + + +
+
+
+ +
+ +
+ + \ No newline at end of file diff --git a/old_code_ci3/views/Medical1/Medical_Invoice_Return_pre.php b/old_code_ci3/views/Medical1/Medical_Invoice_Return_pre.php new file mode 100644 index 0000000..b2cd43c --- /dev/null +++ b/old_code_ci3/views/Medical1/Medical_Invoice_Return_pre.php @@ -0,0 +1,148 @@ +
+

+ Medical Return Items + +

+
+
+'form','class'=>'form1')); ?> +
+
+
+ +
+
+ + +
+
+
+
+ + +
+
+ 0) { ?> +
+
+ + +
+
+ 0){ ?> +
+
+ + +
+
+ +
+
+
+ + + + + + + + + + + + + + + + + + + + '; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + + $tAmount=$tAmount+$row->amount; + } + + echo ' + + + + + + + + + + + + + + + '; + + ?> + + +
#Inv-DateItem NameBatch NoExp.RateOld Qty.Return Qty.PriceDisc.Amount
'.$srno.''.$row->str_inv_date.''.$row->item_Name.''.$row->batch_no.''.$row->expiry.''.$row->price.''.$row->qty.''.$row->r_qty.''.$row->amount.''.$row->disc_amount.''.$row->tamount.'
Total'.$tAmount.'
+ '; + echo ''; + ?> +
+
+ + +
+ + + + \ No newline at end of file diff --git a/old_code_ci3/views/Medical1/Medical_Invoice_Return_print.php b/old_code_ci3/views/Medical1/Medical_Invoice_Return_print.php new file mode 100644 index 0000000..0f0144a --- /dev/null +++ b/old_code_ci3/views/Medical1/Medical_Invoice_Return_print.php @@ -0,0 +1,148 @@ + + + + + + + <?=$pharmacyName?> | Invoice + + + + + + + + + + + + + + +
+ +
+
+ +
+
+

+ +

+


+ +
GST: / L.No: DEMO LIC

+
+ +
+
+

Return Medicine List

+
+
+
+ To +
+ p_fname ?>
+ Patient ID : p_code ?>
+ Refer By : doc_name ?>
+
+ +
+
+
+ IPD Code : ipd_code ?>
+ +
+
+
+ +
+
+ + + + + + + + + + + + + + + + '; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + $tAmount=$tAmount+$row->amount; + } + + echo ' + + + + + + + + + + + + '; + ?> + + +
Sr.No.Return DateInv.Code.Item NameBatch No.ExpiryRateOld Qty.Return Qty.AmountUpdate By
'.$srno.''.$row->return_date_time.''.$row->inv_med_code.''.$row->item_Name.''.$row->batch_no.''.$row->expiry.''.$row->price.''.$row->qty.''.$row->r_qty.''.$row->amount.''.$row->update_remark.'
Total'.$tAmount.'
+
+
+ +
+
+ +
+
+
+
+ For Krishna Pharmacy +
+
+
+
+
+ This is computer generated invoice , Signature and stamp not required +
+
+ + +
+ + + + diff --git a/old_code_ci3/views/Medical1/Medical_Invoice_V.php b/old_code_ci3/views/Medical1/Medical_Invoice_V.php new file mode 100644 index 0000000..bfac535 --- /dev/null +++ b/old_code_ci3/views/Medical1/Medical_Invoice_V.php @@ -0,0 +1,549 @@ +
+

+ Medical Invoice No. inv_med_code?> + + Edit + +

+
+
+'form','class'=>'form1')); ?> +
+
+
+
+ + + patient_id==0) { ?> + + + + + + + + + + +
Patient Name : Doctor Name : + + Other Doctor: + +
+ +
+

Name : + inv_name?> + / P Code :patient_code?> + / Invoice No. :inv_med_code?> + / Date : inv_date)?> + ipd_id > 0) { ?> + IPD Code : + + ipd_code?> + + Admit Date : str_register_date ?> reg_time ?> + / Doctor :doc_name?> + / TPA-Org. :admit_type?> + / Bill Type :ipd_credit)?'Credit To Hospital':'CASH/Direct'?> + case_id > 0){ ?> + / Org. Case ID : + case_id_code ?> + + + + + + + + + + +
Doctor Name : + + Other Doctor: + +
+ + + +

+
+ +
+
+
+
+
+
+ +
+
+ +
+
+
+
+
+ +
+
+
+
+ + + +
+
+
+
+ +
+
+
+
+ + +

+ + + + + + + + +

+
+
+
+
+
+ + +
+
+
+
+ + + +
+
+
+
+ + +
+
+
+
+ +
+
+
+ +
+ +
+ +
+
+
+
+
+

Sale Medicine

+
+ +
+
+ + +
+ +
+ + + +
+
+ + +
+ + \ No newline at end of file diff --git a/old_code_ci3/views/Medical1/Medical_invoice_list.php b/old_code_ci3/views/Medical1/Medical_invoice_list.php new file mode 100644 index 0000000..249af1e --- /dev/null +++ b/old_code_ci3/views/Medical1/Medical_invoice_list.php @@ -0,0 +1,338 @@ +
+
+ 'form','class'=>'form1')); ?> +
+
+
+
+
+

Name :p_fname?> {p_rname?>} + / Age :age?> + / Gender :xgender?> + / P Code :p_code?>
+

+ + + +
+
+ ipd_status==0) + { + ?> + + + lock_medical==0) + { + ?> + + + + + 0){ ?> + bill_final==0){ ?> + + + + + +
+
+
+
+
+ IPD Code : + + ipd_code?> + + Admit Date : str_register_date ?> reg_time ?> / + Discharge Date : str_discharge_date ?> discharge_time ?> / + No. of Days : no_days==0) {echo '1';} else {echo $ipd_list[0]->no_days; } ?> / + 0){ ?> + Bed No : bed_no ?> room_name ?> + + / Doctor :doc_name?> + / Status :Disstatus?> + +
+
+ case_id>0) { ?> +
+
+ Organisation Code #case_id_code?> / + Organisation :ins_company_name?> +
+
+ +
+
+
+ + + + + + + + + + + + '; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + $srno=$srno+1; + echo ''; + } + echo ''; + ?> + + + + + + + + + + + +
#Invoice ID.Inv.DateInv.DescCredit/CashPackageAmount
'.$srno.''.$row->inv_med_code.''.$row->inv_date.''.$row->remark_ipd.''.$row->credit.''.$row->Package.''.$row->net_amount.''; + if($ipd_master[0]->ipd_status==0) + { + echo ''; + if($row->group_invoice_id==0 && $row->ipd_credit==0 ) + { + echo ''; + } + }else{ + if($row->ipd_credit==0 ) + { + echo ''; + } + + } + echo ' Print'; + + echo '
#Invoice ID.Inv.DateInv.DescCredit/CashPackageAmount
+
+
+
+
+ + + + + + + + + + + + + +
+ Total Cash : cash_netAmount ?> + + + + Total Credit : IPDCrAmount ?> + + + + Total Package : PackageCrAmount ?> + + + + Total Amount : t_net_amount ?> + + + + Total Balance : t_payment_balance ?> + + +
+
+
+
+
+ + + + + + + + 0) { ?> + + + + + +
+ + + Print Return List + +
+ + + + discount_group_2>0) { + ?> + + + +
+ + + + +
+
+ + + + + + + + +
+ Print Cash + + Print IPD Credit + + Print IPD Package + + Print Medicine List + + Print Page Wise +
+
+
+
+
+ +
+
+ \ No newline at end of file diff --git a/old_code_ci3/views/Medical1/Medical_invoice_print.php b/old_code_ci3/views/Medical1/Medical_invoice_print.php new file mode 100644 index 0000000..a168dd3 --- /dev/null +++ b/old_code_ci3/views/Medical1/Medical_invoice_print.php @@ -0,0 +1,180 @@ + + + + + + + <?=$pharmacyName?> | Invoice + + + + + + + + + + + + + + + +
+
+ +
+
+

+ +

+


+ +
GST: / L.No: DEMO 1/USN/JAN/2008

+

CASH / Credit Memo

+

+ +
+
+
+

+
+ +
+ +
+
+ +
+
+ To +
+ inv_name ?>
+ Date : inv_date ?>
+ Patient ID : patient_code ?>
+
+ +
+
+
+ Refer By : doc_name ?>
+ ipd_id>0) { ?> + IPD Code : ipd_code ?>
+ + case_id>0) { ?> + Org. Code : case_id_code ?>
+ Org. Name : insurance_company_name ?>
+ +
+ +
+ +
+
+
+ + + + + + + + + + + + + + + '; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + } + echo ''; + ?> + + + + + + + + + + + + + + +
#Item NameBatch NoExp.RateQty.PriceDisc.HSNCODE/GSTGSTAmount
'.$srno.''.$row->item_Name.' ['.$row->formulation.']'.$row->batch_no.''.$row->expiry.''.$row->price.''.$row->qty.''.$row->amount.''.$row->disc_amount.''.$row->HSNCODE.'/'.$row->gst_per.''.$row->gst.''.$row->tamount.'
#Gross TotalGtotal ?>t_dis_amt?>TGST?>tamt?>
+
+
+
+ + + + + + + + + + +
#Deduction :[discount_remark ?>] discount_amount?>CGST : TCGST?>SGST : TSGST?>Net Amount : net_amount?>Amount received : payment_received?>Balance Amount : payment_balance?>
+
+ +
+
+ Payment Details [Payment No.:Mode of Payment:Amount]: + id.':'.$row->Payment_type_str.':'.$row->amount.']/'; + } + ?> +
+
+
+
+ Prepared By : prepared_by ?> +
+
+
+
+ Signature +
+
+
+
+
+ This is computer generated invoice , Signature and stamp not required +
+
+ +
+ + + diff --git a/old_code_ci3/views/Medical1/Medical_invoice_print_1.php b/old_code_ci3/views/Medical1/Medical_invoice_print_1.php new file mode 100644 index 0000000..d37c24b --- /dev/null +++ b/old_code_ci3/views/Medical1/Medical_invoice_print_1.php @@ -0,0 +1,182 @@ + + + + + + + <?=$pharmacyName?> | Invoice + + + + + + + + + + + + + + + +
+
+ +
+
+ +
+ +
+ +
+
+ +
+
+ From
+
+
+ +
+ Invoice ID #inv_med_code ?>
+ GST :
+
+ +
+ To +
+ inv_name ?>
+ Date : inv_date ?>
+ Patient ID : patient_code ?>
+ Refer By : doc_name ?>
+ ipd_id>0) { ?> + IPD Code : ipd_code ?>
+ + case_id>0) { ?> + Org. Code : case_id_code ?>
+ Org. Name : insurance_company_name ?>
+ +
+ +
+ +
+
+
+ + + + + + + + + + + + + + + + + '; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + } + echo ''; + ?> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
#Item NameFormulationBatch NoExp.RateQty.PriceDisc.HSNCODE/C-SGSTCGSTSGSTAmount
'.$srno.''.$row->item_Name.''.$row->formulation.''.$row->batch_no.''.$row->expiry.''.$row->price.''.$row->qty.''.$row->amount.''.$row->disc_amount.''.$row->HSNCODE.'/'.$row->CGST_per.'/'.$row->SGST_per.''.$row->CGST.''.$row->SGST.''.$row->tamount.'
#Gross TotalGtotal ?>t_dis_amt?>TCGST?>TSGST?>tamt?>
#Deductiondiscount_remark ?>discount_amount ?>
#Amount received : payment_received?>Balance Amount : payment_balance?>Net Amount : net_amount?>
+
+
+ +
+
+ Payment Details [Payment No.:Mode of Payment:Amount]: + id.':'.$row->Payment_type_str.':'.$row->amount.']/'; + } + ?> +
+
+
+
+ Prepared By : prepared_by ?> +
+
+
+
+ Signature +
+
+
+
+
+ This is computer generated invoice , Signature and stamp not required +
+
+ +
+ + + diff --git a/old_code_ci3/views/Medical1/Medical_invoice_print_2.php b/old_code_ci3/views/Medical1/Medical_invoice_print_2.php new file mode 100644 index 0000000..accd2dd --- /dev/null +++ b/old_code_ci3/views/Medical1/Medical_invoice_print_2.php @@ -0,0 +1,178 @@ + + + + + + + <?=$pharmacyName?> | Invoice + + + + + + + + + + + + + + +
+ +
+
+ +
+
+

+ +

+


+ +
GST: / L.No: DEMO 1/USN/JUNE/2008

+
+ +
+
+

CASH / Credit Memo

+
+
+
+ To +
+ inv_name ?>
+ Patient ID : patient_code ?>
+ Refer By : doc_name ?>
+
+ +
+
+
+ Medical Invoice : inv_med_code ?>
+ Invoice Date : inv_date) ?>
+ +
+
+
+
+ ipd_id>0) { ?> + IPD Code : ipd_code ?>
+ + case_id>0) { ?> + Org. Code : case_id_code ?>
+ Org. Name : insurance_company_name ?>
+ +
+
+
+
+
+
+
+
+ + + + + + + + + + + + + + + '; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + } + echo ''; + ?> + + + + + + + + + + + + + +
#Item NameBatch NoExp.RateQty.PriceDisc.HSNCODE/GSTGSTAmount
'.$srno.''.$row->item_Name.' '.$row->formulation.''.$row->batch_no.''.$row->expiry.''.$row->price.''.$row->qty.''.$row->amount.''.$row->d_amt.''.$row->HSNCODE.'/'.$row->gst_per.''.$row->gst.''.$row->twdisc_amount.'
#Gross Totalgross_amount ?>inv_disc_total?>TGST?>net_amount?>
+
+
+
+ + + + + + + + + + + +
#Deduction :[discount_remark ?>] inv_disc_total?>CGST : CGST_Tamount?>SGST : SGST_Tamount?>Taxable Amount : TaxableAmount?>Net Amount : net_amount?>Amount received : payment_received?>Balance Amount : payment_balance?>
+
+ +
+
+ Payment Details [Payment No.:Mode of Payment:Amount]: + id.':'.$row->Payment_type_str.':'.$row->amount.']/'; + } + ?> +
+
+
+
+ Prepared By : prepared_by ?> +
+
+
+
+ Signature +
+
+
+
+
+ This is computer generated invoice , Signature and stamp not required +
+
+ +
+ + + + diff --git a/old_code_ci3/views/Medical1/Medical_invoice_print_all.php b/old_code_ci3/views/Medical1/Medical_invoice_print_all.php new file mode 100644 index 0000000..7651ee7 --- /dev/null +++ b/old_code_ci3/views/Medical1/Medical_invoice_print_all.php @@ -0,0 +1,197 @@ + + + + + + + <?=$pharmacyName?> | Invoice + + + + + + + + + + + + + + +
+ +
+
+ +
+
+

+ +

+


+ +
GST: / L.No: DEMO 1/USN/JUNE/2008

+
+ +
+
+ +

CASH / Credit Memo

+
+
+
+ To +
+ p_fname ?>
+ Patient ID : p_code ?>
+ Refer By : doc_name ?>
+
+ +
+
+
+ IPD Code : ipd_code ?>
+ org_id>0) { ?> + Org. Code : case_id_code ?>
+ Org. Name : insurance_company_name ?>
+ +
+
+
+ +
+
+ + id=='' && $row->inv_med_id != '') + { + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + + $head_start=0; + } + elseif($row->id=='' && $row->inv_med_id == ''){ + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + }else{ + + if($head_start==0) + { + echo ''; + + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + } + + $srno=$srno+1; + $head_start=$head_start+1; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + } + } + ?> + + +
#Invoice Total :'.$row->inv_med_code.''.$row->amount.''.$row->d_amt.''.$row->gst.''.$row->twdisc_amount.'

#Grand Total'.$row->amount.''.$row->d_amt.''.$row->gst.''.$row->twdisc_amount.'

Invoice ID : '.$row->inv_med_code.' [Dated : '.$row->str_inv_date.']
#Item NameBatch NoExp.RateQty.PriceDisc.HSNCODE/GSTGSTAmount
'.$srno.''.$row->item_Name.' '.$row->formulation.''.$row->batch_no.''.$row->expiry.''.$row->price.''.$row->qty.''.$row->amount.''.$row->d_amt.''.$row->HSNCODE.'/'.$row->gst_per.''.$row->gst.''.$row->twdisc_amount.'
+
+
+ 0) { ?> +
+ + + + + + + + + + + +
#Deduction : discount_group?>CGST : CGST_Tamount?>SGST : SGST_Tamount?>Taxable Amount : TaxableAmount?>Net Amount : net_amount?>Amount received : payment_received?>Balance Amount : payment_balance?>
+
+ +
+
+ Payment Details [Payment No.:Mode of Payment:Amount]: + id.':'.$row->Payment_type_str.':'.$row->amount.']/'; + } + ?> +
+
+
+
+ +
+
+
+
+ For Krishna Pharmacy +
+
+
+
+
+ This is computer generated invoice , Signature and stamp not required +
+
+ + +
+ + + + diff --git a/old_code_ci3/views/Medical1/Medical_invoice_print_all_provisional.php b/old_code_ci3/views/Medical1/Medical_invoice_print_all_provisional.php new file mode 100644 index 0000000..dc375ae --- /dev/null +++ b/old_code_ci3/views/Medical1/Medical_invoice_print_all_provisional.php @@ -0,0 +1,179 @@ + + + + + + + <?=$pharmacyName?> | Provisional Invoice + + + + + + + + + + + + + + +
+ +
+
+ +
+
+

+ +

+


+ +
GST: / L.No: OBR 1/NTL/AUG/2004 / BR 1/NTL/AUG/2004

+
+ +
+
+ +

Provisional CASH / Credit Memo

+
+
+
+ To +
+ p_fname ?>
+ Patient ID : p_code ?>
+ Refer By : doc_name ?>
+
+ +
+
+
+ IPD Code : ipd_code ?>
+ org_id>0) { ?> + Org. Code : case_id_code ?>
+ Org. Name : insurance_company_name ?>
+ +
+
+
+ +
+
+ + id=='' && $row->inv_med_id != '') + { + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + + $head_start=0; + } + elseif($row->id=='' && $row->inv_med_id == ''){ + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + }else{ + + if($head_start==0) + { + echo ''; + + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + } + + $srno=$srno+1; + $head_start=$head_start+1; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + } + } + ?> + + +
#Invoice Total :'.$row->inv_med_code.''.$row->amount.'

#Grand Total'.$row->amount.'

[Dated : '.$row->str_inv_date.']
#Item NameBatch NoExp.RateQty.Price
'.$srno.''.$row->item_Name.' '.$row->formulation.''.$row->batch_no.''.$row->expiry.''.$row->price.''.$row->qty.''.$row->amount.'
+
+
+ 0) { ?> +
+ + + + + + + + + +
#Gross Amount : gross_amount?>Deduction : discount_group?>Net Amount : net_amount?>Amount received : payment_received?>Balance Amount : payment_balance?>
+
+ +
+
+ Payment Details [Payment No.:Mode of Payment:Amount]: + id.':'.$row->Payment_type_str.':'.$row->amount.']/'; + } + ?> +
+
+
+
+ +
+
+
+
+ For Krishna Pharmacy +
+
+
+
+
+ This is computer generated invoice , Signature and stamp not required +
+
+ + +
+ + + + diff --git a/old_code_ci3/views/Medical1/Medical_ipd_org_list.php b/old_code_ci3/views/Medical1/Medical_ipd_org_list.php new file mode 100644 index 0000000..5fea2dd --- /dev/null +++ b/old_code_ci3/views/Medical1/Medical_ipd_org_list.php @@ -0,0 +1,57 @@ +
+
+
+

IPD List

+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
IPD CodeName/Patient CodeBed No.[Type]Register DateNo. of DaysDr. NameAdmit TypeAmount
+ + ipd_code ?> + + [p_code ?>] p_fname ?>
p_rname ?>
Bed_Desc ?>str_register_date ?>no_days ?>doc_name ?>admit_type ?>
Org_Status ?>
M:med_amount ?>
IPD CodeName/Patient CodeRegister DateAdmit TypeAmount
+ +
+ +
+
+ + diff --git a/old_code_ci3/views/Medical1/Medical_org_invoicelist.php b/old_code_ci3/views/Medical1/Medical_org_invoicelist.php new file mode 100644 index 0000000..d9572ae --- /dev/null +++ b/old_code_ci3/views/Medical1/Medical_org_invoicelist.php @@ -0,0 +1,97 @@ +
+
+ 'form','class'=>'form1')); ?> +
+
+
+
+
+

Name :p_fname?> {p_rname?>} + / Age :age?> + / Gender :xgender?> + / P Code :p_code?> + / Organisation Invoice #case_id_code?> + /Organisation :insurance_company_name?> +

+ + + +
+
+ +
+
+
+
+
+ + + + + + + + + + + + + '; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + $srno=$srno+1; + echo ''; + } + echo ''; + ?> + + + + + + + + + + + + + +
#Invoice ID.PatientInv.DateInv.DescCredit/CashAmountBalance
'.$srno.''.$row->inv_med_code.''.$row->inv_name.''.$row->inv_date.''.$row->remark_ipd.''.$row->credit.''.$row->net_amount.''.$row->payment_balance.' + + Print +
#
+
+
+
+
+ +
+
+ \ No newline at end of file diff --git a/old_code_ci3/views/Medical1/Medical_org_list.php b/old_code_ci3/views/Medical1/Medical_org_list.php new file mode 100644 index 0000000..22059a3 --- /dev/null +++ b/old_code_ci3/views/Medical1/Medical_org_list.php @@ -0,0 +1,49 @@ +
+
+
+

ORG List

+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + +
ORG CodeName/Patient CodeRegister DateInsurance Company
+ + case_id_code ?> + + [p_code ?>] p_fname ?>
p_rname ?>
str_register_date ?>insurance_company_name ?>
ORG CodeName/Patient CodeRegister DateInsurance Company
+ +
+ +
+
+ + diff --git a/old_code_ci3/views/Medical1/Medical_stock_drug.php b/old_code_ci3/views/Medical1/Medical_stock_drug.php new file mode 100644 index 0000000..3c8afae --- /dev/null +++ b/old_code_ci3/views/Medical1/Medical_stock_drug.php @@ -0,0 +1,116 @@ +
+
+
+

Drug Details

+
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
SS No.Item CodeItem NameFormulationRack No.Shelf No.Batch No.QtyExpiryMRPSaled Qty
+
+ +
+
+ + \ No newline at end of file diff --git a/old_code_ci3/views/Medical1/Patient_Search_Result.php b/old_code_ci3/views/Medical1/Patient_Search_Result.php new file mode 100644 index 0000000..03d062b --- /dev/null +++ b/old_code_ci3/views/Medical1/Patient_Search_Result.php @@ -0,0 +1,49 @@ +

+
+
+

Result

+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Sr.No.Patient/UHID CodeName {Relative Name}AgeLast VisitPhone No.InsuranceAction
p_code ?>p_fname ?> {p_rname ?>}age ?>Last_Visit ?>mphone1 ?>insurance_id==0 ? 'Self': 'Insuranced'); ?> +
Patient CodeNamePhone NumberEMailAction
+
+ +
+ \ No newline at end of file diff --git a/old_code_ci3/views/Medical1/Print/Medicine_List.php b/old_code_ci3/views/Medical1/Print/Medicine_List.php new file mode 100644 index 0000000..a8aedaa --- /dev/null +++ b/old_code_ci3/views/Medical1/Print/Medicine_List.php @@ -0,0 +1,86 @@ + + + + + + + + + + + +
Page : {PAGENO}/{nbpg}IPD-ID:ipd_code ?> / UHID:p_code ?> /Name : p_fname ?>
+
+ + + + + + + + +
+

Medicine Prescription

+

Rx

+ Patient Info.
+ p_fname ?>
+ UHID ID : p_code ?>
+ IPD Code : ipd_code ?>
+

+
+ + + str_inv_date<>$inv_date){ + if(($srno % 3)==2 ) + { + echo ''; + }elseif(($srno % 3)==0){ + echo ''; + } + + $srno=1; + echo ' + + '; + echo ''; + } + + if(($srno % 3)==1) + { + echo ''; + } + + echo ''; + + if(($srno % 3)==0){ + echo ''; + } + + $inv_date=$row->str_inv_date; + } + ?> +

Dated : ' + .$row->str_inv_date.'
'.$srno.' : ' + .$row->item_Name.' '.$row->formulation. ' /Qty :' + .$row->qty.'
+

+ +

diff --git a/old_code_ci3/views/Medical1/Print/medical_bill_print_a6.php b/old_code_ci3/views/Medical1/Print/medical_bill_print_a6.php new file mode 100644 index 0000000..5dcb1d4 --- /dev/null +++ b/old_code_ci3/views/Medical1/Print/medical_bill_print_a6.php @@ -0,0 +1,190 @@ + + + + + + + + + + + +

+

, Uttarakhand
+ '; + + if(H_Med_GST!='') + { + echo 'GST: '.H_Med_GST .''; + } + + if(M_LIC!='') + { + echo ' L.No: '.M_LIC; + } + ?> +

+

+ Invoice To : + inv_name?>
+ customer_type==0) { ?> + Phone No. : inv_phone_number?>
+ doc_name!=''){ ?> + Refer By : Dr. doc_name ?>
+ + + customer_type==1 && count($patient_master)>0) { ?> + Patient Info. as per Hospital Records
+ UHID ID : p_code ?>
+ + ipd_id>0) { ?> + IPD Code : ipd_code ?>
+ Refer By : doc_name ?>
+ case_id>0 && $ipd_master[0]->case_id<>'') { ?> + Org. Code : case_id_code ?>
+ Org. Name : insurance_company_name ?>
+ + case_credit==1 && $invoice_med_master[0]->case_id>0) { ?> + Org. Code : case_id_code ?>
+ Org. Name : insurance_company_name ?>
+ +

+
+

TAX Invoice

+
+ + + + + + +
Page : {PAGENO}/{nbpg}Invoice No.:inv_med_code ?> / Name : inv_name ?>
+
+ + + '; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + } + + $srno=$srno+1; + $head_start=$head_start+1; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + + echo ''; + } + + if(count($invoice_med_master)>0) { + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + } + ?> +
Invoice ID : '.$row->inv_med_code.' [Dated : '.$row->str_inv_date.']
#Item NameBatch NoExp.RateQty.Gross AmtDisc.Net Amt
'.$srno.''.$row->item_Name.' '.$row->formulation.''.$row->batch_no.''.$row->expiry.''.$row->price.''.$row->qty.''.$row->amount.''.$row->d_amt.''.$row->twdisc_amount.'
#Total '.$invoice_med_master[0]->gross_amount.' '.$invoice_med_master[0]->inv_disc_total.' '.round($invoice_med_master[0]->net_amount).'
+ +0) { ?> +
+ + + + + + + + payment_balance>=0 ){ ?> + + + + + + + + + + + payment_balance>=0 ){ ?> + + + + +
#CGSTSGSTTaxable AmountNet AmountAmount receivedBalance Amount
#CGST_Tamount?>SGST_Tamount?>TaxableAmount?>net_amount),2)?>payment_received?>payment_balance?>
+
+ + + + + + + + + + +
+ Payment Details [Payment No.:Mode of Payment:Amount:Date]: + id.':'.$row->Payment_type_str.':'.$row->amount.':'.$row->payment_date.']/'; + } + ?> + +
+

+
+ For +
diff --git a/old_code_ci3/views/Medical1/Print/medical_bill_print_format.php b/old_code_ci3/views/Medical1/Print/medical_bill_print_format.php new file mode 100644 index 0000000..67bea67 --- /dev/null +++ b/old_code_ci3/views/Medical1/Print/medical_bill_print_format.php @@ -0,0 +1,191 @@ + + + + + + + + +
+

+

, Uttarakhand
+ '; + + if(H_Med_GST!='') + { + echo 'GST: '.H_Med_GST .''; + } + + if(M_LIC!='') + { + echo ' L.No: '.M_LIC; + } + ?> +

+ +

+ Invoice To : + p_fname ?>
+ Patient Info. as per Hospital Records
+ UHID ID : p_code ?>
+ IPD Code : ipd_code ?>
+ Refer By : doc_name ?>
+ org_id>0) { ?> + Org. Code : case_id_code ?>
+ Org. Name : insurance_company_name ?>
+ +

+
+

TAX Invoice

+
+ + + + + + +
Page : {PAGENO}/{nbpg}IPD-ID:ipd_code ?> / UHID:p_code ?> /Name : p_fname ?>
+
+ + id=='' && $row->inv_med_id != '') + { + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + + $head_start=0; + } + elseif($row->id=='' && $row->inv_med_id == ''){ + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + }else{ + + if($head_start==0) + { + echo ' + '; + + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + } + + $srno=$srno+1; + $head_start=$head_start+1; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + } + } + ?> +
#Invoice Total :'.$row->inv_med_code.''.$row->amount.''.$row->d_amt.''.$row->gst.''.$row->twdisc_amount.'

#Grand Total'.$row->amount.''.$row->d_amt.''.$row->gst.''.$row->twdisc_amount.'

Invoice ID : '.$row->inv_med_code.' [Dated : '.$row->str_inv_date.']
#Item NameBatch NoExp.RateQty.PriceDisc.HSNCODE/GSTGSTAmount
'.$srno.''.$row->item_Name.' '.$row->formulation.''.$row->batch_no.''.$row->expiry.''.$row->price.''.$row->qty.''.$row->amount.''.$row->d_amt.''.$row->HSNCODE.'/'.$row->gst_per.''.$row->gst.''.$row->twdisc_amount.'
+ +0) { ?> +
+ + + + + + + + + payment_balance>=0 ){ ?> + + + + + + + + + + + + payment_balance>=0 ){ ?> + + + + +
#Deduction CGSTSGSTTaxable AmountNet AmountAmount receivedBalance Amount
#discount_group?>CGST_Tamount?>SGST_Tamount?>TaxableAmount?>net_amount),2)?>payment_received?>payment_balance?>
+
+ +

+ + + + +
+ Payment Details [Payment No.:Mode of Payment:Amount]: + id.':'.$row->Payment_type_str.':'.$row->amount.']/'; + } + ?> + + + For +
diff --git a/old_code_ci3/views/Medical1/Print/medical_bill_print_format_newpage.php b/old_code_ci3/views/Medical1/Print/medical_bill_print_format_newpage.php new file mode 100644 index 0000000..9e95100 --- /dev/null +++ b/old_code_ci3/views/Medical1/Print/medical_bill_print_format_newpage.php @@ -0,0 +1,145 @@ + + + + + + + + +
+

+

, Uttarakhand
+ '; + + if(H_Med_GST!='') + { + echo 'GST: '.H_Med_GST .''; + } + + if(M_LIC!='') + { + echo ' L.No: '.M_LIC; + } + ?> +

+ Invoice To : + p_fname ?>
+

+ Patient Info. as per KHRC Records
+ UHID ID : p_code ?>
+ IPD Code : ipd_code ?>
+ Refer By : doc_name ?>
+ org_id>0) { ?> + Org. Code : case_id_code ?>
+ Org. Name : insurance_company_name ?>
+ +

+
+

CASH / Credit Memo

+
+ + + + + + +
IPD-ID:ipd_code ?> / UHID:p_code ?> /Name : p_fname ?>
+
+ + id=='' && $row->inv_med_id != '') + { + echo ''; + echo '#'; + echo 'Invoice Total :'.$row->inv_med_code.''; + echo ''.$row->amount.''; + echo ''.$row->d_amt.''; + echo ''; + echo ''.$row->gst.''; + echo ''.$row->twdisc_amount.''; + echo ''; + echo ''; + echo ''; + + $head_start=0; + } + elseif($row->id=='' && $row->inv_med_id == ''){ + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo '

#Grand Total'.$row->amount.''.$row->d_amt.''.$row->gst.''.$row->twdisc_amount.'
'; + }else{ + + if($head_start==0) + { + echo ''; + + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + } + + $srno=$srno+1; + $head_start=$head_start+1; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + } + } + ?> +

diff --git a/old_code_ci3/views/Medical1/Print/medical_bill_print_format_single.php b/old_code_ci3/views/Medical1/Print/medical_bill_print_format_single.php new file mode 100644 index 0000000..c34e44a --- /dev/null +++ b/old_code_ci3/views/Medical1/Print/medical_bill_print_format_single.php @@ -0,0 +1,184 @@ + + + +

Invoice ID : '.$row->inv_med_code.' [Dated : '.$row->str_inv_date.']

#Item NameBatch NoExp.RateQty.PriceDisc.HSNCODE/GSTGSTAmount
'.$srno.''.$row->item_Name.' '.$row->formulation.''.$row->batch_no.''.$row->expiry.''.$row->price.''.$row->qty.''.$row->amount.''.$row->d_amt.''.$row->HSNCODE.'/'.$row->gst_per.''.$row->gst.''.$row->twdisc_amount.'
+ + + + +
+

+

, Uttarakhand
+ '; + + if(H_Med_GST!='') + { + echo 'GST: '.H_Med_GST .''; + } + + if(M_LIC!='') + { + echo ' L.No: '.M_LIC; + } + ?> +

+

+ Invoice To : + inv_name?>
+ customer_type==0) { ?> + Phone No. : inv_phone_number?>
+ doc_name<>''){ ?> + Refer By : Dr. doc_name ?>
+ + + customer_type==1 && count($patient_master)>0) { ?> + Patient Info. as per Hospital Records
+ UHID ID : p_code ?>
+ + ipd_id>0) { ?> + IPD Code : ipd_code ?>
+ Refer By : doc_name ?>
+ case_id>0 && $ipd_master[0]->case_id<>'') { ?> + Org. Code : case_id_code ?>
+ Org. Name : insurance_company_name ?>
+ + case_credit==1 && $invoice_med_master[0]->case_id>0) { ?> + Org. Code : case_id_code ?>
+ Org. Name : insurance_company_name ?>
+ +

+
+

TAX Invoice

+ + + + + + + +
Page : {PAGENO}/{nbpg}Invoice No.:inv_med_code ?> / Name : inv_name ?>
+
+ + '; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + } + + $srno=$srno+1; + $head_start=$head_start+1; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + } + + if(count($invoice_med_master)>0) { + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + } + ?> +
Invoice ID : '.$row->inv_med_code.' [Dated : '.$row->str_inv_date.']
#Item NameBatch NoExp.RateQty.Gross AmtDisc.HSNCODE/GSTGSTNet Amt
'.$srno.''.$row->item_Name.' '.$row->formulation.''.$row->batch_no.''.$row->expiry.''.$row->price.''.$row->qty.''.$row->amount.''.$row->d_amt.''.$row->HSNCODE.'/'.$row->gst_per.''.$row->gst.''.$row->twdisc_amount.'
#Total'.$invoice_med_master[0]->gross_amount.''.$invoice_med_master[0]->inv_disc_total.''.$invoice_med_master[0]->TGST.''.number_format(round($invoice_med_master[0]->net_amount),2).'
+ +0) { ?> +
+ + + + + + + + + payment_balance>=0 ){ ?> + + + + + + + + + + + payment_balance>=0 ){ ?> + + + + +
#CGSTSGSTTaxable AmountNet AmountAmount receivedBalance Amount
#CGST_Tamount?>SGST_Tamount?>TaxableAmount?>net_amount),2)?>payment_received?>payment_balance?>
+
+ +

+ + + + +
+ Payment Details [Payment No.:Mode of Payment:Amount:Date]: + id.':'.$row->Payment_type_str.':'.$row->amount.':'.$row->payment_date.']/'; + } + ?> + + + For +
diff --git a/old_code_ci3/views/Medical1/Purchase/company_Edit.php b/old_code_ci3/views/Medical1/Purchase/company_Edit.php new file mode 100644 index 0000000..89cdbf2 --- /dev/null +++ b/old_code_ci3/views/Medical1/Purchase/company_Edit.php @@ -0,0 +1,76 @@ +
+
+

Supplier

+
+
+ 'form','class'=>'form1')); ?> + 0) + { + $cid=$med_company[0]->id; + $company_name=$med_company[0]->company_name; + $contact_person_name=$med_company[0]->contact_person_name; + $contact_phone_no=$med_company[0]->contact_phone_no; + } + + ?> + +
+
+
+ + +
+
+
+
+ + +
+
+
+
+
+
+ + +
+
+
+
+
+
+ + +
+
+
+ +
+
+ \ No newline at end of file diff --git a/old_code_ci3/views/Medical1/Purchase/company_list.php b/old_code_ci3/views/Medical1/Purchase/company_list.php new file mode 100644 index 0000000..877d442 --- /dev/null +++ b/old_code_ci3/views/Medical1/Purchase/company_list.php @@ -0,0 +1,60 @@ +
+

+ Company +

+
+
+
+
+
+
+ +

Company List

+
+
+
+ +
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + +
Company NamePerson/PhoneAction
company_name ?>contact_person_name ?>/contact_phone_no ?> + +
Company NamePerson/PhoneAction
+ +
+ +
+
+
+ +
+
+
+ + \ No newline at end of file diff --git a/old_code_ci3/views/Medical1/Purchase/company_list_sub.php b/old_code_ci3/views/Medical1/Purchase/company_list_sub.php new file mode 100644 index 0000000..1deb7e1 --- /dev/null +++ b/old_code_ci3/views/Medical1/Purchase/company_list_sub.php @@ -0,0 +1,27 @@ + + + + + + + + + + + + + + + + + + + + + + + + +
Company NamePerson/PhoneAction
company_name ?>contact_person_name ?>/contact_phone_no ?> + +
NameGSTAction
\ No newline at end of file diff --git a/old_code_ci3/views/Medical1/Purchase/drug_master_list.php b/old_code_ci3/views/Medical1/Purchase/drug_master_list.php new file mode 100644 index 0000000..9479269 --- /dev/null +++ b/old_code_ci3/views/Medical1/Purchase/drug_master_list.php @@ -0,0 +1,30 @@ +
+ +'form','class'=>'form2')); ?> +
+ + + + + + + + + + +
+ +
+
+ \ No newline at end of file diff --git a/old_code_ci3/views/Medical1/Purchase/indent_req_list.php b/old_code_ci3/views/Medical1/Purchase/indent_req_list.php new file mode 100644 index 0000000..5fefe5e --- /dev/null +++ b/old_code_ci3/views/Medical1/Purchase/indent_req_list.php @@ -0,0 +1,30 @@ +
+ +'form','class'=>'form2')); ?> +
+ + + + + + + + + + +
+ +
+
+ \ No newline at end of file diff --git a/old_code_ci3/views/Medical1/Purchase/indent_req_list_search.php b/old_code_ci3/views/Medical1/Purchase/indent_req_list_search.php new file mode 100644 index 0000000..e970c0a --- /dev/null +++ b/old_code_ci3/views/Medical1/Purchase/indent_req_list_search.php @@ -0,0 +1,57 @@ +
+
+
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Indent IDReq. TypeDateProduct ListStatus
indent_code ?>indent_request_type_str ?>created_date ?>product_list ?>request_status_str?> + request_status==0) { ?> + + request_status==1) { ?> + + request_status==4) { ?> + + + + +
Indent IDStoreDateStatus
+ +
+
+
+ + \ No newline at end of file diff --git a/old_code_ci3/views/Medical1/Purchase/indent_request_edit.php b/old_code_ci3/views/Medical1/Purchase/indent_request_edit.php new file mode 100644 index 0000000..0f64ee9 --- /dev/null +++ b/old_code_ci3/views/Medical1/Purchase/indent_request_edit.php @@ -0,0 +1,203 @@ +
+
+
+
+
+

Indent Request Information

+ Indent No.: indent_code ?> | + Indent Date & Time : created_date ?> + Indent Current Status : request_status] ?> + request_status==0){ ?> + + request_status==1){ ?> + + + +
+
+
+
+ +
+
+
+ + \ No newline at end of file diff --git a/old_code_ci3/views/Medical1/Purchase/indent_request_item_list.php b/old_code_ci3/views/Medical1/Purchase/indent_request_item_list.php new file mode 100644 index 0000000..4ee64b2 --- /dev/null +++ b/old_code_ci3/views/Medical1/Purchase/indent_request_item_list.php @@ -0,0 +1,43 @@ + + + + + + + + + + + + '; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + } + echo ''; + ?> + + + + + + + + + + + + +
#Product CodeItem NameFormulationGeneric NameQty.Min Qty
'.$srno.''.$row->item_name.''.$row->formulation.''.$row->genericname.''.$row->request_qty.''.$row->min_requirement.' + +
#Product CodeItem NameFormulationGeneric NameQty.Min Qty
\ No newline at end of file diff --git a/old_code_ci3/views/Medical1/Purchase/indent_request_view.php b/old_code_ci3/views/Medical1/Purchase/indent_request_view.php new file mode 100644 index 0000000..291e9b3 --- /dev/null +++ b/old_code_ci3/views/Medical1/Purchase/indent_request_view.php @@ -0,0 +1,60 @@ +
+
+
+
+
+

Indent Request Information

+ Indent No.: indent_code ?> | + Indent Date & Time : created_date ?> + Indent Current Status : request_status] ?> + request_status==0){ ?> + + request_status==1){ ?> + + + +
+
+ + + + + + + + + + '; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + } + echo ''; + ?> + + + + + + + + + + +
#Item NameFormulationGeneric NameQty.Min Qty
'.$srno.''.$row->item_name.''.$row->formulation.''.$row->genericname.''.$row->request_qty.''.$row->min_requirement.'
#Item NameFormulationGeneric NameQty.Min Qty
+
+ +
+
+
diff --git a/old_code_ci3/views/Medical1/Purchase/ledger_add_entry.php b/old_code_ci3/views/Medical1/Purchase/ledger_add_entry.php new file mode 100644 index 0000000..8e3efe7 --- /dev/null +++ b/old_code_ci3/views/Medical1/Purchase/ledger_add_entry.php @@ -0,0 +1,85 @@ +
+
+
+
+

Add Entry

+
+ +
+
+ 'myform_add_entry'); + echo form_open('Medical_backpanel/add_entry/'.$s_id,$attributes); ?> + +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+
+ +
+ +
+
+
+ +
+ +
+
+
+
+
+ +
+ +
+
+
+
+ + +
+
+
+ \ No newline at end of file diff --git a/old_code_ci3/views/Medical1/Purchase/ledger_data.php b/old_code_ci3/views/Medical1/Purchase/ledger_data.php new file mode 100644 index 0000000..b7f2dd6 --- /dev/null +++ b/old_code_ci3/views/Medical1/Purchase/ledger_data.php @@ -0,0 +1,63 @@ +
+
+
+
+

Statement Details + Opening Balance : / Total Cr. : / Total Dr. : + / Closing Blance : + +

+
+ +
+
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
IDDate TranDescriptionCreditDebitActions
tran_date); ?>mode_desc.' '.$c->tran_desc; ?>credit_debit==0?$c->amount:''); ?>credit_debit==1?$c->amount:''); ?> + bank_id>1) { ?> + + +
IDDate TranDescriptionCreditDebitActions
+ +
+
+
+
diff --git a/old_code_ci3/views/Medical1/Purchase/ledger_edit_entry.php b/old_code_ci3/views/Medical1/Purchase/ledger_edit_entry.php new file mode 100644 index 0000000..98bd68b --- /dev/null +++ b/old_code_ci3/views/Medical1/Purchase/ledger_edit_entry.php @@ -0,0 +1,87 @@ +
+
+
+
+

Edit Entry

+
+ +
+
+ 'myform_add_entry'); + echo form_open('Medical_backpanel/edit_entry/'.$tran_id,$attributes); ?> + +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+
+ +
+ +
+
+
+ +
+ +
+
+
+
+
+ +
+ +
+
+
+
+ + +
+
+
+ \ No newline at end of file diff --git a/old_code_ci3/views/Medical1/Purchase/new_indent_request.php b/old_code_ci3/views/Medical1/Purchase/new_indent_request.php new file mode 100644 index 0000000..e75aff1 --- /dev/null +++ b/old_code_ci3/views/Medical1/Purchase/new_indent_request.php @@ -0,0 +1,56 @@ +
+
+
+
+
+
+

New Purchase Invoice

+
+
+ 'form','class'=>'form1')); ?> + +
+
+
+ + +
+
+
+ +
+
+ +
+
+
+
+ \ No newline at end of file diff --git a/old_code_ci3/views/Medical1/Purchase/new_purchase_invoice.php b/old_code_ci3/views/Medical1/Purchase/new_purchase_invoice.php new file mode 100644 index 0000000..ff5d56b --- /dev/null +++ b/old_code_ci3/views/Medical1/Purchase/new_purchase_invoice.php @@ -0,0 +1,69 @@ +
+
+
+
+
+
+

New Purchase Invoice

+
+
+ 'form','class'=>'form1')); ?> +
+
+
+ + +
+
+
+
+ + +
+
+
+ +
+
+ +
+ +
+
+
+ +
+
+ +
+
+
+
+ \ No newline at end of file diff --git a/old_code_ci3/views/Medical1/Purchase/product_edit.php b/old_code_ci3/views/Medical1/Purchase/product_edit.php new file mode 100644 index 0000000..7684f6b --- /dev/null +++ b/old_code_ci3/views/Medical1/Purchase/product_edit.php @@ -0,0 +1,313 @@ +
+
+
+ 'form','class'=>'form1')); ?> +
+
+

Product

+ item_name?> +
+
+ + +
+
+
+
+ + +
+
+
+
+
+
+
+
+
+ + +
+
+
+
+
+
+ + +
+
+
+
+
+ + +
+
+
+
+ + +
+
+
+
+ + +
+
+ ban_flag_id; + if($chk_ban_flag_id==1) + { + $chk_ban_flag_id_checkbox_checked="checked"; + }else{ + $chk_ban_flag_id_checkbox_checked=""; + } + + $chk_is_continue=$product_data[0]->is_continue; + if($chk_is_continue==1) + { + $chk_is_continue_checkbox_checked="checked"; + }else{ + $chk_is_continue_checkbox_checked=""; + } + + $chk_batch_applicable=$product_data[0]->batch_applicable; + if($chk_batch_applicable==1) + { + $chk_batch_applicable_checkbox_checked="checked"; + }else{ + $chk_batch_applicable_checkbox_checked=""; + } + + $chk_exp_date_applicable=$product_data[0]->exp_date_applicable; + if($chk_exp_date_applicable==1) + { + $chk_exp_date_applicable="checked"; + }else{ + $chk_exp_date_applicable=""; + } + + $chk_schedule_h=$product_data[0]->schedule_h; + if($chk_schedule_h==1) + { + $chk_schedule_h_checkbox_checked="checked"; + }else{ + $chk_schedule_h_checkbox_checked=""; + } + + $chk_schedule_h1=$product_data[0]->schedule_h1; + if($chk_schedule_h1==1) + { + $chk_schedule_h1_checkbox_checked="checked"; + }else{ + $chk_schedule_h1_checkbox_checked=""; + } + + $chk_narcotic=$product_data[0]->narcotic; + if($chk_narcotic==1) + { + $chk_narcotic_checkbox_checked="checked"; + }else{ + $chk_narcotic_checkbox_checked=""; + } + + ?> +
+
+ +
+
+
+
+ + +
+
+
+
+ + +
+
+ +
+
+ + +
+
+
+
+ + +
+
+
+
+ + +
+
+
+
+ + +
+
+
+ +
+ +
+
+
+
+ +
+ +
+
+ + \ No newline at end of file diff --git a/old_code_ci3/views/Medical1/Purchase/product_new.php b/old_code_ci3/views/Medical1/Purchase/product_new.php new file mode 100644 index 0000000..f85794c --- /dev/null +++ b/old_code_ci3/views/Medical1/Purchase/product_new.php @@ -0,0 +1,247 @@ +
+
+
+ 'form','class'=>'form1')); ?> +
+
+

Product

+ New Product +
+
+ + +
+
+
+
+ + +
+
+
+
+
+
+ + +
+
+
+
+
+
+
+
+ + +
+
+
+
+
+ + +
+
+
+
+ + +
+
+
+
+ + +
+
+
+
+
+
+ + +
+
+
+
+ + +
+
+
+
+ + +
+
+
+
+ +
+
+ + +
+
+
+
+ + +
+
+
+
+ + +
+
+
+ +
+ +
+
+
+
+ +
+ +
+
+ + \ No newline at end of file diff --git a/old_code_ci3/views/Medical1/Purchase/product_search_result.php b/old_code_ci3/views/Medical1/Purchase/product_search_result.php new file mode 100644 index 0000000..ee5cb78 --- /dev/null +++ b/old_code_ci3/views/Medical1/Purchase/product_search_result.php @@ -0,0 +1,48 @@ +
+
+
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameFormulationGeneric NamePacking Type
item_name ?>formulation ?>genericname ?>packing ?> + + +
NameFormulationGeneric NamePacking Type
+ +
+
+
+ + \ No newline at end of file diff --git a/old_code_ci3/views/Medical1/Purchase/purchase_Invoice_Edit.php b/old_code_ci3/views/Medical1/Purchase/purchase_Invoice_Edit.php new file mode 100644 index 0000000..d146adf --- /dev/null +++ b/old_code_ci3/views/Medical1/Purchase/purchase_Invoice_Edit.php @@ -0,0 +1,489 @@ +
+
+
+
+
+

Purchase Invoice Information

+ Supplier: | name_supplier ?> + |Invoice No.: Invoice_no ?> | + Invoice Date : str_date_of_invoice ?> + + +
+
+ 'form','class'=>'form2')); ?> +
+ +
+ +
+
+
+ + + \ No newline at end of file diff --git a/old_code_ci3/views/Medical1/Purchase/purchase_invoice_item.php b/old_code_ci3/views/Medical1/Purchase/purchase_invoice_item.php new file mode 100644 index 0000000..ee8fc7b --- /dev/null +++ b/old_code_ci3/views/Medical1/Purchase/purchase_invoice_item.php @@ -0,0 +1,72 @@ + + + + + + + + + + + + + + + + + + item_return==1) + { + $style='style="color:Red;"'; + }else{ + $style=''; + } + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + } + echo ''; + ?> + + + + + + + + + + + + + + + + + + +
#Item NameBatch NoExp.MRPQty.RateAmountDisc.Tax AmountCGSTSGSTNet Amount
'.$srno.''.$row->Item_name.''.$row->batch_no.''.$row->exp_date_str.''.$row->mrp.''.floatval($row->qty).'+'.floatval($row->qty_free).''.$row->purchase_price.''.$row->amount.''.$row->discount.''.$row->taxable_amount.''.$row->CGST_per.''.$row->SGST_per.''.$row->net_amount.''; + if($purchase_invoice[0]->inv_status==0) + { + echo ' + '; + } + echo '
#Taxable_Amt ?>CGST_Amt ?>SGST_Amt ?>T_Net_Amount ?>
\ No newline at end of file diff --git a/old_code_ci3/views/Medical1/Purchase/purchase_invoice_master_edit.php b/old_code_ci3/views/Medical1/Purchase/purchase_invoice_master_edit.php new file mode 100644 index 0000000..845604a --- /dev/null +++ b/old_code_ci3/views/Medical1/Purchase/purchase_invoice_master_edit.php @@ -0,0 +1,226 @@ +
+
+
+
+
+
+ 'form','class'=>'form1')); ?> + + inv_status==0){ ?> +
+
+
+ + +
+
+
+
+ + +
+
+
+ +
+
+ +
+ +
+
+
+ +
+
+ +
+
+ +
name_supplier?>
+
+
+
+
+ +
Invoice_no?>
+
+
+
+ +
date_of_invoice)?>
+ +
+ + +
+
+ + + + + + + + + + + + + + + + + item_return==1) + { + $style='style="color:Red;"'; + }else{ + $style=''; + } + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + } + echo ''; + ?> + + + + + + + + + + + + + + + + + +
#Item NameBatch NoExp.MRPQty.RateAmountDisc.Tax AmountCGSTSGSTNet Amount
'.$srno.''.$row->Item_name.''.$row->batch_no.''.$row->expiry_date.''.$row->mrp.''.floatval($row->qty).'+'.floatval($row->qty_free).''.$row->purchase_price.''.$row->amount.''.$row->discount.''.$row->taxable_amount.''.$row->CGST_per.''.$row->SGST_per.''.$row->net_amount.'
#Taxable_Amt ?>CGST_Amt ?>SGST_Amt ?>T_Net_Amount ?>
+
+ +
+
+
+ \ No newline at end of file diff --git a/old_code_ci3/views/Medical1/Purchase/purchase_item_old.php b/old_code_ci3/views/Medical1/Purchase/purchase_item_old.php new file mode 100644 index 0000000..2fcb615 --- /dev/null +++ b/old_code_ci3/views/Medical1/Purchase/purchase_item_old.php @@ -0,0 +1,31 @@ +

Last 5 Purchase Orders

+ + + + + + + + + + + '; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + } + echo ''; + ?> + +
#Item NameDateMRPQtyRateSupplier
'.$srno.''.$row->Item_name.''.$row->date_of_invoice_str.''.$row->mrp.''.floatval($row->qty).'+'.floatval($row->qty_free).''.$row->purchase_price.''.$row->name_supplier.'
\ No newline at end of file diff --git a/old_code_ci3/views/Medical1/Purchase/purchase_supp_list.php b/old_code_ci3/views/Medical1/Purchase/purchase_supp_list.php new file mode 100644 index 0000000..235e74e --- /dev/null +++ b/old_code_ci3/views/Medical1/Purchase/purchase_supp_list.php @@ -0,0 +1,66 @@ +
+
+
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Invoice IDSupplierDateAmount
Invoice_no ?>name_supplier ?>date_of_invoice ?>tamount ?> + + tamount==0){ ?> + + +
Invoice IDSupplierDateAmount
+ +
+
+
+ + \ No newline at end of file diff --git a/old_code_ci3/views/Medical1/Purchase/supplier_Edit.php b/old_code_ci3/views/Medical1/Purchase/supplier_Edit.php new file mode 100644 index 0000000..39592ea --- /dev/null +++ b/old_code_ci3/views/Medical1/Purchase/supplier_Edit.php @@ -0,0 +1,111 @@ + + +
+
+

Supplier

+
+
+ 'form','class'=>'form1')); ?> + 0) + { + $sid=$supplier_data[0]->sid; + $name_supplier=$supplier_data[0]->name_supplier; + $short_name=$supplier_data[0]->short_name; + $contact_no=$supplier_data[0]->contact_no; + $gst_no=$supplier_data[0]->gst_no; + $city=$supplier_data[0]->city; + $state=$supplier_data[0]->state; + } + + ?> + +
+
+
+ + +
+
+
+
+ + +
+
+
+
+
+
+ + +
+
+
+
+ + +
+
+
+
+
+
+ + +
+
+
+
+ + +
+
+
+
+
+
+ + +
+
+
+ +
+
+ \ No newline at end of file diff --git a/old_code_ci3/views/Medical1/Purchase/supplier_account.php b/old_code_ci3/views/Medical1/Purchase/supplier_account.php new file mode 100644 index 0000000..4927222 --- /dev/null +++ b/old_code_ci3/views/Medical1/Purchase/supplier_account.php @@ -0,0 +1,58 @@ +
+

+ Supplier +

+
+
+
+
+
+
+

Supplier List

+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameBalanceLast Inv. DateLast Payment Date
name_supplier ?>Tot_Balance ?>Last_InvDate ?>Last_Payment ?> + +
NameBalanceLast Inv. DateLast Payment Date
+ +
+ +
+
+
+
+ + \ No newline at end of file diff --git a/old_code_ci3/views/Medical1/Purchase/supplier_account_detail.php b/old_code_ci3/views/Medical1/Purchase/supplier_account_detail.php new file mode 100644 index 0000000..1479d86 --- /dev/null +++ b/old_code_ci3/views/Medical1/Purchase/supplier_account_detail.php @@ -0,0 +1,90 @@ +
+
+
+
+

Ledger Account : name_supplier?> + Balance : Tot_Balance?>

+ +
+
+ 'form_search'); + echo form_open('/Medical_backpanel/search_result_tran/'.$supplier_data[0]->sid,$attributes); ?> +
+
+ +
+   + +
+ +
+
+ +
+ +
+
+
+ +
+
+
+
+
+
+
+
+
+ \ No newline at end of file diff --git a/old_code_ci3/views/Medical1/Purchase/supplier_list.php b/old_code_ci3/views/Medical1/Purchase/supplier_list.php new file mode 100644 index 0000000..734a017 --- /dev/null +++ b/old_code_ci3/views/Medical1/Purchase/supplier_list.php @@ -0,0 +1,30 @@ +
+ +'form','class'=>'form2')); ?> +
+ + + + + + + + + + +
+ +
+
+ \ No newline at end of file diff --git a/old_code_ci3/views/Medical1/Purchase/supplier_master.php b/old_code_ci3/views/Medical1/Purchase/supplier_master.php new file mode 100644 index 0000000..cf435c1 --- /dev/null +++ b/old_code_ci3/views/Medical1/Purchase/supplier_master.php @@ -0,0 +1,60 @@ +
+

+ Supplier +

+
+
+
+
+
+
+ +

Supplier List

+
+
+
+ +
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + +
NameGSTAction
name_supplier ?>gst_no ?> + +
NameGSTAction
+ +
+ +
+
+
+ +
+
+
+ + \ No newline at end of file diff --git a/old_code_ci3/views/Medical1/Purchase/supplier_master_sub.php b/old_code_ci3/views/Medical1/Purchase/supplier_master_sub.php new file mode 100644 index 0000000..a5551df --- /dev/null +++ b/old_code_ci3/views/Medical1/Purchase/supplier_master_sub.php @@ -0,0 +1,30 @@ + + + + + + + + + + + + + + + + + + + + + + + + +
NameGSTAction
name_supplier ?>name_supplier ?> + +
NameGSTAction
+ \ No newline at end of file diff --git a/old_code_ci3/views/Medical1/Purchase_Invoice_Edit.php b/old_code_ci3/views/Medical1/Purchase_Invoice_Edit.php new file mode 100644 index 0000000..5928ebd --- /dev/null +++ b/old_code_ci3/views/Medical1/Purchase_Invoice_Edit.php @@ -0,0 +1,386 @@ +
+
+
+
+
+

Purchase Invoice Information

+ Supplier: | name_supplier ?> + |Invoice No.: Invoice_no ?> | + Invoice Date : str_date_of_invoice ?> + +
+
+
+
+ +
+
+
+ + \ No newline at end of file diff --git a/old_code_ci3/views/Medical1/Report/IPD_Discharge_Report.php b/old_code_ci3/views/Medical1/Report/IPD_Discharge_Report.php new file mode 100644 index 0000000..35134dc --- /dev/null +++ b/old_code_ci3/views/Medical1/Report/IPD_Discharge_Report.php @@ -0,0 +1,79 @@ +
+

+ IPD Discharge Report + Panel +

+
+
+
+
+ +
+   + +
+ +
+
+ +
+ + +
+
+
+
+
+
+
+
+
+ \ No newline at end of file diff --git a/old_code_ci3/views/Medical1/Report/Med_Payment_Recevie.php b/old_code_ci3/views/Medical1/Report/Med_Payment_Recevie.php new file mode 100644 index 0000000..af60099 --- /dev/null +++ b/old_code_ci3/views/Medical1/Report/Med_Payment_Recevie.php @@ -0,0 +1,105 @@ +
+

+ Daily Payment Report +

+
+
+
+
+ +
+   + +
+ +
+
+ + +
+
+ +
+ + +
+
+
+ +
+
+
+
+
+
+ \ No newline at end of file diff --git a/old_code_ci3/views/Medical1/Report/Med_Report_1.php b/old_code_ci3/views/Medical1/Report/Med_Report_1.php new file mode 100644 index 0000000..5445f11 --- /dev/null +++ b/old_code_ci3/views/Medical1/Report/Med_Report_1.php @@ -0,0 +1,80 @@ +
+

+ Daily Sale Report +

+
+
+
+
+ +
+   + +
+ +
+
+ +
+ + +
+
+
+ +
+
+
+
+
+
+ \ No newline at end of file diff --git a/old_code_ci3/views/Medical1/Report/Med_Report_2.php b/old_code_ci3/views/Medical1/Report/Med_Report_2.php new file mode 100644 index 0000000..3eae13d --- /dev/null +++ b/old_code_ci3/views/Medical1/Report/Med_Report_2.php @@ -0,0 +1,77 @@ +
+

+ Day Cash Payment Report + Panel +

+
+
+
+
+ + +
+
+ + +
+
+ +
+ + + +
+
+
+
+
+
+
+
+
+ \ No newline at end of file diff --git a/old_code_ci3/views/Medical1/Report/Med_Report_2_Pending.php b/old_code_ci3/views/Medical1/Report/Med_Report_2_Pending.php new file mode 100644 index 0000000..c4bb772 --- /dev/null +++ b/old_code_ci3/views/Medical1/Report/Med_Report_2_Pending.php @@ -0,0 +1,86 @@ +
+

+ Day OPD / Cash Invoice Pending Report + Panel +

+
+
+
+
+ +
+   + +
+ +
+
+ +
+ + +
+
+
+
+
+
+
+
+
+ \ No newline at end of file diff --git a/old_code_ci3/views/Medical1/Report/Med_Report_2_Pending_paid.php b/old_code_ci3/views/Medical1/Report/Med_Report_2_Pending_paid.php new file mode 100644 index 0000000..7573e2c --- /dev/null +++ b/old_code_ci3/views/Medical1/Report/Med_Report_2_Pending_paid.php @@ -0,0 +1,51 @@ +
+

+ Old Invoice Payment Report + Panel +

+
+
+
+
+ + +
+
+ +
+ + +
+
+
+
+
+
+
+
+
+ \ No newline at end of file diff --git a/old_code_ci3/views/Medical1/Report/Med_Report_3.php b/old_code_ci3/views/Medical1/Report/Med_Report_3.php new file mode 100644 index 0000000..637ae44 --- /dev/null +++ b/old_code_ci3/views/Medical1/Report/Med_Report_3.php @@ -0,0 +1,79 @@ +
+

+ GST Report + Panel +

+
+
+
+
+ +
+   + +
+ +
+
+ +
+ + +
+
+
+
+
+
+
+
+
+ \ No newline at end of file diff --git a/old_code_ci3/views/Medical1/Report/Med_Report_4.php b/old_code_ci3/views/Medical1/Report/Med_Report_4.php new file mode 100644 index 0000000..91fb7b4 --- /dev/null +++ b/old_code_ci3/views/Medical1/Report/Med_Report_4.php @@ -0,0 +1,80 @@ +
+

+ IPD Invoice + Panel +

+
+
+
+
+ +
+   + +
+ +
+
+ +
+ + +
+
+
+
+
+
+
+
+
+ \ No newline at end of file diff --git a/old_code_ci3/views/Medical1/Report/Med_Report_5.php b/old_code_ci3/views/Medical1/Report/Med_Report_5.php new file mode 100644 index 0000000..73b2afe --- /dev/null +++ b/old_code_ci3/views/Medical1/Report/Med_Report_5.php @@ -0,0 +1,80 @@ +
+

+ GST Invoice List + Panel +

+
+
+
+
+ +
+   + +
+ +
+
+ +
+ + +
+
+
+
+
+
+
+
+
+ \ No newline at end of file diff --git a/old_code_ci3/views/Medical1/Report/Med_Report_IPD_Credit.php b/old_code_ci3/views/Medical1/Report/Med_Report_IPD_Credit.php new file mode 100644 index 0000000..9e9e5ea --- /dev/null +++ b/old_code_ci3/views/Medical1/Report/Med_Report_IPD_Credit.php @@ -0,0 +1,91 @@ +
+

+ IPD Invoice + Panel +

+
+
+
+
+ +
+   + +
+ +
+
+ + +
+
+ +
+ + +
+
+
+
+
+
+
+
+
+ \ No newline at end of file diff --git a/old_code_ci3/views/Medical1/Report/Med_Report_company_med_sale.php b/old_code_ci3/views/Medical1/Report/Med_Report_company_med_sale.php new file mode 100644 index 0000000..e5ef06d --- /dev/null +++ b/old_code_ci3/views/Medical1/Report/Med_Report_company_med_sale.php @@ -0,0 +1,119 @@ +
+

+ Company Wise Medicine Sale / Purchase Report +

+
+
+
+
+ +
+   + +
+ +
+
+ +
+ +
+
+
+ +
+ + +
+
+
+ +
+ + +
+
+
+ +
+
+
+
+
+
+ \ No newline at end of file diff --git a/old_code_ci3/views/Medical1/Report/Med_Report_daily_med_sale.php b/old_code_ci3/views/Medical1/Report/Med_Report_daily_med_sale.php new file mode 100644 index 0000000..d6b9cb6 --- /dev/null +++ b/old_code_ci3/views/Medical1/Report/Med_Report_daily_med_sale.php @@ -0,0 +1,79 @@ +
+

+ Daily Medicine Sale Report +

+
+
+
+
+ +
+   + +
+ +
+
+ +
+ + +
+
+
+ +
+
+
+
+
+
+ \ No newline at end of file diff --git a/old_code_ci3/views/Medical1/Report/Purchase_Invoice.php b/old_code_ci3/views/Medical1/Report/Purchase_Invoice.php new file mode 100644 index 0000000..5e78dd8 --- /dev/null +++ b/old_code_ci3/views/Medical1/Report/Purchase_Invoice.php @@ -0,0 +1,94 @@ +
+

+ Report Purchase Invoice + Panel +

+
+
+
+
+ +
+   + +
+ +
+
+ + +
+
+ +
+ + +
+
+
+
+
+
+
+
+
+ \ No newline at end of file diff --git a/old_code_ci3/views/Medical1/Report/Report_Med_patient.php b/old_code_ci3/views/Medical1/Report/Report_Med_patient.php new file mode 100644 index 0000000..e946e40 --- /dev/null +++ b/old_code_ci3/views/Medical1/Report/Report_Med_patient.php @@ -0,0 +1,88 @@ +
+

+ Report Drug Sale to Patient + Panel +

+
+
+'form','class'=>'form2')); ?> +
+
+ +
+   + +
+ +
+
+ + +
+
+ +
+ + +
+
+
+
+
+
+
+
+ +
+ \ No newline at end of file diff --git a/old_code_ci3/views/Medical1/Report/Report_Med_patient_result.php b/old_code_ci3/views/Medical1/Report/Report_Med_patient_result.php new file mode 100644 index 0000000..30ebf36 --- /dev/null +++ b/old_code_ci3/views/Medical1/Report/Report_Med_patient_result.php @@ -0,0 +1,67 @@ +
+
+ + + + + + + + + + + + + + + + + + + + + +
Item NameSale Drug Report Customer Wise
+

item_Name ?>

+
+ p_list); + echo ' + + + + + + + + + '; + foreach ($data_array as $value) { + $value_array=explode(";",$value); + + if(count($value_array)<9) + { + echo ''; + echo ' '; + echo ''; + }else{ + echo ''; + echo ' '; + echo ' '; + echo ' '; + echo ' '; + echo ' '; + echo ' '; + echo ' '; + echo ''; + } + + } + echo '
Inv.No.Inv.DateIPD No.P Code/NameExp. DateBatchQty
Too many Records, Select min Date Range
'.$value_array[0].''.$value_array[1].''.$value_array[7].''.$value_array[4].' / '.$value_array[5].''.$value_array[2].''.$value_array[8].''.$value_array[9].'
'; + ?> +
Item NameStock Batch Invoice Status
+ +
+
diff --git a/old_code_ci3/views/Medical1/Report/Report_org_invoice_list.php b/old_code_ci3/views/Medical1/Report/Report_org_invoice_list.php new file mode 100644 index 0000000..c2ec7d6 --- /dev/null +++ b/old_code_ci3/views/Medical1/Report/Report_org_invoice_list.php @@ -0,0 +1,96 @@ +
+

+ Org. Invoice + Panel +

+
+
+
+
+ +
+   + +
+ +
+
+
+ + +
+
+
+ +
+ + +
+
+
+
+
+
+
+
+
+ \ No newline at end of file diff --git a/old_code_ci3/views/Medical1/Search_Patient.php b/old_code_ci3/views/Medical1/Search_Patient.php new file mode 100644 index 0000000..8538815 --- /dev/null +++ b/old_code_ci3/views/Medical1/Search_Patient.php @@ -0,0 +1,22 @@ +
+ 'form','class'=>'form2')); ?> +
+ + + + +
+ +
+
+ \ No newline at end of file diff --git a/old_code_ci3/views/Medical1/Stock/Stock_search_qty_result.php b/old_code_ci3/views/Medical1/Stock/Stock_search_qty_result.php new file mode 100644 index 0000000..3a3cbea --- /dev/null +++ b/old_code_ci3/views/Medical1/Stock/Stock_search_qty_result.php @@ -0,0 +1,96 @@ + +
+
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Item NameSupplierSale Unit QtyCurrent Unit QtyRe-Order QtyAlert Qty
+

Item_name ?>

+
+

supplier_names ?>

+
+

sal_qty ?>

+
T_unit - $row->sal_qty; + echo $C_Qty; + ?> + + +

re_order_qty ?>

+
+ re_order_qty) + { + echo '

Qty Low

'; + } + + ?> + +
Item NameSupplierSale Unit QtyCurrent Unit QtyRe-Order QtyAlert Qty
+ +
+
+
+ + + \ No newline at end of file diff --git a/old_code_ci3/views/Medical1/Stock/Stock_search_result.php b/old_code_ci3/views/Medical1/Stock/Stock_search_result.php new file mode 100644 index 0000000..24ace19 --- /dev/null +++ b/old_code_ci3/views/Medical1/Stock/Stock_search_result.php @@ -0,0 +1,120 @@ + +
+
+
+ + + + + + + + + + + + + + + + + + + + + +
Item NameStock Batch Invoice Status
+

Item_name ?>

+

Supplier :name_supplier ?>

+

Current Total Stock : Current_Stock ?>

+
+ Qty_BatchWise); + echo ' + + + + + + + + + + + + + + '; + foreach ($data_array as $value) { + $value_array=explode(";",$value); + + if($value_array[8]==1) + { + $style='style="color:Red;"'; + }else{ + $style=''; + } + + echo ''; + echo ' '; + echo ' '; + echo ' '; + echo ' '; + echo ' '; + echo ' '; + echo ' '; + echo ' '; + echo ' '; + echo ' '; + echo ' '; + echo ''; + echo ''; + } + echo '
Inv.No.Bat.No.Exp.Dt.MRP/Purchase Price/DateQtyT.Unit Qty.Cur.Unit Qty.Sale UnitReturn UnitLost UnitUpdate New Lost UnitsRemove Unit
'.$value_array[1].''.$value_array[2].''.$value_array[3].''.$value_array[4].'/'.$value_array[12].'/'.$value_array[13].''.$value_array[5].''.$value_array[11].'
'.$value_array[6].'
'.$value_array[7].''.$value_array[9].''.$value_array[10].'
+ + + + +
+
'; + ?> +
Item NameStock Batch Invoice Status
+ +
+
+
+ + + \ No newline at end of file diff --git a/old_code_ci3/views/Medical1/Stock/indent_accept_items_list.php b/old_code_ci3/views/Medical1/Stock/indent_accept_items_list.php new file mode 100644 index 0000000..3ade01a --- /dev/null +++ b/old_code_ci3/views/Medical1/Stock/indent_accept_items_list.php @@ -0,0 +1,86 @@ + +
+
+
+
+
+

Indent Request Information

+ Indent No.: indent_code ?> | + Indent Date & Time : created_date ?> +
+
+
+
+ +
+
+ +
+
+
+ +
+
+
+ + \ No newline at end of file diff --git a/old_code_ci3/views/Medical1/Stock/indent_counter_edit.php b/old_code_ci3/views/Medical1/Stock/indent_counter_edit.php new file mode 100644 index 0000000..43a4ab4 --- /dev/null +++ b/old_code_ci3/views/Medical1/Stock/indent_counter_edit.php @@ -0,0 +1,213 @@ +
+
+
+
+
+

Indent : store_name ?>

+ Indent No.: indent_code ?> | + Indent Date & Time : created_date ?> + Indent Current Status : request_status] ?> + request_status==3) { ?> + + + request_status==0){ ?> + + request_status==4){ ?> + + + +
+
+
+
+ +
+
+
+ + \ No newline at end of file diff --git a/old_code_ci3/views/Medical1/Stock/indent_counter_item_list.php b/old_code_ci3/views/Medical1/Stock/indent_counter_item_list.php new file mode 100644 index 0000000..ce4a324 --- /dev/null +++ b/old_code_ci3/views/Medical1/Stock/indent_counter_item_list.php @@ -0,0 +1,36 @@ + + + + + + + + + + '; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + } + echo ''; + ?> + + + + + + + + + +
#Item NameFormulationGeneric NameQty.
'.$srno.''.$row->item_name.''.$row->formulation.''.$row->genericname.''.$row->request_qty.' +
#Item NameFormulationGeneric NameQty.
\ No newline at end of file diff --git a/old_code_ci3/views/Medical1/Stock/indent_counter_list.php b/old_code_ci3/views/Medical1/Stock/indent_counter_list.php new file mode 100644 index 0000000..3487b50 --- /dev/null +++ b/old_code_ci3/views/Medical1/Stock/indent_counter_list.php @@ -0,0 +1,41 @@ +
+'form','class'=>'form2')); ?> +
+ + + + + + + +
+ + +
+ +
+ +
+
+ \ No newline at end of file diff --git a/old_code_ci3/views/Medical1/Stock/indent_counter_search_result.php b/old_code_ci3/views/Medical1/Stock/indent_counter_search_result.php new file mode 100644 index 0000000..ae59701 --- /dev/null +++ b/old_code_ci3/views/Medical1/Stock/indent_counter_search_result.php @@ -0,0 +1,58 @@ +
+
+
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Indent IDStore/TypeDateProduct ListStatus
indent_code ?>store_name.'/'.$indent_req_list[$i]->indent_request_type_str ?>created_date ?>product_list ?>request_status_str ?> + request_status==0 ) { ?> + + request_status==1 ) { ?> + + request_status==2){ ?> + + request_status==3){ ?> + + + +
Indent IDStoreDateStatus
+ +
+
+
+ + \ No newline at end of file diff --git a/old_code_ci3/views/Medical1/Stock/indent_issue.php b/old_code_ci3/views/Medical1/Stock/indent_issue.php new file mode 100644 index 0000000..e69de29 diff --git a/old_code_ci3/views/Medical1/Stock/indent_issue_item_view.php b/old_code_ci3/views/Medical1/Stock/indent_issue_item_view.php new file mode 100644 index 0000000..9978455 --- /dev/null +++ b/old_code_ci3/views/Medical1/Stock/indent_issue_item_view.php @@ -0,0 +1,38 @@ + +
+
+
+
+
+

Indent Request Information

+ Indent No.: indent_code ?> | + Indent Date & Time : created_date ?> + Indent Current Status : request_status] ?> + request_status==3) { ?> + + + request_status==4){ ?> + + + +
+
+
+
+ +
+
+
+ +
+
+
+ + \ No newline at end of file diff --git a/old_code_ci3/views/Medical1/Stock/indent_issue_items.php b/old_code_ci3/views/Medical1/Stock/indent_issue_items.php new file mode 100644 index 0000000..937dae0 --- /dev/null +++ b/old_code_ci3/views/Medical1/Stock/indent_issue_items.php @@ -0,0 +1,78 @@ + +
+
+
+
+
+

Indent Request Information

+ Indent No.: indent_code ?> | + Indent Date & Time : created_date ?> + Indent Current Status : request_status] ?> + request_status==2) { ?> + + request_status==3){ ?> + + + +
+
+
+
+ +
+
+ +
+
+
+ +
+
+
+ + \ No newline at end of file diff --git a/old_code_ci3/views/Medical1/Stock/indent_req_view_with_store.php b/old_code_ci3/views/Medical1/Stock/indent_req_view_with_store.php new file mode 100644 index 0000000..5e83dd4 --- /dev/null +++ b/old_code_ci3/views/Medical1/Stock/indent_req_view_with_store.php @@ -0,0 +1,65 @@ +
+
+
+
+
+

Indent Request Information

+ Indent No.: indent_code ?> | + Indent Date & Time : created_date ?> + Indent Current Status : request_status] ?> + +
+
+ + + + + + + + + + '; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + } + echo ''; + ?> + + + + + + + + + + +
#Item NameFormulationGeneric NameQty.Min Qty
'.$srno.''.$row->item_name.''.$row->formulation.''.$row->genericname.''.$row->request_qty.''.$row->min_requirement.'
#Item NameFormulationGeneric NameQty.Min Qty
+
+ +
+
+
diff --git a/old_code_ci3/views/Medical1/Stock/indent_request.php b/old_code_ci3/views/Medical1/Stock/indent_request.php new file mode 100644 index 0000000..1f30b32 --- /dev/null +++ b/old_code_ci3/views/Medical1/Stock/indent_request.php @@ -0,0 +1,30 @@ +
+ +'form','class'=>'form2')); ?> +
+ + + + + + + + + + +
+ +
+
+ \ No newline at end of file diff --git a/old_code_ci3/views/Medical1/Stock/indent_request_search_result.php b/old_code_ci3/views/Medical1/Stock/indent_request_search_result.php new file mode 100644 index 0000000..ab8562c --- /dev/null +++ b/old_code_ci3/views/Medical1/Stock/indent_request_search_result.php @@ -0,0 +1,56 @@ +
+
+
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Indent IDStore/TypeDateProduct ListStatus
indent_code ?>store_name.'/'.$indent_req_list[$i]->indent_request_type_str ?>created_date ?>product_list ?>request_status_str ?> + request_status==1 ) { ?> + + request_status==2){ ?> + + request_status==3){ ?> + + + +
Indent IDStoreDateStatus
+ +
+
+
+ + \ No newline at end of file diff --git a/old_code_ci3/views/Medical1/Stock/indent_stock_list.php b/old_code_ci3/views/Medical1/Stock/indent_stock_list.php new file mode 100644 index 0000000..846f15c --- /dev/null +++ b/old_code_ci3/views/Medical1/Stock/indent_stock_list.php @@ -0,0 +1,61 @@ +'form','class'=>'form1')); ?> + + + + + + + + + + + + + + '; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + if($row->store_stock_id==0) + { + echo '' ; + } + + echo ''; + } + echo ''; + ?> + + + + + + + + + + +
#Item NameBatch No.Expiry DateQty.Issued Qty.Action
'.$srno.''.$row->Item_name.''.$row->batch_no.''.$row->expiry_date.''.$row->tqty.''.$row->issue_item.' + + + + + +
+ + + + +
'; + }else{ + echo '
#Item NameBatch No.Expiry DateQty.Issued Qty.Action
+ \ No newline at end of file diff --git a/old_code_ci3/views/Medical1/Stock/main_store_dashboard.php b/old_code_ci3/views/Medical1/Stock/main_store_dashboard.php new file mode 100644 index 0000000..7dfc9b5 --- /dev/null +++ b/old_code_ci3/views/Medical1/Stock/main_store_dashboard.php @@ -0,0 +1,58 @@ +
+

+ Store Main + Panel +

+
+
+
+ +
+
+
+ Inventory +
+
+ +
+
+
+ +
diff --git a/old_code_ci3/views/Medical1/Stock/stock_search.php b/old_code_ci3/views/Medical1/Stock/stock_search.php new file mode 100644 index 0000000..de502b8 --- /dev/null +++ b/old_code_ci3/views/Medical1/Stock/stock_search.php @@ -0,0 +1,58 @@ +
+'form','class'=>'form2')); ?> +
+ +
+
+
+ +
+
+
+
+ + + + + + + +
+
+ +
+
+ \ No newline at end of file diff --git a/old_code_ci3/views/Medical1/Stock_Update.php b/old_code_ci3/views/Medical1/Stock_Update.php new file mode 100644 index 0000000..f1bd0a9 --- /dev/null +++ b/old_code_ci3/views/Medical1/Stock_Update.php @@ -0,0 +1,211 @@ +
+
+
+
+
+

Stock Information

+
+
+ 'form','class'=>'form1')); ?> + +
+
+
+ + +
+
+
+
+ + +
+
+
+
+ + +
+
+
+
+ + +
+
+
+
+ + +
+
+
+
+
+
+ + +
+
+
+
+ + +
+
+
+
+ +
+
+ +
+ +
+
+
+
+
+ + +
+
+
+
+ + +
+
+
+
+ +
+
+ +
+ +
+
+
+
+
+
+
+ + +
+
+
+
+ + +
+
+
+
+ + +
+
+
+
+ + +
+
+
+
+ + +
+
+
+
+
+
+ + +
+
+
+
+ + +
+
+
+
+ + +
+
+
+
+ + +
+
+
+
+ + +
+
+
+
+ + +
+
+
+ + +
+
+
+
+ + \ No newline at end of file diff --git a/old_code_ci3/views/Medical1/Store/Stock_Item_history.php b/old_code_ci3/views/Medical1/Store/Stock_Item_history.php new file mode 100644 index 0000000..bf0872a --- /dev/null +++ b/old_code_ci3/views/Medical1/Store/Stock_Item_history.php @@ -0,0 +1,54 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
SupplierInv.No / DateBat.No.Exp.Dt.MRPPurchaseQty / PackingUnit QtySale U.QtyLost UnitCurr.U.QtyUpdate Lost UnitRemove
name_supplier?>Invoice_no?>
date_of_invoice?>
batch_no?>expiry_date?>mrp?>purchase_price?>tqty?> / packing?>total_unit?>total_sale_unit?>total_lost_unit?>cur_unit?> +
+ + + + +
+
+ +
\ No newline at end of file diff --git a/old_code_ci3/views/Medical1/Store/Stock_Item_history_removed.php b/old_code_ci3/views/Medical1/Store/Stock_Item_history_removed.php new file mode 100644 index 0000000..ead00a4 --- /dev/null +++ b/old_code_ci3/views/Medical1/Store/Stock_Item_history_removed.php @@ -0,0 +1,54 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
SupplierInv.No / DateBat.No.Exp.Dt.MRPPurchaseQtyUnit QtySale U.QtyLost UnitCurr.U.QtyUpdate Lost UnitRemove
name_supplier?>Invoice_no?>
date_of_invoice?>
batch_no?>expiry_date?>mrp?>purchase_price?>tqty?>total_unit?>total_sale_unit?>total_lost_unit?>cur_unit?> +
+ + + + +
+
+ +
\ No newline at end of file diff --git a/old_code_ci3/views/Medical1/Store/Stock_search_result.php b/old_code_ci3/views/Medical1/Store/Stock_search_result.php new file mode 100644 index 0000000..927c435 --- /dev/null +++ b/old_code_ci3/views/Medical1/Store/Stock_search_result.php @@ -0,0 +1,189 @@ + +
+
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Item NameCurrent Pak.Current Unit QtyTotal Sale Pak.Total Sale Unit QtyLost UnitPackage/Re-Order QtyRemoved Qty
+

+ item_name ?>

+
+

C_Pak_Qty,2) ?>

+
+

C_Unit_Stock_Qty,2) ?>

+
+

C_Pak_Sale_Qty,2) ?>

+
+

sale_unit,2) ?>

+
+

total_lost_unit,2) ?>

+
+

packing ?>/re_order_qty ?>

+
+ +
Item NameCurrent Pak.Current Unit QtyTotal Sale Pak.Total Sale Unit QtyLost UnitPackage/Re-Order QtyRemoved Qty
+ +
+
+
+ + + + \ No newline at end of file diff --git a/old_code_ci3/views/Medical1/Store/stock_store_statement.php b/old_code_ci3/views/Medical1/Store/stock_store_statement.php new file mode 100644 index 0000000..34a8647 --- /dev/null +++ b/old_code_ci3/views/Medical1/Store/stock_store_statement.php @@ -0,0 +1,154 @@ +
+'form','class'=>'form2')); ?> +
+
+ + +
+
+
+ +
+   + +
+ +
+
+ +
+ + + + + + + + + + +
+
+ +
+
+ \ No newline at end of file diff --git a/old_code_ci3/views/Medical1/Store/stock_store_statement_data.php b/old_code_ci3/views/Medical1/Store/stock_store_statement_data.php new file mode 100644 index 0000000..e561935 --- /dev/null +++ b/old_code_ci3/views/Medical1/Store/stock_store_statement_data.php @@ -0,0 +1,199 @@ + +
+
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Item NamePur Pak.Pur CostCurrent Pak.Current Unit QtyTotal Sale Pak.Total Sale Unit QtyLost UnitPackage/Re-Order QtyRemoved Qty
+

+ item_name ?>

+
+

total_pak_qty,2) ?>

+
+

purchase_cost,2) ?>

+
+

C_Pak_Qty,2) ?>

+
+

C_Unit_Stock_Qty,2) ?>

+
+

C_Pak_Sale_Qty,2) ?>

+
+

sale_unit,2) ?>

+
+

total_lost_unit,2) ?>

+
+

packing ?>/re_order_qty ?>

+
+ +
Item NamePur Pak.Pur CostCurrent Pak.Current Unit QtyTotal Sale Pak.Total Sale Unit QtyLost UnitPackage/Re-Order QtyRemoved Qty
+ +
+
+
+ + + + \ No newline at end of file diff --git a/old_code_ci3/views/Medical1/Store/store_stock_search.php b/old_code_ci3/views/Medical1/Store/store_stock_search.php new file mode 100644 index 0000000..848017d --- /dev/null +++ b/old_code_ci3/views/Medical1/Store/store_stock_search.php @@ -0,0 +1,64 @@ +
+'form','class'=>'form2')); ?> +
+
+ +
+
+
+
+ + + + + + + + + + +
+
+ +
+
+ \ No newline at end of file diff --git a/old_code_ci3/views/Medical1/Store_Dashboard.php b/old_code_ci3/views/Medical1/Store_Dashboard.php new file mode 100644 index 0000000..42b94f4 --- /dev/null +++ b/old_code_ci3/views/Medical1/Store_Dashboard.php @@ -0,0 +1,45 @@ + +
+

+ Medical Store : store_name?> + Dashboard +

+
+ +
+ +
+ +
+
+ \ No newline at end of file diff --git a/old_code_ci3/views/Medical1/Supplier_Edit.php b/old_code_ci3/views/Medical1/Supplier_Edit.php new file mode 100644 index 0000000..39592ea --- /dev/null +++ b/old_code_ci3/views/Medical1/Supplier_Edit.php @@ -0,0 +1,111 @@ + + +
+
+

Supplier

+
+
+ 'form','class'=>'form1')); ?> + 0) + { + $sid=$supplier_data[0]->sid; + $name_supplier=$supplier_data[0]->name_supplier; + $short_name=$supplier_data[0]->short_name; + $contact_no=$supplier_data[0]->contact_no; + $gst_no=$supplier_data[0]->gst_no; + $city=$supplier_data[0]->city; + $state=$supplier_data[0]->state; + } + + ?> + +
+
+
+ + +
+
+
+
+ + +
+
+
+
+
+
+ + +
+
+
+
+ + +
+
+
+
+
+
+ + +
+
+
+
+ + +
+
+
+
+
+
+ + +
+
+
+ +
+
+ \ No newline at end of file diff --git a/old_code_ci3/views/Medical1/Supplier_master.php b/old_code_ci3/views/Medical1/Supplier_master.php new file mode 100644 index 0000000..db90a1f --- /dev/null +++ b/old_code_ci3/views/Medical1/Supplier_master.php @@ -0,0 +1,60 @@ +
+

+ Supplier +

+
+
+
+
+
+
+ +

Supplier List

+
+
+ +
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + +
NameGSTAction
name_supplier ?>name_supplier ?> + + +
NameGSTAction
+ +
+ +
+
+
+ +
+
+ +
+ \ No newline at end of file diff --git a/old_code_ci3/views/Medical1/Supplier_master_sub.php b/old_code_ci3/views/Medical1/Supplier_master_sub.php new file mode 100644 index 0000000..a5551df --- /dev/null +++ b/old_code_ci3/views/Medical1/Supplier_master_sub.php @@ -0,0 +1,30 @@ + + + + + + + + + + + + + + + + + + + + + + + + +
NameGSTAction
name_supplier ?>name_supplier ?> + +
NameGSTAction
+ \ No newline at end of file diff --git a/old_code_ci3/views/Medical1/invoice_master_edit.php b/old_code_ci3/views/Medical1/invoice_master_edit.php new file mode 100644 index 0000000..42ca3e6 --- /dev/null +++ b/old_code_ci3/views/Medical1/invoice_master_edit.php @@ -0,0 +1,408 @@ +
+
+

+ Medical Invoice Master Edit : + + Back to Invoice + +

+
+
+'form','class'=>'form1')); ?> + +
+
+
+
+ + +

Name :inv_name?> + / P Code :patient_code?> + / Invoice No. :inv_med_code?> + / Date : inv_date)?> + ipd_id > 0) { ?> + IPD Code : + + ipd_code?> + + Admit Date : str_register_date ?> reg_time ?> + / Doctor :doc_name?> + / TPA-Org. : + case_id > 0){ ?> + / Org. Case ID :case_id_code ?> + +

+
+
+
+
+
+
+
+ +
+
+ +
+ +
+
+
+
+
+ + +
+
+
+
+ ipd_id > 0) { ?> +
+ payment_received ==0) { ?> +
+
+ + +
+
+ +
+ +
credit_status ?>
+
+ +
+
+
+ + +
+
+ case_id > 0){ ?> +
+ payment_received ==0) { ?> +
+
+ + +
+
+ +
+ +
+
+
+
+
+
+

Change Name : Current Name : patient_code ?>

+
+
+
+
+
+
+ + +
+
+
+
+ + Patient Name
+
+
+
+
+ + +
+
+
+
+
+
+
+

Change UHID : Current UHID : patient_code ?>

+
+
+
+
+
+
+ + +
+
+
+
+ +
Patient Information
+
+
+
+
+ + + +
+
+
+
+
+
+
+

Change IPD : + ipd_credit>0){ ?> + Current IPD : ipd_code ?> + +

+
+
+
+
+
+
+ + +
+
+
+
+ +
+
+
+
+
+ + + +
+
+
+
+
+
+
+

Change Org. Case : + case_credit>0){ ?> + Current Org. Case : case_id ?> + + +

+
+
+
+
+
+
+ + +
+
+
+
+ +
Patient Information
+
+
+
+
+ + + +
+
+
+
+ + +
+ + + +
\ No newline at end of file diff --git a/old_code_ci3/views/Medical1/new_purchase_invoice.php b/old_code_ci3/views/Medical1/new_purchase_invoice.php new file mode 100644 index 0000000..3e430d2 --- /dev/null +++ b/old_code_ci3/views/Medical1/new_purchase_invoice.php @@ -0,0 +1,70 @@ +
+
+
+
+
+
+

New Purchase Invoice

+
+
+ 'form','class'=>'form1')); ?> +
+
+
+ + +
+
+
+
+ + +
+
+
+ +
+
+ +
+ +
+
+
+ +
+
+ +
+
+
+
+ \ No newline at end of file diff --git a/old_code_ci3/views/Medical1/payment_edit.php b/old_code_ci3/views/Medical1/payment_edit.php new file mode 100644 index 0000000..d5a0e3b --- /dev/null +++ b/old_code_ci3/views/Medical1/payment_edit.php @@ -0,0 +1,156 @@ +
+
+
+
+

+ Payment ID : +

+
+
+

Invoice Type :

+
+
+

IPD/OPD No :

+
+
+

Invoice To :

+
+
+

Amount : Rs. Amount_str ?>

+
+
+

Mode of Payment. : payment_mode==1)?'CASH':'BANK');?>

+
+
+ +
+
+
+ payment_mode==1){ ?> +
+
+ + +
+
+
+
+ + +
+
+
+
+ + +
+
+
+
+ + +
+
+
+ +
+ +
+ +
+ +
+
+
+
+ +
+ +
+
+
+ +
+
+
+
+
+
+ + +
+
+
+ +
+
+
+
+
+
+ diff --git a/old_code_ci3/views/Medical1/payment_search.php b/old_code_ci3/views/Medical1/payment_search.php new file mode 100644 index 0000000..b7d4adb --- /dev/null +++ b/old_code_ci3/views/Medical1/payment_search.php @@ -0,0 +1,25 @@ +
+'form','class'=>'form_payment_search')); ?> +
+ + + + +
+ +
+ +
+ + \ No newline at end of file diff --git a/old_code_ci3/views/Medical1/purchase_invoice_item.php b/old_code_ci3/views/Medical1/purchase_invoice_item.php new file mode 100644 index 0000000..468b73f --- /dev/null +++ b/old_code_ci3/views/Medical1/purchase_invoice_item.php @@ -0,0 +1,62 @@ + + + + + + + + + + + + + + + + + + '; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + } + echo ''; + ?> + + + + + + + + + + + + + + + + + + +
#Item NameBatch NoExp.MRPQty.RateAmountDisc.Tax AmountCGSTSGSTNet Amount
'.$srno.''.$row->Item_name.''.$row->batch_no.''.$row->expiry_date.''.$row->mrp.''.floatval($row->qty).'+'.floatval($row->qty_free).''.$row->purchase_price.''.$row->amount.''.$row->discount.''.$row->taxable_amount.''.$row->CGST_per.''.$row->SGST_per.''.$row->net_amount.' + +
#Taxable_Amt ?>CGST_Amt ?>SGST_Amt ?>T_Net_Amount ?>
\ No newline at end of file diff --git a/old_code_ci3/views/Medical1/purchase_supp_list.php b/old_code_ci3/views/Medical1/purchase_supp_list.php new file mode 100644 index 0000000..ce4b75d --- /dev/null +++ b/old_code_ci3/views/Medical1/purchase_supp_list.php @@ -0,0 +1,47 @@ +
+
+
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Invoice IDSupplierDateAmount
Invoice_no ?>name_supplier ?>date_of_invoice ?>tamount ?> + +
Invoice IDSupplierDateAmount
+ +
+
+
+ + \ No newline at end of file diff --git a/old_code_ci3/views/Medical1/sale_item_list_for_add.php b/old_code_ci3/views/Medical1/sale_item_list_for_add.php new file mode 100644 index 0000000..dc1a5c7 --- /dev/null +++ b/old_code_ci3/views/Medical1/sale_item_list_for_add.php @@ -0,0 +1,30 @@ + + + + + + + + + + + + + + + + + +
Item NameBatch No.Qty in StockMRPQty
+
+ +
+
+
+ \ No newline at end of file diff --git a/old_code_ci3/views/Medical1/supplier_list.php b/old_code_ci3/views/Medical1/supplier_list.php new file mode 100644 index 0000000..734a017 --- /dev/null +++ b/old_code_ci3/views/Medical1/supplier_list.php @@ -0,0 +1,30 @@ +
+ +'form','class'=>'form2')); ?> +
+ + + + + + + + + + +
+ +
+
+ \ No newline at end of file diff --git a/old_code_ci3/views/Medical2/Dashboard.php b/old_code_ci3/views/Medical2/Dashboard.php new file mode 100644 index 0000000..6f7002b --- /dev/null +++ b/old_code_ci3/views/Medical2/Dashboard.php @@ -0,0 +1,44 @@ +
+

+ Medical Store + Dashboard +

+
+ +
+ +
+ +
+
+ \ No newline at end of file diff --git a/old_code_ci3/views/Medical2/Draft_Med_Invoice.php b/old_code_ci3/views/Medical2/Draft_Med_Invoice.php new file mode 100644 index 0000000..d9af6ce --- /dev/null +++ b/old_code_ci3/views/Medical2/Draft_Med_Invoice.php @@ -0,0 +1,126 @@ +
+
+
+

Draft Invoice

+
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + +
Invoice No.CustomersPCodeDateNet AmountReceivedBalance
+
+ +
+
+ + \ No newline at end of file diff --git a/old_code_ci3/views/Medical2/Drug_Details.php b/old_code_ci3/views/Medical2/Drug_Details.php new file mode 100644 index 0000000..c28e439 --- /dev/null +++ b/old_code_ci3/views/Medical2/Drug_Details.php @@ -0,0 +1,110 @@ +
+
+
+

Drug Details

+
+
+ + + + + + + + + + + + + + + + + + + + + + + + +
Item CodeItem NameFormulationGeneric NameMRF NameMRP
+
+ +
+
+ + \ No newline at end of file diff --git a/old_code_ci3/views/Medical2/Drug_Details_all.php b/old_code_ci3/views/Medical2/Drug_Details_all.php new file mode 100644 index 0000000..0580736 --- /dev/null +++ b/old_code_ci3/views/Medical2/Drug_Details_all.php @@ -0,0 +1,46 @@ +
+
+
+

Drug Details

+
+
+ + + + + + + + + + + + + + + + + + + + + + + + +
Item CodeItem NameDosageFormulationTherapeuticsubtherapeuticMRF NameMRP
item_id ?>itemname ?>dosage ?>
+
+ +
+
+ + \ No newline at end of file diff --git a/old_code_ci3/views/Medical2/Drug_Stock.php b/old_code_ci3/views/Medical2/Drug_Stock.php new file mode 100644 index 0000000..52319c4 --- /dev/null +++ b/old_code_ci3/views/Medical2/Drug_Stock.php @@ -0,0 +1,123 @@ +
+
+
+

Stock Drug

+
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + +
Item CodeItem NameDosageFormulationTherapeuticsubtherapeuticMRF NameMRP
+
+ +
+
+ + \ No newline at end of file diff --git a/old_code_ci3/views/Medical2/Drug_Stock_Add.php b/old_code_ci3/views/Medical2/Drug_Stock_Add.php new file mode 100644 index 0000000..bd6fd13 --- /dev/null +++ b/old_code_ci3/views/Medical2/Drug_Stock_Add.php @@ -0,0 +1,273 @@ +
+
+
+
+
+

Drug Search

+
+
+ 'form','class'=>'form1')); ?> +
+
+
+ + +
+
+
+
+ + +
+
+
+
+ + +
+
+
+
+ + +
+
+
+
+ + +
+
+
+
+
+
+ + +
+
+
+
+ + +
+
+
+
+ +
+
+ +
+ +
+
+
+
+
+ + +
+
+
+
+ + +
+
+
+
+ +
+
+ +
+ +
+
+
+
+
+
+
+ + +
+
+
+
+ + +
+
+
+
+ + +
+
+
+
+ + +
+
+
+
+
+
+ + +
+
+
+
+ + +
+
+
+
+ + +
+
+
+
+ + +
+
+
+
+ + +
+
+
+ + +
+
+
+
+
+
+
+
+

Stock Drug

+
+
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Item CodeItem NameFormulationStorage/Shelf/Rack No.Batch No.Qty /Sale QtyExpiryMRPRate/Unit
item_code ?>item_name ?>formulation ?>cold_storage ?>/shelf_no ?>/rack_no ?>batch_no ?>total_unit ?> / total_sale_unit ?>expiry_date ?>mrp ?>unit_rate ?>
Item CodeItem NameFormulationStorage/Shelf/Rack No.Batch No.Qty /Sale QtyExpiryMRPRate/Unit
+
+
+
+
+
+ \ No newline at end of file diff --git a/old_code_ci3/views/Medical2/Medical_Final_Invoice.php b/old_code_ci3/views/Medical2/Medical_Final_Invoice.php new file mode 100644 index 0000000..239c12c --- /dev/null +++ b/old_code_ci3/views/Medical2/Medical_Final_Invoice.php @@ -0,0 +1,415 @@ +
+
+

+ Medical Invoice + +

+
+
+'form','class'=>'form1')); ?> +
+
+
+ + +
+
+
+
+
+
+ +
patient_code ?>
+
+
+
+
+ +
inv_name ?>
+
+
+
+
+ +
doc_name?>
+
+
+ ipd_id > 0) { ?> +
+
+ + +
+
+
+
+ +
credit_status ?>
+
+
+
+
+ + +
+
+ case_id > 0) { ?> +
+
+ + +
+
+
+
+ +
credit_org_status ?>
+
+
+ +
+
+ + + + + + + + + + + + + + + + + + '; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + } + echo ''; + ?> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
#Item codeItem NameFormulationBatch NoExp.RateQty.PriceDisc.HSNCODE/C-SGSTCGSTSGSTAmount
'.$srno.''.$row->item_code.''.$row->item_Name.''.$row->formulation.''.$row->batch_no.''.$row->expiry.''.$row->price.''.$row->qty.''.$row->amount.''.$row->disc_amount.''.$row->HSNCODE.''.$row->CGST.''.$row->SGST.''.$row->tamount.'
#Gross Totalgross_amount ?>inv_disc_total?>CGST_Tamount?>SGST_Tamount?>net_amount?>
#Deduction
#Amount received : payment_received?>Balance Amount : payment_balance?>Net Amountnet_amount?>
+
+ + + payment_balance<>0) { ?> +
+ +
+
+
+ + +
+
+
+
+
+ +
+ ipd_credit==0 && $invoiceMaster[0]->case_credit==0) { ?> + payment_balance>0) { ?> +
+
+

+ + Cash +

+
+
+
+ +
+
+
+
+ +
+
+
+
+
+ + +
+
+ +
+
+ + +
+
+
+
+ + +
+
+
+
+ + +
+
+
+
+ + +
+
+
+
+
+
+ payment_balance<0) { ?> +
+ +
+
+ +
+
+
+ +
+ +
+
+ +
+
+
+
+
+
+
+
+ +
+
+ Print +
+
+ +
+
+ +
+ + + +
\ No newline at end of file diff --git a/old_code_ci3/views/Medical2/Medical_Invoice_V.php b/old_code_ci3/views/Medical2/Medical_Invoice_V.php new file mode 100644 index 0000000..216bed8 --- /dev/null +++ b/old_code_ci3/views/Medical2/Medical_Invoice_V.php @@ -0,0 +1,443 @@ + +
+

+ Medical Invoice + +

+
+
+'form','class'=>'form1')); ?> +
+
+
+ + +
+
+ + +
+
+
+
+ + +
+
+
+
+ + +
+
+
+
+ + +
+
+
+
+ + +
+
+
+
+ ion_auth->in_group('InvoiceDateChanged') || $this->ion_auth->in_group('admin')) { ?> +
+
+ +
+
+ +
+ +
+
+
+ + ipd_id > 0) { ?> +
+
+ + +
+
+
+ payment_received ==0) { ?> +
+
+ + +
+
+ +
+ +
credit_status ?>
+
+ +
+
+
+ + +
+
+ case_id > 0){ ?> +
+
+ + +
+
+
+ payment_received ==0) { ?> +
+
+ + +
+
+ +
+ +
credit_org_status ?>
+
+ +
+ +
+
+
+
+
+ +
+ + + + + + + + + + + + + + + '; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + } + echo ''; + ?> + + + + + + + + + + + + + + + + + + + + + + + + + + + +
#Item NameBatch NoExp.RateSaved Qty.Qty.PriceDisc.Amount
'.$srno.''.$row->item_Name.'['.$row->formulation.']'.$row->batch_no.''.$row->expiry.''.$row->price.''.$row->qty.' + '.$row->amount.''.$row->disc_amount.''.$row->tamount.' + +
#Gross TotalGtotal ?>t_dis_amt?>tamt?>
#Tax TotalTCGST : TCGST?> / TSGST :TSGST?>
+
+
+
+
+
+
+ + +
+
+
+
+
+ +
+
+ +
+
+
+
+
+ +
+
+
+
+
+ +
+
+
+
+
+ +
+
+
+
+
+ + +
+
+ +
+
+
+
+ + +
+
+
+
+ + +
+
+
+
+ +
+
+
+
+ +
+
+ +
+
+
+
+
+
+ +
+
+
+
+ + +
+ + \ No newline at end of file diff --git a/old_code_ci3/views/Medical2/Medical_invoice_list.php b/old_code_ci3/views/Medical2/Medical_invoice_list.php new file mode 100644 index 0000000..3db2cf2 --- /dev/null +++ b/old_code_ci3/views/Medical2/Medical_invoice_list.php @@ -0,0 +1,235 @@ +
+
+ 'form','class'=>'form1')); ?> +
+
+
+
+
+

Name :p_fname?> {p_rname?>} + / Age :age?> + / Gender :xgender?> + / P Code :p_code?> + / No of Days :no_days?> +

+ + + +
+
+ ipd_status==0) + { + ?> + + + lock_medical==0) + { + ?> + + + + +
+
+
+ case_id>0) { ?> +
+
+ IPD Code :ipd_code?> + Admit Date : str_register_date ?> reg_time ?> / + Discharge Date : str_discharge_date ?> discharge_time ?> / + No. of Days : no_days==0) {echo '1';} else {echo $ipd_list[0]->no_days; } ?> / + 0){ ?> + Bed No : bed_no ?> room_name ?>
+ +
+
+ + case_id>0) { ?> +
+
+ Organisation Code #case_id_code?> / + Organisation :ins_company_name?> +
+
+ +
+
+
+ + + + + + + + + + + + + '; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + if($ipd_master[0]->ipd_status==0) + { + echo ''; + }else{ + echo ''; + } + + $srno=$srno+1; + echo ''; + } + echo ''; + ?> + + + + + + + + + + + + + +
#Invoice ID.Inv.DateInv.DescCredit/CashPackageAmountBalance
'.$srno.''.$row->inv_med_code.''.$row->inv_date.''.$row->remark_ipd.''.$row->credit.''.$row->Package.''.$row->net_amount.''.$row->payment_balance.' + + Print Invoice +
#
+
+
+
+
+ + + + + + + + + + + + + +
+ Total Cash : cash_netAmount ?> + + + + Total Credit : IPDCrAmount ?> + + + + Total Package : PackageCrAmount ?> + + + + Total Amount : t_net_amount ?> + + + + Total Balance : t_payment_balance ?> + + +
+
+
+
+
+ + + + + + + + + + + + + +
+ Print Cash + + + + Print IPD Credit + + + + Print IPD Package + + + + Print Total + + + + + + +
+
+
+
+
+ +
+
+ \ No newline at end of file diff --git a/old_code_ci3/views/Medical2/Medical_invoice_print.php b/old_code_ci3/views/Medical2/Medical_invoice_print.php new file mode 100644 index 0000000..6a52b3e --- /dev/null +++ b/old_code_ci3/views/Medical2/Medical_invoice_print.php @@ -0,0 +1,174 @@ + + + + + + Krishna Pharmacy | Invoice + + + + + + + + + + + + + + + +
+
+ +
+
+

+ Krishna Pharmacy +

+

3-136, Guru Nanakpura, Haldwani,Distt. Nainital, Uttarakhand
+ Phone: (05946) 222426,282623 Fax No.:(05946) 282624, Email: krishnahospitalhaldwani@gmail.com +
GST: 05AAJFK5301R1Z2 / L.No: OBR 1/NTL/AUG/2004

+

CASH / Credit Memo

+

+ +
+
+
+

+
+ +
+ +
+
+ +
+
+ To +
+ inv_name ?>
+ Date : inv_date ?>
+ Patient ID : patient_code ?>
+
+ +
+
+
+ Refer By : doc_name ?>
+ ipd_id>0) { ?> + IPD Code : ipd_code ?>
+ + case_id>0) { ?> + Org. Code : case_id_code ?>
+ Org. Name : insurance_company_name ?>
+ +
+ +
+ +
+
+
+ + + + + + + + + + + + + + + '; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + } + echo ''; + ?> + + + + + + + + + + + + + + +
#Item NameBatch NoExp.RateQty.PriceDisc.HSNCODE/GSTGSTAmount
'.$srno.''.$row->item_Name.' ['.$row->formulation.']'.$row->batch_no.''.$row->expiry.''.$row->price.''.$row->qty.''.$row->amount.''.$row->disc_amount.''.$row->HSNCODE.'/'.$row->gst_per.''.$row->gst.''.$row->tamount.'
#Gross TotalGtotal ?>t_dis_amt?>TGST?>tamt?>
+
+
+
+ + + + + + + + + + +
#Deduction :[discount_remark ?>] discount_amount?>CGST : TCGST?>SGST : TSGST?>Net Amount : net_amount?>Amount received : payment_received?>Balance Amount : payment_balance?>
+
+ +
+
+ Payment Details [Payment No.:Mode of Payment:Amount]: + id.':'.$row->Payment_type_str.':'.$row->amount.']/'; + } + ?> +
+
+
+
+ Prepared By : prepared_by ?> +
+
+
+
+ Signature +
+
+
+
+
+ This is computer generated invoice , Signature and stamp not required +
+
+ +
+ + + diff --git a/old_code_ci3/views/Medical2/Medical_invoice_print_1.php b/old_code_ci3/views/Medical2/Medical_invoice_print_1.php new file mode 100644 index 0000000..2739b8d --- /dev/null +++ b/old_code_ci3/views/Medical2/Medical_invoice_print_1.php @@ -0,0 +1,176 @@ + + + + + + Krishna Pharmacy | Invoice + + + + + + + + + + + + + + + +
+
+ +
+
+ +
+ +
+ +
+
+ +
+
+ From
+ Krishna Pharmacy
+ 3-136, Guru Nanakpura, Haldwani,Distt. Nainital, Uttarakhand
+ Phone: (05946) 222426,282623 Fax No.:(05946) 282624, Email: krishnahospitalhaldwani@gmail.com +
+ Invoice ID #inv_med_code ?>
+ GST : 05AAJFK5301R1Z2
+
+ +
+ To +
+ inv_name ?>
+ Date : inv_date ?>
+ Patient ID : patient_code ?>
+ Refer By : doc_name ?>
+ ipd_id>0) { ?> + IPD Code : ipd_code ?>
+ + case_id>0) { ?> + Org. Code : case_id_code ?>
+ Org. Name : insurance_company_name ?>
+ +
+ +
+ +
+
+
+ + + + + + + + + + + + + + + + + '; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + } + echo ''; + ?> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
#Item NameFormulationBatch NoExp.RateQty.PriceDisc.HSNCODE/C-SGSTCGSTSGSTAmount
'.$srno.''.$row->item_Name.''.$row->formulation.''.$row->batch_no.''.$row->expiry.''.$row->price.''.$row->qty.''.$row->amount.''.$row->disc_amount.''.$row->HSNCODE.'/'.$row->CGST_per.'/'.$row->SGST_per.''.$row->CGST.''.$row->SGST.''.$row->tamount.'
#Gross TotalGtotal ?>t_dis_amt?>TCGST?>TSGST?>tamt?>
#Deductiondiscount_remark ?>discount_amount ?>
#Amount received : payment_received?>Balance Amount : payment_balance?>Net Amount : net_amount?>
+
+
+ +
+
+ Payment Details [Payment No.:Mode of Payment:Amount]: + id.':'.$row->Payment_type_str.':'.$row->amount.']/'; + } + ?> +
+
+
+
+ Prepared By : prepared_by ?> +
+
+
+
+ Signature +
+
+
+
+
+ This is computer generated invoice , Signature and stamp not required +
+
+ +
+ + + diff --git a/old_code_ci3/views/Medical2/Medical_invoice_print_2.php b/old_code_ci3/views/Medical2/Medical_invoice_print_2.php new file mode 100644 index 0000000..c8a8894 --- /dev/null +++ b/old_code_ci3/views/Medical2/Medical_invoice_print_2.php @@ -0,0 +1,172 @@ + + + + + + Krishna Pharmacy | Invoice + + + + + + + + + + + + + + +
+ +
+
+ +
+
+

+ Krishna Pharmacy +

+

3-136, Guru Nanakpura, Haldwani,Distt. Nainital, Uttarakhand
+ Phone: +91 9837669939, Email: krishnahospitalhaldwani@gmail.com +
GST: 05AAJFK5301R1Z2 / L.No: OBR 1/NTL/AUG/2004 / BR 1/NTL/AUG/2004

+
+ +
+
+

CASH / Credit Memo

+
+
+
+ To +
+ inv_name ?>
+ Patient ID : patient_code ?>
+ Refer By : doc_name ?>
+
+ +
+
+
+ Medical Invoice : inv_med_code ?>
+ Invoice Date : inv_date) ?>
+ +
+
+
+
+ ipd_id>0) { ?> + IPD Code : ipd_code ?>
+ + case_id>0) { ?> + Org. Code : case_id_code ?>
+ Org. Name : insurance_company_name ?>
+ +
+
+
+
+
+
+
+
+ + + + + + + + + + + + + + + '; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + } + echo ''; + ?> + + + + + + + + + + + + + +
#Item NameBatch NoExp.RateQty.PriceDisc.HSNCODE/GSTGSTAmount
'.$srno.''.$row->item_Name.' ['.$row->formulation.']'.$row->batch_no.''.$row->expiry.''.$row->price.''.$row->qty.''.$row->amount.''.$row->d_amt.''.$row->HSNCODE.'/'.$row->gst_per.''.$row->gst.''.$row->twdisc_amount.'
#Gross Totalgross_amount ?>inv_disc_total?>TGST?>net_amount?>
+
+
+
+ + + + + + + + + + + +
#Deduction :[discount_remark ?>] inv_disc_total?>CGST : CGST_Tamount?>SGST : SGST_Tamount?>Taxable Amount : TaxableAmount?>Net Amount : net_amount?>Amount received : payment_received?>Balance Amount : payment_balance?>
+
+ +
+
+ Payment Details [Payment No.:Mode of Payment:Amount]: + id.':'.$row->Payment_type_str.':'.$row->amount.']/'; + } + ?> +
+
+
+
+ Prepared By : prepared_by ?> +
+
+
+
+ Signature +
+
+
+
+
+ This is computer generated invoice , Signature and stamp not required +
+
+ +
+ + + + diff --git a/old_code_ci3/views/Medical2/Medical_invoice_print_all.php b/old_code_ci3/views/Medical2/Medical_invoice_print_all.php new file mode 100644 index 0000000..13da0e0 --- /dev/null +++ b/old_code_ci3/views/Medical2/Medical_invoice_print_all.php @@ -0,0 +1,187 @@ + + + + + + Krishna Pharmacy | Invoice + + + + + + + + + + + + + + +
+ +
+
+ +
+
+

+ Krishna Pharmacy +

+

3-136, Guru Nanakpura, Haldwani,Distt. Nainital, Uttarakhand
+ Phone: +91 9837669939, Email: krishnahospitalhaldwani@gmail.com +
GST: 05AAJFK5301R1Z2 / L.No: OBR 1/NTL/AUG/2004 / BR 1/NTL/AUG/2004

+
+ +
+
+

CASH / Credit Memo

+
+
+
+ To +
+ p_fname ?>
+ Patient ID : p_code ?>
+ Refer By : doc_name ?>
+
+ +
+
+
+ IPD Code : ipd_code ?>
+ org_id>0) { ?> + Org. Code : case_id_code ?>
+ Org. Name : insurance_company_name ?>
+ +
+
+
+ +
+
+ + id=='' && $row->inv_med_id != '') + { + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + + $head_start=0; + } + elseif($row->id=='' && $row->inv_med_id == ''){ + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + }else{ + + if($head_start==0) + { + echo ''; + + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + } + + $srno=$srno+1; + $head_start=$head_start+1; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + } + } + ?> + + +
#Invoice Total :'.$row->inv_med_code.''.$row->amount.''.$row->d_amt.''.$row->gst.''.$row->twdisc_amount.'
#Grand Total'.$row->amount.''.$row->d_amt.''.$row->gst.''.$row->twdisc_amount.'

Invoice ID : '.$row->inv_med_code.' [Dated : '.$row->str_inv_date.']
#Item NameBatch NoExp.RateQty.PriceDisc.HSNCODE/GSTGSTAmount
'.$srno.''.$row->item_Name.' ['.$row->formulation.']'.$row->batch_no.''.$row->expiry.''.$row->price.''.$row->qty.''.$row->amount.''.$row->d_amt.''.$row->HSNCODE.'/'.$row->gst_per.''.$row->gst.''.$row->twdisc_amount.'
+
+
+ 0) { ?> +
+ + + + + + + + + + + +
#Deduction : inv_disc_total?>CGST : CGST_Tamount?>SGST : SGST_Tamount?>Taxable Amount : TaxableAmount?>Net Amount : net_amount?>Amount received : payment_received?>Balance Amount : payment_balance?>
+
+ +
+
+ Payment Details [Payment No.:Mode of Payment:Amount]: + id.':'.$row->Payment_type_str.':'.$row->amount.']/'; + } + ?> +
+
+
+
+ +
+
+
+
+ For Krishna Pharmacy +
+
+
+
+
+ This is computer generated invoice , Signature and stamp not required +
+
+ + +
+ + + + diff --git a/old_code_ci3/views/Medical2/Medical_ipd_org_list.php b/old_code_ci3/views/Medical2/Medical_ipd_org_list.php new file mode 100644 index 0000000..5fea2dd --- /dev/null +++ b/old_code_ci3/views/Medical2/Medical_ipd_org_list.php @@ -0,0 +1,57 @@ +
+
+
+

IPD List

+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
IPD CodeName/Patient CodeBed No.[Type]Register DateNo. of DaysDr. NameAdmit TypeAmount
+ + ipd_code ?> + + [p_code ?>] p_fname ?>
p_rname ?>
Bed_Desc ?>str_register_date ?>no_days ?>doc_name ?>admit_type ?>
Org_Status ?>
M:med_amount ?>
IPD CodeName/Patient CodeRegister DateAdmit TypeAmount
+ +
+ +
+
+ + diff --git a/old_code_ci3/views/Medical2/Medical_org_invoicelist.php b/old_code_ci3/views/Medical2/Medical_org_invoicelist.php new file mode 100644 index 0000000..a4cdb45 --- /dev/null +++ b/old_code_ci3/views/Medical2/Medical_org_invoicelist.php @@ -0,0 +1,101 @@ +
+
+ 'form','class'=>'form1')); ?> +
+
+
+
+
+

Name :p_fname?> {p_rname?>} + / Age :age?> + / Gender :xgender?> + / P Code :p_code?> + / Organisation Invoice #case_id_code?> + /Organisation :insurance_company_name?> +

+ + + +
+
+ +
+
+
+
+
+ + + + + + + + + + + + + '; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + $srno=$srno+1; + echo ''; + } + echo ''; + ?> + + + + + + + + + + + + + +
#Invoice ID.PatientInv.DateInv.DescCredit/CashAmountBalance
'.$srno.''.$row->inv_med_code.''.$row->inv_name.''.$row->inv_date.''.$row->remark_ipd.''.$row->credit.''.$row->net_amount.''.$row->payment_balance.' +
#
+
+
+
+
+ +
+
+ + \ No newline at end of file diff --git a/old_code_ci3/views/Medical2/Medical_org_list.php b/old_code_ci3/views/Medical2/Medical_org_list.php new file mode 100644 index 0000000..3302cd5 --- /dev/null +++ b/old_code_ci3/views/Medical2/Medical_org_list.php @@ -0,0 +1,49 @@ +
+
+
+

IPD List

+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + +
ORG CodeName/Patient CodeRegister DateInsurance Company
+ + case_id_code ?> + + [p_code ?>] p_fname ?>
p_rname ?>
str_register_date ?>insurance_company_name ?>
ORG CodeName/Patient CodeRegister DateInsurance Company
+ +
+ +
+
+ + diff --git a/old_code_ci3/views/Medical2/Medical_stock_drug.php b/old_code_ci3/views/Medical2/Medical_stock_drug.php new file mode 100644 index 0000000..43491f6 --- /dev/null +++ b/old_code_ci3/views/Medical2/Medical_stock_drug.php @@ -0,0 +1,118 @@ +
+
+
+

Drug Details

+
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
SS No.Item CodeItem NameFormulationRack No.Shelf No.Batch No.QtyExpiryMRPSaled Qty
+
+ +
+
+ + \ No newline at end of file diff --git a/old_code_ci3/views/Medical2/Patient_Search_Result.php b/old_code_ci3/views/Medical2/Patient_Search_Result.php new file mode 100644 index 0000000..29698aa --- /dev/null +++ b/old_code_ci3/views/Medical2/Patient_Search_Result.php @@ -0,0 +1,44 @@ +

+
+
+

Result

+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Patient CodeName {Relative Name}AgePhone NumberInsuranceAction
p_code ?>p_fname ?> {p_rname ?>}age ?>mphone1 ?>insurance_id==0 ? 'Self': 'Insuranced'); ?>
Patient CodeNamePhone NumberEMailAction
+
+ +
+ \ No newline at end of file diff --git a/old_code_ci3/views/Medical2/Report/Med_Report_1.php b/old_code_ci3/views/Medical2/Report/Med_Report_1.php new file mode 100644 index 0000000..30aee40 --- /dev/null +++ b/old_code_ci3/views/Medical2/Report/Med_Report_1.php @@ -0,0 +1,80 @@ +
+

+ Daily Sale Report +

+
+
+
+
+ +
+   + +
+ +
+
+ +
+ + +
+
+
+ +
+
+
+
+
+
+ \ No newline at end of file diff --git a/old_code_ci3/views/Medical2/Report/Med_Report_2.php b/old_code_ci3/views/Medical2/Report/Med_Report_2.php new file mode 100644 index 0000000..8b133ba --- /dev/null +++ b/old_code_ci3/views/Medical2/Report/Med_Report_2.php @@ -0,0 +1,79 @@ +
+

+ Day Cash Payment Report + Panel +

+
+
+
+
+ +
+   + +
+ +
+
+ +
+ + +
+
+
+
+
+
+
+
+
+ \ No newline at end of file diff --git a/old_code_ci3/views/Medical2/Report/Med_Report_3.php b/old_code_ci3/views/Medical2/Report/Med_Report_3.php new file mode 100644 index 0000000..cd036a2 --- /dev/null +++ b/old_code_ci3/views/Medical2/Report/Med_Report_3.php @@ -0,0 +1,79 @@ +
+

+ Day Cash Payment Report + Panel +

+
+
+
+
+ +
+   + +
+ +
+
+ +
+ + +
+
+
+
+
+
+
+
+
+ \ No newline at end of file diff --git a/old_code_ci3/views/Medical2/Search_Patient.php b/old_code_ci3/views/Medical2/Search_Patient.php new file mode 100644 index 0000000..8538815 --- /dev/null +++ b/old_code_ci3/views/Medical2/Search_Patient.php @@ -0,0 +1,22 @@ +
+ 'form','class'=>'form2')); ?> +
+ + + + +
+ +
+
+ \ No newline at end of file diff --git a/old_code_ci3/views/Medical2/Stock_Update.php b/old_code_ci3/views/Medical2/Stock_Update.php new file mode 100644 index 0000000..b973351 --- /dev/null +++ b/old_code_ci3/views/Medical2/Stock_Update.php @@ -0,0 +1,192 @@ +
+
+
+
+
+

Stock Information

+
+
+ 'form','class'=>'form1')); ?> + +
+
+
+ + +
+
+
+
+ + +
+
+
+
+ + +
+
+
+
+ + +
+
+
+
+ + +
+
+
+
+
+
+ + +
+
+
+
+ + +
+
+
+
+ +
+
+ +
+ +
+
+
+
+
+ + +
+
+
+
+ + +
+
+
+
+ +
+
+ +
+ +
+
+
+
+
+
+
+ + +
+
+
+
+ + +
+
+
+
+ + +
+
+
+
+ + +
+
+
+
+ + +
+
+
+
+
+
+ + +
+
+
+
+ + +
+
+
+
+ + +
+
+
+
+ + +
+
+
+ + +
+
+
+
+ + \ No newline at end of file diff --git a/old_code_ci3/views/Medical_13062021/Dashboard.php b/old_code_ci3/views/Medical_13062021/Dashboard.php new file mode 100644 index 0000000..c80e2b1 --- /dev/null +++ b/old_code_ci3/views/Medical_13062021/Dashboard.php @@ -0,0 +1,49 @@ +
+

+ Medical Store + Dashboard +

+
+ +
+ +
+ +
+
\ No newline at end of file diff --git a/old_code_ci3/views/Medical_13062021/Draft_Med_Invoice.php b/old_code_ci3/views/Medical_13062021/Draft_Med_Invoice.php new file mode 100644 index 0000000..3c30658 --- /dev/null +++ b/old_code_ci3/views/Medical_13062021/Draft_Med_Invoice.php @@ -0,0 +1,131 @@ +
+
+
+

Draft Invoice

+
+
+ + + + + + + + + + + + + + + + + + + + + + + + +
Invoice No.Name / Phone NoPCodeDateNet AmountReceivedBalance
+
+ +
+
+ + \ No newline at end of file diff --git a/old_code_ci3/views/Medical_13062021/Draft_Med_Return_Invoice.php b/old_code_ci3/views/Medical_13062021/Draft_Med_Return_Invoice.php new file mode 100644 index 0000000..30e274a --- /dev/null +++ b/old_code_ci3/views/Medical_13062021/Draft_Med_Return_Invoice.php @@ -0,0 +1,132 @@ +
+
+
+

Return Invoice

+
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Invoice No.Name / Phone NoPCodeDateNet AmountReceivedBalance
+
+ +
+
+ + \ No newline at end of file diff --git a/old_code_ci3/views/Medical_13062021/Drug_Details.php b/old_code_ci3/views/Medical_13062021/Drug_Details.php new file mode 100644 index 0000000..c28e439 --- /dev/null +++ b/old_code_ci3/views/Medical_13062021/Drug_Details.php @@ -0,0 +1,110 @@ +
+
+
+

Drug Details

+
+
+ + + + + + + + + + + + + + + + + + + + + + + + +
Item CodeItem NameFormulationGeneric NameMRF NameMRP
+
+ +
+
+ + \ No newline at end of file diff --git a/old_code_ci3/views/Medical_13062021/Drug_Details_all.php b/old_code_ci3/views/Medical_13062021/Drug_Details_all.php new file mode 100644 index 0000000..0580736 --- /dev/null +++ b/old_code_ci3/views/Medical_13062021/Drug_Details_all.php @@ -0,0 +1,46 @@ +
+
+
+

Drug Details

+
+
+ + + + + + + + + + + + + + + + + + + + + + + + +
Item CodeItem NameDosageFormulationTherapeuticsubtherapeuticMRF NameMRP
item_id ?>itemname ?>dosage ?>
+
+ +
+
+ + \ No newline at end of file diff --git a/old_code_ci3/views/Medical_13062021/Drug_Stock.php b/old_code_ci3/views/Medical_13062021/Drug_Stock.php new file mode 100644 index 0000000..52319c4 --- /dev/null +++ b/old_code_ci3/views/Medical_13062021/Drug_Stock.php @@ -0,0 +1,123 @@ +
+
+
+

Stock Drug

+
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + +
Item CodeItem NameDosageFormulationTherapeuticsubtherapeuticMRF NameMRP
+
+ +
+
+ + \ No newline at end of file diff --git a/old_code_ci3/views/Medical_13062021/Drug_Stock_Add.php b/old_code_ci3/views/Medical_13062021/Drug_Stock_Add.php new file mode 100644 index 0000000..4af98e9 --- /dev/null +++ b/old_code_ci3/views/Medical_13062021/Drug_Stock_Add.php @@ -0,0 +1,292 @@ +
+
+
+
+
+

Drug Search

+
+
+ 'form','class'=>'form1')); ?> +
+
+
+ + +
+
+
+
+ + +
+
+
+
+ + +
+
+
+
+ + +
+
+
+
+ + +
+
+
+
+
+
+ + +
+
+
+
+ + +
+
+
+
+ +
+
+ +
+ +
+
+
+
+
+ + +
+
+
+
+ + +
+
+
+
+ +
+
+ +
+ +
+
+
+
+
+
+
+ + +
+
+
+
+ + +
+
+
+
+ + +
+
+
+
+ + +
+
+
+
+
+
+ + +
+
+
+
+ + +
+
+
+
+ + +
+
+
+
+ + +
+
+
+
+ + +
+
+
+
+ + +
+
+
+
+ + +
+
+
+ + +
+
+
+
+
+
+
+
+

Stock Drug

+
+
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Item CodeItem NameFormulationStorage/Shelf/Rack No.Batch No.Qty /Sale QtyExpiryMRPRate/Unit
item_code ?>item_name ?>formulation ?>cold_storage ?>/shelf_no ?>/rack_no ?>batch_no ?>total_unit ?> / total_sale_unit ?>expiry_date ?>mrp ?>unit_rate ?>
Item CodeItem NameFormulationStorage/Shelf/Rack No.Batch No.Qty /Sale QtyExpiryMRPRate/Unit
+
+
+
+
+
+ \ No newline at end of file diff --git a/old_code_ci3/views/Medical_13062021/Invoice_OLD_Master.php b/old_code_ci3/views/Medical_13062021/Invoice_OLD_Master.php new file mode 100644 index 0000000..d4250b4 --- /dev/null +++ b/old_code_ci3/views/Medical_13062021/Invoice_OLD_Master.php @@ -0,0 +1,200 @@ +
+
+

+ Medical Invoice + +

+
+
+'form','class'=>'form1')); ?> +
+
+
+ + +
+
+
+
+
+
+ +
patient_code ?>
+
+
+
+
+ +
inv_name ?>
+
+
+
+
+ +
doc_name?>
+
+
+ ipd_id > 0) { ?> +
+
+ + +
+
+
+
+ +
credit_status ?>
+
+
+
+
+ + +
+
+ case_id > 0) { ?> +
+
+ + +
+
+
+
+ +
credit_org_status ?>
+
+
+ +
+
+ + + + + + + + + + + + + + + + + + '; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + } + echo ''; + ?> + + + + + + + + + + + + + + + + + + group_invoice_id==0) { ?> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
#Item codeItem NameFormulationBatch NoExp.RateQty.PriceDisc.HSNCODE/C-SGSTCGSTSGSTAmount
'.$srno.''.$row->item_code.''.$row->item_Name.''.$row->formulation.''.$row->batch_no.''.$row->expiry.''.$row->price.''.$row->qty.''.$row->amount.''.$row->disc_amount.''.$row->HSNCODE.''.$row->CGST.''.$row->SGST.''.$row->tamount.'
#Gross Totalgross_amount ?>inv_disc_total?>CGST_Tamount?>SGST_Tamount?>net_amount?>
#Deductiondiscount_remark ?>discount_amount ?>
#Amount received : payment_received?>Balance Amount : payment_balance?>Net Amountnet_amount?>
#Net Amountnet_amount?>
#Rate Deduction
+
+
+
+ Print +
+
+ +
+
+ +
+ + + +
\ No newline at end of file diff --git a/old_code_ci3/views/Medical_13062021/Invoice_med_list.php b/old_code_ci3/views/Medical_13062021/Invoice_med_list.php new file mode 100644 index 0000000..2e4a36c --- /dev/null +++ b/old_code_ci3/views/Medical_13062021/Invoice_med_list.php @@ -0,0 +1,117 @@ +
+
+
+

Invoice

+
+
+ + + + + + + + + + + + + + + + + + + + + + + +
Invoice No.CustomersPCodeDateNet Amount
+
+ +
+
+ + \ No newline at end of file diff --git a/old_code_ci3/views/Medical_13062021/Med_Item_List.php b/old_code_ci3/views/Medical_13062021/Med_Item_List.php new file mode 100644 index 0000000..ca6d1ba --- /dev/null +++ b/old_code_ci3/views/Medical_13062021/Med_Item_List.php @@ -0,0 +1,86 @@ + + + + + + + + + + + + + + + sale_return==1){ + echo ''; + }else{ + echo ''; + } + + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + + echo ''; + echo ''; + } + echo ''; + echo ''; + ?> + + + + + + + + + + + + + + + + + + + + + + + + + + +
#Item NameBatch NoExp.RateS.Qty.Qty.PriceDisc.Amount
'.$srno.''.$row->item_Name.''.$row->batch_no.''.$row->expiry.''.$row->price.''.$row->qty.''; + if($row->sale_return==0){ + echo '
+ + + + +
'; + } + echo '
'.$row->amount.''.$row->disc_amount.''.$row->tamount.''; + echo ' '; + echo '
#Gross TotalGtotal ?>t_dis_amt?>tamt?>
#Tax TotalTCGST : TCGST?> / TSGST :TSGST?>
\ No newline at end of file diff --git a/old_code_ci3/views/Medical_13062021/Med_Item_old_list.php b/old_code_ci3/views/Medical_13062021/Med_Item_old_list.php new file mode 100644 index 0000000..0367288 --- /dev/null +++ b/old_code_ci3/views/Medical_13062021/Med_Item_old_list.php @@ -0,0 +1,46 @@ + + + + + + + + + + + + + + '; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + } + ?> +
#Item NameBatch NoPriceS.Qty.Amt.Disc.TAmt.R.Qty.
'.$srno.''.$row->item_Name.''.$row->batch_no.'/'.$row->exp_date.''.$row->price.''.$row->qty.''.$row->amount.''.$row->t_discount.''.$row->twdisc_amount.''; + echo '
+ + + + +
'; + echo '
diff --git a/old_code_ci3/views/Medical_13062021/Med_Model_Payment.php b/old_code_ci3/views/Medical_13062021/Med_Model_Payment.php new file mode 100644 index 0000000..4444dff --- /dev/null +++ b/old_code_ci3/views/Medical_13062021/Med_Model_Payment.php @@ -0,0 +1,323 @@ + +
+
+
+
+
+
+

Name :p_fname?> {p_rname?>} + / Age :age?> + / Gender :xgender?> + / P Code :p_code?> + / IPD Code : + + ipd_code ?> + + / No of Days :no_days?> + + + + +

+
+
+
+
+
+
+
+
+
+
+
+
+

Medical Amount :

+
+
+
+
+ +
+
+
+ +
+ /> +
+
+
+
+
+
+ +
+ +
+
+
+
+
+ +
+ +
+
+
+
+
+
+
+
+

+ + Cash +

+
+
+
+
+
+ + +
+
+ +
+
+
+
+ +
+
+ +
+
+ + +
+
+
+
+ + +
+
+
+
+ + +
+
+
+
+ + +
+
+
+
+ + +
+
+ +
+
+
+ +
+
+
+
+
+ Payment Details + + + + + + + + + + '; + } + ?> +
Pay.No.ModeDate Amount
'.$row->id.''.$row->Payment_type_str.''.$row->str_payment_date.''.$row->paid_amount.'
+
+
+ 0) { ?> +

+ Pharmacy Bill Amount: + Rs. net_amount ?>
+ Total Amount Paid : Rs. payment_received ?> +
+ Balance Amount: + Rs. payment_balance ?>
+ Print Cash +

+ + +
+ > + + + +
+ + +
+
+ +
+
+ \ No newline at end of file diff --git a/old_code_ci3/views/Medical_13062021/Med_Payment.php b/old_code_ci3/views/Medical_13062021/Med_Payment.php new file mode 100644 index 0000000..07d28f6 --- /dev/null +++ b/old_code_ci3/views/Medical_13062021/Med_Payment.php @@ -0,0 +1,308 @@ +
+
+
+
+

Name :p_fname?> {p_rname?>} + / Age :age?> + / Gender :xgender?> + / P Code :p_code?> + / IPD Code :ipd_code?> + / No of Days :no_days?> +

+
+
+
+
+
+
+
+

Amount :

+
+
+
+
+ +
+
+
+ +
+ /> +
+
+
+
+
+
+ + +
+
+
+
+ +
+ +
+
+
+
+
+
+
+
+

+ + Cash +

+
+
+
+
+
+ + +
+
+ +
+
+
+
+ +
+
+ +
+
+ + +
+
+
+
+ + +
+
+
+
+ + +
+
+
+
+ + +
+
+
+
+ + +
+
+
+
+
+
+ +
+
+
+
+ + +
+
+
+
+ + +
+
+
+
+ + +
+
+
+
+ + +
+
+
+
+ + +
+
+ +
+
+
+
+
+ \ No newline at end of file diff --git a/old_code_ci3/views/Medical_13062021/Med_Payment_Receipt.php b/old_code_ci3/views/Medical_13062021/Med_Payment_Receipt.php new file mode 100644 index 0000000..c9b8ed0 --- /dev/null +++ b/old_code_ci3/views/Medical_13062021/Med_Payment_Receipt.php @@ -0,0 +1,112 @@ + + + + + + + + + +
+

+

, Uttarakhand
+ '; + + if(H_Med_GST!='') + { + echo 'GST: '.H_Med_GST .''; + } + + if(M_LIC!='') + { + echo ' L.No: '.M_LIC; + } + ?> +

+ p_fname.':IPD-'.$ipd_master[0]->ipd_code .':P-'.date('Y-m-d H:i:s'); + ?> + + +
+

Payment Receipt

+
+ + + + + + +
Page : {PAGENO}/{nbpg}IPD-ID:ipd_code ?> / UHID:p_code ?> /Name : p_fname ?>
+
+

+ To : + p_fname ?>
+ Patient Info. as per Hospital Records
+ UHID ID : p_code ?>
+ IPD Code : ipd_code ?>
+ Refer By : doc_name ?>
+ org_id>0) { ?> + Org. Code : case_id_code ?>
+ Org. Name : insurance_company_name ?>
+ +

+ + + + + + + + '; + + } + ?> +
Pay.No.ModeDate Amount
'.$row->id.''.$row->Payment_type_str.''.$row->str_payment_date.''.$row->amount.'
+
+
+0) { ?> + Pharmacy Bill Amount at the Time of Print Receipt : + Rs. net_amount ?>
+ Total Amount Paid : Rs. payment_received ?>
+ Balance Amount : Rs. net_amount-$inv_med_group[0]->payment_received ?> + +
+
+
+
+
+
+

+ For +

\ No newline at end of file diff --git a/old_code_ci3/views/Medical_13062021/Med_Return_Invoice_search.php b/old_code_ci3/views/Medical_13062021/Med_Return_Invoice_search.php new file mode 100644 index 0000000..5e10f8b --- /dev/null +++ b/old_code_ci3/views/Medical_13062021/Med_Return_Invoice_search.php @@ -0,0 +1,67 @@ + +

Search By Phone No. (Complete 10 Digit Phone No.)

+
+ + + + +
+
+

Search By UHID (Type Last 5 to 6 Digit of UHID/Patient ID)

+
+ + + + +
+
+

Search By Invoice Code (Type Last 5 to 6 Digit of invoice)

+
+ + + + +
+
+

Search By Product

+
+ + + + +
+ + \ No newline at end of file diff --git a/old_code_ci3/views/Medical_13062021/Med_back_Panel.php b/old_code_ci3/views/Medical_13062021/Med_back_Panel.php new file mode 100644 index 0000000..b0f9e9b --- /dev/null +++ b/old_code_ci3/views/Medical_13062021/Med_back_Panel.php @@ -0,0 +1,123 @@ +
+

+ Back + Panel +

+
+
+
diff --git a/old_code_ci3/views/Medical_13062021/Med_old_invoice_list.php b/old_code_ci3/views/Medical_13062021/Med_old_invoice_list.php new file mode 100644 index 0000000..f841dc8 --- /dev/null +++ b/old_code_ci3/views/Medical_13062021/Med_old_invoice_list.php @@ -0,0 +1,67 @@ + + $row->inv_id) + { + $srno=0; + + echo ''; + echo ''; + echo ''; + + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + } + + $srno=$srno+1; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + if($row->sale_return==0){ + echo ''; + }else{ + echo ''; + } + echo ''; + + $inv_id=$row->inv_id; + } + ?> +
#'.$row->inv_med_code.''.$row->inv_date.''.$row->net_amount.'
#ItemBat./Exp.DtRateQtyN.Amt.R.Qty
'.$srno.''.$row->item_Name.''.$row->batch_no.'
'.$row->exp_date.'
'.$row->price.''.$row->qty.''.$row->twdisc_amount.' +
+ + + + +
'; + echo '
diff --git a/old_code_ci3/views/Medical_13062021/Medical_Final_Invoice.php b/old_code_ci3/views/Medical_13062021/Medical_Final_Invoice.php new file mode 100644 index 0000000..b8faae3 --- /dev/null +++ b/old_code_ci3/views/Medical_13062021/Medical_Final_Invoice.php @@ -0,0 +1,394 @@ +
+
+

+ Medical Invoice + +

+
+
+'form','class'=>'form1')); ?> +
+
+
+ + +
+

Name : + inv_name?> + / P Code :patient_code?> + / Invoice No. :inv_med_code?> + / Date : inv_date)?> + ipd_id > 0) { ?> + IPD Code : + + ipd_code?> + + Admit Date : str_register_date ?> reg_time ?> + / Doctor :doc_name?> + / TPA-Org. :admit_type?> + / Bill Type :ipd_credit)?'Credit To Hospital':'CASH/Direct'?> + case_id > 0){ ?> + / Org. Case ID : + case_id_code ?> + + + med_group_id==0){ ?> + + +

+
+
+
+
+
+
+ + + + + + + + + + + + + + + + + + '; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + } + echo ''; + ?> + + + + + + + + + + + + + + + + + +
#Item codeItem NameFormulationBatch NoExp.RateQty.PriceDisc.HSNCODE/C-SGSTCGSTSGSTAmount
'.$srno.''.$row->item_code.''.$row->item_Name.''.$row->formulation.''.$row->batch_no.''.$row->expiry.''.$row->price.''.$row->qty.''.$row->amount.''.$row->disc_amount.''.$row->HSNCODE.''.$row->CGST.''.$row->SGST.''.$row->tamount.'
#Gross Totalgross_amount ?>inv_disc_total?>CGST_Tamount?>SGST_Tamount?>net_amount?>
+
+ group_invoice_id==0) { ?> +
+ + + + + + + + +
#Deduction
+
+ +
+ + + + + + + + + +
#Amount received : payment_received?>Balance Amount : payment_balance?>Net Amount : net_amount?>
+
+
+ + payment_balance<>0) { ?> +
+ +
+
+
+ + +
+
+
+
+
+ +
+ ipd_credit==0 || $invoiceMaster[0]->ipd_credit=='')&& $invoiceMaster[0]->case_credit==0 && $invoiceMaster[0]->group_invoice_id==0) { ?> + payment_balance>0) { ?> +
+
+

+ + Cash +

+
+
+
+ +
+
+
+
+ +
+
+
+
+
+ + +
+
+ +
+
+ + +
+
+
+
+ + +
+
+
+
+ + +
+
+
+
+ + +
+
+
+
+
+
+ payment_balance<0) { ?> +
+ +
+
+ +
+
+
+ +
+
+
+
+
+ +
+ +
+ +
+
+ +
+ + + +
\ No newline at end of file diff --git a/old_code_ci3/views/Medical_13062021/Medical_Invoice_Return.php b/old_code_ci3/views/Medical_13062021/Medical_Invoice_Return.php new file mode 100644 index 0000000..382edc2 --- /dev/null +++ b/old_code_ci3/views/Medical_13062021/Medical_Invoice_Return.php @@ -0,0 +1,212 @@ +
+

+ Medical Return Items + +

+
+
+'form','class'=>'form1')); ?> +
+
+
+ +
+
+ + +
+
+
+
+ + +
+
+ 0) { ?> +
+
+ + +
+
+ 0){ ?> +
+
+ + +
+
+ +
+
+
+ + + + + + + + + + + + + + + + + + + + item_id.'">'; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + + if($row->r_qty=='') + { + echo ''; + $visible_return=''; + $visible_undo='style="display:none;"'; + + }else{ + echo ''; + $visible_return='style="display:none;"'; + $visible_undo=''; + } + echo ''; + echo ''; + } + ?> + + +
#Inv-DateItem NameBatch NoExp.RateSaved Qty.PriceDisc.AmountReturn Qty.Update
'.$srno.''.$row->str_inv_date.''.$row->item_Name.''.$row->batch_no.''.$row->expiry.''.$row->price.''.$row->qty.''.$row->amount.''.$row->disc_amount.''.$row->tamount.' + + + + + + + +
+ '; + echo ''; + ?> +
+
+ +
+ + + + \ No newline at end of file diff --git a/old_code_ci3/views/Medical_13062021/Medical_Invoice_Return_V.php b/old_code_ci3/views/Medical_13062021/Medical_Invoice_Return_V.php new file mode 100644 index 0000000..b02b1fc --- /dev/null +++ b/old_code_ci3/views/Medical_13062021/Medical_Invoice_Return_V.php @@ -0,0 +1,294 @@ +
+

+ Medical Return Invoice No. inv_med_code?> + + Edit + +

+
+
+'form','class'=>'form1')); ?> +
+
+
+ + + patient_id==0) { ?> +
+
+ +
+ +
+
+
+
+
+ +
+ +
+
+
+
+
+ + +
+
+ +
+

Name : + inv_name?> + / P Code :patient_code?> + / Invoice No. :inv_med_code?> + / Date : inv_date)?> + ipd_id > 0) { ?> + IPD Code : + + ipd_code?> + + Admit Date : str_register_date ?> reg_time ?> + / Doctor :doc_name?> + / TPA-Org. :admit_type?> + / Bill Type :ipd_credit)?'Credit To Hospital':'CASH/Direct'?> + case_id > 0){ ?> + / Org. Case ID : + case_id_code ?> + + +

+
+ +
+
+
+
+
+
+ +
+
+
+ +
+
+
+
+

Sale Medicine Within Last 2 months

+
+ +
+
+ + +
+ +
+ + + +
+
+
+ +
+ +
+ + \ No newline at end of file diff --git a/old_code_ci3/views/Medical_13062021/Medical_Invoice_Return_pre.php b/old_code_ci3/views/Medical_13062021/Medical_Invoice_Return_pre.php new file mode 100644 index 0000000..b2cd43c --- /dev/null +++ b/old_code_ci3/views/Medical_13062021/Medical_Invoice_Return_pre.php @@ -0,0 +1,148 @@ +
+

+ Medical Return Items + +

+
+
+'form','class'=>'form1')); ?> +
+
+
+ +
+
+ + +
+
+
+
+ + +
+
+ 0) { ?> +
+
+ + +
+
+ 0){ ?> +
+
+ + +
+
+ +
+
+
+ + + + + + + + + + + + + + + + + + + + '; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + + $tAmount=$tAmount+$row->amount; + } + + echo ' + + + + + + + + + + + + + + + '; + + ?> + + +
#Inv-DateItem NameBatch NoExp.RateOld Qty.Return Qty.PriceDisc.Amount
'.$srno.''.$row->str_inv_date.''.$row->item_Name.''.$row->batch_no.''.$row->expiry.''.$row->price.''.$row->qty.''.$row->r_qty.''.$row->amount.''.$row->disc_amount.''.$row->tamount.'
Total'.$tAmount.'
+ '; + echo ''; + ?> +
+
+ + +
+ + + + \ No newline at end of file diff --git a/old_code_ci3/views/Medical_13062021/Medical_Invoice_Return_print.php b/old_code_ci3/views/Medical_13062021/Medical_Invoice_Return_print.php new file mode 100644 index 0000000..0f0144a --- /dev/null +++ b/old_code_ci3/views/Medical_13062021/Medical_Invoice_Return_print.php @@ -0,0 +1,148 @@ + + + + + + + <?=$pharmacyName?> | Invoice + + + + + + + + + + + + + + +
+ +
+
+ +
+
+

+ +

+


+ +
GST: / L.No: DEMO LIC

+
+ +
+
+

Return Medicine List

+
+
+
+ To +
+ p_fname ?>
+ Patient ID : p_code ?>
+ Refer By : doc_name ?>
+
+ +
+
+
+ IPD Code : ipd_code ?>
+ +
+
+
+ +
+
+ + + + + + + + + + + + + + + + '; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + $tAmount=$tAmount+$row->amount; + } + + echo ' + + + + + + + + + + + + '; + ?> + + +
Sr.No.Return DateInv.Code.Item NameBatch No.ExpiryRateOld Qty.Return Qty.AmountUpdate By
'.$srno.''.$row->return_date_time.''.$row->inv_med_code.''.$row->item_Name.''.$row->batch_no.''.$row->expiry.''.$row->price.''.$row->qty.''.$row->r_qty.''.$row->amount.''.$row->update_remark.'
Total'.$tAmount.'
+
+
+ +
+
+ +
+
+
+
+ For Krishna Pharmacy +
+
+
+
+
+ This is computer generated invoice , Signature and stamp not required +
+
+ + +
+ + + + diff --git a/old_code_ci3/views/Medical_13062021/Medical_Invoice_V.php b/old_code_ci3/views/Medical_13062021/Medical_Invoice_V.php new file mode 100644 index 0000000..a4d636c --- /dev/null +++ b/old_code_ci3/views/Medical_13062021/Medical_Invoice_V.php @@ -0,0 +1,654 @@ +
+

+ Medical Invoice No. inv_med_code?> + + Edit + +

+
+
+'form','class'=>'form1')); ?> +
+
+
+
+ + + patient_id==0) { ?> + + + + + + + + + + +
Patient Name : Doctor Name : + + Other Doctor: + +
+ +
+

Name : + inv_name?> + / P Code :patient_code?> + / Invoice No. :inv_med_code?> + / Date : inv_date)?> + ipd_id > 0) { ?> + IPD Code : + + ipd_code?> + + Admit Date : str_register_date ?> reg_time ?> + / Doctor :doc_name?> + / TPA-Org. :admit_type?> + / Bill Type :ipd_credit)?'Credit To Hospital':'CASH/Direct'?> + case_id > 0){ ?> + / Org. Case ID : + case_id_code ?> + + + + + + + + + + +
Doctor Name : + + Other Doctor: + +
+ + + +

+
+ +
+
+
+
+
+
+ +
+
+ +
+
+
+
+
+ +
+
+
+
+ + + +
+
+
+
+ +
+
+
+
+ +

+ + + + + + + + +

+
+
+
+
+
+
+ + +
+
+
+
+ + +
+
+
+
+ + +
+
+
+
+ + +
+
+
+
+ + +
+
+
+
+ + +
+
+
+
+ + +
+
+
+
+
+
+
+ + +
+
+
+
+ + + +
+
+
+
+ + +
+
+
+
+ +
+
+
+ +
+ +
+ +
+
+
+
+
+

Sale Medicine

+
+ +
+
+ + +
+ +
+ + + +
+
+ + +
+ + \ No newline at end of file diff --git a/old_code_ci3/views/Medical_13062021/Medical_invoice_list.php b/old_code_ci3/views/Medical_13062021/Medical_invoice_list.php new file mode 100644 index 0000000..249af1e --- /dev/null +++ b/old_code_ci3/views/Medical_13062021/Medical_invoice_list.php @@ -0,0 +1,338 @@ +
+
+ 'form','class'=>'form1')); ?> +
+
+
+
+
+

Name :p_fname?> {p_rname?>} + / Age :age?> + / Gender :xgender?> + / P Code :p_code?>
+

+ + + +
+
+ ipd_status==0) + { + ?> + + + lock_medical==0) + { + ?> + + + + + 0){ ?> + bill_final==0){ ?> + + + + + +
+
+
+
+
+ IPD Code : + + ipd_code?> + + Admit Date : str_register_date ?> reg_time ?> / + Discharge Date : str_discharge_date ?> discharge_time ?> / + No. of Days : no_days==0) {echo '1';} else {echo $ipd_list[0]->no_days; } ?> / + 0){ ?> + Bed No : bed_no ?> room_name ?> + + / Doctor :doc_name?> + / Status :Disstatus?> + +
+
+ case_id>0) { ?> +
+
+ Organisation Code #case_id_code?> / + Organisation :ins_company_name?> +
+
+ +
+
+
+ + + + + + + + + + + + '; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + $srno=$srno+1; + echo ''; + } + echo ''; + ?> + + + + + + + + + + + +
#Invoice ID.Inv.DateInv.DescCredit/CashPackageAmount
'.$srno.''.$row->inv_med_code.''.$row->inv_date.''.$row->remark_ipd.''.$row->credit.''.$row->Package.''.$row->net_amount.''; + if($ipd_master[0]->ipd_status==0) + { + echo ''; + if($row->group_invoice_id==0 && $row->ipd_credit==0 ) + { + echo ''; + } + }else{ + if($row->ipd_credit==0 ) + { + echo ''; + } + + } + echo ' Print'; + + echo '
#Invoice ID.Inv.DateInv.DescCredit/CashPackageAmount
+
+
+
+
+ + + + + + + + + + + + + +
+ Total Cash : cash_netAmount ?> + + + + Total Credit : IPDCrAmount ?> + + + + Total Package : PackageCrAmount ?> + + + + Total Amount : t_net_amount ?> + + + + Total Balance : t_payment_balance ?> + + +
+
+
+
+
+ + + + + + + + 0) { ?> + + + + + +
+ + + Print Return List + +
+ + + + discount_group_2>0) { + ?> + + + +
+ + + + +
+
+ + + + + + + + +
+ Print Cash + + Print IPD Credit + + Print IPD Package + + Print Medicine List + + Print Page Wise +
+
+
+
+
+ +
+
+ \ No newline at end of file diff --git a/old_code_ci3/views/Medical_13062021/Medical_invoice_print.php b/old_code_ci3/views/Medical_13062021/Medical_invoice_print.php new file mode 100644 index 0000000..a168dd3 --- /dev/null +++ b/old_code_ci3/views/Medical_13062021/Medical_invoice_print.php @@ -0,0 +1,180 @@ + + + + + + + <?=$pharmacyName?> | Invoice + + + + + + + + + + + + + + + +
+
+ +
+
+

+ +

+


+ +
GST: / L.No: DEMO 1/USN/JAN/2008

+

CASH / Credit Memo

+

+ +
+
+
+

+
+ +
+ +
+
+ +
+
+ To +
+ inv_name ?>
+ Date : inv_date ?>
+ Patient ID : patient_code ?>
+
+ +
+
+
+ Refer By : doc_name ?>
+ ipd_id>0) { ?> + IPD Code : ipd_code ?>
+ + case_id>0) { ?> + Org. Code : case_id_code ?>
+ Org. Name : insurance_company_name ?>
+ +
+ +
+ +
+
+
+ + + + + + + + + + + + + + + '; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + } + echo ''; + ?> + + + + + + + + + + + + + + +
#Item NameBatch NoExp.RateQty.PriceDisc.HSNCODE/GSTGSTAmount
'.$srno.''.$row->item_Name.' ['.$row->formulation.']'.$row->batch_no.''.$row->expiry.''.$row->price.''.$row->qty.''.$row->amount.''.$row->disc_amount.''.$row->HSNCODE.'/'.$row->gst_per.''.$row->gst.''.$row->tamount.'
#Gross TotalGtotal ?>t_dis_amt?>TGST?>tamt?>
+
+
+
+ + + + + + + + + + +
#Deduction :[discount_remark ?>] discount_amount?>CGST : TCGST?>SGST : TSGST?>Net Amount : net_amount?>Amount received : payment_received?>Balance Amount : payment_balance?>
+
+ +
+
+ Payment Details [Payment No.:Mode of Payment:Amount]: + id.':'.$row->Payment_type_str.':'.$row->amount.']/'; + } + ?> +
+
+
+
+ Prepared By : prepared_by ?> +
+
+
+
+ Signature +
+
+
+
+
+ This is computer generated invoice , Signature and stamp not required +
+
+ +
+ + + diff --git a/old_code_ci3/views/Medical_13062021/Medical_invoice_print_1.php b/old_code_ci3/views/Medical_13062021/Medical_invoice_print_1.php new file mode 100644 index 0000000..d37c24b --- /dev/null +++ b/old_code_ci3/views/Medical_13062021/Medical_invoice_print_1.php @@ -0,0 +1,182 @@ + + + + + + + <?=$pharmacyName?> | Invoice + + + + + + + + + + + + + + + +
+
+ +
+
+ +
+ +
+ +
+
+ +
+
+ From
+
+
+ +
+ Invoice ID #inv_med_code ?>
+ GST :
+
+ +
+ To +
+ inv_name ?>
+ Date : inv_date ?>
+ Patient ID : patient_code ?>
+ Refer By : doc_name ?>
+ ipd_id>0) { ?> + IPD Code : ipd_code ?>
+ + case_id>0) { ?> + Org. Code : case_id_code ?>
+ Org. Name : insurance_company_name ?>
+ +
+ +
+ +
+
+
+ + + + + + + + + + + + + + + + + '; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + } + echo ''; + ?> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
#Item NameFormulationBatch NoExp.RateQty.PriceDisc.HSNCODE/C-SGSTCGSTSGSTAmount
'.$srno.''.$row->item_Name.''.$row->formulation.''.$row->batch_no.''.$row->expiry.''.$row->price.''.$row->qty.''.$row->amount.''.$row->disc_amount.''.$row->HSNCODE.'/'.$row->CGST_per.'/'.$row->SGST_per.''.$row->CGST.''.$row->SGST.''.$row->tamount.'
#Gross TotalGtotal ?>t_dis_amt?>TCGST?>TSGST?>tamt?>
#Deductiondiscount_remark ?>discount_amount ?>
#Amount received : payment_received?>Balance Amount : payment_balance?>Net Amount : net_amount?>
+
+
+ +
+
+ Payment Details [Payment No.:Mode of Payment:Amount]: + id.':'.$row->Payment_type_str.':'.$row->amount.']/'; + } + ?> +
+
+
+
+ Prepared By : prepared_by ?> +
+
+
+
+ Signature +
+
+
+
+
+ This is computer generated invoice , Signature and stamp not required +
+
+ +
+ + + diff --git a/old_code_ci3/views/Medical_13062021/Medical_invoice_print_2.php b/old_code_ci3/views/Medical_13062021/Medical_invoice_print_2.php new file mode 100644 index 0000000..accd2dd --- /dev/null +++ b/old_code_ci3/views/Medical_13062021/Medical_invoice_print_2.php @@ -0,0 +1,178 @@ + + + + + + + <?=$pharmacyName?> | Invoice + + + + + + + + + + + + + + +
+ +
+
+ +
+
+

+ +

+


+ +
GST: / L.No: DEMO 1/USN/JUNE/2008

+
+ +
+
+

CASH / Credit Memo

+
+
+
+ To +
+ inv_name ?>
+ Patient ID : patient_code ?>
+ Refer By : doc_name ?>
+
+ +
+
+
+ Medical Invoice : inv_med_code ?>
+ Invoice Date : inv_date) ?>
+ +
+
+
+
+ ipd_id>0) { ?> + IPD Code : ipd_code ?>
+ + case_id>0) { ?> + Org. Code : case_id_code ?>
+ Org. Name : insurance_company_name ?>
+ +
+
+
+
+
+
+
+
+ + + + + + + + + + + + + + + '; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + } + echo ''; + ?> + + + + + + + + + + + + + +
#Item NameBatch NoExp.RateQty.PriceDisc.HSNCODE/GSTGSTAmount
'.$srno.''.$row->item_Name.' '.$row->formulation.''.$row->batch_no.''.$row->expiry.''.$row->price.''.$row->qty.''.$row->amount.''.$row->d_amt.''.$row->HSNCODE.'/'.$row->gst_per.''.$row->gst.''.$row->twdisc_amount.'
#Gross Totalgross_amount ?>inv_disc_total?>TGST?>net_amount?>
+
+
+
+ + + + + + + + + + + +
#Deduction :[discount_remark ?>] inv_disc_total?>CGST : CGST_Tamount?>SGST : SGST_Tamount?>Taxable Amount : TaxableAmount?>Net Amount : net_amount?>Amount received : payment_received?>Balance Amount : payment_balance?>
+
+ +
+
+ Payment Details [Payment No.:Mode of Payment:Amount]: + id.':'.$row->Payment_type_str.':'.$row->amount.']/'; + } + ?> +
+
+
+
+ Prepared By : prepared_by ?> +
+
+
+
+ Signature +
+
+
+
+
+ This is computer generated invoice , Signature and stamp not required +
+
+ +
+ + + + diff --git a/old_code_ci3/views/Medical_13062021/Medical_invoice_print_all.php b/old_code_ci3/views/Medical_13062021/Medical_invoice_print_all.php new file mode 100644 index 0000000..7651ee7 --- /dev/null +++ b/old_code_ci3/views/Medical_13062021/Medical_invoice_print_all.php @@ -0,0 +1,197 @@ + + + + + + + <?=$pharmacyName?> | Invoice + + + + + + + + + + + + + + +
+ +
+
+ +
+
+

+ +

+


+ +
GST: / L.No: DEMO 1/USN/JUNE/2008

+
+ +
+
+ +

CASH / Credit Memo

+
+
+
+ To +
+ p_fname ?>
+ Patient ID : p_code ?>
+ Refer By : doc_name ?>
+
+ +
+
+
+ IPD Code : ipd_code ?>
+ org_id>0) { ?> + Org. Code : case_id_code ?>
+ Org. Name : insurance_company_name ?>
+ +
+
+
+ +
+
+ + id=='' && $row->inv_med_id != '') + { + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + + $head_start=0; + } + elseif($row->id=='' && $row->inv_med_id == ''){ + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + }else{ + + if($head_start==0) + { + echo ''; + + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + } + + $srno=$srno+1; + $head_start=$head_start+1; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + } + } + ?> + + +
#Invoice Total :'.$row->inv_med_code.''.$row->amount.''.$row->d_amt.''.$row->gst.''.$row->twdisc_amount.'

#Grand Total'.$row->amount.''.$row->d_amt.''.$row->gst.''.$row->twdisc_amount.'

Invoice ID : '.$row->inv_med_code.' [Dated : '.$row->str_inv_date.']
#Item NameBatch NoExp.RateQty.PriceDisc.HSNCODE/GSTGSTAmount
'.$srno.''.$row->item_Name.' '.$row->formulation.''.$row->batch_no.''.$row->expiry.''.$row->price.''.$row->qty.''.$row->amount.''.$row->d_amt.''.$row->HSNCODE.'/'.$row->gst_per.''.$row->gst.''.$row->twdisc_amount.'
+
+
+ 0) { ?> +
+ + + + + + + + + + + +
#Deduction : discount_group?>CGST : CGST_Tamount?>SGST : SGST_Tamount?>Taxable Amount : TaxableAmount?>Net Amount : net_amount?>Amount received : payment_received?>Balance Amount : payment_balance?>
+
+ +
+
+ Payment Details [Payment No.:Mode of Payment:Amount]: + id.':'.$row->Payment_type_str.':'.$row->amount.']/'; + } + ?> +
+
+
+
+ +
+
+
+
+ For Krishna Pharmacy +
+
+
+
+
+ This is computer generated invoice , Signature and stamp not required +
+
+ + +
+ + + + diff --git a/old_code_ci3/views/Medical_13062021/Medical_invoice_print_all_provisional.php b/old_code_ci3/views/Medical_13062021/Medical_invoice_print_all_provisional.php new file mode 100644 index 0000000..dc375ae --- /dev/null +++ b/old_code_ci3/views/Medical_13062021/Medical_invoice_print_all_provisional.php @@ -0,0 +1,179 @@ + + + + + + + <?=$pharmacyName?> | Provisional Invoice + + + + + + + + + + + + + + +
+ +
+
+ +
+
+

+ +

+


+ +
GST: / L.No: OBR 1/NTL/AUG/2004 / BR 1/NTL/AUG/2004

+
+ +
+
+ +

Provisional CASH / Credit Memo

+
+
+
+ To +
+ p_fname ?>
+ Patient ID : p_code ?>
+ Refer By : doc_name ?>
+
+ +
+
+
+ IPD Code : ipd_code ?>
+ org_id>0) { ?> + Org. Code : case_id_code ?>
+ Org. Name : insurance_company_name ?>
+ +
+
+
+ +
+
+ + id=='' && $row->inv_med_id != '') + { + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + + $head_start=0; + } + elseif($row->id=='' && $row->inv_med_id == ''){ + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + }else{ + + if($head_start==0) + { + echo ''; + + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + } + + $srno=$srno+1; + $head_start=$head_start+1; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + } + } + ?> + + +
#Invoice Total :'.$row->inv_med_code.''.$row->amount.'

#Grand Total'.$row->amount.'

[Dated : '.$row->str_inv_date.']
#Item NameBatch NoExp.RateQty.Price
'.$srno.''.$row->item_Name.' '.$row->formulation.''.$row->batch_no.''.$row->expiry.''.$row->price.''.$row->qty.''.$row->amount.'
+
+
+ 0) { ?> +
+ + + + + + + + + +
#Gross Amount : gross_amount?>Deduction : discount_group?>Net Amount : net_amount?>Amount received : payment_received?>Balance Amount : payment_balance?>
+
+ +
+
+ Payment Details [Payment No.:Mode of Payment:Amount]: + id.':'.$row->Payment_type_str.':'.$row->amount.']/'; + } + ?> +
+
+
+
+ +
+
+
+
+ For Krishna Pharmacy +
+
+
+
+
+ This is computer generated invoice , Signature and stamp not required +
+
+ + +
+ + + + diff --git a/old_code_ci3/views/Medical_13062021/Medical_ipd_org_list.php b/old_code_ci3/views/Medical_13062021/Medical_ipd_org_list.php new file mode 100644 index 0000000..5fea2dd --- /dev/null +++ b/old_code_ci3/views/Medical_13062021/Medical_ipd_org_list.php @@ -0,0 +1,57 @@ +
+
+
+

IPD List

+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
IPD CodeName/Patient CodeBed No.[Type]Register DateNo. of DaysDr. NameAdmit TypeAmount
+ + ipd_code ?> + + [p_code ?>] p_fname ?>
p_rname ?>
Bed_Desc ?>str_register_date ?>no_days ?>doc_name ?>admit_type ?>
Org_Status ?>
M:med_amount ?>
IPD CodeName/Patient CodeRegister DateAdmit TypeAmount
+ +
+ +
+
+ + diff --git a/old_code_ci3/views/Medical_13062021/Medical_org_invoicelist.php b/old_code_ci3/views/Medical_13062021/Medical_org_invoicelist.php new file mode 100644 index 0000000..d9572ae --- /dev/null +++ b/old_code_ci3/views/Medical_13062021/Medical_org_invoicelist.php @@ -0,0 +1,97 @@ +
+
+ 'form','class'=>'form1')); ?> +
+
+
+
+
+

Name :p_fname?> {p_rname?>} + / Age :age?> + / Gender :xgender?> + / P Code :p_code?> + / Organisation Invoice #case_id_code?> + /Organisation :insurance_company_name?> +

+ + + +
+
+ +
+
+
+
+
+ + + + + + + + + + + + + '; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + $srno=$srno+1; + echo ''; + } + echo ''; + ?> + + + + + + + + + + + + + +
#Invoice ID.PatientInv.DateInv.DescCredit/CashAmountBalance
'.$srno.''.$row->inv_med_code.''.$row->inv_name.''.$row->inv_date.''.$row->remark_ipd.''.$row->credit.''.$row->net_amount.''.$row->payment_balance.' + + Print +
#
+
+
+
+
+ +
+
+ \ No newline at end of file diff --git a/old_code_ci3/views/Medical_13062021/Medical_org_list.php b/old_code_ci3/views/Medical_13062021/Medical_org_list.php new file mode 100644 index 0000000..22059a3 --- /dev/null +++ b/old_code_ci3/views/Medical_13062021/Medical_org_list.php @@ -0,0 +1,49 @@ +
+
+
+

ORG List

+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + +
ORG CodeName/Patient CodeRegister DateInsurance Company
+ + case_id_code ?> + + [p_code ?>] p_fname ?>
p_rname ?>
str_register_date ?>insurance_company_name ?>
ORG CodeName/Patient CodeRegister DateInsurance Company
+ +
+ +
+
+ + diff --git a/old_code_ci3/views/Medical_13062021/Medical_stock_drug.php b/old_code_ci3/views/Medical_13062021/Medical_stock_drug.php new file mode 100644 index 0000000..3c8afae --- /dev/null +++ b/old_code_ci3/views/Medical_13062021/Medical_stock_drug.php @@ -0,0 +1,116 @@ +
+
+
+

Drug Details

+
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
SS No.Item CodeItem NameFormulationRack No.Shelf No.Batch No.QtyExpiryMRPSaled Qty
+
+ +
+
+ + \ No newline at end of file diff --git a/old_code_ci3/views/Medical_13062021/Patient_Search_Result.php b/old_code_ci3/views/Medical_13062021/Patient_Search_Result.php new file mode 100644 index 0000000..03d062b --- /dev/null +++ b/old_code_ci3/views/Medical_13062021/Patient_Search_Result.php @@ -0,0 +1,49 @@ +

+
+
+

Result

+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Sr.No.Patient/UHID CodeName {Relative Name}AgeLast VisitPhone No.InsuranceAction
p_code ?>p_fname ?> {p_rname ?>}age ?>Last_Visit ?>mphone1 ?>insurance_id==0 ? 'Self': 'Insuranced'); ?> +
Patient CodeNamePhone NumberEMailAction
+
+ +
+ \ No newline at end of file diff --git a/old_code_ci3/views/Medical_13062021/Print/Medicine_List.php b/old_code_ci3/views/Medical_13062021/Print/Medicine_List.php new file mode 100644 index 0000000..a8aedaa --- /dev/null +++ b/old_code_ci3/views/Medical_13062021/Print/Medicine_List.php @@ -0,0 +1,86 @@ + + + + + + + + + + + +
Page : {PAGENO}/{nbpg}IPD-ID:ipd_code ?> / UHID:p_code ?> /Name : p_fname ?>
+
+ + + + + + + + +
+

Medicine Prescription

+

Rx

+ Patient Info.
+ p_fname ?>
+ UHID ID : p_code ?>
+ IPD Code : ipd_code ?>
+

+
+ + + str_inv_date<>$inv_date){ + if(($srno % 3)==2 ) + { + echo ''; + }elseif(($srno % 3)==0){ + echo ''; + } + + $srno=1; + echo ' + + '; + echo ''; + } + + if(($srno % 3)==1) + { + echo ''; + } + + echo ''; + + if(($srno % 3)==0){ + echo ''; + } + + $inv_date=$row->str_inv_date; + } + ?> +

Dated : ' + .$row->str_inv_date.'
'.$srno.' : ' + .$row->item_Name.' '.$row->formulation. ' /Qty :' + .$row->qty.'
+

+ +

diff --git a/old_code_ci3/views/Medical_13062021/Print/medical_bill_print_a6.php b/old_code_ci3/views/Medical_13062021/Print/medical_bill_print_a6.php new file mode 100644 index 0000000..5dcb1d4 --- /dev/null +++ b/old_code_ci3/views/Medical_13062021/Print/medical_bill_print_a6.php @@ -0,0 +1,190 @@ + + + + + + + + + + + +

+

, Uttarakhand
+ '; + + if(H_Med_GST!='') + { + echo 'GST: '.H_Med_GST .''; + } + + if(M_LIC!='') + { + echo ' L.No: '.M_LIC; + } + ?> +

+

+ Invoice To : + inv_name?>
+ customer_type==0) { ?> + Phone No. : inv_phone_number?>
+ doc_name!=''){ ?> + Refer By : Dr. doc_name ?>
+ + + customer_type==1 && count($patient_master)>0) { ?> + Patient Info. as per Hospital Records
+ UHID ID : p_code ?>
+ + ipd_id>0) { ?> + IPD Code : ipd_code ?>
+ Refer By : doc_name ?>
+ case_id>0 && $ipd_master[0]->case_id<>'') { ?> + Org. Code : case_id_code ?>
+ Org. Name : insurance_company_name ?>
+ + case_credit==1 && $invoice_med_master[0]->case_id>0) { ?> + Org. Code : case_id_code ?>
+ Org. Name : insurance_company_name ?>
+ +

+
+

TAX Invoice

+
+ + + + + + +
Page : {PAGENO}/{nbpg}Invoice No.:inv_med_code ?> / Name : inv_name ?>
+
+ + + '; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + } + + $srno=$srno+1; + $head_start=$head_start+1; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + + echo ''; + } + + if(count($invoice_med_master)>0) { + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + } + ?> +
Invoice ID : '.$row->inv_med_code.' [Dated : '.$row->str_inv_date.']
#Item NameBatch NoExp.RateQty.Gross AmtDisc.Net Amt
'.$srno.''.$row->item_Name.' '.$row->formulation.''.$row->batch_no.''.$row->expiry.''.$row->price.''.$row->qty.''.$row->amount.''.$row->d_amt.''.$row->twdisc_amount.'
#Total '.$invoice_med_master[0]->gross_amount.' '.$invoice_med_master[0]->inv_disc_total.' '.round($invoice_med_master[0]->net_amount).'
+ +0) { ?> +
+ + + + + + + + payment_balance>=0 ){ ?> + + + + + + + + + + + payment_balance>=0 ){ ?> + + + + +
#CGSTSGSTTaxable AmountNet AmountAmount receivedBalance Amount
#CGST_Tamount?>SGST_Tamount?>TaxableAmount?>net_amount),2)?>payment_received?>payment_balance?>
+
+ + + + + + + + + + +
+ Payment Details [Payment No.:Mode of Payment:Amount:Date]: + id.':'.$row->Payment_type_str.':'.$row->amount.':'.$row->payment_date.']/'; + } + ?> + +
+

+
+ For +
diff --git a/old_code_ci3/views/Medical_13062021/Print/medical_bill_print_format.php b/old_code_ci3/views/Medical_13062021/Print/medical_bill_print_format.php new file mode 100644 index 0000000..67bea67 --- /dev/null +++ b/old_code_ci3/views/Medical_13062021/Print/medical_bill_print_format.php @@ -0,0 +1,191 @@ + + + + + + + + +
+

+

, Uttarakhand
+ '; + + if(H_Med_GST!='') + { + echo 'GST: '.H_Med_GST .''; + } + + if(M_LIC!='') + { + echo ' L.No: '.M_LIC; + } + ?> +

+ +

+ Invoice To : + p_fname ?>
+ Patient Info. as per Hospital Records
+ UHID ID : p_code ?>
+ IPD Code : ipd_code ?>
+ Refer By : doc_name ?>
+ org_id>0) { ?> + Org. Code : case_id_code ?>
+ Org. Name : insurance_company_name ?>
+ +

+
+

TAX Invoice

+
+ + + + + + +
Page : {PAGENO}/{nbpg}IPD-ID:ipd_code ?> / UHID:p_code ?> /Name : p_fname ?>
+
+ + id=='' && $row->inv_med_id != '') + { + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + + $head_start=0; + } + elseif($row->id=='' && $row->inv_med_id == ''){ + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + }else{ + + if($head_start==0) + { + echo ' + '; + + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + } + + $srno=$srno+1; + $head_start=$head_start+1; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + } + } + ?> +
#Invoice Total :'.$row->inv_med_code.''.$row->amount.''.$row->d_amt.''.$row->gst.''.$row->twdisc_amount.'

#Grand Total'.$row->amount.''.$row->d_amt.''.$row->gst.''.$row->twdisc_amount.'

Invoice ID : '.$row->inv_med_code.' [Dated : '.$row->str_inv_date.']
#Item NameBatch NoExp.RateQty.PriceDisc.HSNCODE/GSTGSTAmount
'.$srno.''.$row->item_Name.' '.$row->formulation.''.$row->batch_no.''.$row->expiry.''.$row->price.''.$row->qty.''.$row->amount.''.$row->d_amt.''.$row->HSNCODE.'/'.$row->gst_per.''.$row->gst.''.$row->twdisc_amount.'
+ +0) { ?> +
+ + + + + + + + + payment_balance>=0 ){ ?> + + + + + + + + + + + + payment_balance>=0 ){ ?> + + + + +
#Deduction CGSTSGSTTaxable AmountNet AmountAmount receivedBalance Amount
#discount_group?>CGST_Tamount?>SGST_Tamount?>TaxableAmount?>net_amount),2)?>payment_received?>payment_balance?>
+
+ +

+ + + + +
+ Payment Details [Payment No.:Mode of Payment:Amount]: + id.':'.$row->Payment_type_str.':'.$row->amount.']/'; + } + ?> + + + For +
diff --git a/old_code_ci3/views/Medical_13062021/Print/medical_bill_print_format_newpage.php b/old_code_ci3/views/Medical_13062021/Print/medical_bill_print_format_newpage.php new file mode 100644 index 0000000..9e95100 --- /dev/null +++ b/old_code_ci3/views/Medical_13062021/Print/medical_bill_print_format_newpage.php @@ -0,0 +1,145 @@ + + + + + + + + +
+

+

, Uttarakhand
+ '; + + if(H_Med_GST!='') + { + echo 'GST: '.H_Med_GST .''; + } + + if(M_LIC!='') + { + echo ' L.No: '.M_LIC; + } + ?> +

+ Invoice To : + p_fname ?>
+

+ Patient Info. as per KHRC Records
+ UHID ID : p_code ?>
+ IPD Code : ipd_code ?>
+ Refer By : doc_name ?>
+ org_id>0) { ?> + Org. Code : case_id_code ?>
+ Org. Name : insurance_company_name ?>
+ +

+
+

CASH / Credit Memo

+
+ + + + + + +
IPD-ID:ipd_code ?> / UHID:p_code ?> /Name : p_fname ?>
+
+ + id=='' && $row->inv_med_id != '') + { + echo ''; + echo '#'; + echo 'Invoice Total :'.$row->inv_med_code.''; + echo ''.$row->amount.''; + echo ''.$row->d_amt.''; + echo ''; + echo ''.$row->gst.''; + echo ''.$row->twdisc_amount.''; + echo ''; + echo ''; + echo ''; + + $head_start=0; + } + elseif($row->id=='' && $row->inv_med_id == ''){ + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo '

#Grand Total'.$row->amount.''.$row->d_amt.''.$row->gst.''.$row->twdisc_amount.'
'; + }else{ + + if($head_start==0) + { + echo ''; + + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + } + + $srno=$srno+1; + $head_start=$head_start+1; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + } + } + ?> +

diff --git a/old_code_ci3/views/Medical_13062021/Print/medical_bill_print_format_single.php b/old_code_ci3/views/Medical_13062021/Print/medical_bill_print_format_single.php new file mode 100644 index 0000000..c34e44a --- /dev/null +++ b/old_code_ci3/views/Medical_13062021/Print/medical_bill_print_format_single.php @@ -0,0 +1,184 @@ + + + +

Invoice ID : '.$row->inv_med_code.' [Dated : '.$row->str_inv_date.']

#Item NameBatch NoExp.RateQty.PriceDisc.HSNCODE/GSTGSTAmount
'.$srno.''.$row->item_Name.' '.$row->formulation.''.$row->batch_no.''.$row->expiry.''.$row->price.''.$row->qty.''.$row->amount.''.$row->d_amt.''.$row->HSNCODE.'/'.$row->gst_per.''.$row->gst.''.$row->twdisc_amount.'
+ + + + +
+

+

, Uttarakhand
+ '; + + if(H_Med_GST!='') + { + echo 'GST: '.H_Med_GST .''; + } + + if(M_LIC!='') + { + echo ' L.No: '.M_LIC; + } + ?> +

+

+ Invoice To : + inv_name?>
+ customer_type==0) { ?> + Phone No. : inv_phone_number?>
+ doc_name<>''){ ?> + Refer By : Dr. doc_name ?>
+ + + customer_type==1 && count($patient_master)>0) { ?> + Patient Info. as per Hospital Records
+ UHID ID : p_code ?>
+ + ipd_id>0) { ?> + IPD Code : ipd_code ?>
+ Refer By : doc_name ?>
+ case_id>0 && $ipd_master[0]->case_id<>'') { ?> + Org. Code : case_id_code ?>
+ Org. Name : insurance_company_name ?>
+ + case_credit==1 && $invoice_med_master[0]->case_id>0) { ?> + Org. Code : case_id_code ?>
+ Org. Name : insurance_company_name ?>
+ +

+
+

TAX Invoice

+ + + + + + + +
Page : {PAGENO}/{nbpg}Invoice No.:inv_med_code ?> / Name : inv_name ?>
+
+ + '; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + } + + $srno=$srno+1; + $head_start=$head_start+1; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + } + + if(count($invoice_med_master)>0) { + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + } + ?> +
Invoice ID : '.$row->inv_med_code.' [Dated : '.$row->str_inv_date.']
#Item NameBatch NoExp.RateQty.Gross AmtDisc.HSNCODE/GSTGSTNet Amt
'.$srno.''.$row->item_Name.' '.$row->formulation.''.$row->batch_no.''.$row->expiry.''.$row->price.''.$row->qty.''.$row->amount.''.$row->d_amt.''.$row->HSNCODE.'/'.$row->gst_per.''.$row->gst.''.$row->twdisc_amount.'
#Total'.$invoice_med_master[0]->gross_amount.''.$invoice_med_master[0]->inv_disc_total.''.$invoice_med_master[0]->TGST.''.number_format(round($invoice_med_master[0]->net_amount),2).'
+ +0) { ?> +
+ + + + + + + + + payment_balance>=0 ){ ?> + + + + + + + + + + + payment_balance>=0 ){ ?> + + + + +
#CGSTSGSTTaxable AmountNet AmountAmount receivedBalance Amount
#CGST_Tamount?>SGST_Tamount?>TaxableAmount?>net_amount),2)?>payment_received?>payment_balance?>
+
+ +

+ + + + +
+ Payment Details [Payment No.:Mode of Payment:Amount:Date]: + id.':'.$row->Payment_type_str.':'.$row->amount.':'.$row->payment_date.']/'; + } + ?> + + + For +
diff --git a/old_code_ci3/views/Medical_13062021/Purchase/Company_Edit.php b/old_code_ci3/views/Medical_13062021/Purchase/Company_Edit.php new file mode 100644 index 0000000..89cdbf2 --- /dev/null +++ b/old_code_ci3/views/Medical_13062021/Purchase/Company_Edit.php @@ -0,0 +1,76 @@ +
+
+

Supplier

+
+
+ 'form','class'=>'form1')); ?> + 0) + { + $cid=$med_company[0]->id; + $company_name=$med_company[0]->company_name; + $contact_person_name=$med_company[0]->contact_person_name; + $contact_phone_no=$med_company[0]->contact_phone_no; + } + + ?> + +
+
+
+ + +
+
+
+
+ + +
+
+
+
+
+
+ + +
+
+
+
+
+
+ + +
+
+
+ +
+
+ \ No newline at end of file diff --git a/old_code_ci3/views/Medical_13062021/Purchase/Purchase_Invoice_Edit.php b/old_code_ci3/views/Medical_13062021/Purchase/Purchase_Invoice_Edit.php new file mode 100644 index 0000000..62f88fc --- /dev/null +++ b/old_code_ci3/views/Medical_13062021/Purchase/Purchase_Invoice_Edit.php @@ -0,0 +1,488 @@ +
+
+
+
+
+

Purchase Invoice Information

+ Supplier: | name_supplier ?> + |Invoice No.: Invoice_no ?> | + Invoice Date : str_date_of_invoice ?> + + +
+
+ 'form','class'=>'form2')); ?> +
+ +
+ +
+
+
+ + + \ No newline at end of file diff --git a/old_code_ci3/views/Medical_13062021/Purchase/Supplier_Edit.php b/old_code_ci3/views/Medical_13062021/Purchase/Supplier_Edit.php new file mode 100644 index 0000000..39592ea --- /dev/null +++ b/old_code_ci3/views/Medical_13062021/Purchase/Supplier_Edit.php @@ -0,0 +1,111 @@ + + +
+
+

Supplier

+
+
+ 'form','class'=>'form1')); ?> + 0) + { + $sid=$supplier_data[0]->sid; + $name_supplier=$supplier_data[0]->name_supplier; + $short_name=$supplier_data[0]->short_name; + $contact_no=$supplier_data[0]->contact_no; + $gst_no=$supplier_data[0]->gst_no; + $city=$supplier_data[0]->city; + $state=$supplier_data[0]->state; + } + + ?> + +
+
+
+ + +
+
+
+
+ + +
+
+
+
+
+
+ + +
+
+
+
+ + +
+
+
+
+
+
+ + +
+
+
+
+ + +
+
+
+
+
+
+ + +
+
+
+ +
+
+ \ No newline at end of file diff --git a/old_code_ci3/views/Medical_13062021/Purchase/Supplier_account.php b/old_code_ci3/views/Medical_13062021/Purchase/Supplier_account.php new file mode 100644 index 0000000..4927222 --- /dev/null +++ b/old_code_ci3/views/Medical_13062021/Purchase/Supplier_account.php @@ -0,0 +1,58 @@ +
+

+ Supplier +

+
+
+
+
+
+
+

Supplier List

+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameBalanceLast Inv. DateLast Payment Date
name_supplier ?>Tot_Balance ?>Last_InvDate ?>Last_Payment ?> + +
NameBalanceLast Inv. DateLast Payment Date
+ +
+ +
+
+
+
+ + \ No newline at end of file diff --git a/old_code_ci3/views/Medical_13062021/Purchase/Supplier_account_detail.php b/old_code_ci3/views/Medical_13062021/Purchase/Supplier_account_detail.php new file mode 100644 index 0000000..1479d86 --- /dev/null +++ b/old_code_ci3/views/Medical_13062021/Purchase/Supplier_account_detail.php @@ -0,0 +1,90 @@ +
+
+
+
+

Ledger Account : name_supplier?> + Balance : Tot_Balance?>

+ +
+
+ 'form_search'); + echo form_open('/Medical_backpanel/search_result_tran/'.$supplier_data[0]->sid,$attributes); ?> +
+
+ +
+   + +
+ +
+
+ +
+ +
+
+
+ +
+
+
+
+
+
+
+
+
+ \ No newline at end of file diff --git a/old_code_ci3/views/Medical_13062021/Purchase/Supplier_master.php b/old_code_ci3/views/Medical_13062021/Purchase/Supplier_master.php new file mode 100644 index 0000000..cf435c1 --- /dev/null +++ b/old_code_ci3/views/Medical_13062021/Purchase/Supplier_master.php @@ -0,0 +1,60 @@ +
+

+ Supplier +

+
+
+
+
+
+
+ +

Supplier List

+
+
+
+ +
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + +
NameGSTAction
name_supplier ?>gst_no ?> + +
NameGSTAction
+ +
+ +
+
+
+ +
+
+
+ + \ No newline at end of file diff --git a/old_code_ci3/views/Medical_13062021/Purchase/Supplier_master_sub.php b/old_code_ci3/views/Medical_13062021/Purchase/Supplier_master_sub.php new file mode 100644 index 0000000..a5551df --- /dev/null +++ b/old_code_ci3/views/Medical_13062021/Purchase/Supplier_master_sub.php @@ -0,0 +1,30 @@ + + + + + + + + + + + + + + + + + + + + + + + + +
NameGSTAction
name_supplier ?>name_supplier ?> + +
NameGSTAction
+ \ No newline at end of file diff --git a/old_code_ci3/views/Medical_13062021/Purchase/company_list.php b/old_code_ci3/views/Medical_13062021/Purchase/company_list.php new file mode 100644 index 0000000..877d442 --- /dev/null +++ b/old_code_ci3/views/Medical_13062021/Purchase/company_list.php @@ -0,0 +1,60 @@ +
+

+ Company +

+
+
+
+
+
+
+ +

Company List

+
+
+
+ +
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + +
Company NamePerson/PhoneAction
company_name ?>contact_person_name ?>/contact_phone_no ?> + +
Company NamePerson/PhoneAction
+ +
+ +
+
+
+ +
+
+ +
+ \ No newline at end of file diff --git a/old_code_ci3/views/Medical_13062021/Purchase/company_list_sub.php b/old_code_ci3/views/Medical_13062021/Purchase/company_list_sub.php new file mode 100644 index 0000000..1deb7e1 --- /dev/null +++ b/old_code_ci3/views/Medical_13062021/Purchase/company_list_sub.php @@ -0,0 +1,27 @@ + + + + + + + + + + + + + + + + + + + + + + + + +
Company NamePerson/PhoneAction
company_name ?>contact_person_name ?>/contact_phone_no ?> + +
NameGSTAction
\ No newline at end of file diff --git a/old_code_ci3/views/Medical_13062021/Purchase/drug_master_list.php b/old_code_ci3/views/Medical_13062021/Purchase/drug_master_list.php new file mode 100644 index 0000000..9479269 --- /dev/null +++ b/old_code_ci3/views/Medical_13062021/Purchase/drug_master_list.php @@ -0,0 +1,30 @@ +
+ +'form','class'=>'form2')); ?> +
+ + + + + + + + + + +
+ +
+
+ \ No newline at end of file diff --git a/old_code_ci3/views/Medical_13062021/Purchase/indent_req_list.php b/old_code_ci3/views/Medical_13062021/Purchase/indent_req_list.php new file mode 100644 index 0000000..5fefe5e --- /dev/null +++ b/old_code_ci3/views/Medical_13062021/Purchase/indent_req_list.php @@ -0,0 +1,30 @@ +
+ +'form','class'=>'form2')); ?> +
+ + + + + + + + + + +
+ +
+
+ \ No newline at end of file diff --git a/old_code_ci3/views/Medical_13062021/Purchase/indent_req_list_search.php b/old_code_ci3/views/Medical_13062021/Purchase/indent_req_list_search.php new file mode 100644 index 0000000..e970c0a --- /dev/null +++ b/old_code_ci3/views/Medical_13062021/Purchase/indent_req_list_search.php @@ -0,0 +1,57 @@ +
+
+
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Indent IDReq. TypeDateProduct ListStatus
indent_code ?>indent_request_type_str ?>created_date ?>product_list ?>request_status_str?> + request_status==0) { ?> + + request_status==1) { ?> + + request_status==4) { ?> + + + + +
Indent IDStoreDateStatus
+ +
+
+
+ + \ No newline at end of file diff --git a/old_code_ci3/views/Medical_13062021/Purchase/indent_request_edit.php b/old_code_ci3/views/Medical_13062021/Purchase/indent_request_edit.php new file mode 100644 index 0000000..0f64ee9 --- /dev/null +++ b/old_code_ci3/views/Medical_13062021/Purchase/indent_request_edit.php @@ -0,0 +1,203 @@ +
+
+
+
+
+

Indent Request Information

+ Indent No.: indent_code ?> | + Indent Date & Time : created_date ?> + Indent Current Status : request_status] ?> + request_status==0){ ?> + + request_status==1){ ?> + + + +
+
+
+
+ +
+
+
+ + \ No newline at end of file diff --git a/old_code_ci3/views/Medical_13062021/Purchase/indent_request_item_list.php b/old_code_ci3/views/Medical_13062021/Purchase/indent_request_item_list.php new file mode 100644 index 0000000..4ee64b2 --- /dev/null +++ b/old_code_ci3/views/Medical_13062021/Purchase/indent_request_item_list.php @@ -0,0 +1,43 @@ + + + + + + + + + + + + '; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + } + echo ''; + ?> + + + + + + + + + + + + +
#Product CodeItem NameFormulationGeneric NameQty.Min Qty
'.$srno.''.$row->item_name.''.$row->formulation.''.$row->genericname.''.$row->request_qty.''.$row->min_requirement.' + +
#Product CodeItem NameFormulationGeneric NameQty.Min Qty
\ No newline at end of file diff --git a/old_code_ci3/views/Medical_13062021/Purchase/indent_request_view.php b/old_code_ci3/views/Medical_13062021/Purchase/indent_request_view.php new file mode 100644 index 0000000..291e9b3 --- /dev/null +++ b/old_code_ci3/views/Medical_13062021/Purchase/indent_request_view.php @@ -0,0 +1,60 @@ +
+
+
+
+
+

Indent Request Information

+ Indent No.: indent_code ?> | + Indent Date & Time : created_date ?> + Indent Current Status : request_status] ?> + request_status==0){ ?> + + request_status==1){ ?> + + + +
+
+ + + + + + + + + + '; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + } + echo ''; + ?> + + + + + + + + + + +
#Item NameFormulationGeneric NameQty.Min Qty
'.$srno.''.$row->item_name.''.$row->formulation.''.$row->genericname.''.$row->request_qty.''.$row->min_requirement.'
#Item NameFormulationGeneric NameQty.Min Qty
+
+ +
+
+
diff --git a/old_code_ci3/views/Medical_13062021/Purchase/ledger_add_entry.php b/old_code_ci3/views/Medical_13062021/Purchase/ledger_add_entry.php new file mode 100644 index 0000000..8e3efe7 --- /dev/null +++ b/old_code_ci3/views/Medical_13062021/Purchase/ledger_add_entry.php @@ -0,0 +1,85 @@ +
+
+
+
+

Add Entry

+
+ +
+
+ 'myform_add_entry'); + echo form_open('Medical_backpanel/add_entry/'.$s_id,$attributes); ?> + +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+
+ +
+ +
+
+
+ +
+ +
+
+
+
+
+ +
+ +
+
+
+
+ + +
+
+
+ \ No newline at end of file diff --git a/old_code_ci3/views/Medical_13062021/Purchase/ledger_data.php b/old_code_ci3/views/Medical_13062021/Purchase/ledger_data.php new file mode 100644 index 0000000..b7f2dd6 --- /dev/null +++ b/old_code_ci3/views/Medical_13062021/Purchase/ledger_data.php @@ -0,0 +1,63 @@ +
+
+
+
+

Statement Details + Opening Balance : / Total Cr. : / Total Dr. : + / Closing Blance : + +

+
+ +
+
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
IDDate TranDescriptionCreditDebitActions
tran_date); ?>mode_desc.' '.$c->tran_desc; ?>credit_debit==0?$c->amount:''); ?>credit_debit==1?$c->amount:''); ?> + bank_id>1) { ?> + + +
IDDate TranDescriptionCreditDebitActions
+ +
+
+
+
diff --git a/old_code_ci3/views/Medical_13062021/Purchase/ledger_edit_entry.php b/old_code_ci3/views/Medical_13062021/Purchase/ledger_edit_entry.php new file mode 100644 index 0000000..98bd68b --- /dev/null +++ b/old_code_ci3/views/Medical_13062021/Purchase/ledger_edit_entry.php @@ -0,0 +1,87 @@ +
+
+
+
+

Edit Entry

+
+ +
+
+ 'myform_add_entry'); + echo form_open('Medical_backpanel/edit_entry/'.$tran_id,$attributes); ?> + +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+
+ +
+ +
+
+
+ +
+ +
+
+
+
+
+ +
+ +
+
+
+
+ + +
+
+
+ \ No newline at end of file diff --git a/old_code_ci3/views/Medical_13062021/Purchase/new_indent_request.php b/old_code_ci3/views/Medical_13062021/Purchase/new_indent_request.php new file mode 100644 index 0000000..e75aff1 --- /dev/null +++ b/old_code_ci3/views/Medical_13062021/Purchase/new_indent_request.php @@ -0,0 +1,56 @@ +
+
+
+
+
+
+

New Purchase Invoice

+
+
+ 'form','class'=>'form1')); ?> + +
+
+
+ + +
+
+
+ +
+
+ +
+
+
+
+ \ No newline at end of file diff --git a/old_code_ci3/views/Medical_13062021/Purchase/new_purchase_invoice.php b/old_code_ci3/views/Medical_13062021/Purchase/new_purchase_invoice.php new file mode 100644 index 0000000..ff5d56b --- /dev/null +++ b/old_code_ci3/views/Medical_13062021/Purchase/new_purchase_invoice.php @@ -0,0 +1,69 @@ +
+
+
+
+
+
+

New Purchase Invoice

+
+
+ 'form','class'=>'form1')); ?> +
+
+
+ + +
+
+
+
+ + +
+
+
+ +
+
+ +
+ +
+
+
+ +
+
+ +
+
+
+
+ \ No newline at end of file diff --git a/old_code_ci3/views/Medical_13062021/Purchase/product_edit.php b/old_code_ci3/views/Medical_13062021/Purchase/product_edit.php new file mode 100644 index 0000000..7684f6b --- /dev/null +++ b/old_code_ci3/views/Medical_13062021/Purchase/product_edit.php @@ -0,0 +1,313 @@ +
+
+
+ 'form','class'=>'form1')); ?> +
+
+

Product

+ item_name?> +
+
+ + +
+
+
+
+ + +
+
+
+
+
+
+
+
+
+ + +
+
+
+
+
+
+ + +
+
+
+
+
+ + +
+
+
+
+ + +
+
+
+
+ + +
+
+ ban_flag_id; + if($chk_ban_flag_id==1) + { + $chk_ban_flag_id_checkbox_checked="checked"; + }else{ + $chk_ban_flag_id_checkbox_checked=""; + } + + $chk_is_continue=$product_data[0]->is_continue; + if($chk_is_continue==1) + { + $chk_is_continue_checkbox_checked="checked"; + }else{ + $chk_is_continue_checkbox_checked=""; + } + + $chk_batch_applicable=$product_data[0]->batch_applicable; + if($chk_batch_applicable==1) + { + $chk_batch_applicable_checkbox_checked="checked"; + }else{ + $chk_batch_applicable_checkbox_checked=""; + } + + $chk_exp_date_applicable=$product_data[0]->exp_date_applicable; + if($chk_exp_date_applicable==1) + { + $chk_exp_date_applicable="checked"; + }else{ + $chk_exp_date_applicable=""; + } + + $chk_schedule_h=$product_data[0]->schedule_h; + if($chk_schedule_h==1) + { + $chk_schedule_h_checkbox_checked="checked"; + }else{ + $chk_schedule_h_checkbox_checked=""; + } + + $chk_schedule_h1=$product_data[0]->schedule_h1; + if($chk_schedule_h1==1) + { + $chk_schedule_h1_checkbox_checked="checked"; + }else{ + $chk_schedule_h1_checkbox_checked=""; + } + + $chk_narcotic=$product_data[0]->narcotic; + if($chk_narcotic==1) + { + $chk_narcotic_checkbox_checked="checked"; + }else{ + $chk_narcotic_checkbox_checked=""; + } + + ?> +
+
+ +
+
+
+
+ + +
+
+
+
+ + +
+
+ +
+
+ + +
+
+
+
+ + +
+
+
+
+ + +
+
+
+
+ + +
+
+
+ +
+ +
+
+
+
+ +
+ +
+
+ + \ No newline at end of file diff --git a/old_code_ci3/views/Medical_13062021/Purchase/product_new.php b/old_code_ci3/views/Medical_13062021/Purchase/product_new.php new file mode 100644 index 0000000..f85794c --- /dev/null +++ b/old_code_ci3/views/Medical_13062021/Purchase/product_new.php @@ -0,0 +1,247 @@ +
+
+
+ 'form','class'=>'form1')); ?> +
+
+

Product

+ New Product +
+
+ + +
+
+
+
+ + +
+
+
+
+
+
+ + +
+
+
+
+
+
+
+
+ + +
+
+
+
+
+ + +
+
+
+
+ + +
+
+
+
+ + +
+
+
+
+
+
+ + +
+
+
+
+ + +
+
+
+
+ + +
+
+
+
+ +
+
+ + +
+
+
+
+ + +
+
+
+
+ + +
+
+
+ +
+ +
+
+
+
+ +
+ +
+
+ + \ No newline at end of file diff --git a/old_code_ci3/views/Medical_13062021/Purchase/product_search_result.php b/old_code_ci3/views/Medical_13062021/Purchase/product_search_result.php new file mode 100644 index 0000000..ee5cb78 --- /dev/null +++ b/old_code_ci3/views/Medical_13062021/Purchase/product_search_result.php @@ -0,0 +1,48 @@ +
+
+
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameFormulationGeneric NamePacking Type
item_name ?>formulation ?>genericname ?>packing ?> + + +
NameFormulationGeneric NamePacking Type
+ +
+
+
+ + \ No newline at end of file diff --git a/old_code_ci3/views/Medical_13062021/Purchase/purchase_invoice_item.php b/old_code_ci3/views/Medical_13062021/Purchase/purchase_invoice_item.php new file mode 100644 index 0000000..ee8fc7b --- /dev/null +++ b/old_code_ci3/views/Medical_13062021/Purchase/purchase_invoice_item.php @@ -0,0 +1,72 @@ + + + + + + + + + + + + + + + + + + item_return==1) + { + $style='style="color:Red;"'; + }else{ + $style=''; + } + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + } + echo ''; + ?> + + + + + + + + + + + + + + + + + + +
#Item NameBatch NoExp.MRPQty.RateAmountDisc.Tax AmountCGSTSGSTNet Amount
'.$srno.''.$row->Item_name.''.$row->batch_no.''.$row->exp_date_str.''.$row->mrp.''.floatval($row->qty).'+'.floatval($row->qty_free).''.$row->purchase_price.''.$row->amount.''.$row->discount.''.$row->taxable_amount.''.$row->CGST_per.''.$row->SGST_per.''.$row->net_amount.''; + if($purchase_invoice[0]->inv_status==0) + { + echo ' + '; + } + echo '
#Taxable_Amt ?>CGST_Amt ?>SGST_Amt ?>T_Net_Amount ?>
\ No newline at end of file diff --git a/old_code_ci3/views/Medical_13062021/Purchase/purchase_invoice_master_edit.php b/old_code_ci3/views/Medical_13062021/Purchase/purchase_invoice_master_edit.php new file mode 100644 index 0000000..845604a --- /dev/null +++ b/old_code_ci3/views/Medical_13062021/Purchase/purchase_invoice_master_edit.php @@ -0,0 +1,226 @@ +
+
+
+
+
+
+ 'form','class'=>'form1')); ?> + + inv_status==0){ ?> +
+
+
+ + +
+
+
+
+ + +
+
+
+ +
+
+ +
+ +
+
+
+ +
+
+ +
+
+ +
name_supplier?>
+
+
+
+
+ +
Invoice_no?>
+
+
+
+ +
date_of_invoice)?>
+ +
+ + +
+
+ + + + + + + + + + + + + + + + + item_return==1) + { + $style='style="color:Red;"'; + }else{ + $style=''; + } + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + } + echo ''; + ?> + + + + + + + + + + + + + + + + + +
#Item NameBatch NoExp.MRPQty.RateAmountDisc.Tax AmountCGSTSGSTNet Amount
'.$srno.''.$row->Item_name.''.$row->batch_no.''.$row->expiry_date.''.$row->mrp.''.floatval($row->qty).'+'.floatval($row->qty_free).''.$row->purchase_price.''.$row->amount.''.$row->discount.''.$row->taxable_amount.''.$row->CGST_per.''.$row->SGST_per.''.$row->net_amount.'
#Taxable_Amt ?>CGST_Amt ?>SGST_Amt ?>T_Net_Amount ?>
+
+ +
+
+
+ \ No newline at end of file diff --git a/old_code_ci3/views/Medical_13062021/Purchase/purchase_item_old.php b/old_code_ci3/views/Medical_13062021/Purchase/purchase_item_old.php new file mode 100644 index 0000000..2fcb615 --- /dev/null +++ b/old_code_ci3/views/Medical_13062021/Purchase/purchase_item_old.php @@ -0,0 +1,31 @@ +

Last 5 Purchase Orders

+ + + + + + + + + + + '; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + } + echo ''; + ?> + +
#Item NameDateMRPQtyRateSupplier
'.$srno.''.$row->Item_name.''.$row->date_of_invoice_str.''.$row->mrp.''.floatval($row->qty).'+'.floatval($row->qty_free).''.$row->purchase_price.''.$row->name_supplier.'
\ No newline at end of file diff --git a/old_code_ci3/views/Medical_13062021/Purchase/purchase_supp_list.php b/old_code_ci3/views/Medical_13062021/Purchase/purchase_supp_list.php new file mode 100644 index 0000000..235e74e --- /dev/null +++ b/old_code_ci3/views/Medical_13062021/Purchase/purchase_supp_list.php @@ -0,0 +1,66 @@ +
+
+
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Invoice IDSupplierDateAmount
Invoice_no ?>name_supplier ?>date_of_invoice ?>tamount ?> + + tamount==0){ ?> + + +
Invoice IDSupplierDateAmount
+ +
+
+
+ + \ No newline at end of file diff --git a/old_code_ci3/views/Medical_13062021/Purchase/supplier_list.php b/old_code_ci3/views/Medical_13062021/Purchase/supplier_list.php new file mode 100644 index 0000000..734a017 --- /dev/null +++ b/old_code_ci3/views/Medical_13062021/Purchase/supplier_list.php @@ -0,0 +1,30 @@ +
+ +'form','class'=>'form2')); ?> +
+ + + + + + + + + + +
+ +
+
+ \ No newline at end of file diff --git a/old_code_ci3/views/Medical_13062021/Purchase_Invoice_Edit.php b/old_code_ci3/views/Medical_13062021/Purchase_Invoice_Edit.php new file mode 100644 index 0000000..0d1e1eb --- /dev/null +++ b/old_code_ci3/views/Medical_13062021/Purchase_Invoice_Edit.php @@ -0,0 +1,386 @@ +
+
+
+
+
+

Purchase Invoice Information

+ Supplier: | name_supplier ?> + |Invoice No.: Invoice_no ?> | + Invoice Date : str_date_of_invoice ?> + +
+
+
+
+ +
+
+
+ + \ No newline at end of file diff --git a/old_code_ci3/views/Medical_13062021/Report/IPD_Discharge_Report.php b/old_code_ci3/views/Medical_13062021/Report/IPD_Discharge_Report.php new file mode 100644 index 0000000..35134dc --- /dev/null +++ b/old_code_ci3/views/Medical_13062021/Report/IPD_Discharge_Report.php @@ -0,0 +1,79 @@ +
+

+ IPD Discharge Report + Panel +

+
+
+
+
+ +
+   + +
+ +
+
+ +
+ + +
+
+
+
+
+
+
+
+
+ \ No newline at end of file diff --git a/old_code_ci3/views/Medical_13062021/Report/Med_Payment_Recevie.php b/old_code_ci3/views/Medical_13062021/Report/Med_Payment_Recevie.php new file mode 100644 index 0000000..af60099 --- /dev/null +++ b/old_code_ci3/views/Medical_13062021/Report/Med_Payment_Recevie.php @@ -0,0 +1,105 @@ +
+

+ Daily Payment Report +

+
+
+
+
+ +
+   + +
+ +
+
+ + +
+
+ +
+ + +
+
+
+ +
+
+
+
+
+
+ \ No newline at end of file diff --git a/old_code_ci3/views/Medical_13062021/Report/Med_Report_1.php b/old_code_ci3/views/Medical_13062021/Report/Med_Report_1.php new file mode 100644 index 0000000..5445f11 --- /dev/null +++ b/old_code_ci3/views/Medical_13062021/Report/Med_Report_1.php @@ -0,0 +1,80 @@ +
+

+ Daily Sale Report +

+
+
+
+
+ +
+   + +
+ +
+
+ +
+ + +
+
+
+ +
+
+
+
+
+
+ \ No newline at end of file diff --git a/old_code_ci3/views/Medical_13062021/Report/Med_Report_2.php b/old_code_ci3/views/Medical_13062021/Report/Med_Report_2.php new file mode 100644 index 0000000..5a5fdbb --- /dev/null +++ b/old_code_ci3/views/Medical_13062021/Report/Med_Report_2.php @@ -0,0 +1,68 @@ +
+

+ Day Cash Payment Report + Panel +

+
+
+
+
+ + +
+
+ + +
+
+ +
+ + +
+
+
+
+
+
+
+
+
+ \ No newline at end of file diff --git a/old_code_ci3/views/Medical_13062021/Report/Med_Report_2_Pending.php b/old_code_ci3/views/Medical_13062021/Report/Med_Report_2_Pending.php new file mode 100644 index 0000000..c4bb772 --- /dev/null +++ b/old_code_ci3/views/Medical_13062021/Report/Med_Report_2_Pending.php @@ -0,0 +1,86 @@ +
+

+ Day OPD / Cash Invoice Pending Report + Panel +

+
+
+
+
+ +
+   + +
+ +
+
+ +
+ + +
+
+
+
+
+
+
+
+
+ \ No newline at end of file diff --git a/old_code_ci3/views/Medical_13062021/Report/Med_Report_2_Pending_paid.php b/old_code_ci3/views/Medical_13062021/Report/Med_Report_2_Pending_paid.php new file mode 100644 index 0000000..7573e2c --- /dev/null +++ b/old_code_ci3/views/Medical_13062021/Report/Med_Report_2_Pending_paid.php @@ -0,0 +1,51 @@ +
+

+ Old Invoice Payment Report + Panel +

+
+
+
+
+ + +
+
+ +
+ + +
+
+
+
+
+
+
+
+
+ \ No newline at end of file diff --git a/old_code_ci3/views/Medical_13062021/Report/Med_Report_3.php b/old_code_ci3/views/Medical_13062021/Report/Med_Report_3.php new file mode 100644 index 0000000..637ae44 --- /dev/null +++ b/old_code_ci3/views/Medical_13062021/Report/Med_Report_3.php @@ -0,0 +1,79 @@ +
+

+ GST Report + Panel +

+
+
+
+
+ +
+   + +
+ +
+
+ +
+ + +
+
+
+
+
+
+
+
+
+ \ No newline at end of file diff --git a/old_code_ci3/views/Medical_13062021/Report/Med_Report_4.php b/old_code_ci3/views/Medical_13062021/Report/Med_Report_4.php new file mode 100644 index 0000000..91fb7b4 --- /dev/null +++ b/old_code_ci3/views/Medical_13062021/Report/Med_Report_4.php @@ -0,0 +1,80 @@ +
+

+ IPD Invoice + Panel +

+
+
+
+
+ +
+   + +
+ +
+
+ +
+ + +
+
+
+
+
+
+
+
+
+ \ No newline at end of file diff --git a/old_code_ci3/views/Medical_13062021/Report/Med_Report_5.php b/old_code_ci3/views/Medical_13062021/Report/Med_Report_5.php new file mode 100644 index 0000000..73b2afe --- /dev/null +++ b/old_code_ci3/views/Medical_13062021/Report/Med_Report_5.php @@ -0,0 +1,80 @@ +
+

+ GST Invoice List + Panel +

+
+
+
+
+ +
+   + +
+ +
+
+ +
+ + +
+
+
+
+
+
+
+
+
+ \ No newline at end of file diff --git a/old_code_ci3/views/Medical_13062021/Report/Med_Report_IPD_Credit.php b/old_code_ci3/views/Medical_13062021/Report/Med_Report_IPD_Credit.php new file mode 100644 index 0000000..9e9e5ea --- /dev/null +++ b/old_code_ci3/views/Medical_13062021/Report/Med_Report_IPD_Credit.php @@ -0,0 +1,91 @@ +
+

+ IPD Invoice + Panel +

+
+
+
+
+ +
+   + +
+ +
+
+ + +
+
+ +
+ + +
+
+
+
+
+
+
+
+
+ \ No newline at end of file diff --git a/old_code_ci3/views/Medical_13062021/Report/Med_Report_company_med_sale.php b/old_code_ci3/views/Medical_13062021/Report/Med_Report_company_med_sale.php new file mode 100644 index 0000000..e5ef06d --- /dev/null +++ b/old_code_ci3/views/Medical_13062021/Report/Med_Report_company_med_sale.php @@ -0,0 +1,119 @@ +
+

+ Company Wise Medicine Sale / Purchase Report +

+
+
+
+
+ +
+   + +
+ +
+
+ +
+ +
+
+
+ +
+ + +
+
+
+ +
+ + +
+
+
+ +
+
+
+
+
+
+ \ No newline at end of file diff --git a/old_code_ci3/views/Medical_13062021/Report/Med_Report_daily_med_sale.php b/old_code_ci3/views/Medical_13062021/Report/Med_Report_daily_med_sale.php new file mode 100644 index 0000000..d6b9cb6 --- /dev/null +++ b/old_code_ci3/views/Medical_13062021/Report/Med_Report_daily_med_sale.php @@ -0,0 +1,79 @@ +
+

+ Daily Medicine Sale Report +

+
+
+
+
+ +
+   + +
+ +
+
+ +
+ + +
+
+
+ +
+
+
+
+
+
+ \ No newline at end of file diff --git a/old_code_ci3/views/Medical_13062021/Report/Purchase_Invoice.php b/old_code_ci3/views/Medical_13062021/Report/Purchase_Invoice.php new file mode 100644 index 0000000..5e78dd8 --- /dev/null +++ b/old_code_ci3/views/Medical_13062021/Report/Purchase_Invoice.php @@ -0,0 +1,94 @@ +
+

+ Report Purchase Invoice + Panel +

+
+
+
+
+ +
+   + +
+ +
+
+ + +
+
+ +
+ + +
+
+
+
+
+
+
+
+
+ \ No newline at end of file diff --git a/old_code_ci3/views/Medical_13062021/Report/Report_Med_patient.php b/old_code_ci3/views/Medical_13062021/Report/Report_Med_patient.php new file mode 100644 index 0000000..e946e40 --- /dev/null +++ b/old_code_ci3/views/Medical_13062021/Report/Report_Med_patient.php @@ -0,0 +1,88 @@ +
+

+ Report Drug Sale to Patient + Panel +

+
+
+'form','class'=>'form2')); ?> +
+
+ +
+   + +
+ +
+
+ + +
+
+ +
+ + +
+
+
+
+
+
+
+
+ +
+ \ No newline at end of file diff --git a/old_code_ci3/views/Medical_13062021/Report/Report_Med_patient_result.php b/old_code_ci3/views/Medical_13062021/Report/Report_Med_patient_result.php new file mode 100644 index 0000000..30ebf36 --- /dev/null +++ b/old_code_ci3/views/Medical_13062021/Report/Report_Med_patient_result.php @@ -0,0 +1,67 @@ +
+
+ + + + + + + + + + + + + + + + + + + + + +
Item NameSale Drug Report Customer Wise
+

item_Name ?>

+
+ p_list); + echo ' + + + + + + + + + '; + foreach ($data_array as $value) { + $value_array=explode(";",$value); + + if(count($value_array)<9) + { + echo ''; + echo ' '; + echo ''; + }else{ + echo ''; + echo ' '; + echo ' '; + echo ' '; + echo ' '; + echo ' '; + echo ' '; + echo ' '; + echo ''; + } + + } + echo '
Inv.No.Inv.DateIPD No.P Code/NameExp. DateBatchQty
Too many Records, Select min Date Range
'.$value_array[0].''.$value_array[1].''.$value_array[7].''.$value_array[4].' / '.$value_array[5].''.$value_array[2].''.$value_array[8].''.$value_array[9].'
'; + ?> +
Item NameStock Batch Invoice Status
+ +
+
diff --git a/old_code_ci3/views/Medical_13062021/Report/Report_org_invoice_list.php b/old_code_ci3/views/Medical_13062021/Report/Report_org_invoice_list.php new file mode 100644 index 0000000..c2ec7d6 --- /dev/null +++ b/old_code_ci3/views/Medical_13062021/Report/Report_org_invoice_list.php @@ -0,0 +1,96 @@ +
+

+ Org. Invoice + Panel +

+
+
+
+
+ +
+   + +
+ +
+
+
+ + +
+
+
+ +
+ + +
+
+
+
+
+
+
+
+
+ \ No newline at end of file diff --git a/old_code_ci3/views/Medical_13062021/Search_Patient.php b/old_code_ci3/views/Medical_13062021/Search_Patient.php new file mode 100644 index 0000000..8538815 --- /dev/null +++ b/old_code_ci3/views/Medical_13062021/Search_Patient.php @@ -0,0 +1,22 @@ +
+ 'form','class'=>'form2')); ?> +
+ + + + +
+ +
+
+ \ No newline at end of file diff --git a/old_code_ci3/views/Medical_13062021/Stock/Stock_search_qty_result.php b/old_code_ci3/views/Medical_13062021/Stock/Stock_search_qty_result.php new file mode 100644 index 0000000..3a3cbea --- /dev/null +++ b/old_code_ci3/views/Medical_13062021/Stock/Stock_search_qty_result.php @@ -0,0 +1,96 @@ + +
+
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Item NameSupplierSale Unit QtyCurrent Unit QtyRe-Order QtyAlert Qty
+

Item_name ?>

+
+

supplier_names ?>

+
+

sal_qty ?>

+
T_unit - $row->sal_qty; + echo $C_Qty; + ?> + + +

re_order_qty ?>

+
+ re_order_qty) + { + echo '

Qty Low

'; + } + + ?> + +
Item NameSupplierSale Unit QtyCurrent Unit QtyRe-Order QtyAlert Qty
+ +
+
+
+ + + \ No newline at end of file diff --git a/old_code_ci3/views/Medical_13062021/Stock/Stock_search_result.php b/old_code_ci3/views/Medical_13062021/Stock/Stock_search_result.php new file mode 100644 index 0000000..24ace19 --- /dev/null +++ b/old_code_ci3/views/Medical_13062021/Stock/Stock_search_result.php @@ -0,0 +1,120 @@ + +
+
+
+ + + + + + + + + + + + + + + + + + + + + +
Item NameStock Batch Invoice Status
+

Item_name ?>

+

Supplier :name_supplier ?>

+

Current Total Stock : Current_Stock ?>

+
+ Qty_BatchWise); + echo ' + + + + + + + + + + + + + + '; + foreach ($data_array as $value) { + $value_array=explode(";",$value); + + if($value_array[8]==1) + { + $style='style="color:Red;"'; + }else{ + $style=''; + } + + echo ''; + echo ' '; + echo ' '; + echo ' '; + echo ' '; + echo ' '; + echo ' '; + echo ' '; + echo ' '; + echo ' '; + echo ' '; + echo ' '; + echo ''; + echo ''; + } + echo '
Inv.No.Bat.No.Exp.Dt.MRP/Purchase Price/DateQtyT.Unit Qty.Cur.Unit Qty.Sale UnitReturn UnitLost UnitUpdate New Lost UnitsRemove Unit
'.$value_array[1].''.$value_array[2].''.$value_array[3].''.$value_array[4].'/'.$value_array[12].'/'.$value_array[13].''.$value_array[5].''.$value_array[11].'
'.$value_array[6].'
'.$value_array[7].''.$value_array[9].''.$value_array[10].'
+ + + + +
+
'; + ?> +
Item NameStock Batch Invoice Status
+ +
+
+
+ + + \ No newline at end of file diff --git a/old_code_ci3/views/Medical_13062021/Stock/indent_accept_items_list.php b/old_code_ci3/views/Medical_13062021/Stock/indent_accept_items_list.php new file mode 100644 index 0000000..3ade01a --- /dev/null +++ b/old_code_ci3/views/Medical_13062021/Stock/indent_accept_items_list.php @@ -0,0 +1,86 @@ + +
+
+
+
+
+

Indent Request Information

+ Indent No.: indent_code ?> | + Indent Date & Time : created_date ?> +
+
+
+
+ +
+
+ +
+
+
+ +
+
+
+ + \ No newline at end of file diff --git a/old_code_ci3/views/Medical_13062021/Stock/indent_counter_edit.php b/old_code_ci3/views/Medical_13062021/Stock/indent_counter_edit.php new file mode 100644 index 0000000..43a4ab4 --- /dev/null +++ b/old_code_ci3/views/Medical_13062021/Stock/indent_counter_edit.php @@ -0,0 +1,213 @@ +
+
+
+
+
+

Indent : store_name ?>

+ Indent No.: indent_code ?> | + Indent Date & Time : created_date ?> + Indent Current Status : request_status] ?> + request_status==3) { ?> + + + request_status==0){ ?> + + request_status==4){ ?> + + + +
+
+
+
+ +
+
+
+ + \ No newline at end of file diff --git a/old_code_ci3/views/Medical_13062021/Stock/indent_counter_item_list.php b/old_code_ci3/views/Medical_13062021/Stock/indent_counter_item_list.php new file mode 100644 index 0000000..ce4a324 --- /dev/null +++ b/old_code_ci3/views/Medical_13062021/Stock/indent_counter_item_list.php @@ -0,0 +1,36 @@ + + + + + + + + + + '; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + } + echo ''; + ?> + + + + + + + + + +
#Item NameFormulationGeneric NameQty.
'.$srno.''.$row->item_name.''.$row->formulation.''.$row->genericname.''.$row->request_qty.' +
#Item NameFormulationGeneric NameQty.
\ No newline at end of file diff --git a/old_code_ci3/views/Medical_13062021/Stock/indent_counter_list.php b/old_code_ci3/views/Medical_13062021/Stock/indent_counter_list.php new file mode 100644 index 0000000..3487b50 --- /dev/null +++ b/old_code_ci3/views/Medical_13062021/Stock/indent_counter_list.php @@ -0,0 +1,41 @@ +
+'form','class'=>'form2')); ?> +
+ + + + + + + +
+ + +
+ +
+ +
+
+ \ No newline at end of file diff --git a/old_code_ci3/views/Medical_13062021/Stock/indent_counter_search_result.php b/old_code_ci3/views/Medical_13062021/Stock/indent_counter_search_result.php new file mode 100644 index 0000000..ae59701 --- /dev/null +++ b/old_code_ci3/views/Medical_13062021/Stock/indent_counter_search_result.php @@ -0,0 +1,58 @@ +
+
+
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Indent IDStore/TypeDateProduct ListStatus
indent_code ?>store_name.'/'.$indent_req_list[$i]->indent_request_type_str ?>created_date ?>product_list ?>request_status_str ?> + request_status==0 ) { ?> + + request_status==1 ) { ?> + + request_status==2){ ?> + + request_status==3){ ?> + + + +
Indent IDStoreDateStatus
+ +
+
+
+ + \ No newline at end of file diff --git a/old_code_ci3/views/Medical_13062021/Stock/indent_issue.php b/old_code_ci3/views/Medical_13062021/Stock/indent_issue.php new file mode 100644 index 0000000..e69de29 diff --git a/old_code_ci3/views/Medical_13062021/Stock/indent_issue_item_view.php b/old_code_ci3/views/Medical_13062021/Stock/indent_issue_item_view.php new file mode 100644 index 0000000..9978455 --- /dev/null +++ b/old_code_ci3/views/Medical_13062021/Stock/indent_issue_item_view.php @@ -0,0 +1,38 @@ + +
+
+
+
+
+

Indent Request Information

+ Indent No.: indent_code ?> | + Indent Date & Time : created_date ?> + Indent Current Status : request_status] ?> + request_status==3) { ?> + + + request_status==4){ ?> + + + +
+
+
+
+ +
+
+
+ +
+
+
+ + \ No newline at end of file diff --git a/old_code_ci3/views/Medical_13062021/Stock/indent_issue_items.php b/old_code_ci3/views/Medical_13062021/Stock/indent_issue_items.php new file mode 100644 index 0000000..937dae0 --- /dev/null +++ b/old_code_ci3/views/Medical_13062021/Stock/indent_issue_items.php @@ -0,0 +1,78 @@ + +
+
+
+
+
+

Indent Request Information

+ Indent No.: indent_code ?> | + Indent Date & Time : created_date ?> + Indent Current Status : request_status] ?> + request_status==2) { ?> + + request_status==3){ ?> + + + +
+
+
+
+ +
+
+ +
+
+
+ +
+
+
+ + \ No newline at end of file diff --git a/old_code_ci3/views/Medical_13062021/Stock/indent_req_view_with_store.php b/old_code_ci3/views/Medical_13062021/Stock/indent_req_view_with_store.php new file mode 100644 index 0000000..5e83dd4 --- /dev/null +++ b/old_code_ci3/views/Medical_13062021/Stock/indent_req_view_with_store.php @@ -0,0 +1,65 @@ +
+
+
+
+
+

Indent Request Information

+ Indent No.: indent_code ?> | + Indent Date & Time : created_date ?> + Indent Current Status : request_status] ?> + +
+
+ + + + + + + + + + '; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + } + echo ''; + ?> + + + + + + + + + + +
#Item NameFormulationGeneric NameQty.Min Qty
'.$srno.''.$row->item_name.''.$row->formulation.''.$row->genericname.''.$row->request_qty.''.$row->min_requirement.'
#Item NameFormulationGeneric NameQty.Min Qty
+
+ +
+
+
diff --git a/old_code_ci3/views/Medical_13062021/Stock/indent_request.php b/old_code_ci3/views/Medical_13062021/Stock/indent_request.php new file mode 100644 index 0000000..1f30b32 --- /dev/null +++ b/old_code_ci3/views/Medical_13062021/Stock/indent_request.php @@ -0,0 +1,30 @@ +
+ +'form','class'=>'form2')); ?> +
+ + + + + + + + + + +
+ +
+
+ \ No newline at end of file diff --git a/old_code_ci3/views/Medical_13062021/Stock/indent_request_search_result.php b/old_code_ci3/views/Medical_13062021/Stock/indent_request_search_result.php new file mode 100644 index 0000000..ab8562c --- /dev/null +++ b/old_code_ci3/views/Medical_13062021/Stock/indent_request_search_result.php @@ -0,0 +1,56 @@ +
+
+
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Indent IDStore/TypeDateProduct ListStatus
indent_code ?>store_name.'/'.$indent_req_list[$i]->indent_request_type_str ?>created_date ?>product_list ?>request_status_str ?> + request_status==1 ) { ?> + + request_status==2){ ?> + + request_status==3){ ?> + + + +
Indent IDStoreDateStatus
+ +
+
+
+ + \ No newline at end of file diff --git a/old_code_ci3/views/Medical_13062021/Stock/indent_stock_list.php b/old_code_ci3/views/Medical_13062021/Stock/indent_stock_list.php new file mode 100644 index 0000000..846f15c --- /dev/null +++ b/old_code_ci3/views/Medical_13062021/Stock/indent_stock_list.php @@ -0,0 +1,61 @@ +'form','class'=>'form1')); ?> + + + + + + + + + + + + + + '; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + if($row->store_stock_id==0) + { + echo '' ; + } + + echo ''; + } + echo ''; + ?> + + + + + + + + + + +
#Item NameBatch No.Expiry DateQty.Issued Qty.Action
'.$srno.''.$row->Item_name.''.$row->batch_no.''.$row->expiry_date.''.$row->tqty.''.$row->issue_item.' + + + + + +
+ + + + +
'; + }else{ + echo '
#Item NameBatch No.Expiry DateQty.Issued Qty.Action
+ \ No newline at end of file diff --git a/old_code_ci3/views/Medical_13062021/Stock/main_store_dashboard.php b/old_code_ci3/views/Medical_13062021/Stock/main_store_dashboard.php new file mode 100644 index 0000000..7dfc9b5 --- /dev/null +++ b/old_code_ci3/views/Medical_13062021/Stock/main_store_dashboard.php @@ -0,0 +1,58 @@ +
+

+ Store Main + Panel +

+
+
+
+ +
+
+
+ Inventory +
+
+ +
+
+
+ +
diff --git a/old_code_ci3/views/Medical_13062021/Stock/stock_search.php b/old_code_ci3/views/Medical_13062021/Stock/stock_search.php new file mode 100644 index 0000000..de502b8 --- /dev/null +++ b/old_code_ci3/views/Medical_13062021/Stock/stock_search.php @@ -0,0 +1,58 @@ +
+'form','class'=>'form2')); ?> +
+ +
+
+
+ +
+
+
+
+ + + + + + + +
+
+ +
+
+ \ No newline at end of file diff --git a/old_code_ci3/views/Medical_13062021/Stock_Update.php b/old_code_ci3/views/Medical_13062021/Stock_Update.php new file mode 100644 index 0000000..f1bd0a9 --- /dev/null +++ b/old_code_ci3/views/Medical_13062021/Stock_Update.php @@ -0,0 +1,211 @@ +
+
+
+
+
+

Stock Information

+
+
+ 'form','class'=>'form1')); ?> + +
+
+
+ + +
+
+
+
+ + +
+
+
+
+ + +
+
+
+
+ + +
+
+
+
+ + +
+
+
+
+
+
+ + +
+
+
+
+ + +
+
+
+
+ +
+
+ +
+ +
+
+
+
+
+ + +
+
+
+
+ + +
+
+
+
+ +
+
+ +
+ +
+
+
+
+
+
+
+ + +
+
+
+
+ + +
+
+
+
+ + +
+
+
+
+ + +
+
+
+
+ + +
+
+
+
+
+
+ + +
+
+
+
+ + +
+
+
+
+ + +
+
+
+
+ + +
+
+
+
+ + +
+
+
+
+ + +
+
+
+ + +
+
+
+
+ + \ No newline at end of file diff --git a/old_code_ci3/views/Medical_13062021/Store/Stock_Item_history.php b/old_code_ci3/views/Medical_13062021/Store/Stock_Item_history.php new file mode 100644 index 0000000..aab521a --- /dev/null +++ b/old_code_ci3/views/Medical_13062021/Store/Stock_Item_history.php @@ -0,0 +1,30 @@ + + + + + + + + + + + + + + + + + + + + + + + +
SupplierInv.No / DateBat.No.Exp.Dt.MRPPurchaseQtyUnit Qty
name_supplier?>Invoice_no?>batch_no?>expiry_date?>mrp?>purchase_price?>tqty?>total_unit?>
\ No newline at end of file diff --git a/old_code_ci3/views/Medical_13062021/Store/Stock_search_result.php b/old_code_ci3/views/Medical_13062021/Store/Stock_search_result.php new file mode 100644 index 0000000..fd15097 --- /dev/null +++ b/old_code_ci3/views/Medical_13062021/Store/Stock_search_result.php @@ -0,0 +1,135 @@ + +
+
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Item NameCurrent Pak.Current Unit QtyTotal Sale Pak.Total Sale Unit QtyPackage/Re-Order Qty
+

+ item_name ?>

+
+

C_Pak_Qty ?>

+
+

C_Unit_Stock_Qty ?>

+
+

C_Pak_Sale_Qty ?>

+
+

sale_unit ?>

+
+

packing ?>/re_order_qty ?>

+
Item NameCurrent Pak.Current Unit QtyTotal Sale Pak.Total Sale Unit QtyPackage/Re-Order Qty
+ +
+
+
+ + + + \ No newline at end of file diff --git a/old_code_ci3/views/Medical_13062021/Store/stock_store_statement.php b/old_code_ci3/views/Medical_13062021/Store/stock_store_statement.php new file mode 100644 index 0000000..bf62ca5 --- /dev/null +++ b/old_code_ci3/views/Medical_13062021/Store/stock_store_statement.php @@ -0,0 +1,113 @@ +
+'form','class'=>'form2')); ?> +
+
+ + +
+
+
+ +
+   + +
+ +
+
+ +
+ + + + + + + +
+
+ +
+
+ \ No newline at end of file diff --git a/old_code_ci3/views/Medical_13062021/Store/store_stock_search.php b/old_code_ci3/views/Medical_13062021/Store/store_stock_search.php new file mode 100644 index 0000000..0a6b007 --- /dev/null +++ b/old_code_ci3/views/Medical_13062021/Store/store_stock_search.php @@ -0,0 +1,64 @@ +
+'form','class'=>'form2')); ?> +
+
+ +
+
+
+
+ + + + + + + + + + +
+
+ +
+
+ \ No newline at end of file diff --git a/old_code_ci3/views/Medical_13062021/Store_Dashboard.php b/old_code_ci3/views/Medical_13062021/Store_Dashboard.php new file mode 100644 index 0000000..42b94f4 --- /dev/null +++ b/old_code_ci3/views/Medical_13062021/Store_Dashboard.php @@ -0,0 +1,45 @@ + +
+

+ Medical Store : store_name?> + Dashboard +

+
+ +
+ +
+ +
+
+ \ No newline at end of file diff --git a/old_code_ci3/views/Medical_13062021/Supplier_Edit.php b/old_code_ci3/views/Medical_13062021/Supplier_Edit.php new file mode 100644 index 0000000..39592ea --- /dev/null +++ b/old_code_ci3/views/Medical_13062021/Supplier_Edit.php @@ -0,0 +1,111 @@ + + +
+
+

Supplier

+
+
+ 'form','class'=>'form1')); ?> + 0) + { + $sid=$supplier_data[0]->sid; + $name_supplier=$supplier_data[0]->name_supplier; + $short_name=$supplier_data[0]->short_name; + $contact_no=$supplier_data[0]->contact_no; + $gst_no=$supplier_data[0]->gst_no; + $city=$supplier_data[0]->city; + $state=$supplier_data[0]->state; + } + + ?> + +
+
+
+ + +
+
+
+
+ + +
+
+
+
+
+
+ + +
+
+
+
+ + +
+
+
+
+
+
+ + +
+
+
+
+ + +
+
+
+
+
+
+ + +
+
+
+ +
+
+ \ No newline at end of file diff --git a/old_code_ci3/views/Medical_13062021/Supplier_master.php b/old_code_ci3/views/Medical_13062021/Supplier_master.php new file mode 100644 index 0000000..db90a1f --- /dev/null +++ b/old_code_ci3/views/Medical_13062021/Supplier_master.php @@ -0,0 +1,60 @@ +
+

+ Supplier +

+
+
+
+
+
+
+ +

Supplier List

+
+
+ +
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + +
NameGSTAction
name_supplier ?>name_supplier ?> + + +
NameGSTAction
+ +
+ +
+
+
+ +
+
+ +
+ \ No newline at end of file diff --git a/old_code_ci3/views/Medical_13062021/Supplier_master_sub.php b/old_code_ci3/views/Medical_13062021/Supplier_master_sub.php new file mode 100644 index 0000000..a5551df --- /dev/null +++ b/old_code_ci3/views/Medical_13062021/Supplier_master_sub.php @@ -0,0 +1,30 @@ + + + + + + + + + + + + + + + + + + + + + + + + +
NameGSTAction
name_supplier ?>name_supplier ?> + +
NameGSTAction
+ \ No newline at end of file diff --git a/old_code_ci3/views/Medical_13062021/invoice_master_edit.php b/old_code_ci3/views/Medical_13062021/invoice_master_edit.php new file mode 100644 index 0000000..42ca3e6 --- /dev/null +++ b/old_code_ci3/views/Medical_13062021/invoice_master_edit.php @@ -0,0 +1,408 @@ +
+
+

+ Medical Invoice Master Edit : + + Back to Invoice + +

+
+
+'form','class'=>'form1')); ?> + +
+
+
+
+ + +

Name :inv_name?> + / P Code :patient_code?> + / Invoice No. :inv_med_code?> + / Date : inv_date)?> + ipd_id > 0) { ?> + IPD Code : + + ipd_code?> + + Admit Date : str_register_date ?> reg_time ?> + / Doctor :doc_name?> + / TPA-Org. : + case_id > 0){ ?> + / Org. Case ID :case_id_code ?> + +

+
+
+
+
+
+
+
+ +
+
+ +
+ +
+
+
+
+
+ + +
+
+
+
+ ipd_id > 0) { ?> +
+ payment_received ==0) { ?> +
+
+ + +
+
+ +
+ +
credit_status ?>
+
+ +
+
+
+ + +
+
+ case_id > 0){ ?> +
+ payment_received ==0) { ?> +
+
+ + +
+
+ +
+ +
+
+
+
+
+
+

Change Name : Current Name : patient_code ?>

+
+
+
+
+
+
+ + +
+
+
+
+ + Patient Name
+
+
+
+
+ + +
+
+
+
+
+
+
+

Change UHID : Current UHID : patient_code ?>

+
+
+
+
+
+
+ + +
+
+
+
+ +
Patient Information
+
+
+
+
+ + + +
+
+
+
+
+
+
+

Change IPD : + ipd_credit>0){ ?> + Current IPD : ipd_code ?> + +

+
+
+
+
+
+
+ + +
+
+
+
+ +
+
+
+
+
+ + + +
+
+
+
+
+
+
+

Change Org. Case : + case_credit>0){ ?> + Current Org. Case : case_id ?> + + +

+
+
+
+
+
+
+ + +
+
+
+
+ +
Patient Information
+
+
+
+
+ + + +
+
+
+
+ + +
+ + + +
\ No newline at end of file diff --git a/old_code_ci3/views/Medical_13062021/new_purchase_invoice.php b/old_code_ci3/views/Medical_13062021/new_purchase_invoice.php new file mode 100644 index 0000000..3e430d2 --- /dev/null +++ b/old_code_ci3/views/Medical_13062021/new_purchase_invoice.php @@ -0,0 +1,70 @@ +
+
+
+
+
+
+

New Purchase Invoice

+
+
+ 'form','class'=>'form1')); ?> +
+
+
+ + +
+
+
+
+ + +
+
+
+ +
+
+ +
+ +
+
+
+ +
+
+ +
+
+
+
+ \ No newline at end of file diff --git a/old_code_ci3/views/Medical_13062021/payment_edit.php b/old_code_ci3/views/Medical_13062021/payment_edit.php new file mode 100644 index 0000000..d5a0e3b --- /dev/null +++ b/old_code_ci3/views/Medical_13062021/payment_edit.php @@ -0,0 +1,156 @@ +
+
+
+
+

+ Payment ID : +

+
+
+

Invoice Type :

+
+
+

IPD/OPD No :

+
+
+

Invoice To :

+
+
+

Amount : Rs. Amount_str ?>

+
+
+

Mode of Payment. : payment_mode==1)?'CASH':'BANK');?>

+
+
+ +
+
+
+ payment_mode==1){ ?> +
+
+ + +
+
+
+
+ + +
+
+
+
+ + +
+
+
+
+ + +
+
+
+ +
+ +
+ +
+ +
+
+
+
+ +
+ +
+
+
+ +
+
+
+
+
+
+ + +
+
+
+ +
+
+
+
+
+
+ diff --git a/old_code_ci3/views/Medical_13062021/payment_search.php b/old_code_ci3/views/Medical_13062021/payment_search.php new file mode 100644 index 0000000..b7d4adb --- /dev/null +++ b/old_code_ci3/views/Medical_13062021/payment_search.php @@ -0,0 +1,25 @@ +
+'form','class'=>'form_payment_search')); ?> +
+ + + + +
+ +
+ +
+ + \ No newline at end of file diff --git a/old_code_ci3/views/Medical_13062021/purchase_invoice_item.php b/old_code_ci3/views/Medical_13062021/purchase_invoice_item.php new file mode 100644 index 0000000..468b73f --- /dev/null +++ b/old_code_ci3/views/Medical_13062021/purchase_invoice_item.php @@ -0,0 +1,62 @@ + + + + + + + + + + + + + + + + + + '; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + } + echo ''; + ?> + + + + + + + + + + + + + + + + + + +
#Item NameBatch NoExp.MRPQty.RateAmountDisc.Tax AmountCGSTSGSTNet Amount
'.$srno.''.$row->Item_name.''.$row->batch_no.''.$row->expiry_date.''.$row->mrp.''.floatval($row->qty).'+'.floatval($row->qty_free).''.$row->purchase_price.''.$row->amount.''.$row->discount.''.$row->taxable_amount.''.$row->CGST_per.''.$row->SGST_per.''.$row->net_amount.' + +
#Taxable_Amt ?>CGST_Amt ?>SGST_Amt ?>T_Net_Amount ?>
\ No newline at end of file diff --git a/old_code_ci3/views/Medical_13062021/purchase_supp_list.php b/old_code_ci3/views/Medical_13062021/purchase_supp_list.php new file mode 100644 index 0000000..ce4b75d --- /dev/null +++ b/old_code_ci3/views/Medical_13062021/purchase_supp_list.php @@ -0,0 +1,47 @@ +
+
+
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Invoice IDSupplierDateAmount
Invoice_no ?>name_supplier ?>date_of_invoice ?>tamount ?> + +
Invoice IDSupplierDateAmount
+ +
+
+
+ + \ No newline at end of file diff --git a/old_code_ci3/views/Medical_13062021/sale_item_list_for_add.php b/old_code_ci3/views/Medical_13062021/sale_item_list_for_add.php new file mode 100644 index 0000000..dc1a5c7 --- /dev/null +++ b/old_code_ci3/views/Medical_13062021/sale_item_list_for_add.php @@ -0,0 +1,30 @@ + + + + + + + + + + + + + + + + + +
Item NameBatch No.Qty in StockMRPQty
+
+ +
+
+
+ \ No newline at end of file diff --git a/old_code_ci3/views/Medical_13062021/supplier_list.php b/old_code_ci3/views/Medical_13062021/supplier_list.php new file mode 100644 index 0000000..734a017 --- /dev/null +++ b/old_code_ci3/views/Medical_13062021/supplier_list.php @@ -0,0 +1,30 @@ +
+ +'form','class'=>'form2')); ?> +
+ + + + + + + + + + +
+ +
+
+ \ No newline at end of file diff --git a/old_code_ci3/views/PathLab_Report/lab_final_report_show_xray.php b/old_code_ci3/views/PathLab_Report/lab_final_report_show_xray.php index e0908fe..f27f580 100644 --- a/old_code_ci3/views/PathLab_Report/lab_final_report_show_xray.php +++ b/old_code_ci3/views/PathLab_Report/lab_final_report_show_xray.php @@ -1,3 +1,4 @@ + @@ -15,14 +16,7 @@
- +
@@ -32,17 +26,9 @@
- - - -
- - - - -
+ + template_name?>
+
@@ -52,9 +38,7 @@ function update_report() { var HTMLData=CKEDITOR.instances.HTMLShow.getData(); - var report_data_Impression=CKEDITOR.instances.report_data_Impression.getData(); - - // var report_data_Impression=$('#report_data_Impression').val() + var report_data_Impression=$('#report_data_Impression').val() var csrf_value=$('input[name=security->get_csrf_token_name()?>]').val(); var req_id=$('#hid_value_req_id').val(); @@ -98,28 +82,4 @@ } - // Live filter for template list - $(function () { - $('#template_search').on('input', function () { - var q = $(this).val().toLowerCase().trim(); - var count = 0; - $('#templateList .template-item').each(function () { - var show = $(this).text().toLowerCase().indexOf(q) !== -1; - $(this).toggle(show); - if (show) count++; - }); - $('#no_templates_msg').toggle(count === 0); - }); - - // Optional: Enter opens the first visible template - $('#template_search').on('keydown', function (e) { - if (e.key === 'Enter') { - var $first = $('#templateList .template-item:visible a').first(); - if ($first.length) { - e.preventDefault(); - $first[0].click(); - } - } - }); - }); \ No newline at end of file diff --git a/old_code_ci3/views/PathLab_Report/ultrasound_report_edit.php b/old_code_ci3/views/PathLab_Report/ultrasound_report_edit.php index 33c82a8..954875b 100644 --- a/old_code_ci3/views/PathLab_Report/ultrasound_report_edit.php +++ b/old_code_ci3/views/PathLab_Report/ultrasound_report_edit.php @@ -106,11 +106,10 @@ var HTMLData=CKEDITOR.instances.HTMLData.getData(); var Impression=$('#Impression').val(); var csrf_value=$('input[name=security->get_csrf_token_name()?>]').val(); - var modality=; if(repo_id>0) { - $.post('/index.php/Lab_Admin/report_ultrasound_update/'+modality,{ + $.post('/index.php/Lab_Admin/report_ultrasound_update',{ "repo_id": repo_id, "input_Reportname": input_Reportname, "charge_id":charge_id, @@ -119,10 +118,14 @@ "Impression":Impression, 'security->get_csrf_token_name()?>':csrf_value }, function(data){ - notify(data.showcontent,'success'); - }, 'json'); + $('#msgshow').html(data.showcontent); + $("#alert_show").alert(); + $("#alert_show").fadeTo(5000, 500).slideUp(500, function(){ + $("#alert_show").slideUp(500); + }); + }, 'json'); }else{ - $.post('/index.php/Lab_Admin/report_ultrasound_insert/'+modality,{ + $.post('/index.php/Lab_Admin/report_ultrasound_insert',{ "repo_id": repo_id, "input_Reportname": input_Reportname, "charge_id":charge_id, @@ -131,10 +134,14 @@ "Impression":Impression, 'security->get_csrf_token_name()?>':csrf_value }, function(data){ - notify(data.showcontent,'success'); + $('#msgshow').html(data.showcontent); + $("#alert_show").alert(); + $("#alert_show").fadeTo(5000, 500).slideUp(500, function(){ + $("#alert_show").slideUp(500); + }); if(data.insertid>0) { - load_form_div('/Lab_Admin/report_ultrasound_list/'+modality,'maindiv','Diagnosis Template'); + load_form_div('/Lab_Admin/report_ultrasound_list','maindiv','Diagnosis Template'); } diff --git a/old_code_ci3/views/PathLab_Report/ultrasound_template_list.php b/old_code_ci3/views/PathLab_Report/ultrasound_template_list.php index 93c8e21..598941e 100644 --- a/old_code_ci3/views/PathLab_Report/ultrasound_template_list.php +++ b/old_code_ci3/views/PathLab_Report/ultrasound_template_list.php @@ -11,7 +11,7 @@

Report List

-
+
@@ -30,7 +30,7 @@ template_name ?> title ?> - + diff --git a/old_code_ci3/views/Patient_V.php b/old_code_ci3/views/Patient_V.php index 157bdb2..b578326 100644 --- a/old_code_ci3/views/Patient_V.php +++ b/old_code_ci3/views/Patient_V.php @@ -33,8 +33,7 @@ - - + @@ -86,7 +85,7 @@
-
@@ -146,11 +145,11 @@
diff --git a/old_code_ci3/views/Person_Edit_V.php b/old_code_ci3/views/Person_Edit_V.php index b401a70..c82a0f5 100644 --- a/old_code_ci3/views/Person_Edit_V.php +++ b/old_code_ci3/views/Person_Edit_V.php @@ -36,8 +36,7 @@ - - +