commit 614713f76b3e229fded8ac02b9f689f00a8eaa7b Author: DevSoftTech Server Date: Fri Feb 27 19:44:36 2026 +0530 Implement OPD template builder, doctor template selection, and OPD print integration fixes diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..87e86b9 --- /dev/null +++ b/.gitignore @@ -0,0 +1,126 @@ +#------------------------- +# Operating Specific Junk Files +#------------------------- + +# OS X +.DS_Store +.AppleDouble +.LSOverride + +# OS X Thumbnails +._* + +# Windows image file caches +Thumbs.db +ehthumbs.db +Desktop.ini + +# Recycle Bin used on file shares +$RECYCLE.BIN/ + +# Windows Installer files +*.cab +*.msi +*.msm +*.msp + +# Windows shortcuts +*.lnk + +# Linux +*~ + +# KDE directory preferences +.directory + +# Linux trash folder which might appear on any partition or disk +.Trash-* + +#------------------------- +# Environment Files +#------------------------- +# These should never be under version control, +# as it poses a security risk. +.env +.vagrant +Vagrantfile + +#------------------------- +# Temporary Files +#------------------------- +writable/cache/* +!writable/cache/index.html + +writable/logs/* +!writable/logs/index.html + +writable/session/* +!writable/session/index.html + +writable/uploads/* +!writable/uploads/index.html + +writable/debugbar/* +!writable/debugbar/index.html + +php_errors.log + +#------------------------- +# User Guide Temp Files +#------------------------- +user_guide_src/build/* +user_guide_src/cilexer/build/* +user_guide_src/cilexer/dist/* +user_guide_src/cilexer/pycilexer.egg-info/* + +#------------------------- +# Test Files +#------------------------- +tests/coverage* + +# Don't save phpunit under version control. +phpunit + +#------------------------- +# Composer +#------------------------- +vendor/ + +#------------------------- +# IDE / Development Files +#------------------------- + +# Modules Testing +_modules/* + +# phpenv local config +.php-version + +# Jetbrains editors (PHPStorm, etc) +.idea/ +*.iml + +# NetBeans +/nbproject/ +/build/ +/nbbuild/ +/dist/ +/nbdist/ +/nbactions.xml +/nb-configuration.xml +/.nb-gradle/ + +# Sublime Text +*.tmlanguage.cache +*.tmPreferences.cache +*.stTheme.cache +*.sublime-workspace +*.sublime-project +.phpintel +/api/ + +# Visual Studio Code +.vscode/ + +/results/ +/phpunit*.xml diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..24728f6 --- /dev/null +++ b/LICENSE @@ -0,0 +1,22 @@ +The MIT License (MIT) + +Copyright (c) 2014-2019 British Columbia Institute of Technology +Copyright (c) 2019-present CodeIgniter Foundation + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. diff --git a/README.md b/README.md new file mode 100644 index 0000000..45f98af --- /dev/null +++ b/README.md @@ -0,0 +1,69 @@ +# CodeIgniter 4 Application Starter + +## What is CodeIgniter? + +CodeIgniter is a PHP full-stack web framework that is light, fast, flexible and secure. +More information can be found at the [official site](https://codeigniter.com). + +This repository holds a composer-installable app starter. +It has been built from the +[development repository](https://github.com/codeigniter4/CodeIgniter4). + +More information about the plans for version 4 can be found in [CodeIgniter 4](https://forum.codeigniter.com/forumdisplay.php?fid=28) on the forums. + +You can read the [user guide](https://codeigniter.com/user_guide/) +corresponding to the latest version of the framework. + +## Installation & updates + +`composer create-project codeigniter4/appstarter` then `composer update` whenever +there is a new release of the framework. + +When updating, check the release notes to see if there are any changes you might need to apply +to your `app` folder. The affected files can be copied or merged from +`vendor/codeigniter4/framework/app`. + +## Setup + +Copy `env` to `.env` and tailor for your app, specifically the baseURL +and any database settings. + +## Important Change with index.php + +`index.php` is no longer in the root of the project! It has been moved inside the *public* folder, +for better security and separation of components. + +This means that you should configure your web server to "point" to your project's *public* folder, and +not to the project root. A better practice would be to configure a virtual host to point there. A poor practice would be to point your web server to the project root and expect to enter *public/...*, as the rest of your logic and the +framework are exposed. + +**Please** read the user guide for a better explanation of how CI4 works! + +## Repository Management + +We use GitHub issues, in our main repository, to track **BUGS** and to track approved **DEVELOPMENT** work packages. +We use our [forum](http://forum.codeigniter.com) to provide SUPPORT and to discuss +FEATURE REQUESTS. + +This repository is a "distribution" one, built by our release preparation script. +Problems with it can be raised on our forum, or as issues in the main repository. + +## Server Requirements + +PHP version 8.2 or higher is required, with the following extensions installed: + +- [intl](http://php.net/manual/en/intl.requirements.php) +- [mbstring](http://php.net/manual/en/mbstring.installation.php) + +> [!WARNING] +> - The end of life date for PHP 7.4 was November 28, 2022. +> - The end of life date for PHP 8.0 was November 26, 2023. +> - The end of life date for PHP 8.1 was December 31, 2025. +> - If you are still using below PHP 8.2, you should upgrade immediately. +> - The end of life date for PHP 8.2 will be December 31, 2026. + +Additionally, make sure that the following extensions are enabled in your PHP: + +- json (enabled by default - don't turn it off) +- [mysqlnd](http://php.net/manual/en/mysqlnd.install.php) if you plan to use MySQL +- [libcurl](http://php.net/manual/en/curl.requirements.php) if you plan to use the HTTP\CURLRequest library diff --git a/WORKLOG_COPILOT.md b/WORKLOG_COPILOT.md new file mode 100644 index 0000000..200c30d --- /dev/null +++ b/WORKLOG_COPILOT.md @@ -0,0 +1,521 @@ +# Worklog - HMS_CI4_OLD + +Date: 2026-02-08 + +## Summary +Ported OPD Charges, IPD Charges, and Package modules from CI3 to CI4 with consistent NiceAdmin UI, AJAX modal flows, Simple-DataTables, insurance rate handling, and print/Excel exports. + +## OPD Charges +- Controller: app/Controllers/Item.php +- Model: app/Models/ItemModel.php +- Routes: app/Config/Routes.php (group: item) +- Views: app/Views/Setting/Charges/OPD_Charges/ + - item_search_V.php (header buttons: Charge Groups, Add New Charge; filters; print/export) + - item_search_adv.php (list partial with DataTable) + - item_profile_V.php (modal edit; insurance rates; refresh list on update) + - item_create_V.php + - item_type_search_v.php / item_type_profile.php / item_type_create.php + - item_item_list.php (print layout with heading, borders, base rate fallback) + - item_item_excel.php (Excel export) + - item_insurance_list.php (insurance rate table partial) +- Model joins (no DB views): + - items: hc_items + hc_item_type + - insurance items: hc_items_insurance + hc_insurance, filter isdelete=0 +- Print: insurance selection adds Amount + Code; missing insurance uses Base Rate +- Excel: output via response headers (no debug toolbar injection) + +## IPD Charges +- Controller: app/Controllers/ItemIpd.php +- Model: app/Models/ItemIpdModel.php +- Routes: app/Config/Routes.php (groups: item-ipd + legacy Item_IPD) +- Views: app/Views/Setting/Charges/IPD_Charges/ + - item_search_V.php, item_search_adv.php + - item_profile_V.php, item_create_V.php + - item_type_search_v.php / item_type_profile.php / item_type_create.php + - item_item_list.php (print) + - item_item_excel.php (Excel) + - item_insurance_list.php +- Model joins (no DB views): + - items: ipd_items + ipd_item_type + - insurance items: ipd_items_insurance + hc_insurance, filter isdelete=0 + +## Package (IPD Package) +- Controller: app/Controllers/Package.php +- Model: app/Models/PackageModel.php +- Routes: app/Config/Routes.php (groups: package + legacy Package + legacy IPD_Package) +- Views: app/Views/Setting/Charges/Package/ + - item_search_V.php, item_search_adv.php + - item_profile_V.php, item_create_V.php + - item_type_search_v.php / item_type_profile.php / item_type_create.php + - item_item_list.php (print) + - item_item_excel.php (Excel) + - item_insurance_list.php +- Model joins (no DB views): + - packages: package, package_group + - insurance items: package_insurance + hc_insurance, filter isdelete=0 +- Audit tables: package_update and package_insurance_update + - If not present, audit insert skipped (prevents errors) + +## UI + Behavior +- Charges tiles updated: + - setting/charges -> IPD tile uses item-ipd/search + - setting/charges -> Package tile uses package/search +- Modal edits refresh list: + - OPD: window.refreshChargeList() + - IPD: window.refreshChargeList() + - Package: window.refreshPackageList() +- Print buttons in header next to filter; export Excel added +- Print layout: heading with group + insurance; no OPD/IPD or group columns; table borders +- Base rate fallback: if insurance-specific rate missing, show base amount and Code column shows "Base Rate" + +## Known Tables Used +- OPD: hc_items, hc_item_type, hc_items_insurance, hc_items_update, hc_items_insurance_update +- IPD: ipd_items, ipd_item_type, ipd_items_insurance, ipd_items_update, ipd_items_insurance_update +- Package: package, package_group, package_insurance, package_update, package_insurance_update +- Insurance: hc_insurance + +## Notes for Next Session +- If audit tables for Package are required, create migrations for package_update and package_insurance_update. +- If isdelete column missing on insurance tables, remove filter. +- Debug toolbar can break Excel; keep response headers to avoid injection. +- Legacy routes are supported for old JS paths. + +--- + +Date: 2026-02-16 + +## Diagnosis CI3 → CI4 Endpoint Mapping (Lab_Report parity) + +### Fully mapped in CI4 +- `lab_master` → `Diagnosis::labMaster` via `Lab_Report/lab_master` +- `lab_path/{lab_type}` → `Diagnosis::labPathLegacy` via `Lab_Report/lab_path/(:num)` +- `search_lab_4/{lab_type}` → `Diagnosis::searchLab` via `Lab_Report/search_lab_4/(:num)` +- `search_lab_4_srno/{lab_type}` → `Diagnosis::searchLabBySrno` via `Lab_Report/search_lab_4_srno/(:num)` +- `search_lab_4_labno/{lab_type}` → `Diagnosis::searchLabByLabno` via `Lab_Report/search_lab_4_labno/(:num)` +- `select_lab_invoice/{inv_id}/{lab_type}` → `Diagnosis::selectLabInvoicePath` +- `select_lab_invoice_path/{inv_id}/{lab_type}` → `Diagnosis::selectLabInvoicePath` +- `lab_date_show/{inv_id}/{lab_type}` → `Diagnosis::labDateShow` +- `test_list/{inv_id}/{lab_type}` → `Diagnosis::testList` +- `xray_test_list/{inv_id}/{lab_type}` → `Diagnosis::testList` +- `lab_tab_1_process/{test_id}/{lab_type}` → `Diagnosis::labTab1Process` +- `create_report_xray/{req_id}` → `Diagnosis::createReportXray` +- `show_report_final/{req_id}` → `Diagnosis::showReportFinalXray` +- `get_template_xray/{id}` → `Diagnosis::getTemplateXray` +- `Final_Update_xray/{req_id}` → `Diagnosis::finalUpdateXray` +- `confirm_report_xray/{req_id}` → `Diagnosis::confirmReportXray` + +### Missing legacy endpoints (not yet mapped) +- `report_file_list/{inv_id}/{lab_type}/{delete?}` +- `select_lab_radiology/{inv_id}/{lab_type}` + +### Notes +- Current CI4 radiology flow uses `Diagnosis::selectLabInvoicePath` for detail screen and does not require a separate `select_lab_radiology` endpoint in active views. +- File upload/list actions in CI4 diagnosis view are currently placeholders (`uploadFiles`, `showFiles`) and do not yet have controller endpoints. + +## Future Backlog: AI-assisted Image Diagnosis (Ultrasound / X-Ray / CT) + +### Goal +- Add a professional image workspace where users can upload/scan images, review them, run AI-assisted analysis, and move AI draft findings into radiology report editor with doctor review. + +### Phase 1 (MVP - internal) +- Build one modal workspace in diagnosis detail screen: + - Left panel: image preview, next/previous, zoom. + - Right panel: AI findings, AI impression, confidence, doctor editable text. +- Wire existing action buttons: + - Upload Files -> open workspace + upload image. + - Scan -> open workspace + scan image flow. + - Show Files -> list previously uploaded/scanned images. +- Add backend APIs in Diagnosis controller: + - uploadImage(reqId) + - listImages(reqId) + - scanImage(reqId) + - analyzeImageAi(reqId, fileId) + - saveAiDraft(reqId, fileId) + - acceptAiToReport(reqId) +- Add DB table for AI result tracking (suggested: diagnosis_image_ai): + - id, req_id, file_id, ai_findings, ai_impression, confidence, + - model_name, model_version, status, reviewed_by, reviewed_at, + - created_at, updated_at. +- Add visible safety label: AI Suggestion - Doctor Review Required. + +### Phase 2 (real AI integration) +- Integrate external AI service endpoint (Python/FastAPI or equivalent). +- Send selected image path to AI service and store structured response. +- Add timeout/error handling and retry button in UI. + +### Phase 3 (clinical workflow hardening) +- Add audit trail for accepted/edited AI content before final report verify. +- Add role check so only authorized users can accept AI output. +- Keep final confirm manual; AI never auto-verifies reports. + +### UI/Workflow Notes +- AI output should prefill radiology editor, not directly replace final report. +- Show per-image history for repeat review and comparison. +- Keep terminology consistent with current imaging workflow labels. + +--- + +Date: 2026-02-16 + +## Pharmacy Module Kickoff (Legacy Medical) + +### What was verified +- Legacy pharmacy dashboard source is in old code: + - `old_code_ci3/views/Medical/Dashboard.php` +- Main legacy pharmacy controller is very large and feature-rich: + - `old_code_ci3/controllers/Medical.php` (~5k lines) +- Related legacy controllers: + - `old_code_ci3/controllers/Medical_backpanel.php` + - `old_code_ci3/controllers/Medical_Report.php` + - `old_code_ci3/controllers/Medical_Print.php` + - `old_code_ci3/controllers/Payment_Medical.php` + +### Important routing finding +- Current CI4 improved auto-routing is disabled (`app/Config/Routing.php` has `autoRoute = false`). +- No explicit CI4 `/Medical` routes found in `app/Config/Routes.php`. +- No current CI4 Medical controller files found under `app/Controllers`. + +### Legacy dashboard button map (from old Dashboard.php) +- OPD Sale -> `/Medical/search_customer` +- Invoice -> `/Medical/Invoice_Med_Draft` +- IPD/Credit -> `/Medical/list_org_ipd` +- Org. Credit -> `/Medical/list_org` +- Return Counter Sale -> `/Medical/Invoice_Med_Return` +- Day Report -> `/Medical_Report/Report_2` +- Sale Day Report -> `/Medical_Report/Report_1` +- Payment Report -> `/Medical_Report/Report_Payment_Recieved` +- Store Stock -> `/Medical_backpanel/store_stock` +- Store Main -> `/Medical/main_store` +- Master -> `/Medical_backpanel` + +### Suggested migration order (phase wise) +1. Dashboard + navigation tiles. +2. OPD Sale + Invoice Draft list. +3. Return invoice flow. +4. Store stock and stock statement. +5. Reports (day/sale/payment). +6. Backpanel master screens. + +### SQL views received from user (confirmed) +- `v_med_item_return` +- `v_med_item_with_return` +- `v_ipd_list` +- `v_med_short_list` +- `v_product_stock` +- `v_product_stock_sub` +- `v_sale_item` +- `v_sale_item_sub` + +### Dependency note +- `v_ipd_list` depends on `v_ipd_doc_list` (seen in view body join). +- Before CI4 pharmacy migration, ensure `v_ipd_doc_list` exists in target DB with compatible schema. + +### Next implementation start point +- Begin CI4 Pharmacy phase-1 with dashboard route/controller/view parity for `/Medical` tiles, then wire OPD Sale + Draft Invoice list endpoints. + +### Phase-1 implementation done (CI4) +- Added controller: app/Controllers/Medical.php +- Added routes: + - Medical + - Medical/search_customer + - Medical/Invoice_Med_Draft + - Medical/Invoice_Med_Return + - Medical/list_org_ipd + - Medical/list_org + - Medical/main_store + - Medical/store_stock + - Medical/master +- Added views: + - app/Views/medical/dashboard.php + - app/Views/medical/search_customer.php + - app/Views/medical/invoice_med_draft.php + - app/Views/medical/placeholder.php +- Status: + - Dashboard works at /Medical. + - OPD Sale and Invoice Draft panels are functional. + - Remaining tiles currently show migration placeholder pending deeper CI3 parity port. + +--- + +Date: 2026-02-19 + +## Pharmacy -> Master continuation + +### Fix completed +- Module: `Drug Sale Customer Wise Report` +- Endpoint: `Medical::drug_patient_distribute` +- Root-cause fixed in `getDrugPatientDistributeRows()`: + - Legacy behavior: when Drug Name is blank and Schedule filter is blank, show all matching date-range records. + - CI4 regression: returned empty result unless at least one schedule was selected. + - Fix: schedule condition is now applied only when schedules are selected; blank schedule no longer forces empty result. + +### Validation +- `php -l app/Controllers/Medical.php` passed (no syntax errors). + +### Step done: Med. Payment Edit Logs (legacy links) +- Implemented legacy page endpoint: `Payment_Medical/payment_log` +- Implemented legacy result endpoint: `Payment_Medical/payment_log_data` +- Added CI4 controller methods in `app/Controllers/Payment_Medical.php`: + - `payment_log()` for filter page + - `payment_log_data()` for date-range log result table +- Added CI4 views: + - `app/Views/medical/payment_log.php` + - `app/Views/medical/payment_log_data.php` +- Updated routes in `app/Config/Routes.php`: + - `GET Payment_Medical/payment_log -> Payment_Medical::payment_log` + - `GET|POST Payment_Medical/payment_log_data -> Payment_Medical::payment_log_data` +- Updated Master menu link in `app/Views/medical/master.php`: + - `Med. Payment Edit Logs` now opens `Payment_Medical/payment_log` + +### Step fix: Med. Payment Edit action buttons not working +- Root cause: `payment_edit` HTML was injected using `innerHTML` in `payment_search`, so inline ` diff --git a/app/Views/Invoice/Case_Form_profile_V.php b/app/Views/Invoice/Case_Form_profile_V.php new file mode 100644 index 0000000..824ccdf --- /dev/null +++ b/app/Views/Invoice/Case_Form_profile_V.php @@ -0,0 +1,195 @@ +
+

+ Insurance Case + case_id_code ?> +

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

Remarks + Write some about the problem +

+ +
+ + +
+ +
+ +
+ + +
+
+
+
+
+
+
+ +
+
+
+
+
+
+
+ +
+ + + \ No newline at end of file diff --git a/app/Views/Invoice/Case_List.php b/app/Views/Invoice/Case_List.php new file mode 100644 index 0000000..9308464 --- /dev/null +++ b/app/Views/Invoice/Case_List.php @@ -0,0 +1,53 @@ +
+
+
+

Result

+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Case No.Patient NameCase DateCard Holder NameInsuranceOPD AmountInvoice AmountStatus
case_id_code ?>p_name ?>date_registration ?>insurance_card_name ?>insurance_company_name ?>OPD_Amount ?>Invoice_Amount ?>str_status ?>
Case No.Patient NameCase DateCard Holder NameInsuranceOPD AmountInvoice Amount
+
+ +
+
\ No newline at end of file diff --git a/app/Views/Invoice/Invoice_org_payment.php b/app/Views/Invoice/Invoice_org_payment.php new file mode 100644 index 0000000..8678b18 --- /dev/null +++ b/app/Views/Invoice/Invoice_org_payment.php @@ -0,0 +1,64 @@ + + + + + + + + + +
+ + +

+

,
+ +

+org_id ?? '').':'.($req_payment_order[0]->pay_id ?? '').':'.($req_payment_order[0]->payment_amount ?? '').':PT'.date('dmYhis'); +?> + +
+

Org Payment Credit Receipt : pay_id ?? '') ?>

+
+ + + + + + +
Patient Info.
+ UHID : p_code ?? '') ?>
+ Name : title ?? '') ?> p_fname ?? ''))) ?>
+ p_relative ?? '') ?> p_rname ?? ''))) ?>
+ Sex : xgender ?? '') ?> age ?? '') ?> P.No. :mphone1 ?? '') ?> +
+ Org. Case No. : org_code ?? '') ?>
+ Payment Date : payment_date_str ?? '') ?> +
+
+

+ Org Case Payment Amount : Rs. payment_amount ?? '') ?>
+ Amount in Words : Rs.payment_amount ?? 0) ?> +

+

+ Prepared By :payment_accept_by ?? '') ?> +

+

+ Signature +

diff --git a/app/Views/Invoice/Org_Contingent_bill.php b/app/Views/Invoice/Org_Contingent_bill.php new file mode 100644 index 0000000..8095eeb --- /dev/null +++ b/app/Views/Invoice/Org_Contingent_bill.php @@ -0,0 +1,87 @@ +
+
+ +
+
+
+

+ Name :p_fname?> + / Age :age?> + / Gender :xgender?> + / P Code :p_code?> + / Ins. Comp. :ins_company_name?> +

+ + + +
+
+
+
+ + +
+
+ +
+
+
+
+ diff --git a/app/Views/Invoice/Organization_Invoice_PathLab.php b/app/Views/Invoice/Organization_Invoice_PathLab.php new file mode 100644 index 0000000..2c43b20 --- /dev/null +++ b/app/Views/Invoice/Organization_Invoice_PathLab.php @@ -0,0 +1,238 @@ +
+

+ Charges + +

+ +
+
+
+ +
+
+
+

Name :p_fname?> + / Age :age?> + / Gender :xgender?> + / P Code :p_code?> + insurance_id>0) + { + echo '/ Ins. Comp. :'.$insurance[0]->ins_company_name; + } + ?> +

+ + + +
+
+
+
+
+
+ + +
+
+
+
+ + +
+
+
+
+ + + + + + + + + + + '; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + } + echo ''; + ?> + + + + + + + + + + +
#Charges GroupCharge NameRateQtyAmount
'.$srno.''.$row->item_type.''.$row->item_name.''.$row->item_rate.''.$row->item_qty.''.$row->item_amount.'
#Gross TotalGtotal?>
+
+
+
+
+
+ + +
+
+
+
+ + +
+
+
+
+ + +
+
+
+
+ + +
+
+
+
+ +
+
+
+ +
+
+
+ +
+
+
+
+
+
+
+ + + \ No newline at end of file diff --git a/app/Views/Invoice/Organization_Invoice_PathLab_final_V.php b/app/Views/Invoice/Organization_Invoice_PathLab_final_V.php new file mode 100644 index 0000000..e941ab8 --- /dev/null +++ b/app/Views/Invoice/Organization_Invoice_PathLab_final_V.php @@ -0,0 +1,378 @@ +
+

+ Invoice + #invoice_code ?> +

+ +
+
+ +
+
+ +
+ +
+ +
+
+ From +
+
+
+
+ Phone:
+ Email: +
+
+ +
+ To +
+ p_fname ?>
+ 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 ?>
+ payment_id>0 ) + { + echo 'Payment No. :'.$invoice_master[0]->payment_id.'
'; + } + ?> + + Refer By : refer_by_other ?>
+ + +
+ +
+ + + +
+
+ + + + + + + + + + '; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + $srno=$srno+1; + echo ''; + } + ?> + + + + + + + + + +
#Charges GroupCharge NameRateQtyAmount
'.$srno.''.$row->desc.''.$row->item_name.''.$row->item_rate.''.$row->item_qty.''.$row->item_amount.'
#Amount received : payment_part_received?>Balance Amount : payment_part_balance?>Net Amountnet_amount?>
+
+ +
+ + payment_status==0 || $invoice_master[0]->payment_part ==1 ) { ?> +
+
+
+
+ + +
+
+
+ +
+
+
+
+ +
+ insurance_cash==1) { ?> +
+
+

+ + Cash +

+
+
+
+ +
+
+
+
+ +
+
+
+
+
+ + +
+
+
+
+ + +
+
+
+
+ + +
+
+
+
+ + +
+
+
+
+ + +
+
+
+
+
+
+ + 0) { ?> +
+ +
+
+
+
+
+ + ipd_code ?> autocomplete="off" readonly> + +
+
+
+
+ + +
+
+
+
+
+
+ insurance_id>0 && $invoice_master[0]->insurance_credit==1) { ?> +
+ +
+
+ 0) { ?> +
+
+
+ + case_id_code ?> autocomplete="off" readonly> + +
+
+
+
+ + +
+
+
+ +
+
+ +
+
+ +
+
+
+ +
+ +
+
+ +
+
+
+
+
+
+
+
+ +
+
+ Print +
+
+ Payment Method by : payment_mode_desc ?> +
+
+ + +
+ +
+ + \ No newline at end of file diff --git a/app/Views/Invoice/Organization_invoice_print_v.php b/app/Views/Invoice/Organization_invoice_print_v.php new file mode 100644 index 0000000..0e55ac9 --- /dev/null +++ b/app/Views/Invoice/Organization_invoice_print_v.php @@ -0,0 +1,181 @@ + + + + + + <?= H_Name ?> | Invoice + + + + + + + + + + + + + + + + + + + + +
+
+ +
+
+ +
+ +
+ +
+
+ + + +
+ Provisional Invoice #invoice_code ?>
+ insurance_id>0) + { + 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.'
'; + if($invoice_master[0]->insurance_case_id==2) + { + echo ' Service No. :'.$case_master[0]->insurance_no_2.'
'; + } + echo 'Claim ID/No : '.$case_master[0]->insurance_no_1.'
'; + } + } + ?> + Date : inv_date ?>
+ Patient ID : p_code ?>
+ payment_id>0 ) + { + echo 'Payment No. :'.$invoice_master[0]->payment_id.'
'; + } + ?> + + +
+
+ From +
+
+
+
+ Phone:
+ Email: +
+
+ +
+ To +
+ p_fname ?>
+ Gender : xgender ?>
+ Age : age ?>
+ Phone No : mphone1 ?>
+ Refer By : refer_by_other ?>
+
+
+ + +
+ + + +
+
+ + + + + + + + + + + + + '; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + $srno=$srno+1; + echo ''; + } + ?> + + + + + + + + + + +
#Charges GroupCharge NameRateQtyAmount
'.$srno.''.$row->desc.''.$row->item_name.''.$row->item_rate.''.$row->item_qty.''.$row->item_amount.'
#Amount received : payment_part_received?>Balance Amount : payment_part_balance?>Net Amountnet_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 Provisional invoice , Signature and stamp not required +
+ + +
+ + + diff --git a/app/Views/Invoice/case_list_all.php b/app/Views/Invoice/case_list_all.php new file mode 100644 index 0000000..e303b97 --- /dev/null +++ b/app/Views/Invoice/case_list_all.php @@ -0,0 +1,183 @@ + + +
+
+

Org. Case List

+
+
+
+
+ DataTable plugin is not loaded. Please include jQuery DataTables to enable filtering. +
+
+ + + + + + + + + + + + + + + + + + + + + + + + +
Case No.Claim/Insurance CardPatient Name/P-Code/IPDCase DateCard Holder NameInsuranceStatus
+ + +
+
+
+
+
+ + + \ No newline at end of file diff --git a/app/Views/Invoice/caseinvoice_V.php b/app/Views/Invoice/caseinvoice_V.php new file mode 100644 index 0000000..82e7c1c --- /dev/null +++ b/app/Views/Invoice/caseinvoice_V.php @@ -0,0 +1,497 @@ + + +
+
+
+

+ case_type==0){ + echo 'Organisation OPD Invoice'; + }else{ + echo 'Organisation IPD Invoice'; + } + ?> + Case ID: + + case_id_code?> + +

+ +
+
+
+
+
+ +
+
+
+
Name: p_fname?>
+
Age: age?>
+
Gender: xgender?>
+
P Code: p_code?>
+
Ins. Comp.: ins_company_name?>
+
Case Type: case_type==0 ? 'OPD' : 'IPD'?>
+
+ + + +
+
+
+ + + + + + + + + + + + + + + + + status<2) + { + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + }else{ + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + } + $Gamount=$Gamount+$row->Amount; + } + foreach($showinvoice2 as $row) + { + $srno=$srno+1; + if($orgcase[0]->status<2) + { + if(($row->discount_amount ?? 0) > 0){ + $readonly = 'readonly'; + $disabled = 'disabled'; + $rate = $row->d_rate ?? $row->item_rate; + $discription = $row->Description.' (Discounted) Rate : '.$row->item_rate; + }else{ + $readonly = ''; + $disabled = ''; + $rate = $row->item_rate; + $discription = $row->Description; + } + + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + }else{ + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + } + $Gamount=$Gamount+$row->Amount; + } + ?> + + + + + + + + + + + + + + +
#Date : InvIDCharges TypeDescriptionQtyRateAmountOrg. CodeAction
'.$srno.''.$row->str_date.' : '.$row->Code.''.$row->Charge_type.''.$row->Description.''.$row->item_qty.''.$row->item_rate.''.$row->Amount.''.$row->orgcode.'
'.$srno.''.$row->str_date.' : '.$row->Code.''.$row->Charge_type.''.$row->Description.''.$row->item_qty.''.$row->item_rate.''.$row->Amount.''.$row->orgcode.'
'.$srno.''.$row->str_date.' : '.$row->Code.''.$row->Charge_type.''.$discription.''.$row->item_qty.''.$row->Amount.'
'.$srno.''.$row->str_date.' : '.$row->Code.''.$row->Charge_type.''.$row->Description.''.$row->item_qty.''.$row->item_rate.''.$row->Amount.''.$row->orgcode.'
#Gross Total
+
+
+

Medical Bills

+
+
+ + + + + + + + + + + + '; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + $srno=$srno+1; + echo ''; + } + echo ''; + ?> + +
#Invoice ID.Inv.DateAmount
'.$srno.''.$row->inv_med_code.''.$row->inv_date.''.$row->net_amount.' Print
+
+
+
+
+
+
+ Current Status : + status==0) + { + echo 'Pending'; + } + if($orgcase[0]->status==1) + { + echo 'Ready For Submission'; + } + if($orgcase[0]->status==2) + { + echo 'Submitted in Org.'; + } + ?> +
+
+ org_submit_date=='') + { + $Dateofsubmit=date('d/m/Y'); + }else{ + $Dateofsubmit=MysqlDate_to_str($orgcase[0]->org_submit_date); + } + ?> +
+ status==0){ + ?> + +
+
+ +
+ +
+ '; + } + ?> +
+
+
+ + status==0) + { + echo ''; + echo ''; + }else if($orgcase[0]->status==1){ + echo ''; + echo ''; + }else{ + echo ''; + } + ?> +
+
+
+ case_type==0){ ?> +
+
+
+
+ + +
+
+
+
+ + +
+
+
+ +
+
+
+
+
+
+ + +
+
+
+
+ + +
+
+
+ +
+
+ +
+
+ 0){ + echo "

Payment History

"; + echo "
+ + + + + + + + + "; + + foreach($payment_history as $row){ + echo ""; + echo ""; + echo ""; + echo ""; + echo ""; + echo ""; + echo ""; + } + echo "
Pay IDDateAmountModeUpdate By
".$row->id."".$row->str_date."".$row->Pay_mode."".$row->amount."".$row->update_by."
"; + } + ?> +
+
+
+
+ +
+
+ + \ No newline at end of file diff --git a/app/Views/Invoice/caseinvoice_ipd_V.php b/app/Views/Invoice/caseinvoice_ipd_V.php new file mode 100644 index 0000000..8df4b31 --- /dev/null +++ b/app/Views/Invoice/caseinvoice_ipd_V.php @@ -0,0 +1,148 @@ +
+

Organisation IPD Invoice

+
+
+
+ +
+
+
+

+ Name :p_fname?> + / Age :age?> + / Gender :xgender?> + / P Code :p_code?> + / Ins. Comp. :ins_company_name?> +

+ + + +
+
+
+
+ + + + + + + + + + + + + + status<2) + { + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + }else{ + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + } + $Gamount=$Gamount+$row->Amount; + } + foreach($showinvoice2 as $row) + { + $srno=$srno+1; + if($orgcase[0]->status<2) + { + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + }else{ + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + } + $Gamount=$Gamount+$row->Amount; + } + ?> + + + + + + + + + + + + +
#Date : InvIDCharges TypeDescriptionQtyRateAmountOrg. CodeAction
'.$srno.''.$row->str_date.' : '.$row->Code.''.$row->Charge_type.''.$row->Description.''.$row->item_qty.''.$row->item_rate.''.$row->Amount.''.$row->orgcode.'
'.$srno.''.$row->str_date.' : '.$row->Code.''.$row->Charge_type.''.$row->Description.''.$row->item_qty.''.$row->item_rate.''.$row->Amount.''.$row->orgcode.'
'.$srno.''.$row->str_date.' : '.$row->Code.''.$row->Charge_type.''.$row->Description.''.$row->item_qty.''.$row->Amount.'
'.$srno.''.$row->str_date.' : '.$row->Code.''.$row->Charge_type.''.$row->Description.''.$row->item_qty.''.$row->item_rate.''.$row->Amount.''.$row->orgcode.'
#Gross Total
+
+ +
+ +
+ +
+
+ \ No newline at end of file diff --git a/app/Views/Invoice/caseinvoice_print_V.php b/app/Views/Invoice/caseinvoice_print_V.php new file mode 100644 index 0000000..28a774f --- /dev/null +++ b/app/Views/Invoice/caseinvoice_print_V.php @@ -0,0 +1,186 @@ + + + + + + + + + +
+ + +

+

, Uttarakhand
+ +

+ p_code.':'.$orgcase[0]->id .':P-'.date('Y-m-d H:i:s'); + ?> + +
+

Bill No.# :id?>

+
+ + + + + + +
Page : {PAGENO}/{nbpg}Bill No.:id?> / UHID:p_code ?> /Name : p_fname ?>
+
+ + + + + +
+ To
+ Patient ID : p_code ?>
+ p_fname ?>
+ Gender : xgender ?>
+ Age : age ?>
+ Phone No : mphone1 ?>
+ +
+ Organisation Invoice #case_id_code?>
+ Organisation :ins_company_name?>
+ Card / Insuranc No : insurance_no ?>
+ insurance_id==2) + { + echo ' Referral No. :'.$orgcase[0]->insurance_no_2.'
'; + } + ?> + Claim ID/No : insurance_no_1 ?>
+ org_submit_date=='') + { + $Dateofsubmit=date('d/m/Y'); + }else{ + $Dateofsubmit=MysqlDate_to_str($orgcase[0]->org_submit_date); + } + ?> + Bill Submit Date :
+
+

+ + + + + + + + + + + + + '; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + $Inv_total=$Inv_total+$row->Amount; + } + + foreach($showinvoice2 as $row) + { + $srno=$srno+1; + if(($row->discount_amount ?? 0) > 0){ + $readonly = 'readonly'; + $disabled = 'disabled'; + $rate = $row->d_rate ?? $row->item_rate; + $discription = $row->Description.' (Discounted) Rate : '.$row->item_rate; + }else{ + $readonly = ''; + $disabled = ''; + $rate = $row->item_rate; + $discription = $row->Description; + } + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + $Inv_total=$Inv_total+$row->Amount; + } + + if(count($MedInvoice)>0 && $med_include==1) + { + $srno=$srno+1; + $Inv_total=Round($Inv_total,0)+Round($MedInvoice[0]->Med_Amount,0); + ?> + + + + + + + + + + + + + + + + + +
#DateCharges TypeDescriptionOrg. CodeQtyRateSub Invoice CodeAmount
'.$srno.''.$row->str_date.''.$row->Charge_type.''.$row->Description.''.$row->orgcode.''.$row->Code.''.$row->Amount.'
'.$srno.''.$row->str_date.''.$row->Charge_type.''.$discription.''.$row->orgcode.''.$row->item_qty.''.$rate.''.$row->Code.''.$row->Amount.'
Medicine ExpenseMed_Amount?>
#Gross Total
+

+

+

+

+

Authorized Signatory

\ No newline at end of file diff --git a/app/Views/Invoice/org_case_payment.php b/app/Views/Invoice/org_case_payment.php new file mode 100644 index 0000000..5fe45e7 --- /dev/null +++ b/app/Views/Invoice/org_case_payment.php @@ -0,0 +1,144 @@ +
+ +
+ +
+
+
+

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

+ +
+
+
+
+

+ Org Code :case_id_code?> + / Org. Name :insurance_company_name?> + / Card No :insurance_no?> + insurance_no_1?> + insurance_no_2?> +

+ +
+
+ 0){ ?> +
+
+

+ IPD Code :ipd_code?> + / Admit Date :str_register_date?> + / Dis. Date :str_discharge_date?> + / Charge Amt :charge_amount?> + / Medical Bill :med_amount?> +

+
+
+ +
+
+
+
+
+

Amount :

+
+
+
+
+ + +
+
+
+
+ +
+
+ +
+ /> +
+
+
+
+
+ + +
+
+
+
+ + +
+
+
+
+ + +
+
+
+
+ + +
+
+ +
+ +
+
+
+ \ No newline at end of file diff --git a/app/Views/Invoice/payment_req_panel.php b/app/Views/Invoice/payment_req_panel.php new file mode 100644 index 0000000..b02051a --- /dev/null +++ b/app/Views/Invoice/payment_req_panel.php @@ -0,0 +1,145 @@ + +
+
+
+
Name: p_fname ?? '') ?> {p_rname ?? '') ?>}
+
Age: age ?? '') ?>
+
Gender: xgender ?? '') ?>
+
P Code: p_code ?? '') ?>
+
ORG. Code: case_id_code ?? '') ?>
+
+
+
+ +
+
+ Payment Amount + +
+
+
+
+ + +
+
+ +
+
+

+ +

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

+ +

+
+
+
+
+ + +
+
+ + +
+
+ + +
+
+
+
+
+
+
+
+ + diff --git a/app/Views/Invoice/payment_request_list.php b/app/Views/Invoice/payment_request_list.php new file mode 100644 index 0000000..a10862f --- /dev/null +++ b/app/Views/Invoice/payment_request_list.php @@ -0,0 +1,127 @@ + + +
+
+

Payment Paid Request

+
+
+
+
+ DataTable plugin is not loaded. Please include jQuery DataTables to enable filtering. +
+
+ + + + + + + + + + + + + + + + + + + + + + +
#Org. Case No.Patient NameRequest DateAmountStatus
+ +
+
+
+
+
+ diff --git a/app/Views/Invoice/refund_amount_panel.php b/app/Views/Invoice/refund_amount_panel.php new file mode 100644 index 0000000..e3cb3d9 --- /dev/null +++ b/app/Views/Invoice/refund_amount_panel.php @@ -0,0 +1,88 @@ + +
+
+
Refund Amount
+
+
+ +
+
+
CODE: refund_type_code ?? '') ?>
+
Patient Name: patient_name ?? '') ?>
+
+
+
Refund Reason: refund_type_reason ?? '') ?>
+
Refund Amount: Rs. refund_amount ?? '') ?>
+
+
+
Approved By: approved_by ?? '') ?>
+
Date Time: approved_datetime ?? '') ?>
+
+
+
+
+ +
+ +refund_process ?? 0) == 0) : ?> +
+
+
+
+ + +
+
+ + +
+
+ +
+
+
+
+ +
+
+
Refund Done
+
+
+ + + + diff --git a/app/Views/Invoice/refund_invoice.php b/app/Views/Invoice/refund_invoice.php new file mode 100644 index 0000000..da1a846 --- /dev/null +++ b/app/Views/Invoice/refund_invoice.php @@ -0,0 +1,129 @@ + + +
+
+

Payment Refund Request

+
+
+
+
+ DataTable plugin is not loaded. Please include jQuery DataTables to enable filtering. +
+
+ + + + + + + + + + + + + + + + + + + + + + + + +
Refund No.Invoice No.Invoice TypePatient NameApproved DateAmountStatus
+ +
+
+
+
+
+ diff --git a/app/Views/PathLab_Report/_test_option_table.php b/app/Views/PathLab_Report/_test_option_table.php new file mode 100644 index 0000000..1a78f29 --- /dev/null +++ b/app/Views/PathLab_Report/_test_option_table.php @@ -0,0 +1,38 @@ + + + + + + + + + + + + + + + + + + + +
#CodeBoldAction
sort_id ?? '') ?>option_value ?? '') ?>option_bold_str ?? '') ?> +
+ + id ?? 0; + $sort_current = $lab_test_option[$i]->sort_id ?? 0; + if ($i + 1 < count($lab_test_option ?? [])) { + $option_next = $lab_test_option[$i + 1]->id ?? 0; + $sort_next = $lab_test_option[$i + 1]->sort_id ?? 0; + echo ''; + } + if ($i > 0) { + $option_prev = $lab_test_option[$i - 1]->id ?? 0; + $sort_prev = $lab_test_option[$i - 1]->sort_id ?? 0; + echo ''; + } + ?> +
+
diff --git a/app/Views/PathLab_Report/lab_report_edit.php b/app/Views/PathLab_Report/lab_report_edit.php new file mode 100644 index 0000000..8597cf2 --- /dev/null +++ b/app/Views/PathLab_Report/lab_report_edit.php @@ -0,0 +1,135 @@ + +
+
+

Report Edit

+
+
+
+
+
+ + 0) { + $repo_name = $labReport_master[0]->Title ?? ''; + $repo_id = $labReport_master[0]->mstRepoKey ?? '0'; + $HTMLData = $labReport_master[0]->HTMLData ?? ''; + } + ?> + + +
+
+
+
+ + +
+
+
+
+ + +
+
+
+
+
+ + +
+
+
+
+ +
+
+
+
+ +
+
+

Report Parameter

+
+
+
+
+ id ?? 0) % max(1, count($color_name ?? []))]->code_code_2 ?? '#0f172a'; + echo '
' . esc($lab_Rep_Item_List[$i]->Test ?? '') . '[' . esc($lab_Rep_Item_List[$i]->TestID ?? '') . ']
'; + } ?> +
+
+
+
+ +
+
+
+
+ + diff --git a/app/Views/PathLab_Report/lab_report_item_edit.php b/app/Views/PathLab_Report/lab_report_item_edit.php new file mode 100644 index 0000000..bc67384 --- /dev/null +++ b/app/Views/PathLab_Report/lab_report_item_edit.php @@ -0,0 +1,264 @@ + 0) { + $mstTestKey = $lab_test_parameter[0]->mstTestKey ?? 0; + $Test = $lab_test_parameter[0]->Test ?? ''; + $TestID = $lab_test_parameter[0]->TestID ?? ''; + $Result = $lab_test_parameter[0]->Result ?? ''; + $Formula = $lab_test_parameter[0]->Formula ?? ''; + $VRule = $lab_test_parameter[0]->VRule ?? ''; + $VMsg = $lab_test_parameter[0]->VMsg ?? ''; + $Unit = $lab_test_parameter[0]->Unit ?? ''; + $FixedNormals = $lab_test_parameter[0]->FixedNormals ?? ''; + $isGenderSpecific = (int) ($lab_test_parameter[0]->isGenderSpecific ?? 0); + $FixedNormalsWomen = $lab_test_parameter[0]->FixedNormalsWomen ?? ''; + + if ($isGenderSpecific == 1) { + $checkbox_checked = 'checked'; + } +} +?> + +
+
+

Test Parameter

+
+
+
+
+
+ + + + +
+
+
+
+ + +
+
+
+
+
+
+ + +
+
+
+
+ + +
+
+
+
+
+
+ + +
+
+
+
+ + +
+
+
+
+
+
+ + +
+
+
+
+ + +
+
+
+
+
+
+ +
+
+
+
+ + +
+
+
+
+
+
+ $lab_test_option ?? [], 'mstTestKey' => $mstTestKey]) ?> +
+
+
+
+ + +
+
+
+
+ +
+
+
+
+ + +
+
+
+
+
+
+
+ + +
+
+
+
+ + +
+
+
+
+ + +
+
+
+
+
+ + diff --git a/app/Views/PathLab_Report/lab_report_list.php b/app/Views/PathLab_Report/lab_report_list.php new file mode 100644 index 0000000..1995c99 --- /dev/null +++ b/app/Views/PathLab_Report/lab_report_list.php @@ -0,0 +1,135 @@ + +
+ +
+
+
+
+

Report List

+ +
+
+ + + + + + + + + + + + + + + + + + + + + + + + +
Report TitleGroupAction
Title ?? '') ?>RepoGrp ?? '') ?> + + +
Report TitleGroupAction
+
+
+
+ +
+
+
+ + + diff --git a/app/Views/PathLab_Report/lab_report_test_list.php b/app/Views/PathLab_Report/lab_report_test_list.php new file mode 100644 index 0000000..2ee5b3d --- /dev/null +++ b/app/Views/PathLab_Report/lab_report_test_list.php @@ -0,0 +1,80 @@ + +
+
+

Test List

+ +
+
+ + + + + + + + + + + + + + + + + + + +
#Test NameTest CodeAction
Test ?? '') ?>TestID ?? '') ?> +
+ + + id ?? 0; + $sort_current = $lab_Rep_Item_List[$i]->EOrder ?? 0; + if ($i + 1 < count($lab_Rep_Item_List ?? [])) { + $option_next = $lab_Rep_Item_List[$i + 1]->id ?? 0; + $sort_next = $lab_Rep_Item_List[$i + 1]->EOrder ?? 0; + echo ''; + } + if ($i > 0) { + $option_prev = $lab_Rep_Item_List[$i - 1]->id ?? 0; + $sort_prev = $lab_Rep_Item_List[$i - 1]->EOrder ?? 0; + echo ''; + } + ?> +
+
+
+
+ + diff --git a/app/Views/PathLab_Report/lab_test_search.php b/app/Views/PathLab_Report/lab_test_search.php new file mode 100644 index 0000000..d01391c --- /dev/null +++ b/app/Views/PathLab_Report/lab_test_search.php @@ -0,0 +1,55 @@ + +
+
+

Test Parameter

+ + +
+
+
+
+
+ + +
+
+
+
+ + +
+
+
+
+
+
+
+
+ + diff --git a/app/Views/PathLab_Report/ultrasound_report_edit.php b/app/Views/PathLab_Report/ultrasound_report_edit.php new file mode 100644 index 0000000..115ff53 --- /dev/null +++ b/app/Views/PathLab_Report/ultrasound_report_edit.php @@ -0,0 +1,135 @@ + +
+
+

Radiology Report Edit

+
+
+
+
+
+ + 0) { + $repo_id = $labReport_master[0]->id ?? '0'; + $repo_name = $labReport_master[0]->template_name ?? ''; + $repo_title = $labReport_master[0]->title ?? ''; + $HTMLData = $labReport_master[0]->Findings ?? ''; + $Impression = $labReport_master[0]->Impression ?? ''; + } + ?> + + +
+
+
+
+ + +
+
+
+
+ + +
+
+
+
+
+
+ + + +
+
+
+
+
+ + + +
+
+
+
+
+
+ + +
+
+
+
+
+ + diff --git a/app/Views/PathLab_Report/ultrasound_template_list.php b/app/Views/PathLab_Report/ultrasound_template_list.php new file mode 100644 index 0000000..280c703 --- /dev/null +++ b/app/Views/PathLab_Report/ultrasound_template_list.php @@ -0,0 +1,134 @@ + +
+ +
+
+
+
+

Report List

+ +
+
+ + + + + + + + + + + + + + + + + + + + + + + + +
Report TitleGroupAction
template_name ?? '') ?>title ?? '') ?> + +
Report TitleGroupAction
+
+
+
+ +
+
+
+ + + diff --git a/app/Views/Setting/Admin/Doctor/temp/Doctor_Search_V.php b/app/Views/Setting/Admin/Doctor/temp/Doctor_Search_V.php new file mode 100644 index 0000000..813527b --- /dev/null +++ b/app/Views/Setting/Admin/Doctor/temp/Doctor_Search_V.php @@ -0,0 +1,59 @@ +
+

+ Doctor + List +

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

Result

+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + +
NamePhone NumberEMailAction
p_title ?> p_fname ?>mphone1 ?>email1 ?>
NamePhone NumberEMailAction
+
+ +
+
+
\ No newline at end of file diff --git a/app/Views/Setting/Admin/Doctor/temp/Doctor_V.php b/app/Views/Setting/Admin/Doctor/temp/Doctor_V.php new file mode 100644 index 0000000..bb23567 --- /dev/null +++ b/app/Views/Setting/Admin/Doctor/temp/Doctor_V.php @@ -0,0 +1,105 @@ +
+

+ Doctor + Add New +

+ +
+ +
+
+
+
+ 'form','class'=>'form1')); ?> +
+
+
+ + +
+
+
+
+ + +
+
+
+
+ + +
+
+
+
+
+
+
+ + +
+
+
+
+
+ + +
+
+
+
+ +
+
+ +
+ +
+
+
+
+
+ + +
+
+ + +
+ + + +
+
+
+ + + + \ No newline at end of file diff --git a/app/Views/Setting/Admin/Doctor/temp/Doctor_profile_V.php b/app/Views/Setting/Admin/Doctor/temp/Doctor_profile_V.php new file mode 100644 index 0000000..a93029d --- /dev/null +++ b/app/Views/Setting/Admin/Doctor/temp/Doctor_profile_V.php @@ -0,0 +1,300 @@ +
+

+ Doctor + Dr. p_fname; ?> +

+ +
+ +
+
+
+
+ 'form','class'=>'form1')); ?> + +
+
+
+ + +
+
+
+
+ + +
+
+
+
+ + +
+
+
+
+
+
+ +
+ + +
+
+
+
+
+ + +
+
+
+
+ +
+
+ +
+ +
+
+
+
+
+
+
+ + +
+
+
+
+
+
+
+ +
+
+
+
+
+
+
+
+
+ +
+ '; + echo ' '; + echo ' '; + echo ' '; + echo '
'; + } + ?> +
+
+
+ + + + + +
+
+
+
+
+
+
+
+
+
+
+ ''); + $this->table->set_template($table_property); + $this->table->set_heading('Fee Type', 'Description', 'Amount'); + foreach($doc_fee_list as $row) + { + if($row->id=='') + { + $button_code=' Not Define'; + }else{ + $button_code='Remove'; + } + + $this->table->add_row($row->fee_type, $row->doc_fee_desc, $row->amount,$button_code); + } + echo $this->table->generate(); + + ?> + + + + +
+ + +
+ + + + + + + + + + + \ No newline at end of file diff --git a/app/Views/Setting/Admin/UserManagement/create.php b/app/Views/Setting/Admin/UserManagement/create.php new file mode 100644 index 0000000..13b1e07 --- /dev/null +++ b/app/Views/Setting/Admin/UserManagement/create.php @@ -0,0 +1,84 @@ + + +
+
+

New Users

+
+ +
+
+
+ + + +
+ +
+ +
+ +
+ +
+
+ + +
Username is required.
+
+
+ + +
Email is required.
+
+
+ + +
Password is required.
+
+
+ + +
Role is required.
+
+
+ +
+ + +
+ +
+
+ + diff --git a/app/Views/Setting/Admin/UserManagement/edit.php b/app/Views/Setting/Admin/UserManagement/edit.php new file mode 100644 index 0000000..43ab2f2 --- /dev/null +++ b/app/Views/Setting/Admin/UserManagement/edit.php @@ -0,0 +1,79 @@ +
+
+

Edit User

+
+ +
+
+
+ + + +
+ +
+ +
+ + +
+ +
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+
+
+ active ?? 0)) === 1 ? 'checked' : '' ?>> + +
+
+
+ +
+ + +
+ +
+
+ + diff --git a/app/Views/Setting/Admin/UserManagement/index.php b/app/Views/Setting/Admin/UserManagement/index.php new file mode 100644 index 0000000..cfbee14 --- /dev/null +++ b/app/Views/Setting/Admin/UserManagement/index.php @@ -0,0 +1,145 @@ +
+
+

Users

+ +
+ + +
+
+
+ + + +
+ + +
+ +
+ +
+ +
+
+ + +
+
+ + +
+
+ +
+
+
+
+ + + + + + + + + + + + + + + + $user) : ?> + getEmailIdentity(); + $email = $emailIdentity ? $emailIdentity->secret : ''; + $personName = ''; + $phoneNo = ''; + if ($emailIdentity && isset($emailIdentity->extra)) { + $extra = $emailIdentity->extra; + if (is_string($extra) && trim($extra) !== '') { + $decodedExtra = json_decode($extra, true); + if (is_array($decodedExtra)) { + $personName = trim((string) ($decodedExtra['full_name'] ?? '')); + $phoneNo = trim((string) ($decodedExtra['phone_no'] ?? '')); + } + } elseif (is_array($extra)) { + $personName = trim((string) ($extra['full_name'] ?? '')); + $phoneNo = trim((string) ($extra['phone_no'] ?? '')); + } + } + $groups = $user->getGroups() ?? []; + $roleLabels = []; + foreach ($groups as $group) { + $roleLabels[] = $rolesConfig[$group]['title'] ?? $group; + } + $roleText = $roleLabels !== [] ? implode(', ', $roleLabels) : '-'; + ?> + + + + + + + + + + + + + + + + + +
#Login IDPerson NamePhone No.EmailRoleStatusAction
username ?? '') ?> + active)) : ?> + Active + + Inactive + + +
+ + +
+
No users loaded yet.
+
+
+
+ + \ No newline at end of file diff --git a/app/Views/Setting/Admin/UserManagement/permissions.php b/app/Views/Setting/Admin/UserManagement/permissions.php new file mode 100644 index 0000000..8fbe2fb --- /dev/null +++ b/app/Views/Setting/Admin/UserManagement/permissions.php @@ -0,0 +1,181 @@ +
+
+

Give Permissions

+
+ +
+
+
+ + + +
+ + +
+ +
+ +
+ +
+ +
+
+ + +
User is required.
+
+
+ +
+
+ +
+ +
+ Pharmacy module access is controlled by pharmacy.access. +
+
+ getPermissions() ?? []; + } + + $groupedPermissions = []; + $groupTitles = [ + 'admin' => 'Admin', + 'users' => 'Users', + 'beta' => 'Beta', + 'template' => 'Templates', + 'pharmacy' => 'Pharmacy', + 'opd' => 'OPD Doctor Panel', + 'billing.opd' => 'OPD', + 'billing.charges' => 'Charges', + 'billing.ipd' => 'IPD Billing', + 'billing' => 'Billing', + 'other' => 'Other', + ]; + foreach ($permissions as $permissionKey => $permissionLabel) { + $parts = explode('.', $permissionKey); + $groupKey = $parts[0] ?? 'other'; + if ($groupKey === 'billing' && isset($parts[1])) { + $groupKey = $groupKey . '.' . $parts[1]; + } + + if (! isset($groupTitles[$groupKey])) { + $titleBase = str_replace(['-', '_'], ' ', $groupKey); + $titleBase = str_replace('billing ', '', $titleBase); + $groupTitles[$groupKey] = ucwords($titleBase); + } + + if (! isset($groupedPermissions[$groupKey])) { + $groupedPermissions[$groupKey] = []; + } + + $groupedPermissions[$groupKey][$permissionKey] = $permissionLabel; + } + if (! isset($groupedPermissions['other'])) { + $groupedPermissions['other'] = []; + } + + $groupOrder = [ + 'admin', + 'users', + 'template', + 'pharmacy', + 'opd', + 'billing.opd', + 'billing.charges', + 'billing.ipd', + 'billing', + 'beta', + 'other', + ]; + ?> + +
+ + +
+
+ $permissionLabel) : ?> +
+ > + +
+ +
+ +
+ +
No permissions configured.
+ +
+
+ +
+ + +
+
+
+
+ + +
diff --git a/app/Views/Setting/Admin/UserManagement/reset_password.php b/app/Views/Setting/Admin/UserManagement/reset_password.php new file mode 100644 index 0000000..cc5581a --- /dev/null +++ b/app/Views/Setting/Admin/UserManagement/reset_password.php @@ -0,0 +1,106 @@ +
+
+

Set Temporary PIN

+
+ +
+
+
+ + +
+ +
+ +
+ + +
+
Login ID: username ?? '')) ?>
+
User ID: id ?? '')) ?>
+
Set a 6-digit temporary PIN. User will be forced to change password at next login.
+
+ +
+ +
+
+ + +
+
+ + +
+
+ +
+ + + Use generated PIN or enter manually. +
+ +
+ + +
+
+
+
+ + diff --git a/app/Views/Setting/Admin/ai_settings.php b/app/Views/Setting/Admin/ai_settings.php new file mode 100644 index 0000000..4ec835a --- /dev/null +++ b/app/Views/Setting/Admin/ai_settings.php @@ -0,0 +1,227 @@ +
+
+

AI Settings

+
+
+ + +
Gemini (optional fallback)
+ +
+ + +
+ + Current key: + + No API key configured yet. + +
+
+ +
+
How to get Gemini API key
+
    +
  1. + Open Google AI Studio API Keys + . +
  2. +
  3. Sign in and click Create API key.
  4. +
  5. Copy the key and paste it in this field.
  6. +
  7. Click Save Key, then Test Connection.
  8. +
+
If test fails, check internet access from server, remove extra spaces/newline in key, or regenerate key.
+
+ +
+
Azure OpenAI (Primary)
+
+ + +
+
+ + +
+ + Current key: + + No Azure OpenAI key configured yet. + +
+
+
+
+ + +
+
+ + +
+
+ +
+
OCR (Azure Document Intelligence)
+
+ + +
+
+ + +
+ + Current key: + + No Document Intelligence key configured yet. + +
+
+ +
+ + + +
+ +
+
+
+ + diff --git a/app/Views/Setting/Admin/index.php b/app/Views/Setting/Admin/index.php new file mode 100644 index 0000000..8e681e8 --- /dev/null +++ b/app/Views/Setting/Admin/index.php @@ -0,0 +1,106 @@ +
+
+

Admin Panel

+ +
+ + + + +
+
+
+
+
diff --git a/app/Views/Setting/Bank/bank_search_v.php b/app/Views/Setting/Bank/bank_search_v.php new file mode 100644 index 0000000..35d7540 --- /dev/null +++ b/app/Views/Setting/Bank/bank_search_v.php @@ -0,0 +1,339 @@ +
+
+

Bank & Payment Sources

+
+
+ +
+
+ + +
+
+ + +
+
+ +
+ +
+
+
+
Payment Sources (Items)
+
+ + + + + + + + + + + + +
Pay Type
Select a bank to view payment sources.
+
+
+
+
+ +
+ +
+
+
Banks
+
+ + + + + + + + + + + + + + + + + + + + + +
Bank
bank_name ?? '') ?> + + +
No banks found.
+
+
+
+
+
+ + + + + + diff --git a/app/Views/Setting/Bed/assignment_history.php b/app/Views/Setting/Bed/assignment_history.php new file mode 100644 index 0000000..a487b6a --- /dev/null +++ b/app/Views/Setting/Bed/assignment_history.php @@ -0,0 +1,249 @@ +
+
+

Bed Assignment History

+ +
+
+
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+
+
+
+
+
+ +
+
+ +
+
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + +
BedWardTypeAssignedReleasedTotal DaysReasonAction
bed_code ?? '') . ' ' . ($row->bed_number ?? '')) ?>ward_name ?? '') ?>assignment_type ?? '') ?>assigned_date ?? '') ?>released_date ?? $row->discharged_date ?? '') ?>total_days ?? '') ?>release_reason ?? $row->transfer_reason ?? '') ?> + + +
+
+
+
+ diff --git a/app/Views/Setting/Bed/bed_list.php b/app/Views/Setting/Bed/bed_list.php new file mode 100644 index 0000000..4f7ab56 --- /dev/null +++ b/app/Views/Setting/Bed/bed_list.php @@ -0,0 +1,262 @@ +
+
+

Bed Master

+ +
+
+
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+
+
+ + +
+
+ + +
+
+ + +
+
+
+
+
+
+ +
+
+ +
+
+ +
+
+
+ + + + + + + + + + + + + + + + + + + + + + + + + +
CodeNumberWardCategoryStatusActiveAction
bed_code ?? '') ?>bed_number ?? '') ?>ward_name ?? '') ?>category_name ?? '') ?>bed_status ?? '') ?>status ?? '') ?> + + +
+
+
+
+ diff --git a/app/Views/Setting/Bed/category_list.php b/app/Views/Setting/Bed/category_list.php new file mode 100644 index 0000000..f5ed3ed --- /dev/null +++ b/app/Views/Setting/Bed/category_list.php @@ -0,0 +1,213 @@ +
+
+

Bed Categories

+ +
+
+
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+
+
+
+
+
+ +
+
+ +
+
+
+ + + + + + + + + + + + + + + + + + + + + + + +
CodeNameTypeChargesStatusAction
category_code ?? '') ?>category_name ?? '') ?>category_type ?? '') ?>base_charge_per_day ?? '') ?> / nursing_charge_per_day ?? '') ?>status ?? '') ?> + + +
+
+
+
+ diff --git a/app/Views/Setting/Bed/index.php b/app/Views/Setting/Bed/index.php new file mode 100644 index 0000000..807e943 --- /dev/null +++ b/app/Views/Setting/Bed/index.php @@ -0,0 +1,43 @@ +
+
+

Bed Management

+ +
+ + + +
+
+
+
+
diff --git a/app/Views/Setting/Bed/maintenance_list.php b/app/Views/Setting/Bed/maintenance_list.php new file mode 100644 index 0000000..ecce522 --- /dev/null +++ b/app/Views/Setting/Bed/maintenance_list.php @@ -0,0 +1,233 @@ +
+
+

Bed Maintenance Log

+ +
+
+
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+
+
+
+
+
+ +
+
+ +
+
+ +
+
+
+ + + + + + + + + + + + + + + + + + + + + + + + + +
BedWardTypeStatusScheduledCompletedAction
bed_code ?? '') . ' ' . ($row->bed_number ?? '')) ?>ward_name ?? '') ?>maintenance_type ?? '') ?>status ?? '') ?>scheduled_date ?? '') ?>completed_date ?? '') ?> + + +
+
+
+
+ diff --git a/app/Views/Setting/Charges/IPD_Charges/item_create_V.php b/app/Views/Setting/Charges/IPD_Charges/item_create_V.php new file mode 100644 index 0000000..eb19ca8 --- /dev/null +++ b/app/Views/Setting/Charges/IPD_Charges/item_create_V.php @@ -0,0 +1,69 @@ +
+
+

IPD Charges - Add New

+
+ +
+
+
+
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+
+
+
+ +
+
+
+
+
+ + diff --git a/app/Views/Setting/Charges/IPD_Charges/item_insurance_list.php b/app/Views/Setting/Charges/IPD_Charges/item_insurance_list.php new file mode 100644 index 0000000..2fc3906 --- /dev/null +++ b/app/Views/Setting/Charges/IPD_Charges/item_insurance_list.php @@ -0,0 +1,24 @@ + + + + + + + + + + + + + + + + + + + + + +
Company NameAmountCodeAction
ins_company_name ?? '') ?>i_amount ?? '') ?>code ?? '') ?> + +
diff --git a/app/Views/Setting/Charges/IPD_Charges/item_item_excel.php b/app/Views/Setting/Charges/IPD_Charges/item_item_excel.php new file mode 100644 index 0000000..6a3a825 --- /dev/null +++ b/app/Views/Setting/Charges/IPD_Charges/item_item_excel.php @@ -0,0 +1,33 @@ + +

Rate List of group_desc ?? 'Charges') ?> for

+ +

Rate List of group_desc ?? 'Charges') ?>

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Charge NameCharge DetailsAmountCodeAmount
idesc ?? '') ?>idesc_detail ?? '') ?>display_amount ?? $row->i_amount ?? $row->amount ?? '') ?>code ?? ($row->i_amount === null ? 'Base Rate' : '')) ?>amount ?? '') ?>
diff --git a/app/Views/Setting/Charges/IPD_Charges/item_item_list.php b/app/Views/Setting/Charges/IPD_Charges/item_item_list.php new file mode 100644 index 0000000..462c9e1 --- /dev/null +++ b/app/Views/Setting/Charges/IPD_Charges/item_item_list.php @@ -0,0 +1,54 @@ + + + + + + IPD Charges + + + + + +
+
+ + +

Rate List of group_desc ?? 'Charges') ?> for

+ +

Rate List of group_desc ?? 'Charges') ?>

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Charge NameCharge DetailsAmountCodeAmount
idesc ?? '') ?>idesc_detail ?? '') ?>display_amount ?? $row->i_amount ?? '') ?>code ?? ($row->i_amount === null ? 'Base Rate' : '')) ?>amount ?? '') ?>
+
+
+ + diff --git a/app/Views/Setting/Charges/IPD_Charges/item_profile_V.php b/app/Views/Setting/Charges/IPD_Charges/item_profile_V.php new file mode 100644 index 0000000..c97ed10 --- /dev/null +++ b/app/Views/Setting/Charges/IPD_Charges/item_profile_V.php @@ -0,0 +1,149 @@ + +
+
+

IPD Charge Name: idesc ?? '') ?>

+
+
+
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+
+
+
+ + +
+
+
+
+ +
+
+
+
+
+
+
Insurance Rates
+
+
+
+ $data_insurance_item]) ?> +
+
+
+
+ + +
+
+ + +
+
+ + +
+
+ +
+
+
+
+
+
+ + + diff --git a/app/Views/Setting/Charges/IPD_Charges/item_search_V.php b/app/Views/Setting/Charges/IPD_Charges/item_search_V.php new file mode 100644 index 0000000..5d1f875 --- /dev/null +++ b/app/Views/Setting/Charges/IPD_Charges/item_search_V.php @@ -0,0 +1,110 @@ +
+
+

IPD Charges

+
+ + +
+
+
+
+
+ + +
+
+ + +
+
+ + +
+
+
+
+
+ $data, 'typeId' => $typeId]) ?> +
+
+
+
+
+ + + + diff --git a/app/Views/Setting/Charges/IPD_Charges/item_search_adv.php b/app/Views/Setting/Charges/IPD_Charges/item_search_adv.php new file mode 100644 index 0000000..e8a43f7 --- /dev/null +++ b/app/Views/Setting/Charges/IPD_Charges/item_search_adv.php @@ -0,0 +1,43 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + +
GroupCharge NameAmount
group_desc ?? '') ?>idesc ?? '') ?>amount ?? '') ?> + +
GroupCharge NameAmount
+ + diff --git a/app/Views/Setting/Charges/IPD_Charges/item_type_create.php b/app/Views/Setting/Charges/IPD_Charges/item_type_create.php new file mode 100644 index 0000000..f4c339b --- /dev/null +++ b/app/Views/Setting/Charges/IPD_Charges/item_type_create.php @@ -0,0 +1,54 @@ +
+
+

IPD Charges Group - Add New

+
+ +
+
+
+
+
+ +
+
+ + +
+
+ +
+
+
+
+
+ + diff --git a/app/Views/Setting/Charges/IPD_Charges/item_type_profile.php b/app/Views/Setting/Charges/IPD_Charges/item_type_profile.php new file mode 100644 index 0000000..3b99b98 --- /dev/null +++ b/app/Views/Setting/Charges/IPD_Charges/item_type_profile.php @@ -0,0 +1,56 @@ + +
+
+

IPD Charges Group: group_desc ?? '') ?>

+
+ +
+
+
+
+
+ + +
+
+ + +
+
+ +
+
+
+
+
+ + + diff --git a/app/Views/Setting/Charges/IPD_Charges/item_type_search_v.php b/app/Views/Setting/Charges/IPD_Charges/item_type_search_v.php new file mode 100644 index 0000000..f1d5778 --- /dev/null +++ b/app/Views/Setting/Charges/IPD_Charges/item_type_search_v.php @@ -0,0 +1,46 @@ +
+
+

IPD Charges Groups

+
+ + +
+
+
+ + + + + + + + + + + + + + + + + + + + + +
Charges Group Name
group_desc ?? '') ?> + +
Charges Group Name
+
+
+ + diff --git a/app/Views/Setting/Charges/OPD_Charges/item_create_V.php b/app/Views/Setting/Charges/OPD_Charges/item_create_V.php new file mode 100644 index 0000000..3a20f31 --- /dev/null +++ b/app/Views/Setting/Charges/OPD_Charges/item_create_V.php @@ -0,0 +1,69 @@ +
+
+

OPD Charges - Add New

+
+ +
+
+
+
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+
+
+
+ +
+
+
+
+
+ + diff --git a/app/Views/Setting/Charges/OPD_Charges/item_insurance_list.php b/app/Views/Setting/Charges/OPD_Charges/item_insurance_list.php new file mode 100644 index 0000000..2fc3906 --- /dev/null +++ b/app/Views/Setting/Charges/OPD_Charges/item_insurance_list.php @@ -0,0 +1,24 @@ + + + + + + + + + + + + + + + + + + + + + +
Company NameAmountCodeAction
ins_company_name ?? '') ?>i_amount ?? '') ?>code ?? '') ?> + +
diff --git a/app/Views/Setting/Charges/OPD_Charges/item_item_excel.php b/app/Views/Setting/Charges/OPD_Charges/item_item_excel.php new file mode 100644 index 0000000..6a3a825 --- /dev/null +++ b/app/Views/Setting/Charges/OPD_Charges/item_item_excel.php @@ -0,0 +1,33 @@ + +

Rate List of group_desc ?? 'Charges') ?> for

+ +

Rate List of group_desc ?? 'Charges') ?>

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Charge NameCharge DetailsAmountCodeAmount
idesc ?? '') ?>idesc_detail ?? '') ?>display_amount ?? $row->i_amount ?? $row->amount ?? '') ?>code ?? ($row->i_amount === null ? 'Base Rate' : '')) ?>amount ?? '') ?>
diff --git a/app/Views/Setting/Charges/OPD_Charges/item_item_list.php b/app/Views/Setting/Charges/OPD_Charges/item_item_list.php new file mode 100644 index 0000000..f0c3452 --- /dev/null +++ b/app/Views/Setting/Charges/OPD_Charges/item_item_list.php @@ -0,0 +1,54 @@ + + + + + + OPD Charges + + + + + +
+
+ + +

Rate List of group_desc ?? 'Charges') ?> for

+ +

Rate List of group_desc ?? 'Charges') ?>

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Charge NameCharge DetailsAmountCodeAmount
idesc ?? '') ?>idesc_detail ?? '') ?>display_amount ?? $row->i_amount ?? '') ?>code ?? ($row->i_amount === null ? 'Base Rate' : '')) ?>amount ?? '') ?>
+
+
+ + diff --git a/app/Views/Setting/Charges/OPD_Charges/item_profile_V.php b/app/Views/Setting/Charges/OPD_Charges/item_profile_V.php new file mode 100644 index 0000000..d3b9e34 --- /dev/null +++ b/app/Views/Setting/Charges/OPD_Charges/item_profile_V.php @@ -0,0 +1,149 @@ + +
+
+

OPD Charge Name: idesc ?? '') ?>

+
+
+
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+
+
+
+ + +
+
+
+
+ +
+
+
+
+
+
+
Insurance Rates
+
+
+
+ $data_insurance_item]) ?> +
+
+
+
+ + +
+
+ + +
+
+ + +
+
+ +
+
+
+
+
+
+ + + diff --git a/app/Views/Setting/Charges/OPD_Charges/item_search_V.php b/app/Views/Setting/Charges/OPD_Charges/item_search_V.php new file mode 100644 index 0000000..2998423 --- /dev/null +++ b/app/Views/Setting/Charges/OPD_Charges/item_search_V.php @@ -0,0 +1,110 @@ +
+
+

OPD Charges

+
+ + +
+
+
+
+
+ + +
+
+ + +
+
+ + +
+
+
+
+
+ $data, 'typeId' => $typeId]) ?> +
+
+
+
+
+ + + + diff --git a/app/Views/Setting/Charges/OPD_Charges/item_search_adv.php b/app/Views/Setting/Charges/OPD_Charges/item_search_adv.php new file mode 100644 index 0000000..e7eeffc --- /dev/null +++ b/app/Views/Setting/Charges/OPD_Charges/item_search_adv.php @@ -0,0 +1,46 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
OPD or IPDGroupCharge NameAmount
isIPD_OPD ?? '') ?>group_desc ?? '') ?>idesc ?? '') ?>amount ?? '') ?> + +
OPD or IPDGroupCharge NameAmount
+ + diff --git a/app/Views/Setting/Charges/OPD_Charges/item_type_create.php b/app/Views/Setting/Charges/OPD_Charges/item_type_create.php new file mode 100644 index 0000000..d87dc23 --- /dev/null +++ b/app/Views/Setting/Charges/OPD_Charges/item_type_create.php @@ -0,0 +1,62 @@ +
+
+

OPD Charges Group - Add New

+
+ +
+
+
+
+
+ +
+
+ + +
+
+ + +
+
+ +
+
+
+
+
+ + diff --git a/app/Views/Setting/Charges/OPD_Charges/item_type_profile.php b/app/Views/Setting/Charges/OPD_Charges/item_type_profile.php new file mode 100644 index 0000000..8a43a7d --- /dev/null +++ b/app/Views/Setting/Charges/OPD_Charges/item_type_profile.php @@ -0,0 +1,64 @@ + +
+
+

OPD Charges Group: group_desc ?? '') ?>

+
+ +
+
+
+
+
+ + +
+
+ + +
+
+ + +
+
+ +
+
+
+
+
+ + + diff --git a/app/Views/Setting/Charges/OPD_Charges/item_type_search_v.php b/app/Views/Setting/Charges/OPD_Charges/item_type_search_v.php new file mode 100644 index 0000000..e130c1b --- /dev/null +++ b/app/Views/Setting/Charges/OPD_Charges/item_type_search_v.php @@ -0,0 +1,49 @@ +
+
+

OPD Charges Groups

+
+ + +
+
+
+ + + + + + + + + + + + + + + + + + + + + + + + +
OPD or IPDCharges Group Name
isIPD_OPD ?? '') ?>group_desc ?? '') ?> + +
OPD or IPDCharges Group Name
+
+
+ + diff --git a/app/Views/Setting/Charges/Package/item_create_V.php b/app/Views/Setting/Charges/Package/item_create_V.php new file mode 100644 index 0000000..fc8249c --- /dev/null +++ b/app/Views/Setting/Charges/Package/item_create_V.php @@ -0,0 +1,69 @@ +
+
+

IPD Package - Add New

+
+ +
+
+
+
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+
+
+
+ +
+
+
+
+
+ + diff --git a/app/Views/Setting/Charges/Package/item_insurance_list.php b/app/Views/Setting/Charges/Package/item_insurance_list.php new file mode 100644 index 0000000..2fc3906 --- /dev/null +++ b/app/Views/Setting/Charges/Package/item_insurance_list.php @@ -0,0 +1,24 @@ + + + + + + + + + + + + + + + + + + + + + +
Company NameAmountCodeAction
ins_company_name ?? '') ?>i_amount ?? '') ?>code ?? '') ?> + +
diff --git a/app/Views/Setting/Charges/Package/item_item_excel.php b/app/Views/Setting/Charges/Package/item_item_excel.php new file mode 100644 index 0000000..bad6a4e --- /dev/null +++ b/app/Views/Setting/Charges/Package/item_item_excel.php @@ -0,0 +1,33 @@ + +

Package Rate List for

+ +

Package Rate List

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Package NameDescriptionAmountCodeAmount
ipd_pakage_name ?? '') ?>Pakage_description ?? '') ?>display_amount ?? $row->i_amount ?? $row->Pakage_Min_Amount ?? '') ?>code ?? ($row->i_amount === null ? 'Base Rate' : '')) ?>Pakage_Min_Amount ?? '') ?>
diff --git a/app/Views/Setting/Charges/Package/item_item_list.php b/app/Views/Setting/Charges/Package/item_item_list.php new file mode 100644 index 0000000..efdfcb5 --- /dev/null +++ b/app/Views/Setting/Charges/Package/item_item_list.php @@ -0,0 +1,54 @@ + + + + + + IPD Package + + + + + +
+
+ + +

Package Rate List for

+ +

Package Rate List

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Package NameDescriptionAmountCodeAmount
ipd_pakage_name ?? '') ?>Pakage_description ?? '') ?>display_amount ?? $row->i_amount ?? '') ?>code ?? ($row->i_amount === null ? 'Base Rate' : '')) ?>Pakage_Min_Amount ?? '') ?>
+
+
+ + diff --git a/app/Views/Setting/Charges/Package/item_profile_V.php b/app/Views/Setting/Charges/Package/item_profile_V.php new file mode 100644 index 0000000..167aff9 --- /dev/null +++ b/app/Views/Setting/Charges/Package/item_profile_V.php @@ -0,0 +1,139 @@ + +
+
+

IPD Package: ipd_pakage_name ?? '') ?>

+
+
+
+
+ + +
+
+ + +
+
+ + +
+
+
+
+ + +
+
+
+
+ +
+
+
+
+
+
+
Insurance Rates
+
+
+
+ $data_insurance_item]) ?> +
+
+
+
+ + +
+
+ + +
+
+ + +
+
+ +
+
+
+
+
+
+ + + diff --git a/app/Views/Setting/Charges/Package/item_search_V.php b/app/Views/Setting/Charges/Package/item_search_V.php new file mode 100644 index 0000000..7b5ede0 --- /dev/null +++ b/app/Views/Setting/Charges/Package/item_search_V.php @@ -0,0 +1,110 @@ +
+
+

IPD Package

+
+ + +
+
+
+
+
+ + +
+
+ + +
+
+ + +
+
+
+
+
+ $data, 'groupId' => $groupId]) ?> +
+
+
+
+
+ + + + diff --git a/app/Views/Setting/Charges/Package/item_search_adv.php b/app/Views/Setting/Charges/Package/item_search_adv.php new file mode 100644 index 0000000..aefeb6a --- /dev/null +++ b/app/Views/Setting/Charges/Package/item_search_adv.php @@ -0,0 +1,43 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Package NameCharge NameAmount
ipd_pakage_name ?? '') ?>Pakage_description ?? '') ?>Pakage_Min_Amount ?? '') ?> + +
Package NameCharge NameAmount
+ + diff --git a/app/Views/Setting/Charges/Package/item_type_create.php b/app/Views/Setting/Charges/Package/item_type_create.php new file mode 100644 index 0000000..f8f73f6 --- /dev/null +++ b/app/Views/Setting/Charges/Package/item_type_create.php @@ -0,0 +1,54 @@ +
+
+

Package Group - Add New

+
+ +
+
+
+
+
+ +
+
+ + +
+
+ +
+
+
+
+
+ + diff --git a/app/Views/Setting/Charges/Package/item_type_profile.php b/app/Views/Setting/Charges/Package/item_type_profile.php new file mode 100644 index 0000000..1f482c5 --- /dev/null +++ b/app/Views/Setting/Charges/Package/item_type_profile.php @@ -0,0 +1,56 @@ + +
+
+

Package Group: pakage_group_name ?? '') ?>

+
+ +
+
+
+
+
+ + +
+
+ + +
+
+ +
+
+
+
+
+ + + diff --git a/app/Views/Setting/Charges/Package/item_type_search_v.php b/app/Views/Setting/Charges/Package/item_type_search_v.php new file mode 100644 index 0000000..4a1431e --- /dev/null +++ b/app/Views/Setting/Charges/Package/item_type_search_v.php @@ -0,0 +1,46 @@ +
+
+

Package Groups

+
+ + +
+
+
+ + + + + + + + + + + + + + + + + + + + + +
Package Group Name
pakage_group_name ?? '') ?> + +
Package Group Name
+
+
+ + diff --git a/app/Views/Setting/Charges/index.php b/app/Views/Setting/Charges/index.php new file mode 100644 index 0000000..a0411a1 --- /dev/null +++ b/app/Views/Setting/Charges/index.php @@ -0,0 +1,76 @@ +
+
+

Charges

+ +
+ + + + + +
+
+
+
diff --git a/app/Views/Setting/Doctor/Doctor_Search_V.php b/app/Views/Setting/Doctor/Doctor_Search_V.php new file mode 100644 index 0000000..2fb1826 --- /dev/null +++ b/app/Views/Setting/Doctor/Doctor_Search_V.php @@ -0,0 +1,51 @@ +
+
+

Doctors

+
+ + + +
+
+
+
+ + + + + + + + + + + + + + + + + + + + + + + + + +
NamePhone NumberEmailAction
p_title ?? '') . ' ' . ($row->p_fname ?? '')) ?>mphone1 ?? '') ?>email1 ?? '') ?> + +
No doctors found.
+
+
+
diff --git a/app/Views/Setting/Doctor/Doctor_V.php b/app/Views/Setting/Doctor/Doctor_V.php new file mode 100644 index 0000000..d42f2a4 --- /dev/null +++ b/app/Views/Setting/Doctor/Doctor_V.php @@ -0,0 +1,160 @@ +
+
+

Add Doctor

+
+ +
+
+
+ + + +
+ +
+ +
+ +
+
+ +
+
+ + +
+
+ + +
+
+ + +
+
+
+
+ +
+ + +
+
+ + +
+
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+ +
+ + +
+ + + +
+ + +
+ + + +
+ + +
+ + + +
+ + +
+ + + +
+ + +
+ +
+ +
+ +
+
+
+
+ + diff --git a/app/Views/Setting/Doctor/Doctor_profile_V.php b/app/Views/Setting/Doctor/Doctor_profile_V.php new file mode 100644 index 0000000..77019aa --- /dev/null +++ b/app/Views/Setting/Doctor/Doctor_profile_V.php @@ -0,0 +1,433 @@ +{$regField}) && trim((string) $data[0]->{$regField}) !== '') { + $doctorRegNo = trim((string) $data[0]->{$regField}); + break; + } + } + + if ($doctorRegNo === '') { + $shortDescription = trim((string) ($data[0]->doc_sign ?? '')); + if ($shortDescription !== '') { + $normalizedShortDescription = preg_replace('/\s+/', ' ', $shortDescription); + if ($normalizedShortDescription !== null) { + if (preg_match('/(?:reg(?:istration)?\s*(?:no|number)?\s*[:\-]?\s*)([A-Z0-9\/-]{4,})/i', $normalizedShortDescription, $matches) === 1 && ! empty($matches[1])) { + $doctorRegNo = trim((string) $matches[1]); + } + } + } + } +} +?> + +
+
+

Doctor: p_title ?? '') . ' ' . ($data[0]->p_fname ?? '')) ?>

+
+ +
+
+
+
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+
+
+
+ +
+ gender ?? '') ?> type="radio"> + +
+
+ gender ?? '') ?> type="radio"> + +
+
+
+ + +
+
+ + +
+
+ + +
+
+
+
+ + +
+
+ + +
+ +
+ + +
+ + + +
+ + +
+ + + +
+ + +
+ + + +
+ + +
+ + + +
+ + +
+ +
+ +
+ +
+
+
+
+ +
+ +
+ + + + +
+ +
+
+ + +
+
+
+
+
OPD Fees
+
+
+ Fee TypeDescriptionAmount'; + foreach ($doc_fee_list as $row) { + $button = 'Not Define'; + if (! empty($row->id)) { + $button = 'Remove'; + } + $tableHtml .= '' . esc($row->fee_type ?? '') . '' . esc($row->doc_fee_desc ?? '') . '' . esc($row->amount ?? '') . '' . $button . ''; + } + $tableHtml .= ''; + echo $tableHtml; + ?> +
+
+
+ + +
+
+ + +
+
+ + +
+
+ +
+
+
+
+
IPD Fees
+
+
+ Fee TypeDescriptionAmount'; + foreach ($doc_ipd_fee_list as $row) { + $button = 'Not Define'; + if (! empty($row->id)) { + $button = 'Remove'; + } + $ipdTableHtml .= '' . esc($row->fee_type ?? '') . '' . esc($row->doc_fee_desc ?? '') . '' . esc($row->amount ?? '') . '' . $button . ''; + } + $ipdTableHtml .= ''; + echo $ipdTableHtml; + ?> +
+
+
+ + +
+
+ + +
+
+ + +
+
+ +
+
+
+
+
+
+
+ + + diff --git a/app/Views/Setting/Doctor/Ipd_FeeType_List.php b/app/Views/Setting/Doctor/Ipd_FeeType_List.php new file mode 100644 index 0000000..6ffbb7c --- /dev/null +++ b/app/Views/Setting/Doctor/Ipd_FeeType_List.php @@ -0,0 +1,128 @@ +
+
+

IPD Fee Types

+
+ +
+
+
+ + + +
+ + +
+ +
+ +
+ + +
+ +
+ + +
+
+ +
+
+ +
+ + + + + + + + + + + $type) : ?> + + + + + + + + + + + + +
#IPD Fee TypeAction
+ + + + +
No IPD fee types found.
+
+
+
+ + diff --git a/app/Views/Setting/Doctor/Spec_List.php b/app/Views/Setting/Doctor/Spec_List.php new file mode 100644 index 0000000..d706be1 --- /dev/null +++ b/app/Views/Setting/Doctor/Spec_List.php @@ -0,0 +1,128 @@ +
+
+

Specialities

+
+ +
+
+
+ + + +
+ + +
+ +
+ +
+ + +
+ +
+ + +
+
+ +
+
+ +
+ + + + + + + + + + + $spec) : ?> + + + + + + + + + + + + +
#SpecialityAction
+ + + + +
No specialities found.
+
+
+
+ + diff --git a/app/Views/Setting/Insurance/insurance_create_V.php b/app/Views/Setting/Insurance/insurance_create_V.php new file mode 100644 index 0000000..3917376 --- /dev/null +++ b/app/Views/Setting/Insurance/insurance_create_V.php @@ -0,0 +1,72 @@ +
+
+

Insurance Company - Add New

+
+ +
+
+
+
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+
+
+
+ + +
+
+ + +
+
+
+
+ +
+
+
+
+
+ + diff --git a/app/Views/Setting/Insurance/insurance_profile_V.php b/app/Views/Setting/Insurance/insurance_profile_V.php new file mode 100644 index 0000000..36d6c7e --- /dev/null +++ b/app/Views/Setting/Insurance/insurance_profile_V.php @@ -0,0 +1,185 @@ + +
+
+

Insurance Company - ins_company_name ?? '') ?>

+
+ +
+
+
+
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+
+
+
+ + +
+
+ + +
+
+
+
+
+ active ?? 0) ?>> + +
+
+
+
+
+
+
+
OPD
+
+
+
+
+
+ opd_allowed ?? 0) ?>> + +
+
+
+ +
+ opd_rate_direct ?? '') ?> type="radio"> + +
+
+ opd_rate_direct ?? '') ?> type="radio"> + +
+
+
+
+
+ + +
+
+
+ opd_cash ?? 0) ?>> + +
+
+
+
+ opd_credit ?? 0) ?>> + +
+
+
+
+
+ + +
+
+ + +
+
+
+
+
+
+
+
+
Charges And Medicine
+
+
+
+
+ +
+ charge_rate_direct ?? '') ?> type="radio"> + +
+
+ charge_rate_direct ?? '') ?> type="radio"> + +
+
+
+
+
+ + +
+
+
+ charge_credit ?? 0) ?>> + +
+
+
+
+ med_credit ?? 0) ?>> + +
+
+
+
+
+
+
+
+
+ +
+
+
+
+
+ + + + diff --git a/app/Views/Setting/Insurance/insurance_search_v.php b/app/Views/Setting/Insurance/insurance_search_v.php new file mode 100644 index 0000000..9c78b18 --- /dev/null +++ b/app/Views/Setting/Insurance/insurance_search_v.php @@ -0,0 +1,45 @@ +
+
+

Insurance Company

+
+ +
+
+
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + +
Company NameContact NumberOPD FeeActive
ins_company_name ?? '') ?>ins_contact_number ?? '') ?>opd_fee ?? '') ?>activestatus ?? '') ?> + +
No insurance companies found.
+
+
+
diff --git a/app/Views/Setting/MedicalBank/bank_search_v.php b/app/Views/Setting/MedicalBank/bank_search_v.php new file mode 100644 index 0000000..2b5240e --- /dev/null +++ b/app/Views/Setting/MedicalBank/bank_search_v.php @@ -0,0 +1,339 @@ +
+
+

Medical Bank & Payment Sources

+
+
+ +
+
+ + +
+
+ + +
+
+ +
+ +
+
+
+
Payment Sources
+
+ + + + + + + + + + + + +
Pay Type
Select a bank to view payment sources.
+
+
+
+
+ +
+ +
+
+
Medical Banks
+
+ + + + + + + + + + + + + + + + + + + + + +
Bank
bank_name ?? '') ?> + + +
No banks found.
+
+
+
+
+
+ + + + + + diff --git a/app/Views/Setting/Reffer/reffer_add.php b/app/Views/Setting/Reffer/reffer_add.php new file mode 100644 index 0000000..6249c9b --- /dev/null +++ b/app/Views/Setting/Reffer/reffer_add.php @@ -0,0 +1,70 @@ +
+
+

New Referral Client

+
+ +
+
+
+
+
+ +
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+
+
+
+ +
+
+
+
+
+ + diff --git a/app/Views/Setting/Reffer/reffer_edit.php b/app/Views/Setting/Reffer/reffer_edit.php new file mode 100644 index 0000000..d5981f1 --- /dev/null +++ b/app/Views/Setting/Reffer/reffer_edit.php @@ -0,0 +1,72 @@ + +
+
+

Edit Referral Client

+
+ +
+
+
+
+
+ +
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+
+
+
+ +
+
+
+
+
+ + + diff --git a/app/Views/Setting/Reffer/reffer_index.php b/app/Views/Setting/Reffer/reffer_index.php new file mode 100644 index 0000000..3d3c966 --- /dev/null +++ b/app/Views/Setting/Reffer/reffer_index.php @@ -0,0 +1,72 @@ +
+
+

Referral Clients

+
+ + +
+
+
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeRegister DateStatusEdit
title ?? '') . ' ' . ($row->f_name ?? '')) ?>type_desc ?? 'Others') ?>str_dateadd ?? '') ?> + active)) : ?> + Active + + Inactive + + + +
No referral clients found.
+
+
+
+ + diff --git a/app/Views/Setting/Reffer/reffer_type_list.php b/app/Views/Setting/Reffer/reffer_type_list.php new file mode 100644 index 0000000..1cbcf16 --- /dev/null +++ b/app/Views/Setting/Reffer/reffer_type_list.php @@ -0,0 +1,128 @@ +
+
+

Referral Types

+
+ +
+
+
+ + + +
+ + +
+ +
+ +
+ + +
+ +
+ + +
+
+ +
+
+ +
+ + + + + + + + + + + $type) : ?> + + + + + + + + + + + + +
#TypeAction
+ + + + +
No referral types found.
+
+
+
+ + diff --git a/app/Views/Setting/Reffer/temp/hospital_refer/reffer_add.php b/app/Views/Setting/Reffer/temp/hospital_refer/reffer_add.php new file mode 100644 index 0000000..2351380 --- /dev/null +++ b/app/Views/Setting/Reffer/temp/hospital_refer/reffer_add.php @@ -0,0 +1,78 @@ +
+

+ New Refferal Client + +

+ +
+ +
+
+
+ +'form','class'=>'form1'));?> +
+
+
+ + +
+
+
+
+ + +
+
+
+
+ + +
+
+
+
+ + +
+
+
+
+
+ +
+
+ + +
+
+ \ No newline at end of file diff --git a/app/Views/Setting/Reffer/temp/hospital_refer/reffer_edit.php b/app/Views/Setting/Reffer/temp/hospital_refer/reffer_edit.php new file mode 100644 index 0000000..5107de5 --- /dev/null +++ b/app/Views/Setting/Reffer/temp/hospital_refer/reffer_edit.php @@ -0,0 +1,78 @@ +
+

+ Edit Refferal Client + +

+ +
+ +
+
+
+ +'form','class'=>'form1'));?> +
+
+
+ + +
+
+
+
+ + +
+
+
+
+ + +
+
+
+
+ + +
+
+
+
+
+ +
+
+ + +
+
+ \ No newline at end of file diff --git a/app/Views/Setting/Reffer/temp/hospital_refer/reffer_index.php b/app/Views/Setting/Reffer/temp/hospital_refer/reffer_index.php new file mode 100644 index 0000000..375a2a1 --- /dev/null +++ b/app/Views/Setting/Reffer/temp/hospital_refer/reffer_index.php @@ -0,0 +1,61 @@ +

+
+
+

Reffer Person Name / clinic / Hospital

+
+ +
+ + + + + + + + + + + + + + + + + + + + + +
NameTypeRegister DateStatusEdit
title.' '.$row->f_name?>refer_type==0){ + echo 'Person'; + } elseif($row->refer_type==1){ + echo 'Doctor'; + }elseif($row->refer_type==2){ + echo 'Staff'; + }elseif($row->refer_type==3){ + echo 'Hospital/Clinic'; + }else{ + echo 'Others'; + } + + ?>str_dateadd?> + active){ + echo "".lang('index_active_link').""; + }else{ + echo "".lang('index_inactive_link').""; + } + ?> + Edit
+ +
+ + +
\ No newline at end of file diff --git a/app/Views/Setting/Template/index.php b/app/Views/Setting/Template/index.php new file mode 100644 index 0000000..d724ba1 --- /dev/null +++ b/app/Views/Setting/Template/index.php @@ -0,0 +1,202 @@ +user() : null; +$canPathology = $user && method_exists($user, 'can') ? $user->can('template.pathology') : false; +$canUltrasound = $user && method_exists($user, 'can') ? $user->can('template.ultrasound') : false; +$canXray = $user && method_exists($user, 'can') ? $user->can('template.xray') : false; +$canCt = $user && method_exists($user, 'can') ? $user->can('template.ct') : false; +$canMri = $user && method_exists($user, 'can') ? $user->can('template.mri') : false; +$canEcho = $user && method_exists($user, 'can') ? $user->can('template.echo') : false; +$canOpdPrintTemplate = $user && method_exists($user, 'can') ? $user->can('billing.opd.edit') : false; + +if (! $canOpdPrintTemplate && $user && method_exists($user, 'inGroup')) { + $canOpdPrintTemplate = $user->inGroup('OPDEdit', 'admin', 'superadmin', 'developer'); +} + +$hasTemplateAccess = $canPathology || $canUltrasound || $canXray || $canCt || $canMri || $canEcho; +?> +
+
+

Templates Library

+ +
+ + + + +
+ You do not have access to any templates. Please contact your administrator. +
+ + + + +
+
+
+
diff --git a/app/Views/account/my_profile.php b/app/Views/account/my_profile.php new file mode 100644 index 0000000..00c529b --- /dev/null +++ b/app/Views/account/my_profile.php @@ -0,0 +1,144 @@ +
+
+
+
+
My Profile
+
+ + username ?? '')); + if ($loginId === '') { + $loginId = trim((string) ($user->email ?? 'User')); + } + $personName = trim((string) ($person_name ?? '')); + ?> + +
+ + +
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+ +
+
Change Password (Optional)
+
+ + +
+
+ + +
+
+ +
+ + +
+
Update your email, phone, and password here.
+
+
+
+
+
+ + diff --git a/app/Views/auth/login.php b/app/Views/auth/login.php new file mode 100644 index 0000000..d855656 --- /dev/null +++ b/app/Views/auth/login.php @@ -0,0 +1,147 @@ + + + + + + + + <?= lang('Auth.login') ?> + + + + + + + + + + + + + + + + + + + + + + + +
+
+ +
+
+
+
+ + + +
+ +
+ +
+
+

+
+ + + + + + + + + + + +
+ + +
+ +
+ @ + +
Please enter your username.
+
+
+ +
+ + +
Please enter your password!
+
+ + +
+
+ checked> + +
+
+ + +
+ +
+ + +
+

+
+ + + +
+

+
+ + +
+ +
+
+ +
+
+
+ +
+ +
+
+ + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/Views/auth/register.php b/app/Views/auth/register.php new file mode 100644 index 0000000..f374327 --- /dev/null +++ b/app/Views/auth/register.php @@ -0,0 +1,65 @@ +extend(config('Auth')->views['layout']) ?> + +section('title') ?> endSection() ?> + +section('main') ?> + +
+
+
+
+ + + + + + + +
+ + + +
+ + +
+ + +
+ + +
+ + +
+ + +
+ + +
+ + +
+ +
+ +
+ +

+ +
+
+
+
+ +endSection() ?> diff --git a/app/Views/billing/Patient_Cards_V.php b/app/Views/billing/Patient_Cards_V.php new file mode 100644 index 0000000..a86a7f0 --- /dev/null +++ b/app/Views/billing/Patient_Cards_V.php @@ -0,0 +1,127 @@ +
+

Insurance Cards

+ +
+ +
+
+
+

Insurance Cards

+
+
+
+

Patient: p_fname ?? '') ?>

+ + id ?? 0); + $insCompanyId = (int) ($card->insurance_id ?? ($selectedInsId ?? 0)); + $insInsuranceNo = (string) ($card->insurance_no ?? ''); + $cardHolderName = (string) ($card->card_holder_name ?? ''); + $relationPatient = (string) ($card->relation_patient_cardholder ?? ''); + $issueDate = !empty($card->issue_date) ? date('d/m/Y', strtotime($card->issue_date)) : date('d/m/Y'); + $expiryDate = !empty($card->expiry_date) ? date('d/m/Y', strtotime($card->expiry_date)) : date('d/m/Y'); + ?> + +
+ + + + +
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+
+ +
+
+
+ + +
No insurance cards found for this patient.
+ +
+ + + + + + + + + + + + + + + + + + + + + +
CompanyCard NoHolder NameRelationStatus
ins_company_name ?? '') ?>insurance_no ?? '') ?>card_holder_name ?? '') ?>relation_patient_cardholder ?? '') ?>status) ? esc((string) $card->status) : '' ?>
+
+ + +
+ Use the insurance module to add or edit card details. +
+
+
+
+ + diff --git a/app/Views/billing/Patient_File_Upload_V.php b/app/Views/billing/Patient_File_Upload_V.php new file mode 100644 index 0000000..68d17c2 --- /dev/null +++ b/app/Views/billing/Patient_File_Upload_V.php @@ -0,0 +1,20 @@ +
+
+ +
+ + +
+ + + + +
+ + +
+ +
+
+
diff --git a/app/Views/billing/Patient_Profile_Image_V.php b/app/Views/billing/Patient_Profile_Image_V.php new file mode 100644 index 0000000..0e736e5 --- /dev/null +++ b/app/Views/billing/Patient_Profile_Image_V.php @@ -0,0 +1,311 @@ +
+

Profile Image

+ +
+ +
+
+
+

Profile Image

+
+
+

Patient: p_fname ?? '') ?>

+ +
+
+
+ Profile Image +
+
+
+
+
+
+ +
+
+ + + + +
+
Camera is idle.
+
+
+
+ +
Captured image will appear here.
+
+
+
+
+
Recent Captures
+ +
+
+
+
+
+ +
+ +
+ + + + +
+ + +
+
+
+
+
+
+
+ + + + diff --git a/app/Views/billing/Patient_Profile_Opd_V.php b/app/Views/billing/Patient_Profile_Opd_V.php new file mode 100644 index 0000000..74a5ac5 --- /dev/null +++ b/app/Views/billing/Patient_Profile_Opd_V.php @@ -0,0 +1,80 @@ +
+

OPD Scans

+ +
+ +
+
+
+

OPD Scans

+
+
+

Patient: p_fname ?? '') ?>

+ + +
No OPD scans found.
+ + +
+
+
+ + Dr. +
+
+ +
+
+ + +
No files for this OPD.
+ +
+ $file) { ?> +
+ + Open PDF + + OPD Scan + +
+ +
+ +
+ + +
+
+ + +
+ + diff --git a/app/Views/billing/Patient_Search_V.php b/app/Views/billing/Patient_Search_V.php new file mode 100644 index 0000000..9db43ff --- /dev/null +++ b/app/Views/billing/Patient_Search_V.php @@ -0,0 +1,45 @@ +

+
+
+

Result

+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Sr.No.Patient/UHID CodeName {Relative Name}AgeLast VisitInsurance
p_code ?>p_fname ?> {p_rname ?>}dob ?? null, $data[$i]->age ?? '', $data[$i]->age_in_month ?? '', $data[$i]->estimate_dob ?? '', $data[$i]->Last_Visit ?? null)) ?>Last_Visit ?>insurance_id==0 ? 'Self': 'Insuranced'); ?>
Sr.No.Patient/UHID CodeName {Relative Name}AgeLast VisitInsurance
+
+ +
+ \ No newline at end of file diff --git a/app/Views/billing/Patient_Search_opd.php b/app/Views/billing/Patient_Search_opd.php new file mode 100644 index 0000000..5b32989 --- /dev/null +++ b/app/Views/billing/Patient_Search_opd.php @@ -0,0 +1,50 @@ +

+
+
+

Last OPDs

+
+
+ + + + + + + + + + + + + + + + $row) : ?> + + + + + + + + + + + + + +
Sr.No.OPD CodePatient/UHID CodeName {Relative Name}AgeVisit DateDoctorInsurance
opd_code ?? '') ?>p_code ?>p_fname ?? '') . ' {' . ($row->p_rname ?? '') . '}') ?>dob ?? null, $row->age ?? '', $row->age_in_month ?? '', $row->estimate_dob ?? '', $row->opd_Visit ?? null)) ?>opd_Visit ?? '') ?>doc_name ?? '') ?>short_name ?? '') ?>
+
+
+ + + diff --git a/app/Views/billing/Patient_V.php b/app/Views/billing/Patient_V.php new file mode 100644 index 0000000..3f399e0 --- /dev/null +++ b/app/Views/billing/Patient_V.php @@ -0,0 +1,468 @@ + +
+
+
+
+
+
Patient Management
+ +
+
+
+
+
+
+ +
+
+
+ + +
+
+
+
+ + +
Please enter phone number.
+
+
+
+
+
+ + +
+
+
+
+ + +
Please enter full name.
+
+
+
+
+ +
+
+ + +
+
+ + +
+
+
+
+ +
+
+
+ +
+
+ > + +
+
+ +
> +
+ +
+
+ +
+
+ +
+
+
+
+ +
> + + +
+
+
+ +
+
+
+ + +
+
+
+
+ + +
Please enter relative name.
+
+
+
+
+ + + +
+
+
+
+ + +
+
+
+
+ + +
+
+
+
+ + +
+
+ +
+
+ + +
+
+
+
+ + +
+
+
+
+
+
+ +
+
+
+
+
+ +
+
+
+ +
+ +
+
+
+
+
+
+
+ + + \ No newline at end of file diff --git a/app/Views/billing/Person_Edit_V.php b/app/Views/billing/Person_Edit_V.php new file mode 100644 index 0000000..a44c528 --- /dev/null +++ b/app/Views/billing/Person_Edit_V.php @@ -0,0 +1,404 @@ +
+

Person Profile - p_fname; ?> p_code; ?>

+ +
+user(); + $isAdmin = is_object($user) && method_exists($user, 'inGroup') ? $user->inGroup('admin') : false; + if ($data[0]->p_edit == 1 || $isAdmin) { + $readonly = ''; + } else { + $readonly = 'readonly'; + } +?> + +
+
+
+
+
+
+

Person Profile

+
+
+
+ + +
+
+
+ + +
+
+
+
+ + > +
+
+
+
+ +
+ + +
+
+
+
+
+ + +
+
+
+
+ + +
+
+
+
+ estimate_dob; + if($chk_age==1) + { + $checkbox_checked="checked"; + $age_input_2='style="display: none;"'; + $age_input_1=''; + $DateofBirth=''; + }else{ + $checkbox_checked=""; + $age_input_1='style="display: none;"'; + $age_input_2=''; + $DateofBirth=MysqlDate_to_str($data[0]->dob); + } + ?> +
+
+ +
+
+
> +
+
+ + + + + + + + + +
Year : + Month :
+
+
+
+
> +
+ +
+
+ +
+ +
+
+
+
+
+
+
+ + +
+
+
+
+ + +
+
+
+
+ + +
+
+
+
+ + +
+
+
+
+
+
+ + +
+
+
+
+ + +
+
+
+
+ + +
+
+
+
+
+
+ + +
+
+
+
+ + +
+
+
+
+
+ +
+
+
+ +
+
+
+
+ +
+ +
+ + \ No newline at end of file diff --git a/app/Views/billing/Person_profile_V.php b/app/Views/billing/Person_profile_V.php new file mode 100644 index 0000000..a924c1b --- /dev/null +++ b/app/Views/billing/Person_profile_V.php @@ -0,0 +1,354 @@ +
+

Profile

+ +
+ +
+
+
+ + user(); + $canEditOpd = is_object($user) && method_exists($user, 'can') ? $user->can('billing.opd.edit') : false; + $canChargeEdit = is_object($user) && method_exists($user, 'can') ? $user->can('billing.charges.edit') : false; + ?> + + + + +
+
+
+
+ Profile +

p_fname) ?>

+

p_code; ?>

+
+ + + +
+
+
+ + + + + +
+
+
+
+
+
OPD Visits
+
+
+
+
Invoices
+
+
+
+
Insurance
+
insurance_id ?? 0) > 0 ? 'Yes' : 'No' ?>
+
+
+
+
+
+
+ +
+
+
+ + +
+
+
Profile Details
+
+
Full Name
+
p_fname) ?>
+
+
+
Gender / Age
+
xgender?> / dob ?? null, $data[0]->age ?? '', $data[0]->age_in_month ?? '', $data[0]->estimate_dob ?? '')) ?>
+
+
+
Relation
+
p_relative?> p_rname)?>
+
+
+
Aadhar No.
+
udai?>
+
+
+
Phone
+
mphone1?>
+
+
+
Email
+
email1?>
+
+
+
Blood Group
+
blood_group?>
+
+
+
Address
+
add1?> city ?> district ?> state ?> zip ?>
+
+ +
Quick Update
+
+
+ +
+ + +
+
+
+ +
+
+
+ +
+
Insurance Details
+ insurance_id>0) { ?> +
+
Company
+
ins_company_name?>
+
+
+
Card Holder
+
card_holder_name?>
+
+
+
Relation
+
relation_patient_cardholder?>
+
+
+
Insurance ID
+
insurance_no?>
+
+ +
+ 0){ ?> +
+
Case Code: case_id_code?>
+
Visit Date Start: str_date_registration?>
+
Claim/Case No.: insurance_no_1?>
+
Other IDs: insurance_no_2?>
+ +
+ 0){ ?> + +
+
Case Code: case_id_code?>
+
Org. Date Start: str_date_registration?>
+
Claim/Case No.: insurance_no_1?>
+
Other IDs: insurance_no_2?>
+
IPD No: ipd_code?>
+
IPD Admit Date: str_date_registration?>
+ +
+ +
+ + +
+ +
+ +
+ opd_allowed==1) { ?> + + + charge_cash==1 && $canChargeEdit) { ?> + + +
+ +
No insurance details available.
+ +
+ + 0) { ?> +
+
OPD Registration
+ '; + echo ''.$row->opd_code.''; + echo '
'; + echo 'Dr.'.$row->doc_name.' '; + echo 'D:'.$row->str_apointment_date.' '; + echo 'P:'.$row->p_fname.'
'; + + if($canEditOpd || $row->new_opd==1){ + echo 'Edit OPD'; + echo 'Print Day Care'; + } + echo '
'; + echo '
'; + } + ?> +
+ + + 0) { ?> +
+
Charges Invoice
+ '; + echo ''.$row->invoice_code.''; + echo ' D:'.$row->str_inv_date.''; + echo ' N:'.$row->inv_name.''; + echo '
'; + echo ''.$row->Item_List.'
'; + if($row->invoice_status==0) + { + if ($canChargeEdit) { + echo 'Edit Charges Invoice'; + echo 'Delete : Un-confirm Invoice'; + } + }else{ + echo 'Show Charges Invoice'; + } + echo '
'; + echo '
'; + } + ?> +
+ +
+
+
+
+
+ +
+ + \ No newline at end of file diff --git a/app/Views/billing/charges/charges_invoice_edit.php b/app/Views/billing/charges/charges_invoice_edit.php new file mode 100644 index 0000000..0210f96 --- /dev/null +++ b/app/Views/billing/charges/charges_invoice_edit.php @@ -0,0 +1,266 @@ +
+

Charges

+ +
+
+
+ +user(); + $canChargeDateEdit = is_object($user) && method_exists($user, 'can') ? $user->can('billing.charges.date-edit') : false; + $invoiceDateValue = ''; + if (!empty($invoiceMaster[0]->inv_date)) { + $invoiceDateValue = date('Y-m-d', strtotime((string) $invoiceMaster[0]->inv_date)); + } + $dateReadonly = $canChargeDateEdit ? '' : 'readonly'; + $dateInputClass = $canChargeDateEdit ? 'form-control' : 'form-control bg-light'; +?> +
+
+
+

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

+ + + +
+
+
+
+
+ + +
+
+ + +
+
+ + /> +
+
+
+ + + + + + + + + + + '; + echo ''; + echo ''; + echo ''; + if (in_array((int) $row->item_type, [1, 2, 3, 4, 5], true)) { + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + } + echo ''; + ?> + + + + + + + + + +
#Charges GroupCharge 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 ''; + } + echo ''; + echo '
#Gross TotalGtotal ?? 0) ?>
+
+
+
+
+
+ + +
+
+
+
+ + +
+
+
+
+ + +
+
+
+
+ + +
+
+
+
+ +
+
+
+
+ +
+
+
+ +
+
+
+
+
+
+
+ diff --git a/app/Views/billing/charges/charges_invoice_show.php b/app/Views/billing/charges/charges_invoice_show.php new file mode 100644 index 0000000..2883839 --- /dev/null +++ b/app/Views/billing/charges/charges_invoice_show.php @@ -0,0 +1,520 @@ +user(); + $canChargeView = is_object($user) && method_exists($user, 'can') ? $user->can('billing.charges.view') : false; + $canChargeEdit = is_object($user) && method_exists($user, 'can') ? $user->can('billing.charges.edit') : false; + $canChargePay = is_object($user) && method_exists($user, 'can') ? $user->can('billing.charges.pay') : false; + $canChargeCancel = is_object($user) && method_exists($user, 'can') ? $user->can('billing.charges.cancel') : false; + $canChargeCorrect = is_object($user) && method_exists($user, 'can') ? $user->can('billing.charges.correct') : false; +?> +
+ +
+
+
+

+ Invoice + #invoice_code ?? '') ?> +

+
+
+
+ ipd_id ?? 0) > 0) : ?> + IPD Panel + + payment_status ?? 0) == 0 && $canChargeEdit) : ?> + Edit Invoice + + Person +
+
+
+
+
+
+
+
+
+ To +
+ p_fname ?? '') ?>
+ p_relative ?? '') ?> : p_rname ?? '') ?>
+ Gender : xgender ?? '') ?>
+ Age : age ?? '') ?>
+ Phone No : mphone1 ?? '') ?> +
+
+
+ Invoice #invoice_code ?? '') ?>
+ insurance_id ?? 0) > 1) : ?> + Ins. Comp. :ins_company_name ?? '') ?>
+ insurance_case_id ?? 0) > 0 && count($case_master) > 0) : ?> + Org.Case No. :case_id_code ?? '') ?>
+ + + Date : inv_date ?? '') ?>
+ Patient ID : p_code ?? '') ?>
+ Refer By : refer_by_other ?? '') ?>
+ +
+
+ +
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + payment_status ?? 0) == 0) : ?> + + + + + + + + + + + + + + + + + + + + + + + + +
#Charges GroupCharge NameRateQtyAmount
group_desc ?? '') ?>item_name ?? '') ?>item_rate ?? '') ?>item_qty ?? '') ?>item_amount ?? '') ?>
#Gross Totaltotal_amount ?? '') ?>
#Deduction
#Deductiondiscount_desc ?? '') ?>discount_amount ?? '') ?>
#Net Amountnet_amount ?? '') ?>
+
+
+
+
+
+
+ +payment_status ?? 0) == 0 && $canChargePay) : ?> +
+
+
+
+ + + + + + + + + + +
#Amount received : Balance Amount :
+
+
+
+
+ + +
+
+
+
+
+
+
+ +
+ 0) : ?> +
+

+ +

+
+
+ +
+
+
+
+

+ +

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

+ +

+
+
+ +
+
+
+ + + +
+

+ +

+
+
+ + +
+
+
+ + + insurance_id ?? 0) > 0) : ?> +
+

+ +

+
+
+ +
+
+
+ + + +
+
+
+
+ + +
+
+
+ +
+
+
+ +
+
+
+
+
+
+
+ + +
+ + +payment_status ?? 0) == 1 && $canChargeView) : ?> +
+
+
+ +
+ +
+ + +
+ +
+ +
+ + payment_mode ?? 0) === 1 || (int) ($invoice_master[0]->payment_mode ?? 0) === 2)) : ?> +
+
+ + + + + + + + + +
#Deduction + + + + +
+ + +
+
+ + +
+
+
+ +
+
+ + diff --git a/app/Views/billing/ipd/cash_balance.php b/app/Views/billing/ipd/cash_balance.php new file mode 100644 index 0000000..af07052 --- /dev/null +++ b/app/Views/billing/ipd/cash_balance.php @@ -0,0 +1,116 @@ + + + + +
+ +
+
+

Cash Balance

+
+
+
+ DataTable plugin is not loaded. Please include jQuery DataTables to enable filtering. +
+
+
+ +
+   + +
+ +
+
+ +
+ + +
+
+
+ Shows pending balances for direct customers within the date range. +
+
+
+
+
+
+
+
+
+
+ + + + diff --git a/app/Views/billing/ipd/cash_balance_table.php b/app/Views/billing/ipd/cash_balance_table.php new file mode 100644 index 0000000..95e797f --- /dev/null +++ b/app/Views/billing/ipd/cash_balance_table.php @@ -0,0 +1,56 @@ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
#IPD CodeP CodePerson NamePhone No.Admit DateDischarge DateDoc. NameNet AmountPaid Amt.Balance Amt.Type
ipd_code ?? '') ?>p_code ?? '') ?>p_fname ?? '') ?>Contact_info ?? '') ?>str_register_date ?? '') ?>str_discharge_date ?? '') ?>doc_name ?? '') ?>net_amount ?? '') ?>sum_of_paid ?? '') ?>balance_amount ?? '') ?>admit_type ?? '') ?>
#Total
+
diff --git a/app/Views/billing/ipd/current_admission.php b/app/Views/billing/ipd/current_admission.php new file mode 100644 index 0000000..d7dcbb1 --- /dev/null +++ b/app/Views/billing/ipd/current_admission.php @@ -0,0 +1,78 @@ + + +
+ +
+
+

Current Admission

+
+
+ +
+ DataTable plugin is not loaded. Please include jQuery DataTables to enable filtering. +
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
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 ?? '') ?>
insurance_no_1 ?? '') ?>
C:charge_amount ?? '') ?>/M:med_amount ?? '') ?>/P:paid_amount ?? '') ?>/B:balance ?? '') ?> + id)) : ?> + + + + +
IPD CodeName/Patient CodeBed No. [Type]Register DateNo. of DaysDr. NameAdmit TypeAmount
+
+
+
+
+ + diff --git a/app/Views/billing/ipd/dashboard.php b/app/Views/billing/ipd/dashboard.php new file mode 100644 index 0000000..fe2907f --- /dev/null +++ b/app/Views/billing/ipd/dashboard.php @@ -0,0 +1,22 @@ +
+
+
+

IPD Billing

+
+ + + +
+
+
+ +
+
+
+
\ No newline at end of file diff --git a/app/Views/billing/ipd/invoice_list.php b/app/Views/billing/ipd/invoice_list.php new file mode 100644 index 0000000..db7c6f1 --- /dev/null +++ b/app/Views/billing/ipd/invoice_list.php @@ -0,0 +1,180 @@ + + + + +
+ +
+
+

IPD Invoice

+
+
+ +
+ DataTable plugin is not loaded. Please include jQuery DataTables to enable filtering. +
+
+
+
+ + + +
+   + +
+
+
+
+ +
+
+ Use filters to narrow results. Search per column below. +
+
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
IPD CodePatient CodeNameTypeClaim NoDoctorStatusRegistrationDischargeDis. Status
+
+
+
+
+
+ + + + diff --git a/app/Views/billing/ipd/ipd_model_payment_box.php b/app/Views/billing/ipd/ipd_model_payment_box.php new file mode 100644 index 0000000..d7511a5 --- /dev/null +++ b/app/Views/billing/ipd/ipd_model_payment_box.php @@ -0,0 +1,165 @@ +dob ?? null, $person->age ?? '', $person->age_in_month ?? '', $person->estimate_dob ?? ''); +} +?> +
+
+

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

+
+
+ +
+
+ Amount +
+
+
+
+ + +
+
+ + +
+
+
+
+ +
+
+

+ +

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

+ +

+
+
+
+
+ + +
+
+ + +
+
+ +
+
+
+
+
+
+ + + diff --git a/app/Views/billing/ipd/ipd_panel_deduction_payment.php b/app/Views/billing/ipd/ipd_panel_deduction_payment.php new file mode 100644 index 0000000..3dae95f --- /dev/null +++ b/app/Views/billing/ipd/ipd_panel_deduction_payment.php @@ -0,0 +1,133 @@ +
+
+ Payment Deduction +
+
+
+
+ + +
+
+
+
+ + + +
+
+

+ +

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

+ +

+
+
+
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+
+ +
+
+
+
+
+
+ + diff --git a/app/Views/billing/ipd/ipd_panel_tpa_payment.php b/app/Views/billing/ipd/ipd_panel_tpa_payment.php new file mode 100644 index 0000000..9c44574 --- /dev/null +++ b/app/Views/billing/ipd/ipd_panel_tpa_payment.php @@ -0,0 +1,75 @@ +id ?? 0)); +?> +
+
+ TPA and Other Payment / Discount +
+
+ +
+
+ + +
+
+ + +
+
+
+
+ + +
+
+ + +
+
+
+
+ + +
+
+ + +
+
+
+
+ +
+
+
+
+ + diff --git a/app/Views/billing/ipd/ipd_payment_receipt_print.php b/app/Views/billing/ipd/ipd_payment_receipt_print.php new file mode 100644 index 0000000..10a2f00 --- /dev/null +++ b/app/Views/billing/ipd/ipd_payment_receipt_print.php @@ -0,0 +1,28 @@ + +
+
+ IPD Payment Amount_str ?? '') ?> Receipt : +
+
+
+
+

UHID : p_code ?? '') ?>

+

Name : title ?? '') ?> p_fname ?? '') ?>

+

Sex : xgender ?? '') ?> age ?? '') ?>

+

Phone : mphone1 ?? '') ?>

+
+
+

IPD No. : ipd_code ?? '') ?>

+

Date : payment_date_str ?? '') ?>

+
+
+
+

IPD Amount_str ?? '') ?> Amount : Rs. amount ?? '') ?>

+

Amount in Words : Rs. amount ?? 0)) ?>

+

Prepared By : update_by ?? '') ?>

+
+
diff --git a/app/Views/billing/ipd/panel.php b/app/Views/billing/ipd/panel.php new file mode 100644 index 0000000..6d75882 --- /dev/null +++ b/app/Views/billing/ipd/panel.php @@ -0,0 +1,320 @@ +dob ?? null, $person->age ?? '', $person->age_in_month ?? '', $person->estimate_dob ?? ''); +} +?> +
+ + + + +
+
+
+
IPD : ipd_code ?? '') ?>
+
+ +
+
+
+
+
+
+

+ Name : p_fname ?? '') ?> {p_rname ?? '') ?>} + / Age : + / Gender : xgender ?? '') ?> + / UHID : p_code ?? '') ?> + / No of Days : no_days ?? '') ?> +

+

+ Admit Date : str_register_date ?? '') ?> + / Discharge Date : str_discharge_date ?? '') ?> +

+
+ +
+
+ +
+
+ Charges : charge_amount ?? '0') ?> + Pharmacy Cr. IPD : med_amount ?? '0') ?> + Net Amount : net_amount ?? '0') ?> +
+
+ Total Paid : total_paid_amount ?? '0') ?> + Balance : balance_amount ?? '0') ?> +
+    + +
+
+ Pharmacy Bill : cash_med_amount ?? '0') ?> + Paid Amount : med_paid ?? '0') ?> +
+
+ + ins_company_name ?? '') || ! empty($ipd->case_id_code ?? '') || ! empty($ipd->insurance_no ?? '') || ! empty($ipd->insurance_no_1 ?? '') || ! empty($ipd->insurance_no_2 ?? '')) : ?> +
+ ins_company_name ?? '')) : ?> + + Insurance: ins_company_name ?? '') ?> + ins_short_name ?? '')) : ?> + Short: ins_short_name ?? '') ?> + + + + case_id_code ?? '')) : ?> + Org Case: case_id_code ?? '') ?> + + insurance_no ?? '')) : ?> + Card No: insurance_no ?? '') ?> + + insurance_no_1 ?? '')) : ?> + Claim ID: insurance_no_1 ?? '') ?> + + insurance_no_2 ?? '')) : ?> + Service No: insurance_no_2 ?? '') ?> + +
+ +
+
+
+ + +
+
+ +
+
+
Loading...
+
+
+
Loading...
+
+
+
Loading...
+
+
+
Loading...
+
+
+
Loading...
+
+
+
Loading...
+
+
+
Loading...
+
+
+
Loading...
+
+
+
Loading...
+
+
+
+
+
+ + + + + + + + \ No newline at end of file diff --git a/app/Views/billing/ipd/panel_admission.php b/app/Views/billing/ipd/panel_admission.php new file mode 100644 index 0000000..07dd8ea --- /dev/null +++ b/app/Views/billing/ipd/panel_admission.php @@ -0,0 +1,34 @@ +dob ?? null, $person->age ?? '', $person->age_in_month ?? '', $person->estimate_dob ?? ''); +} +?> +
+
+
+
+
Patient
+

Name : p_fname ?? '') ?> {p_rname ?? '') ?>}

+

UHID : p_code ?? '') ?>

+

Gender : xgender ?? '') ?>

+

Age :

+

Phone : mphone1 ?? '') ?>

+
+
+
+
+
+
+
Admission
+

IPD Code : ipd_code ?? '') ?>

+

Admit Date : str_register_date ?? '') ?>

+

Discharge Date : str_discharge_date ?? '') ?>

+

No. of Days : no_days ?? '') ?>

+

Insurance : ins_company_name ?? 'Direct') ?>

+
+
+
+
diff --git a/app/Views/billing/ipd/panel_bed_assign.php b/app/Views/billing/ipd/panel_bed_assign.php new file mode 100644 index 0000000..6910f68 --- /dev/null +++ b/app/Views/billing/ipd/panel_bed_assign.php @@ -0,0 +1,34 @@ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Bed CodeBed NumberWardAssigned DateReleased DateTypeRemarks
bed_code ?? '') ?>bed_number ?? '') ?>ward_name ?? '') ?>assigned_date ?? '') ?>released_date ?? '') ?>assignment_type ?? '') ?>remarks ?? '') ?>
No bed assignments found.
+
diff --git a/app/Views/billing/ipd/panel_bill_details.php b/app/Views/billing/ipd/panel_bill_details.php new file mode 100644 index 0000000..b7e89c3 --- /dev/null +++ b/app/Views/billing/ipd/panel_bill_details.php @@ -0,0 +1,325 @@ +dob ?? null, $person->age ?? '', $person->age_in_month ?? '', $person->estimate_dob ?? ''); +} +$discountTotal = 0.0; +$extraCharge = 0.0; +if ($ipd) { + $discountTotal = (float) ($ipd->Discount ?? 0) + (float) ($ipd->Discount2 ?? 0) + (float) ($ipd->Discount3 ?? 0); + $extraCharge = (float) ($ipd->chargeamount1 ?? 0) + (float) ($ipd->chargeamount2 ?? 0); +} +$billTotals = $bill_totals ?? ['gross' => 0.0, 'net' => 0.0]; +$paidTotal = (float) ($billTotals['paid'] ?? 0); +$balanceTotal = (float) ($billTotals['balance'] ?? 0); +$grossAmount = (float) ($ipd->gross_amount ?? 0); +$netAmount = (float) ($ipd->net_amount ?? 0); + $balanceAmount = (float) ($ipd->balance_amount ?? 0); +if ($grossAmount <= 0) { + $grossAmount = (float) ($billTotals['gross'] ?? 0); +} +if ($netAmount <= 0) { + $netAmount = (float) ($billTotals['net'] ?? 0); +} +if ($balanceAmount <= 0) { + $balanceAmount = $balanceTotal; +} +?> + +
+
+ IPD Invoice + / IPD ID: ipd_code ?? '') ?> +
+
+

+ Name : p_fname ?? '') ?> + / Age : + / Gender : xgender ?? '') ?> + / P Code : p_code ?? '') ?> + + / Ins. Comp. : + +

+ +
+ + + + + + + + + + + + + '; + echo ''; + echo ''; + echo ''; + $headDesc = 'Package'; + $headTotal = 0.0; + + foreach ($ipd_packages as $row) { + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + $srNo++; + $headTotal += (float) ($row->package_Amount ?? 0); + echo ''; + } + + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + } + + $ipdItems = $ipd_invoice_items ?? []; + $ipdItemCount = count($ipdItems); + for ($i = 0; $i < $ipdItemCount; $i++) { + $row = $ipdItems[$i]; + if ($headDesc !== ($row->group_desc ?? '')) { + echo ''; + echo ''; + echo ''; + echo ''; + $headDesc = (string) ($row->group_desc ?? ''); + $headTotal = 0.0; + } + + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + $srNo++; + $headTotal += (float) ($row->item_amount ?? 0); + echo ''; + + $next = $ipdItems[$i + 1] ?? null; + if ($next === null || ($headDesc !== ($next->group_desc ?? ''))) { + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + } + } + + $showItems = $showinvoice ?? []; + $showCount = count($showItems); + for ($i = 0; $i < $showCount; $i++) { + $row = $showItems[$i]; + if ($headDesc !== ($row->Charge_type ?? '')) { + echo ''; + echo ''; + echo ''; + echo ''; + $headDesc = (string) ($row->Charge_type ?? ''); + $headTotal = 0.0; + } + + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + $srNo++; + $headTotal += (float) ($row->amount ?? 0); + echo ''; + + $next = $showItems[$i + 1] ?? null; + if ($next === null || ($headDesc !== ($next->Charge_type ?? ''))) { + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + } + } + + if (! empty($inv_med_list)) { + echo ''; + echo ''; + echo ''; + echo ''; + + $medTotal = 0.0; + foreach ($inv_med_list as $row) { + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + $srNo++; + $medTotal += (float) ($row->net_amount ?? 0); + echo ''; + } + + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + } + ?> + + + + + + + + + + Discount ?? 0) > 0) : ?> + + + + + + + + + Discount2 ?? 0) > 0) : ?> + + + + + + + + + Discount3 ?? 0) > 0) : ?> + + + + + + + + + chargeamount1 ?? 0) > 0) : ?> + + + + + + + + + chargeamount2 ?? 0) > 0) : ?> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + payable_by_tpa ?? 0) > 0) : ?> + + + + + + + + + discount_for_tpa ?? 0) > 0) : ?> + + + + + + + + + discount_by_hospital ?? 0) > 0) : ?> + + + + + + + + + discount_by_hospital_2 ?? 0) > 0) : ?> + + + + + + + + + + + + + + + + + +
#DescriptionOrg.CodeUnitRateAmount
Package
' . $srNo . '' . esc($row->package_name ?? '') . '' . esc($row->org_code ?? '') . '' . esc(number_format((float) ($row->package_Amount ?? 0), 2)) . '
Sub Total' . esc(number_format($headTotal, 2)) . '
' . esc($row->group_desc ?? '') . '
' . $srNo . '' . esc(($row->item_name ?? '') . ' ' . ($row->comment ?? '')) . '' . esc($row->org_code ?? '') . '' . esc($row->item_qty ?? '') . '' . esc(number_format((float) ($row->item_rate ?? 0), 2)) . '' . esc(number_format((float) ($row->item_amount ?? 0), 2)) . '
Sub Total' . esc(number_format($headTotal, 2)) . '
' . esc($row->Charge_type ?? '') . '
' . $srNo . '' . esc($row->idesc ?? '') . '' . esc($row->orgcode ?? '') . '' . esc($row->no_qty ?? '') . '' . esc(number_format((float) ($row->item_rate ?? 0), 2)) . '' . esc(number_format((float) ($row->amount ?? 0), 2)) . '
Sub Total' . esc(number_format($headTotal, 2)) . '
Medicine
' . $srNo . '' . esc($row->inv_med_code ?? '') . '' . esc(number_format((float) ($row->net_amount ?? 0), 2)) . '
Med. Total' . esc(number_format($medTotal, 2)) . '
#Gross Total
#Remark :
Discount_Remark ?? '') ?>
DeductionDiscount ?? 0), 2)) ?>
#Remark :
Discount_Remark2 ?? '') ?>
DeductionDiscount2 ?? 0), 2)) ?>
#Remark :
Discount_Remark3 ?? '') ?>
DeductionDiscount3 ?? 0), 2)) ?>
#Remark :
charge1 ?? '') ?>
Chargechargeamount1 ?? 0), 2)) ?>
#Remark :
charge2 ?? '') ?>
Chargechargeamount2 ?? 0), 2)) ?>
#Net Amount
# + Payment Recd.
+ id ?? '') . ':' . esc($row->pay_mode ?? '') . ':' . esc($row->pay_date_str ?? '') . ':' . esc($row->amount ?? '') . '] / '; + if ($i % 3 === 0) { + echo '
'; + } + } + ?> +
0 ? $paidTotal : (float) ($ipd->total_paid_amount ?? 0), 2)) ?>
#Balance
#Payable By TPApayable_by_tpa ?? 0), 2)) ?>
#Discount For TPAdiscount_for_tpa ?? 0), 2)) ?>
#Discount By Hospitaldiscount_by_hospital_remark ?? '') ?>discount_by_hospital ?? 0), 2)) ?>
#Discount By Hospital/ Doctordiscount_by_hospital_2_remark ?? '') ?>discount_by_hospital_2 ?? 0), 2)) ?>
#Final Balancebalance_discount_after ?? 0), 2)) ?>
+
+
+
diff --git a/app/Views/billing/ipd/panel_diagnosis.php b/app/Views/billing/ipd/panel_diagnosis.php new file mode 100644 index 0000000..3b9ffdb --- /dev/null +++ b/app/Views/billing/ipd/panel_diagnosis.php @@ -0,0 +1,33 @@ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
#Invoice CodeDateCharge TypeAmountInclude
invoice_code ?? $row->inv_id ?? '') ?>str_date ?? '') ?>charge_list ?? '') ?>amount ?? '') ?>ipd_include ?? 0) > 0) ? 'Yes' : 'No' ?>
No diagnosis charges found.
+
diff --git a/app/Views/billing/ipd/panel_discharge.php b/app/Views/billing/ipd/panel_discharge.php new file mode 100644 index 0000000..9058934 --- /dev/null +++ b/app/Views/billing/ipd/panel_discharge.php @@ -0,0 +1,26 @@ + +
+
+
+
+
Discharge Status
+

Status : status_desc ?? 'Pending') ?>

+

Discharge Date : discharge_date ?? '') ?>

+

Discharge Time : discharge_time ?? '') ?>

+

Discharge By : discharge_by ?? '') ?>

+
+
+
+
+
+
+
Remarks
+

Remark : discharge_remark ?? '') ?>

+

Balance User : discharge_balance_user ?? '') ?>

+

Balance Remark : discharge_balance_remark ?? '') ?>

+
+
+
+
diff --git a/app/Views/billing/ipd/panel_ipd_charges.php b/app/Views/billing/ipd/panel_ipd_charges.php new file mode 100644 index 0000000..5019363 --- /dev/null +++ b/app/Views/billing/ipd/panel_ipd_charges.php @@ -0,0 +1,312 @@ +id ?? 0); +$packages = $ipd_packages ?? []; +$hasPackage = ! empty($packages); +$defaultPackageId = $hasPackage ? (int) ($packages[0]->id ?? 0) : 0; +$csrfName = csrf_token(); +$csrfHash = csrf_hash(); +$today = date('Y-m-d'); +?> + + + +
+
+
+
+ IPD Charges List +
+
+
+ + + + + + + + + + + + + + + + + + group_desc ?? ''; + if ($currentGroup !== $groupDesc) { + if ($currentGroup !== null) { + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + } + $currentGroup = $groupDesc; + $groupTotal = 0.0; + echo ''; + echo ''; + echo ''; + echo ''; + } + $srNo++; + $groupTotal += (float) ($row->item_amount ?? 0); + $itemId = (int) ($row->id ?? 0); + $qty = (float) ($row->item_qty ?? 0); + $rate = (float) ($row->item_rate ?? 0); + $docName = (string) ($row->doc_name ?? ''); + $comment = (string) ($row->comment ?? ''); + $packageChecked = (int) ($row->package_id ?? 0) > 0 ? 'checked' : ''; + ?> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
#Charge NameRateQtyAmount
#Sub Total' . esc(number_format($groupTotal, 2)) . '
#' . esc($currentGroup) . '
item_name ?? '') ?> + + + + + item_amount ?? 0), 2)) ?>
# + +
Dr.
+ + +
+ +
+ + + + +
+ + +
+
#Sub Total
No IPD charges found.
Total
+
+
+
+
+
+
+
+ Add Charges +
+
+
+ itype_id ?? 0); + $items = $item_lists[$typeId] ?? []; + $collapseId = 'chargeType' . $typeId; + $headingId = 'heading' . $typeId; + $typeIndex = ($typeIndex + 1) % count($colorMap); + ?> +
+

+ +

+
+
+
+ + +
+
+
+ + +
+
+ + +
+
+ + +
+
+
+
+ + +
+
+ + +
+
+
+ +
+
+
+
+ +
+
+
+
+
+ + diff --git a/app/Views/billing/ipd/panel_medical_bills.php b/app/Views/billing/ipd/panel_medical_bills.php new file mode 100644 index 0000000..73e92ae --- /dev/null +++ b/app/Views/billing/ipd/panel_medical_bills.php @@ -0,0 +1,31 @@ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + +
#Invoice CodeDateAmountStatus
inv_med_code ?? $row->id ?? '') ?>inv_date ?? '') ?>net_amount ?? '') ?>payment_status ?? 0) > 0) ? 'Paid' : 'Pending' ?>
No medical bills found.
+
diff --git a/app/Views/billing/ipd/panel_package.php b/app/Views/billing/ipd/panel_package.php new file mode 100644 index 0000000..e975076 --- /dev/null +++ b/app/Views/billing/ipd/panel_package.php @@ -0,0 +1,196 @@ +id ?? 0); +$csrfName = csrf_token(); +$csrfHash = csrf_hash(); +?> + +
+
+ IPD Package +
+
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
#Package NameAmount
+ package_name ?? '') ?> + package_desc ?? $row->comment ?? '')) : ?> +
package_desc ?? $row->comment ?? '') ?> + +
+ + + + +
No packages found.
+
+ +
+
+

+ +

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

+ +

+
+
+
+
+ + +
+
+ + +
+
+ + +
+
+ +
+
+
+
+
+
+
+
+ + diff --git a/app/Views/billing/ipd/panel_payments.php b/app/Views/billing/ipd/panel_payments.php new file mode 100644 index 0000000..b61088d --- /dev/null +++ b/app/Views/billing/ipd/panel_payments.php @@ -0,0 +1,40 @@ +
+
+
+
+
IPD Payments
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + +
#IDDateAmountMode
id ?? '') ?>pay_date_str ?? '') ?>amount ?? '') ?>pay_mode ?? '') ?>
No payments found.
+
+
+
+
+
diff --git a/app/Views/billing/ipd/panel_placeholder.php b/app/Views/billing/ipd/panel_placeholder.php new file mode 100644 index 0000000..25c7350 --- /dev/null +++ b/app/Views/billing/ipd/panel_placeholder.php @@ -0,0 +1,3 @@ +
+ : This section is under migration. +
diff --git a/app/Views/billing/main.php b/app/Views/billing/main.php new file mode 100644 index 0000000..eeb682a --- /dev/null +++ b/app/Views/billing/main.php @@ -0,0 +1,19 @@ +
+

Welcome

+ +
+ +
+
+
+
Welcome
+

User ID: id ?? '')) ?>

+

Username: username ?? $user->email ?? 'User') ?>

+
+
+
\ No newline at end of file diff --git a/app/Views/billing/opd_advice_workspace.php b/app/Views/billing/opd_advice_workspace.php new file mode 100644 index 0000000..6a139ea --- /dev/null +++ b/app/Views/billing/opd_advice_workspace.php @@ -0,0 +1,276 @@ +
+
+
+
+
+ Advice Master +
+ + +
+
+
+
+ + + + + + + + + + + +
IDAdvice (English)Advice (Local)EditRemove
No advice found
+
+
+
+
+ +
+
+
Add / Edit Advice
+
+ + + +
+ + +
+
+
+ +
+ + +
+
+ +
+ +
+ + +
+ +
Ready.
+
+
+
+
+
+ + diff --git a/app/Views/billing/opd_app_insurance_V.php b/app/Views/billing/opd_app_insurance_V.php new file mode 100644 index 0000000..efca647 --- /dev/null +++ b/app/Views/billing/opd_app_insurance_V.php @@ -0,0 +1,150 @@ +
+
+
+
+
+
OPD Registration
+
+ Name : p_fname ?? '') ?> + / Age : age ?? '') ?> + / Gender : xgender ?? '') ?> + / P Code : + + p_code ?? '') ?> + +
+ + +
No insurance found for this patient.
+ + +
+ + + + +
+
+ + +
+
+ +
+
+ +
+ + + +
+ +
+
+ +
+
+
+
+
+
+
+
+ + +
+
+
+
+
+
+
+
+
+ + diff --git a/app/Views/billing/opd_appointment_V.php b/app/Views/billing/opd_appointment_V.php new file mode 100644 index 0000000..b3a6fcc --- /dev/null +++ b/app/Views/billing/opd_appointment_V.php @@ -0,0 +1,147 @@ +
+
+
+
+
+
OPD Registration
+
+ Name : p_fname ?? '') ?> + / Age : age ?? '') ?> + / Gender : xgender ?? '') ?> + / P Code : + + p_code ?? '') ?> + +
+ +
+ + + + +
+
+ + +
+
+ + +
+
+ +
+
+ +
+ + + +
+ +
+
+ +
+
+
+
+
+
+
+
+ + +
+
+
+
+
+
+
+
+
+ + diff --git a/app/Views/billing/opd_appointment_dashboard.php b/app/Views/billing/opd_appointment_dashboard.php new file mode 100644 index 0000000..eba8722 --- /dev/null +++ b/app/Views/billing/opd_appointment_dashboard.php @@ -0,0 +1,60 @@ +
+

OPD Appointments

+
+ +
+
+
+
+ + + +
+
+
+ +
+ + + color_code ?? 0) % 6)] ?? 'bg-primary'; + $total = (int) ($row->No_opd ?? 0); + $textClass = in_array($colorClass, ['bg-warning', 'bg-info', 'bg-light'], true) ? 'text-dark' : 'text-white'; + ?> +
+
+
+

Dr. p_fname ?? '') ?>

+ Spec ?? '') ?> +
+
+ + + + + +
Bookedcount_booking ?? 0)) ?>
Waitingcount_wait ?? 0)) ?>
Visitedcount_visit ?? 0)) ?>
Total
+
+ +
+
+ + +
No OPD appointment records found for selected date.
+ +
+
+ + diff --git a/app/Views/billing/opd_appointment_list.php b/app/Views/billing/opd_appointment_list.php new file mode 100644 index 0000000..7840742 --- /dev/null +++ b/app/Views/billing/opd_appointment_list.php @@ -0,0 +1,311 @@ + +
+
+

Dr. p_fname ?? '') ?> Spec ?? '') ?>

+ Back to OPD +
+
+ +
+
+
Booked : count_booking ?? 0)) ?>
+
Waiting : count_wait ?? 0)) ?>
+
Visited : count_visit ?? 0)) ?>
+
Cancelled : count_cancel ?? 0)) ?>
+
Total : No_opd ?? 0)) ?>
+
+ + + +
+
+ $opd_list_0, 'showQueue' => false, 'tabType' => 'booking', 'opd_date' => $opd_date, 'doc_id' => $doc_id]) ?> +
+
+
+
+ + +
+
+ $opd_list_1, 'showQueue' => true, 'tabType' => 'waiting', 'opd_date' => $opd_date, 'doc_id' => $doc_id]) ?> +
All waiting patients already have vitals.
+
+
+ $opd_list_2, 'showQueue' => true, 'tabType' => 'visited', 'opd_date' => $opd_date, 'doc_id' => $doc_id]) ?> +
+
+ $opd_list_3, 'showQueue' => true, 'tabType' => 'cancelled', 'opd_date' => $opd_date, 'doc_id' => $doc_id]) ?> +
+
+
+ + + + + + diff --git a/app/Views/billing/opd_appointment_list_table.php b/app/Views/billing/opd_appointment_list_table.php new file mode 100644 index 0000000..b3fbac1 --- /dev/null +++ b/app/Views/billing/opd_appointment_list_table.php @@ -0,0 +1,85 @@ +user() : null; +if ($authUser) { + if (method_exists($authUser, 'can') && $authUser->can('opd.doctor-panel.access')) { + $canOpenPrescription = true; + } +} +?> +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + +
OPD No.Current PatientQ No.UHIDOPD TypeAction
opd_code ?? '') ?>P_name ?? '') . ' { ' . ($row->p_rname ?? '') . ' }') ?>queue_no ?? 0)) ?>p_code ?? '') ?>opd_type ?? '') ?> / Amt: opd_fee_amount ?? '') ?> + has_vitals) && (int) $row->has_vitals === 1; ?> + + + Consult + + + + + + + Profile + + + + + + +
No records.
+
+ + + + diff --git a/app/Views/billing/opd_invoice_V.php b/app/Views/billing/opd_invoice_V.php new file mode 100644 index 0000000..42e0703 --- /dev/null +++ b/app/Views/billing/opd_invoice_V.php @@ -0,0 +1,455 @@ +user(); +if ($user && method_exists($user, 'inGroup')) { + $canEdit = $user->inGroup('OPDEdit'); +} +?> +
+

OPD Invoice

+ +
+ +
+
+ +
+
+ To +
+ P_name ?? '')) ?>
+ p_relative ?? '') ?> : p_rname ?? '') ?>
+ OPD Book Date (y-m-d time) : opd_book_date ?? '') ?>
+ Gender : xgender ?? '') ?>
+ Age : age ?? '') ?>
+ Phone No : mphone1 ?? '') ?> +
+
+
+ OPD ID: opd_code ?? '') ?>
+ Date of Appointment: str_apointment_date ?? '') ?>
+ Patient ID : p_code ?? '') ?>
+ insurance_id ?? 0) > 1 && !empty($insurance)) : ?> + Ins. Comp. : ins_company_name ?? '') ?>
+ + + payment_id)) : ?> + Payment No. : payment_id ?? '') ?>
+ +
+
+ +
+
+ + + + + + + + + + + + + + + + + + + payment_status ?? 0) == 0) : ?> + + + + + + + + opd_discount)) : ?> + + + + + + + + + + + + + + + +
DateDoctorDepartmentOPD Fee
apointment_date ?? '')) ?>Dr. doc_name ?? '') ?>doc_spec ?? '') ?>opd_fee_gross_amount ?? '') ?>opd_fee_desc ?? '') ?>
Any Deduction + + + +
Deductionopd_disc_remark ?? '') ?>opd_discount ?? '') ?>
#Net Amountopd_fee_amount ?? '') ?>
+
+
+ + payment_status ?? 0) == 0 && ($refund_status ?? 0) == 0) : ?> +
+
+
+
+
+ +
+ 0) : ?> +
+

+ +

+
+
+ +
+
+
+
+

+ +

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

+ +

+
+
+ +
+
+
+ + + insurance_id ?? 0) > 0) : ?> +
+

+ +

+
+
+ +
+
+
+ + + +
+
+
+
+ + +
+
+
+ +
+
+
+ +
+
+
+
+
+ +
+ +
+ + Payment Refund Status : Pending + opd_status ?? 0) == 3) : ?> +

Status is Cancelled

+ + Payment Method by : payment_mode_desc ?? '') ?> + +
+
+ + + opd_status ?? 0) === 1 || (int) ($opd_master[0]->opd_status ?? 0) === 2)) : ?> +
+
+ opd_status ?? 0) === 1) : ?> +
+ +
+
+ +
+ +
+ 0) : ?> + + + +
+
+
+
+ + +
+
+ + +
+
+ + +
+
+ +
+
+
+
+ payment_mode ?? 0) === 4)) : ?> + + +
+
+ +
+
+ +
+ + + diff --git a/app/Views/billing/opd_invoice_pdf_v.php b/app/Views/billing/opd_invoice_pdf_v.php new file mode 100644 index 0000000..10412b1 --- /dev/null +++ b/app/Views/billing/opd_invoice_pdf_v.php @@ -0,0 +1,266 @@ + 42) { + $hospitalNameFontSize = 14; +} elseif ($hospitalNameLen > 36) { + $hospitalNameFontSize = 16; +} elseif ($hospitalNameLen > 30) { + $hospitalNameFontSize = 18; +} + +$invoiceId = (string) ($opd->opd_code ?? ''); +$appointmentDate = (string) ($opd->str_apointment_date ?? ''); +$doctorName = trim((string) ($opd->doc_name ?? '')); +$department = trim((string) ($opd->doc_spec ?? '')); +$description = trim((string) ($opd->opd_fee_desc ?? '')); +$grossAmount = (float) ($opd->opd_fee_gross_amount ?? $opd->opd_fee_amount ?? 0); +$discount = (float) ($opd->opd_discount ?? 0); +$netAmount = (float) ($opd->opd_fee_amount ?? 0); +$paymentMode = trim((string) ($opd->payment_mode_desc ?? $opd->Payment_type_str ?? '')); +$printedOn = date('d-m-Y h:i:s A'); +$invoiceStatus = ((int) ($opd->opd_status ?? 0) === 3) ? 'Cancelled' : (($paymentMode !== '' && strtolower($paymentMode) !== 'pending') ? 'Paid' : 'Pending'); +$currencyPrefix = 'Rs.'; + +$logoPathCandidates = []; +if ($hospitalLogoName !== '') { + $logoPathCandidates[] = FCPATH . 'assets/images/' . $hospitalLogoName; + $logoPathCandidates[] = FCPATH . 'assets/img/' . $hospitalLogoName; +} +$logoPathCandidates[] = FCPATH . 'assets/img/logo.png'; + +$logoSrc = ''; +foreach ($logoPathCandidates as $candidate) { + if (is_file($candidate)) { + $logoSrc = str_replace('\\', '/', $candidate); + break; + } +} + +$qrParts = [ + 'Hospital:' . $hospitalName, + 'HospitalPhone:' . $hospitalPhone, + 'Invoice:' . ($invoiceId !== '' ? $invoiceId : ('OPD-' . (string) ($opd->opd_id ?? ''))), + 'Patient:' . (string) ($patient->p_code ?? ''), + 'Name:' . trim((string) (($patient->title ?? '') . ' ' . ($patient->p_fname ?? ''))), + 'Date:' . $appointmentDate, + 'Net:' . number_format($netAmount, 2, '.', ''), + 'PaymentID:' . (string) ($opd->payment_id ?? ''), + 'Status:' . $invoiceStatus, +]; +$qrContent = implode(' | ', array_filter($qrParts, static fn ($v) => trim((string) $v) !== '')); +$qrPackageAvailable = class_exists('\\Mpdf\\QrCode\\QrCode'); +?> + + + + + OPD Invoice + + + +
+ + + + + + +
+
+ +
+ + +
+ + + +
+ +
+ +
+ +
Scan for invoice info
+
+ +
+
QR unavailable (mpdf/qrcode not installed)
+
+ +
+ + + + + + + +
+
Patient Details
+
Patient ID: p_code ?? '')) ?>
+
Name: title ?? '') . ' ' . ($patient->p_fname ?? '')))) ?>
+
Gender: xgender ?? '')) ?>
+
Age: age ?? '')) ?>
+
Phone: mphone1 ?? '')) ?>
+
+
Visit Details
+
Date:
+
Doctor:
+
Department:
+
Payment No: payment_id ?? '')) ?>
+
Visit Count: no_visit ?? '')) ?>
+
+
Invoice Details
+
Invoice ID:
+
Invoice Date:
+
Printed On:
+
Status:
+
Payment Mode:
+
OPD ID: opd_id ?? '')) ?>
+
+ + + + + + + +
+
Insurance / Organization
+ +
Insurance: ins_company_name ?? '')) ?>
+ + +
Org. Case No: case_id_code ?? '')) ?>
+ +
+
Billing Status
+ opd_status ?? 0) === 3) : ?> +
OPD Cancelled
+
opd_status_remark ?? '')) ?>
+ +
Mode of Payment:
+ +
+ + + + + + + + + + + + + + + + + + + + + 0) : ?> + + + + + + +
DateDoctorDepartmentDescriptionAmount
Discountopd_disc_remark ?? '') ? (' - ' . esc((string) ($opd->opd_disc_remark ?? ''))) : '' ?>-
+ + + + + + +
Amount is collected against OPD consultation and related visit charges. + + + + + + + + + + + + + +
Gross Amount
Discount-
Net Amount
+
+ + +
+ + diff --git a/app/Views/billing/opd_invoice_print_v.php b/app/Views/billing/opd_invoice_print_v.php new file mode 100644 index 0000000..6decc79 --- /dev/null +++ b/app/Views/billing/opd_invoice_print_v.php @@ -0,0 +1,96 @@ + + + + + <?= defined('H_Name') ? H_Name : 'Hospital' ?> | OPD Invoice + + + + +
+

+ + Printed on: +

+
+ +
+
+ OPD Invoice ID: opd_code ?? '') ?>
+ Patient ID: p_code ?? '') ?>
+ insurance_id ?? 0) > 1 && !empty($insurance)) : ?> + Ins. Comp.: ins_company_name ?? '') ?>
+ + insurance_case_id ?? 0) > 0 && !empty($case_master)) : ?> + Org. Case No.: case_id_code ?? '') ?>
+ + payment_id)) : ?> + Payment No.: payment_id ?? '') ?>
+ +
+
+
+
+
+
+ +
+
+ title ?? '') . ' ' . strtoupper($patient_master[0]->p_fname ?? '')) ?>
+ Date: str_apointment_date ?? '') ?>
+ Gender: xgender ?? '') ?>
+ Age: age ?? '') ?>
+ Phone: mphone1 ?? '') ?>
+ Visit Count: no_visit ?? '') ?> +
+
+ +
+ + + + + + + + + + + + + + + + + + + opd_discount) && (float) ($opd_master[0]->opd_discount ?? 0) > 0) : ?> + + + + + + + + + + + + + + +
DateDoctorDepartmentDescriptionOPD Fee
apointment_date ?? '') ?>Dr. doc_name ?? '') ?>doc_spec ?? '') ?>opd_fee_desc ?? '') ?>opd_fee_gross_amount ?? '') ?>
Deductionopd_disc_remark ?? '') ?>-opd_discount ?? '') ?>
Net Amountopd_fee_amount ?? '') ?>
+ + opd_status ?? 0) === 3) : ?> + OPD Cancelled
+ opd_status_remark ?? '') ?> + + Mode of Payment: payment_mode_desc ?? '') ?> + +
+ + diff --git a/app/Views/billing/opd_letter_head.php b/app/Views/billing/opd_letter_head.php new file mode 100644 index 0000000..211c549 --- /dev/null +++ b/app/Views/billing/opd_letter_head.php @@ -0,0 +1,237 @@ + + + + + <?= defined('H_Name') ? constant('H_Name') : 'OPD Letter Head' ?> + + + + +
+
+
+ UHID: p_code ?? '') ?>
+ Name: title ?? '') . ' ' . strtoupper($patient_master[0]->p_fname ?? '')) ?>
+ p_relative ?? '') . ' ' . strtoupper($patient_master[0]->p_rname ?? '')) ?>
+ Sex: xgender ?? '') ?> + / Age: age ?? '') ?> +
+
+ OPD No.: opd_code ?? '') ?> / opd_id ?? '') ?>
+ OPD Fee: opd_fee_amount ?? '') ?> [opd_fee_desc ?? '') ?>]
+ Date: str_apointment_date ?? '') ?>
+ opd_fee_type ?? '') === '3' && !empty($old_opd)) : ?> + Valid Upto: opd_Exp_Date ?? '') ?>
+ + Valid Upto: opd_Exp_Date ?? '') ?>
+ +
+
+ Sr No.: opd_no ?? '') ?>
+ Phone: mphone1 ?? '') ?>
+ Address: add1 ?? '') . ',' . ($patient_master[0]->city ?? '')) ?>
+
+
+ + 'No Pain', + '1' => 'Mild Pain', + '2' => 'Moderate', + '3' => 'Intense', + '4' => 'Worst Pain Possible', + ]; + $painValue = (string) ($rx['pain_value'] ?? ''); + $painText = $painLabels[$painValue] ?? ''; + + $complications = []; + if (!empty($rx['pregnancy'] ?? 0)) { $complications[] = 'Pregnancy'; } + if (!empty($rx['lactation'] ?? 0)) { $complications[] = 'Lactation'; } + if (!empty($rx['liver_insufficiency'] ?? 0)) { $complications[] = 'Liver Insufficiency'; } + if (!empty($rx['renal_insufficiency'] ?? 0)) { $complications[] = 'Renal Insufficiency'; } + if (!empty($rx['pulmonary_insufficiency'] ?? 0)) { $complications[] = 'Pulmonary Insufficiency'; } + if (!empty($rx['corona_suspected'] ?? 0)) { $complications[] = 'Corona Suspected'; } + if (!empty($rx['dengue'] ?? 0)) { $complications[] = 'Dengue'; } + + $addictions = []; + if (!empty($patient_master[0]->is_smoking ?? 0)) { $addictions[] = 'Smoking'; } + if (!empty($patient_master[0]->is_alcohol ?? 0)) { $addictions[] = 'Alcohol'; } + if (!empty($patient_master[0]->is_drug_abuse ?? 0)) { $addictions[] = 'Drug Abuse'; } + + $isFemale = strtoupper((string) ($patient_master[0]->xgender ?? '')) === 'F'; + $womenRelatedProblems = trim((string) ($rx['women_related_problems'] ?? '')); + $womenLmp = trim((string) ($rx['women_lmp'] ?? '')); + $womenLastBaby = trim((string) ($rx['women_last_baby'] ?? '')); + $womenPregnancyRelated = trim((string) ($rx['women_pregnancy_related'] ?? '')); + + $vitals = array_filter([ + trim((string) ($rx['bp'] ?? '')) !== '' ? ('BP: ' . trim((string) ($rx['bp'] ?? '')) . '/' . trim((string) ($rx['diastolic'] ?? ''))) : '', + trim((string) ($rx['pulse'] ?? '')) !== '' ? ('Pulse: ' . trim((string) ($rx['pulse'] ?? '')) . '/min') : '', + trim((string) ($rx['temp'] ?? '')) !== '' ? ('Temp: ' . trim((string) ($rx['temp'] ?? ''))) : '', + trim((string) ($rx['spo2'] ?? '')) !== '' ? ('SpO2: ' . trim((string) ($rx['spo2'] ?? '')) . '%') : '', + trim((string) ($rx['rr_min'] ?? '')) !== '' ? ('RR: ' . trim((string) ($rx['rr_min'] ?? '')) . '/min') : '', + trim((string) ($rx['height'] ?? '')) !== '' ? ('Height: ' . trim((string) ($rx['height'] ?? ''))) : '', + trim((string) ($rx['weight'] ?? '')) !== '' ? ('Weight: ' . trim((string) ($rx['weight'] ?? ''))) : '', + trim((string) ($rx['waist'] ?? '')) !== '' ? ('Waist: ' . trim((string) ($rx['waist'] ?? ''))) : '', + ]); + ?> + + +
+
+
Prescription Summary
+ + +
Complaints:
+ + + +
Diagnosis:
+ + + +
Provisional Diagnosis:
+ + + +
Finding/Examination:
+ + + +
Vitals:
+ + + +
Pain Measurement Scale:
+ + + +
Complication:
+ + + +
Addiction:
+ + + +
Co-Morbidities:
+ + + +
Women Related Problems:
+ + + +
LMP (No. of days before):
+ + + +
Last Baby:
+ + + +
Pregnancy Related:
+ + + +
Investigation:
+ + + +
Prescription Remarks:
+ + + +
Advice:
+ + + +
Next Visit:
+ + + +
Refer To:
+ +
+ + +
Medicines
+ + + + + + + + + + + + + + + + + + + + + + + + + + + +
MedicineTypeDoseWhenFrequencyDaysQtyRemark
+ + + +
Investigations
+ + + + + + + + + + + + + + + +
CodeInvestigation Name
+ + + +
Advice List
+ + + + + + + + + + + + + +
Advice
+ + +
+ + diff --git a/app/Views/billing/opd_letter_head_pdf.php b/app/Views/billing/opd_letter_head_pdf.php new file mode 100644 index 0000000..9063c84 --- /dev/null +++ b/app/Views/billing/opd_letter_head_pdf.php @@ -0,0 +1,417 @@ +p_fname ?? '')); +$doctorDegree = trim((string) ($doctor->qualification ?? ($doctor->degree ?? ''))); +$doctorSpec = trim((string) ($doctor->SpecName ?? '')); + +$doctorRegNo = ''; +if ($doctor !== null) { + foreach (['nmc_reg_no', 'mci_reg_no', 'registration_no', 'reg_no', 'doctor_reg_no', 'doc_reg_no', 'council_reg_no'] as $field) { + if (isset($doctor->{$field}) && trim((string) $doctor->{$field}) !== '') { + $doctorRegNo = trim((string) $doctor->{$field}); + break; + } + } + + if ($doctorRegNo === '') { + $shortDescription = trim((string) ($doctor->doc_sign ?? '')); + if ($shortDescription !== '') { + $normalizedShortDescription = preg_replace('/\s+/', ' ', $shortDescription); + if ($normalizedShortDescription !== null) { + if (preg_match('/(?:reg(?:istration)?\s*(?:no|number)?\s*[:\-]?\s*)([A-Z0-9\/-]{4,})/i', $normalizedShortDescription, $matches) === 1 && ! empty($matches[1])) { + $doctorRegNo = trim((string) $matches[1]); + } + } + } + } +} + +$vitals = []; +if (trim((string) ($rx['bp'] ?? '')) !== '') { + $vitals[] = 'BP: ' . trim((string) ($rx['bp'] ?? '')) . (trim((string) ($rx['diastolic'] ?? '')) !== '' ? '/' . trim((string) ($rx['diastolic'] ?? '')) : ''); +} +if (trim((string) ($rx['pulse'] ?? '')) !== '') { + $vitals[] = 'Pulse: ' . trim((string) ($rx['pulse'] ?? '')) . '/min'; +} +if (trim((string) ($rx['temp'] ?? '')) !== '') { + $vitals[] = 'Temp: ' . trim((string) ($rx['temp'] ?? '')); +} +if (trim((string) ($rx['spo2'] ?? '')) !== '') { + $vitals[] = 'SpO2: ' . trim((string) ($rx['spo2'] ?? '')) . '%'; +} + +$visitDate = (string) ($opd->str_apointment_date ?? ''); +$visitDateTime = ''; +if (!empty($opd->apointment_date ?? '')) { + $ts = strtotime((string) $opd->apointment_date); + if ($ts !== false) { + $visitDateTime = date('d-m-Y h:i A', $ts); + } +} +$validUpto = (string) ($opd->opd_Exp_Date ?? ''); +$nextVisit = trim((string) ($rx['next_visit'] ?? '')); +$investigationText = trim((string) ($rx['investigation'] ?? '')); +$printedOn = date('d-m-Y h:i A'); +$layoutMode = strtolower((string) ($print_layout_mode ?? 'full')); +$showPart1 = in_array($layoutMode, ['full', 'header_meta'], true); +$showPart2 = in_array($layoutMode, ['full', 'meta_content', 'header_meta', 'meta_only'], true); +$showPart3 = in_array($layoutMode, ['full', 'meta_content', 'content_only'], true); +$topSpacerMm = in_array($layoutMode, ['content_only', 'meta_content', 'meta_only'], true) ? 22 : 0; +$drugAllergyStatus = trim((string) ($rx['drug_allergy_status'] ?? '')); +$drugAllergyDetails = trim((string) ($rx['drug_allergy_details'] ?? '')); +$adrHistory = trim((string) ($rx['adr_history'] ?? '')); +$currentMedications = trim((string) ($rx['current_medications'] ?? '')); +$painScaleMap = [ + '0' => 'No Pain', + '1' => 'Mild Pain', + '2' => 'Moderate', + '3' => 'Intense', + '4' => 'Worst Pain Possible', +]; +$painValue = trim((string) ($rx['pain_value'] ?? '')); +$painLabel = $painScaleMap[$painValue] ?? ''; + +$toLocalText = static function (string $input): string { + $text = trim($input); + if ($text === '') { + return ''; + } + + $map = [ + 'before food' => 'भोजन से पहले', + 'after food' => 'भोजन के बाद', + 'after breakfast' => 'नाश्ते के बाद', + 'before breakfast' => 'नाश्ते से पहले', + 'after lunch' => 'दोपहर के भोजन के बाद', + 'before lunch' => 'दोपहर के भोजन से पहले', + 'after dinner' => 'रात के भोजन के बाद', + 'before dinner' => 'रात के भोजन से पहले', + 'morning' => 'सुबह', + 'afternoon' => 'दोपहर', + 'evening' => 'शाम', + 'night' => 'रात', + 'once daily' => 'दिन में एक बार', + 'twice daily' => 'दिन में दो बार', + 'thrice daily' => 'दिन में तीन बार', + 'daily' => 'रोज', + 'for' => 'के लिए', + 'days' => 'दिन', + 'day' => 'दिन', + 'tab' => 'टैब', + 'cap' => 'कैप', + 'syp' => 'सिरप', + 'inj' => 'इंजेक्शन', + 'apply' => 'लगाएं', + 'continue' => 'जारी रखें', + 'rest' => 'आराम करें', + 'hydrate' => 'पर्याप्त पानी लें', + 'avoid oily food' => 'तैलीय भोजन से बचें', + 'follow up' => 'फॉलो-अप करें', + 'review' => 'पुनः जांच', + ]; + + $translated = $text; + uksort($map, static function ($a, $b) { + return strlen((string) $b) <=> strlen((string) $a); + }); + foreach ($map as $en => $local) { + $translated = preg_replace('/\\b' . preg_quote($en, '/') . '\\b/i', $local, $translated) ?? $translated; + } + + return $translated; +}; +?> + + + + + OPD Consult Note + + + +
+ + + + + + +
+
+ +
+ + +
Phone:
+ +
+ +
Dr.
+ + +
+ + +
+ +
+ Reg. No.: + + + + ADD_DOCTOR_REG_NO + +
+
+ + + + + + + + + +
+
Name : title ?? '') . ' ' . ($patient->p_fname ?? '')))) ?>
+
p_relative ?? '') . ' ' . ($patient->p_rname ?? '')))) ?>
+
Gender/Age : age ?? '')) ?> Year / xgender ?? '')) ?>
+
Mob : mphone1 ?? '')) ?>
+
Address : add1 ?? '') . ' ' . ($patient->city ?? '')))) ?>
+
+
UHID : p_code ?? '')) ?>
+
Sr No. : opd_no ?? '')) ?>
+
OPD No. : opd_code ?? '')) ?>
+
Date :
+ +
Date & Time :
+ +
Valid Upto :
+
+
DEPARTMENT :
+
+
No. of Visit : 1
+
Last Visit :
+
Book Time :
+
+ + + + +
Complaint :
+ + + +
Vitals :
+ + + +
Pain Measurement Scale :
+ + + +
Finding :
+ + + +
Drug Allergy Status :
+ +
Drug Allergy Details :
+ + +
ADR History :
+ + +
Current Medications :
+ + + + +
Diagnosis :
+ +
Diagnosis :
+ + +
Rx :
+ + + + + + + + + + + + + + $med) : ?> + + + + + + + + + + + +
#Medicine NameDose / FrequencyQtyDayInstruction
+
+ +
Salt/Generic:
+ +
+
+ +
+ +
+
+ +
+ +
+ +
No medicines prescribed.
+ + + + + +
Investigation Advised :
+ + + + + + +
Advice :
+ +
सलाह :
+ + + + +
Advice :
+ +
सलाह :
+ + + + +
Next Visit :
+ + + + +
BP : __________    Pulse Rate : __________    SPO2 : __________    Ht : __________    Wt. : __________    RBS : __________
+ + + +
+ +
Dr.
+ + +
+ + +
+ +
+ Reg. No.: + + + + ADD_DOCTOR_REG_NO + +
+
+ + + +
+ + diff --git a/app/Views/billing/opd_medicince_workspace.php b/app/Views/billing/opd_medicince_workspace.php new file mode 100644 index 0000000..cd47027 --- /dev/null +++ b/app/Views/billing/opd_medicince_workspace.php @@ -0,0 +1,618 @@ +
+
+
+
+
+ List of Medicine +
+ + + + + + + + + + +
+
+
+
Duplicate scan not run yet.
+
+
+
+ + + + + + + + + + + + + + + +
IDFavNameUsedLast UsedGeneric NameCompany NameEditRemove
No medicine found
+
+
+
+ +
+
+
+ Duplicate Medicine Names +
+ + +
+
+
+
+ + + + + + + + + + +
NameCountIDsAction
Click Check Duplicates to scan.
+
+
+
+
+ +
+
+
New Medicine
+
+ + + +
+ + +
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+
+ + + +
+ +
+ + + +
+ +
Ready.
+
+
+
+
+
+ + diff --git a/app/Views/billing/opd_parts/content/default.html b/app/Views/billing/opd_parts/content/default.html new file mode 100644 index 0000000..46ff213 --- /dev/null +++ b/app/Views/billing/opd_parts/content/default.html @@ -0,0 +1,13 @@ +
+ {{painscale_img}} + {{vital_content}} + {{Complaint}} + {{diagnosis}} + {{Finding_Examinations}} + {{medical}} + {{investigation}} + {{Prescriber_Remarks}} + {{advice}} + {{next_visit}} + {{refer_to}} +
diff --git a/app/Views/billing/opd_parts/hospital/default.html b/app/Views/billing/opd_parts/hospital/default.html new file mode 100644 index 0000000..8cfd6ca --- /dev/null +++ b/app/Views/billing/opd_parts/hospital/default.html @@ -0,0 +1,23 @@ + + +{{hospital_section}} + + +

Print Time : {{print_time}}

+
+{{patient_section}} +
+{{content_section}} diff --git a/app/Views/billing/opd_parts/layout/default.html b/app/Views/billing/opd_parts/layout/default.html new file mode 100644 index 0000000..8cfd6ca --- /dev/null +++ b/app/Views/billing/opd_parts/layout/default.html @@ -0,0 +1,23 @@ + + +{{hospital_section}} + + +

Print Time : {{print_time}}

+
+{{patient_section}} +
+{{content_section}} diff --git a/app/Views/billing/opd_parts/patient/default.html b/app/Views/billing/opd_parts/patient/default.html new file mode 100644 index 0000000..d1db10f --- /dev/null +++ b/app/Views/billing/opd_parts/patient/default.html @@ -0,0 +1,10 @@ + + + + +
+Patient Name : + + +{{pName}} +
\ No newline at end of file diff --git a/app/Views/billing/opd_parts/patient/edit.html b/app/Views/billing/opd_parts/patient/edit.html new file mode 100644 index 0000000..196a8b7 --- /dev/null +++ b/app/Views/billing/opd_parts/patient/edit.html @@ -0,0 +1,18 @@ + + + + + +
+ {{pName}}
+ {{pRelative}}
+ {{age_sex}}
+ {{p_address}}
+ Phone: {{phoneno}} +
+ UHID: {{uhid_no}}
+ OPD: {{opd_no}}
+ SR: {{opd_sr_no}}
+ Date: {{opd_date}}
+ {{exp_date}} +
diff --git a/app/Views/billing/opd_parts/patient/list.html b/app/Views/billing/opd_parts/patient/list.html new file mode 100644 index 0000000..73e668c --- /dev/null +++ b/app/Views/billing/opd_parts/patient/list.html @@ -0,0 +1,26 @@ + + + + + + +
+ Name : {{pName}}
+ {{pRelative}}
+ Gender/Age : {{age_sex}}
+ Mob : {{phoneno}}
+ Address : {{p_address}} +
+ UHID : {{uhid_no}}
+ Sr No.: {{opd_sr_no}}
+ OPD No.: {{opd_no}}
+ Date: {{opd_date}}
+ {{exp_date}} +
+ Department:
+ {{SpecName}}
+ {{opd_fee_desc}}
+ No. of Visit: {{total_no_visit}}
+ {{last_opdvisit_date}}
+ Book Time : {{str_opd_book_date}} +
diff --git a/app/Views/billing/opd_prescription_basic.php b/app/Views/billing/opd_prescription_basic.php new file mode 100644 index 0000000..2436148 --- /dev/null +++ b/app/Views/billing/opd_prescription_basic.php @@ -0,0 +1,3783 @@ +
+ apointment_date ?? ''); + $opdDateOnly = $opdDateRaw !== '' ? date('Y-m-d', strtotime($opdDateRaw)) : ''; + $opdDateDisplay = $opdDateRaw !== '' ? date('d-m-Y', strtotime($opdDateRaw)) : ''; + $doctorName = trim((string) ($opd_master[0]->doc_name ?? 'Doctor')); + $doctorId = (int) ($opd_master[0]->doc_id ?? $opd_master[0]->doctor_id ?? 0); + + $appointmentBackUrl = $opdDateOnly !== '' + ? base_url('Opd/get_appointment_data') . '/' . $opdDateOnly + : base_url('opd/appointment'); + + $doctorListUrl = ($opdDateOnly !== '' && $doctorId > 0) + ? base_url('Opd/get_appointment_list') . '/' . $doctorId . '/' . $opdDateOnly + : ''; + ?> +
+

Consult

+
+ OPD Appointment + → + + + + + + + + → + +
+
+
+ +
+ + +
+ + + + +
+
+ Not Saved + No local changes +
+
+ + + + + +
+ + +
+ + Back to Invoice +
+
+
+ +
+
+
+
Name: p_fname ?? '') ?>
+
UHID: p_code ?? '') ?>
+
Age: str_age ?? '') ?>
+
Gender: xgender ?? '') ?>
+
+ + +
+
OPD: opd_code ?? '') ?>
+
Date: apointment_date ?? '') ?>
+
Doctor: doc_name ?? '') ?>
+
+
+
Quick Tips
+
+
    +
  • Use Ctrl+S to save quickly.
  • +
  • Draft auto-saves locally every few seconds.
  • +
  • Unsaved changes are warned before leaving.
  • +
+
+
+
+
Patient History Alerts
+
+ + +
+ : +
+
+ + +
No significant prior alerts found.
+ +
+
+
+
Remarks
+
+ + +
+
+ +
+ + +
No remarks available.
+ +
+
+ + + +
+
+ Patient Scan History (All OPDs) + +
+
+
Loading scan history...
+
+
+
+
Old Consult (Fast View)
+
+
+ + +
+ +
+
+
+
+ + PDF + + + scan + + +
+
+
+ + + AI Ready + AI Failed + Alert +
+ +
+ + +
Report details are not available yet.
+ +
+
+
+
+
+ +
+ +
No uploaded scan found for this OPD yet.
+ +
+ + + + + + + +
+
+
+ + + +
+ +
C:
+ + +
D:
+ + +
+ + + + + + + + + + $oldMed) { ?> + + + + + + + +
#Medicine NameAction
+ +
+
+ + +
+ + + Open PDF + + scan + + + +
+ +
+ + +
No old consult record found.
+ + +
No old consult record found.
+ + +
+ + +
+ + +
+
+
+
+
+ +
+
+
+ Single Screen Consult + (Old familiar fields + AI assist) +
+ +
+
+
+
General Examination
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
Pain Measurement Scale
+ + pain_value ?? ''); ?> +
+ > + + + > + + + > + + + > + + + > + +
+
+
+
+
Complication
+
+ + + + + + + +
+
+
+
+
+
Addiction(if any)
+
+ + + +
+
+
+
+
+
Drug Allergy / ADR (NABH)
+
Required: Drug Allergy Status is mandatory. If status is Known, Drug Allergy Details are mandatory.
+
+
+ + drug_allergy_status ?? ''))); ?> + + +
+
+ + + +
+
+ + +
+
+ + +
+
+
+
+
+
+
Co-Morbidities
+ +
+ + + +
+ +
Prefilled from patient history.
+ + +
No co-morbidities master data found.
+ +
+
+ xgender ?? '')) === 'female'; ?> + +
+
+
Women Related Problems
+
+
+ +
+
+ +
+
+ +
+
+ + +
+
+ +
+
+
+ +
+ + + +
+ +
+
+
+ + +
0/4000
+
+ +
+ +
AI Assist is optional. Use it only if you want cleaner clinical wording; manual typing works as usual.
+
+ + + + + +
+ +
0/4000
+
+ +
+ +
+ + + + + +
+ +
0/4000
+
+ +
+ +
+ + + + + +
+ +
0/4000
+
+ +
+ +
+ + + + + +
+ +
0/4000
+
+ +
+ +
0/4000
+
+
+ +
+
+ +
+ + + + + +
+ +
0/4000
+
+ +
+
+ +
+ + +
+
+
+
+
Loading predefined advice...
+
+
+
+ +
+
+ + +
+
+ +
+
+
+ + + +
AdviceAction
No advice added
+
+ +
+
+ + +
+
+ + +
+
+ +
+ + + + + + + + + +
+
+ +
+
+ + +
+ +
+
+ + + + + +
+
+ +
+
+ + + +
+
+ + +
+
+
+ + + +
Test NameCodeAction
No investigation added
+
+
+ +
+ +
+
+ + No Rx-Group selected +
+
+ Select group and preview medicines before add. +
+
+
+
+ + +
+
+ +
+
+ +
+
+ +
+
+ +
+
+
+
+ +
+
+ +
+
+ +
+
+ + +
+
+
+ + + + Search shows most-used medicines first. +
+ +
+ + + + + + + + + + +
+
+ + + + + + + +
MedicineTypeDoseWhenFreqDaysQtyRemarkAction
No medicine added
+
+
+
+
+ +
+
+
+
+ + + + + + + + +
+ + diff --git a/app/Views/billing/opd_rx_group_workspace.php b/app/Views/billing/opd_rx_group_workspace.php new file mode 100644 index 0000000..8a11c6f --- /dev/null +++ b/app/Views/billing/opd_rx_group_workspace.php @@ -0,0 +1,239 @@ +
+
+
+
+
+ Rx-Group List + +
+
+
+ + + +
Rx-Group NameAccessAction
No data
+
+
+
+
+ +
+
+
Rx-Group
+
+ + + +
+ + +
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+ +
+ + + +
+ +
Ready.
+
+
+
+
+
+ + diff --git a/app/Views/billing/opd_scan_history_panel.php b/app/Views/billing/opd_scan_history_panel.php new file mode 100644 index 0000000..4ecd1fe --- /dev/null +++ b/app/Views/billing/opd_scan_history_panel.php @@ -0,0 +1,56 @@ + +
No scan history found for this patient.
+ +
+ +
+
+ + +
+ +
+
+ + Open PDF + + + history scan + + + +
+ +
+
+ + + + AI + + AI Ready + + AI Failed + + AI Not Run + +
+ +
+ ⚠ +
+ +
+ +
+ +
+ + +
+
+
+
+ +
+ diff --git a/app/Views/billing/opd_scan_last_list.php b/app/Views/billing/opd_scan_last_list.php new file mode 100644 index 0000000..c30ad96 --- /dev/null +++ b/app/Views/billing/opd_scan_last_list.php @@ -0,0 +1,38 @@ + +
No recent scans.
+ +
+ +
+
+ + Open PDF + + + + + + +
⚠ Alert
+ +
+ + + + AI + + AI Ready + + AI Failed + +
+ +
+ +
+ +
+
+ +
+ diff --git a/app/Views/billing/opd_scan_modal_body.php b/app/Views/billing/opd_scan_modal_body.php new file mode 100644 index 0000000..3bf37a4 --- /dev/null +++ b/app/Views/billing/opd_scan_modal_body.php @@ -0,0 +1,289 @@ +
+
+

Name : p_fname ?? '') ?> + / Age : age ?? '') ?> + / Gender : xgender ?? '') ?> + / P Code : p_code ?? '') ?> + / OPD : opd_code ?? '') ?>

+
+
+
+
+ + + +
+ + +
+
+ + + +
+
+
+
Captured image will appear here.
+
+
+
+
+
Scan to Text
+
+
Loading...
+
+
+
+
AI Diagnosis Support
+
+
AI analysis runs automatically in background after each scan/upload.
+
+
+
+
+ + diff --git a/app/Views/billing/opd_template_builder.php b/app/Views/billing/opd_template_builder.php new file mode 100644 index 0000000..92715b0 --- /dev/null +++ b/app/Views/billing/opd_template_builder.php @@ -0,0 +1,159 @@ +
+
+
+

OPD Print Template Builder

+
+
+
+ Template List + +
+
+
+
+ +
+
+
+
+
+

Edit Template Content

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

Placeholders

+
+
+ + {{}} + +
+
+
+ Old-style (recommended): save a name (example: opd_print_parcha_chamunda_hospital_ksp), then set that name in doctor master fields:
+ opd_print_format, opd_blank_print, rx_pre_print_letter_head_format, rx_blank_letter_head, rx_plain_paper.

+ Optional composed mode: use compose_default with type-specific parts. +
+
+
+
+ + diff --git a/app/Views/billing/opd_template_builder_list.php b/app/Views/billing/opd_template_builder_list.php new file mode 100644 index 0000000..0837e91 --- /dev/null +++ b/app/Views/billing/opd_template_builder_list.php @@ -0,0 +1,87 @@ +
+
+
+

OPD Print Template Builder

+
+
+ +
+ + Edit Template +
+
+
+ +
+ +
+
+
+

Templates

+
+ +
+
+
+
+
+ + + + + + + + + + + + + + + $nm) : ?> + + + + + + + + +
#Template NameAction
No templates found. Click "Add New Template".
+ Edit +
+
+
+
+
+ + diff --git a/app/Views/billing/opd_template_workspace.php b/app/Views/billing/opd_template_workspace.php new file mode 100644 index 0000000..b1c2a46 --- /dev/null +++ b/app/Views/billing/opd_template_workspace.php @@ -0,0 +1,464 @@ +
+
+
+
+
+ Clinical Templates Workspace + Add, edit and monitor newly added templates +
+
+ + + +
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+
+ +
+ + +
+ +
+ + + + +
+ +
+
+
+ + +
+
+ + +
+ +
+ +
+
+
+ +
+
+ Usage Analytics (Doctor-wise) + No usage data yet. +
+
+
+
+ + + + + + + + + + + +
TemplateSectionScopeUsesLast Used
No usage data yet.
+
+
+
+
+ + + + + + + + + +
SectionTemplatesUses
No section data.
+
+
+
+
+ +
Use this workspace to maintain templates.
+ +
+ + + + + + + + + + + + + + + +
IDScopeSectionNameTextUpdatedAction
No template data yet.
+
+
+
+
+
+
+ + diff --git a/app/Views/billing/opd_templates/opd_info_print_letter_head.html b/app/Views/billing/opd_templates/opd_info_print_letter_head.html new file mode 100644 index 0000000..97bcfb2 --- /dev/null +++ b/app/Views/billing/opd_templates/opd_info_print_letter_head.html @@ -0,0 +1 @@ +

Hello World

\ No newline at end of file diff --git a/app/Views/billing/opd_templates/opd_info_print_letter_head_1.html b/app/Views/billing/opd_templates/opd_info_print_letter_head_1.html new file mode 100644 index 0000000..97bcfb2 --- /dev/null +++ b/app/Views/billing/opd_templates/opd_info_print_letter_head_1.html @@ -0,0 +1 @@ +

Hello World

\ No newline at end of file diff --git a/app/Views/billing/opd_templates/opd_print_info_letter_head.html b/app/Views/billing/opd_templates/opd_print_info_letter_head.html new file mode 100644 index 0000000..d87d360 --- /dev/null +++ b/app/Views/billing/opd_templates/opd_print_info_letter_head.html @@ -0,0 +1 @@ +

Test

\ No newline at end of file diff --git a/app/Views/billing/opd_templates/opd_print_parcha_chamunda_hospital_ksp.php b/app/Views/billing/opd_templates/opd_print_parcha_chamunda_hospital_ksp.php new file mode 100644 index 0000000..7184541 --- /dev/null +++ b/app/Views/billing/opd_templates/opd_print_parcha_chamunda_hospital_ksp.php @@ -0,0 +1,74 @@ +title ?? '') . ' ' . ($patient->p_fname ?? '')))); +$pRelative = trim((string) (($patient->p_relative ?? '') . ' ' . ($patient->p_rname ?? ''))); +$ageSex = trim((string) (($patient->xgender ?? '') . ' / ' . ($patient->age ?? ''))); +$phone = (string) ($patient->mphone1 ?? ''); +$pAddress = trim((string) (($patient->add1 ?? '') . ', ' . ($patient->add2 ?? '') . ', ' . ($patient->city ?? '')), ' ,'); + +$uhidNo = (string) ($patient->p_code ?? ''); +$opdSrNo = (string) ($opd->opd_no ?? ''); +$opdNo = (string) ($opd->opd_code ?? ''); +$opdDate = (string) ($opd->str_apointment_date ?? ''); +$expDate = (string) ($opd->opd_Exp_Date ?? ''); + +$specName = trim((string) ($doctor->SpecName ?? $opd->doc_spec ?? '')); +$opdFeeDesc = trim((string) ($opd->opd_fee_desc ?? '')); +$totalNoVisit = (string) ($opd->no_visit ?? ''); +$lastVisitDate = trim((string) (($old_opd[0]->str_apointment_date ?? '') ?: '')); +$bookTime = (string) ($opd->apointment_date ?? ''); + +$lastVisitLine = $lastVisitDate !== '' ? ('
Last Visit : ' . esc($lastVisitDate)) : ''; +$expDateLine = $expDate !== '' ? ('Valid Upto : ' . esc($expDate)) : ''; +?> + + + +

+
+ + +

Print Time :

+
+ + + + + + + +
+ Name :
+
+ Gender/Age :
+ Mob :
+ Address : +
+ UHID :
+ Sr No.:
+ OPD No.:
+
Date:
+ +
+ DEPARTMENT :
+
+
+ No. of Visit : +
+ Book Time : +
diff --git a/app/Views/billing/opd_templates/rx_print_chamunda_plain_paper.html b/app/Views/billing/opd_templates/rx_print_chamunda_plain_paper.html new file mode 100644 index 0000000..170ced1 --- /dev/null +++ b/app/Views/billing/opd_templates/rx_print_chamunda_plain_paper.html @@ -0,0 +1 @@ +

Test again

\ No newline at end of file diff --git a/app/Views/billing/rx_group_medicine_workspace.php b/app/Views/billing/rx_group_medicine_workspace.php new file mode 100644 index 0000000..a22a64f --- /dev/null +++ b/app/Views/billing/rx_group_medicine_workspace.php @@ -0,0 +1,426 @@ +
+
+
+
+
+ Rx-Group Medicine List + +
+
+
+ + + + + + + + + + + +
MedicineSalt/GenericDose PlanEditRemove
No medicine rows found.
+
+
+
+
+ +
+
+
Add / Edit Rx-Group Medicine
+
+ + + + + +
+ + + +
+ +
+ + +
+ +
+ + + +
+ +
+
+ +
+
+ +
+
+ +
+
+ +
+
+
+
+ +
+
+ +
+ + +
+ +
+ + +
+ +
Ready.
+
+
+
+
+
+ + diff --git a/app/Views/billing/search_adv_data.php b/app/Views/billing/search_adv_data.php new file mode 100644 index 0000000..0cf03d2 --- /dev/null +++ b/app/Views/billing/search_adv_data.php @@ -0,0 +1,11 @@ + + + +
No matching records.
+ diff --git a/app/Views/dashboard/index.php b/app/Views/dashboard/index.php new file mode 100644 index 0000000..8d536e5 --- /dev/null +++ b/app/Views/dashboard/index.php @@ -0,0 +1,315 @@ + + +
+

Dashboard

+ +
+ +
+
+
+
+
+
OPD | Today
+
+
+ +
+
+
+ Last 7 days: +
+
+
+
+
+ +
+
+
+
Admit & Discharge | Today
+
+
+ +
+
+
/
+ Admit / Discharge +
+
+
+
+
+ +
+
+
+
Current IPD | In-house
+
+
+ +
+
+
+ Org cases: +
+
+
+
+
+ +
+
+
+
Daily Trend | Current Month
+
+
+ +
+
+
/
+ OPD / IPD total (this month) +
+
+
+
+
+
+ +
+
+
+
+
Daily Case Trend (Current Month)
+
+ +
+
+
+
+
+ +
+
+
+
+
OPD by Organization
+
+ + + + + + + + + + + + + + + + + + + + + +
OrganizationCases
org_name ?? 'Direct') ?>total_cases) ?>
No data
+
+
+
+ +
+
+
OPD by Doctor
+
+ + + + + + + + + + + + + + + + + + + + + + + + + +
DoctorTotalDirectOrg
doc_name) ?>total_cases) ?>direct_cases) ?>org_cases) ?>
No data
+
+
+
+
+ +
+
+
+
IPD Doctors
+
+ + + + + + + + + + + + + + + + + + + + + +
DoctorCases
doc_name) ?>total_cases) ?>
No data
+
+
+
+
+ +
+
+
+
IPD by Organization
+
+ + + + + + + + + + + + + + + + + + + + + +
OrganizationCases
org_name ?? 'Direct') ?>total_cases) ?>
No data
+
+
+
+
+
+
+ + + diff --git a/app/Views/diagnosis/index.php b/app/Views/diagnosis/index.php new file mode 100644 index 0000000..c37eedb --- /dev/null +++ b/app/Views/diagnosis/index.php @@ -0,0 +1,97 @@ +
+

Diagnosis

+ +
+ +
+ +
diff --git a/app/Views/diagnosis/lab_ai_extracted_values.php b/app/Views/diagnosis/lab_ai_extracted_values.php new file mode 100644 index 0000000..353b76d --- /dev/null +++ b/app/Views/diagnosis/lab_ai_extracted_values.php @@ -0,0 +1,58 @@ + + +
+
+ AI Extracted Lab Values + + + + + +
+
+ +
No AI extraction found yet for this invoice.
+ +
+ Batch # | + Panel: | + Model: | + Created: +
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + +
TestValueUnitReferenceFlag
No extracted values found in latest batch.
+
+ +
+
diff --git a/app/Views/diagnosis/lab_date_show.php b/app/Views/diagnosis/lab_date_show.php new file mode 100644 index 0000000..9b5c289 --- /dev/null +++ b/app/Views/diagnosis/lab_date_show.php @@ -0,0 +1,40 @@ + 0) { + $collectedTime = $lab_invoice_request[0]->collected_time ?? ''; + $reportedTime = $lab_invoice_request[0]->reported_time ?? ''; +} +?> + +
+ + + +
+ + +
+ +
+ + +
+ +
+ +
+
diff --git a/app/Views/diagnosis/lab_final_report_show.php b/app/Views/diagnosis/lab_final_report_show.php new file mode 100644 index 0000000..779e022 --- /dev/null +++ b/app/Views/diagnosis/lab_final_report_show.php @@ -0,0 +1,20 @@ + + + +
Report not found.
+ + + + +
+ + +
+ +
+ + +
+ diff --git a/app/Views/diagnosis/lab_final_report_show_xray.php b/app/Views/diagnosis/lab_final_report_show_xray.php new file mode 100644 index 0000000..975845c --- /dev/null +++ b/app/Views/diagnosis/lab_final_report_show_xray.php @@ -0,0 +1,85 @@ + + + +
Report not found.
+ + + + + +
+
+
+ + +
+ +
+ + +
+ +
+ + +
+
+ +
+ + + +
+ + + + +
+
+
+ + + diff --git a/app/Views/diagnosis/lab_invoice_main_test_list.php b/app/Views/diagnosis/lab_invoice_main_test_list.php new file mode 100644 index 0000000..171eee9 --- /dev/null +++ b/app/Views/diagnosis/lab_invoice_main_test_list.php @@ -0,0 +1,145 @@ + 0) { + $labInvoiceData = $lab_invoice_request[0]; + $labReqId = $labInvoiceData->id ?? ''; + $labTestNo = $labInvoiceData->lab_test_no ?? ''; +} +?> + +
+
+
+ + 0): ?> +
+
+
Sr. No.
+
daily_sr_no ?? ''); ?>
+
+
+
+ + + +
+
+
+ + + 0): ?> + + status ?? 0); ?> +
+
+
+
item_name ?? ''); ?>
+ + check_sample) || $test->check_sample < 1): ?> + Sample Collection Pending + + + + + In Progress + + Completed + + +
+ + check_sample) || $test->check_sample < 1): ?> + + +
+
+ print_combine) && $test->print_combine > 0) ? 'checked' : ''; ?>> + +
+
+ +
+ + + + + + + + + + + + +
+ + + + +
+ +
+ + + + + diff --git a/app/Views/diagnosis/lab_report_file_list.php b/app/Views/diagnosis/lab_report_file_list.php new file mode 100644 index 0000000..eb233e1 --- /dev/null +++ b/app/Views/diagnosis/lab_report_file_list.php @@ -0,0 +1,148 @@ +
+

Created Report History

+ +
+
+ Image-assisted AI (Doctor verify first): Use "AI Extract Values" on report image/scan to capture LFT/KFT values into DB for doctor support only. +
+ +
+ + + + id ?? 0); + $fullPath = (string) ($row->full_path ?? ''); + $filePath = str_replace('hms_uploads', 'uploads', $fullPath); + $fileDesc = (string) ($row->file_desc ?? 'File'); + $fileName = (string) ($row->file_name ?? 'View'); + $insertTime = (string) ($row->insert_time ?? ''); + ?> +

+ + [] + / Created : + +

+ + +

No report files found.

+ + +
+
+ + diff --git a/app/Views/diagnosis/lab_report_tab.php b/app/Views/diagnosis/lab_report_tab.php new file mode 100644 index 0000000..cf2e064 --- /dev/null +++ b/app/Views/diagnosis/lab_report_tab.php @@ -0,0 +1,110 @@ +
+
+
Diagnosis Report List
+ + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Invoice No.Day Sr.No.Lab Test No.Person NameDateTests NameAction
invoice_code ?? '-') ?>daily_sr_no ?? '-') ?>lab_test_no ?? '-') ?>inv_name ?? '-') ?> | age ?? '-') ?>inv_date ?? '-') ?> + data_array)) { + $dataArray = explode('#', $row->data_array); + $hasBadge = false; + foreach ($dataArray as $value) { + if (!empty($value)) { + $valueArray = explode(';', $value); + if (count($valueArray) >= 4) { + $testName = $valueArray[0] ?? ''; + $isRequested = isset($valueArray[3]) ? $valueArray[3] : 0; + + if ($isRequested < 1) { + echo '' . esc($testName) . ' '; + } else { + echo '' . esc($testName) . ' '; + } + $hasBadge = true; + } + } + } + if (!$hasBadge) { + echo '-'; + } + } else { + echo '-'; + } + ?> + + +
Invoice No.Day Sr.No.Lab Test No.Person NameDateTests NameAction
+
+ +
+
+ + + + + diff --git a/app/Views/diagnosis/lab_report_tab_path.php b/app/Views/diagnosis/lab_report_tab_path.php new file mode 100644 index 0000000..d73bca0 --- /dev/null +++ b/app/Views/diagnosis/lab_report_tab_path.php @@ -0,0 +1,116 @@ +
+
+
Pathology Report List
+ + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Invoice No.Day Sr.No.Lab Test No.Person NameDateTests NameAction
invoice_code ?? '-') ?>daily_sr_no ?? '-') ?>lab_test_no ?? '-') ?>inv_name ?? '-') ?> | age ?? '-') ?>inv_date ?? '-') ?> + data_array)) { + $dataArray = explode('#', $row->data_array); + $hasBadge = false; + foreach ($dataArray as $value) { + if (!empty($value)) { + $valueArray = explode(';', $value); + if (count($valueArray) >= 4) { + $testName = $valueArray[0] ?? ''; + $isRequested = isset($valueArray[3]) ? $valueArray[3] : 0; + + if ($isRequested < 1) { + echo '' . esc($testName) . ' '; + } else { + if (isset($valueArray[4]) && $valueArray[4] > 0) { + echo '' . esc($testName) . ' '; + } else { + echo '' . esc($testName) . ' '; + } + } + $hasBadge = true; + } + } + } + if (!$hasBadge) { + echo '-'; + } + } else { + echo '-'; + } + ?> + + +
Invoice No.Day Sr.No.Lab Test No.Person NameDateTests NameAction
+
+ +
+
+ + + + + diff --git a/app/Views/diagnosis/pathology_detail.php b/app/Views/diagnosis/pathology_detail.php new file mode 100644 index 0000000..5b9b863 --- /dev/null +++ b/app/Views/diagnosis/pathology_detail.php @@ -0,0 +1,1008 @@ + + +
+

- Invoice Details

+ +
+ +
+
+ +
+
+
+
Person Profile
+
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Patient Name:p_fname . ' ' . ($invoice->p_rname ?? '')); ?>
Patient Code:p_code ?? 'N/A'); ?>
Gender:gender ?? 'N/A'); ?>
Age: + age_in_month) && intval($invoice->age_in_month) > 0) { + echo htmlspecialchars($invoice->age_in_month . ' months'); + } elseif (!empty($invoice->age)) { + echo htmlspecialchars($invoice->age . ' years'); + } else { + echo 'N/A'; + } + ?> +
Aadhar:udai ?? 'N/A'); ?>
Phone:phone_number ?? 'N/A'); ?>
Email:email ?? 'N/A'); ?>
Address: + address_line1)) $address[] = $invoice->address_line1; + if (!empty($invoice->city)) $address[] = $invoice->city; + if (!empty($invoice->state)) $address[] = $invoice->state; + echo htmlspecialchars(implode(', ', $address) ?: 'N/A'); + ?> +
Invoice Date:inv_date ?? ''))); ?>
+ + + +
+
+
+ + +
+ +
+
+
+
+
+
+ + + +
+ + +
+ +
+ + +
+ +
+ +
+
+
+
+ + +
+
+
+
+
+
+
+ Loading... +
+
+
+
+
+
+ + + +
+
+
+
+
Report Operations
+
+
+
+
+ +
+
+ +
+
+ +
+
+ +
+
+ +
+
+ +
+
+
+
+
+
+ +
+ + + + + + + + diff --git a/app/Views/diagnosis/print_compiled_report.php b/app/Views/diagnosis/print_compiled_report.php new file mode 100644 index 0000000..28360ea --- /dev/null +++ b/app/Views/diagnosis/print_compiled_report.php @@ -0,0 +1,65 @@ + + + + + + <?= esc($invoice->invoice_code ?? 'Report') ?> + + + + + +
+ +
+ +
+ +
+
+
+
+
+
+
Letterhead
+
+ + +
+
Invoice ID: invoice_code ?? '') ?>
+
Patient Name: p_fname ?? '') ?>
+
UHID: p_code ?? '') ?>
+
Report Type:
+
+ +
+ + report_header)): ?> +
report_header ?>
+ + +
report_data ?? '' ?>
+
+ + diff --git a/app/Views/diagnosis/print_single_report.php b/app/Views/diagnosis/print_single_report.php new file mode 100644 index 0000000..32284d8 --- /dev/null +++ b/app/Views/diagnosis/print_single_report.php @@ -0,0 +1,37 @@ + + + + + + Print Single Report + + + +
+ +
+ +
+
Patient: patient_name ?? '') ?>
+
Invoice: invoice_code ?? '') ?>
+
+ +
+ Report_Data)): ?> + Report_Data ?> + +

No report data available for this request.

+ +
+ + diff --git a/app/Views/diagnosis/request_list.php b/app/Views/diagnosis/request_list.php new file mode 100644 index 0000000..07c6d81 --- /dev/null +++ b/app/Views/diagnosis/request_list.php @@ -0,0 +1,206 @@ + + +
+

+ +
+ +
+
+
+
Search
+ +
+
+
+ + +
+
+ +
+
+ + +
+
+ +
+
+ + +
+
+ + +
+
+
+ +
+ +
+
+ + diff --git a/app/Views/diagnosis/test_data_entry_form.php b/app/Views/diagnosis/test_data_entry_form.php new file mode 100644 index 0000000..9c2e22f --- /dev/null +++ b/app/Views/diagnosis/test_data_entry_form.php @@ -0,0 +1,51 @@ +item_name ?? ''; +$patientName = $test->p_fname ?? ''; +$patientCode = $test->p_code ?? ''; +$invoiceCode = $test->invoice_code ?? ''; +$status = $test->status ?? 0; +?> + +
+
+
Test Data Entry -
+
+
+ +
+
+

Patient:

+

+
+
+

Invoice:

+

+
+
+ + +
+ + + Enter the laboratory findings and observations for this test. +
+ + +
+ + +
+ + +
+ + +
+
+
diff --git a/app/Views/diagnosis/test_data_entry_table.php b/app/Views/diagnosis/test_data_entry_table.php new file mode 100644 index 0000000..a8b6eb6 --- /dev/null +++ b/app/Views/diagnosis/test_data_entry_table.php @@ -0,0 +1,75 @@ + + + +
No test request data found.
+ + + + +
+
Patient Name :patient_name ?? '') ?> + / invoice_code ?? '') ?> +
+
+ +
+ + + + + + + + + + + + + + + + + + + + +
Test Name/Test IDSaved ValueNew ValueFixedNormals
+ Test ?? '') ?>[TestID ?? '') ?>] + Formula)): ?> +
Formula) ?> + +
lab_test_value ?? '') ?>
+ option_value)): ?> + option_value); ?> +
+ + +
+ Formula)): ?> + After Calculate + + + +
FixedNormals ?? '') ?>
+ +
No test parameters mapped for this report template.
+ +
+ +
+ +
+ + diff --git a/app/Views/errors/cli/error_404.php b/app/Views/errors/cli/error_404.php new file mode 100644 index 0000000..456ea3e --- /dev/null +++ b/app/Views/errors/cli/error_404.php @@ -0,0 +1,7 @@ +getFile()) . ':' . $exception->getLine(), 'green')); +CLI::newLine(); + +$last = $exception; + +while ($prevException = $last->getPrevious()) { + $last = $prevException; + + CLI::write(' Caused by:'); + CLI::write(' [' . $prevException::class . ']', 'red'); + CLI::write(' ' . $prevException->getMessage()); + CLI::write(' at ' . CLI::color(clean_path($prevException->getFile()) . ':' . $prevException->getLine(), 'green')); + CLI::newLine(); +} + +// The backtrace +if (defined('SHOW_DEBUG_BACKTRACE') && SHOW_DEBUG_BACKTRACE) { + $backtraces = $last->getTrace(); + + if ($backtraces) { + CLI::write('Backtrace:', 'green'); + } + + foreach ($backtraces as $i => $error) { + $padFile = ' '; // 4 spaces + $padClass = ' '; // 7 spaces + $c = str_pad($i + 1, 3, ' ', STR_PAD_LEFT); + + if (isset($error['file'])) { + $filepath = clean_path($error['file']) . ':' . $error['line']; + + CLI::write($c . $padFile . CLI::color($filepath, 'yellow')); + } else { + CLI::write($c . $padFile . CLI::color('[internal function]', 'yellow')); + } + + $function = ''; + + if (isset($error['class'])) { + $type = ($error['type'] === '->') ? '()' . $error['type'] : $error['type']; + $function .= $padClass . $error['class'] . $type . $error['function']; + } elseif (! isset($error['class']) && isset($error['function'])) { + $function .= $padClass . $error['function']; + } + + $args = implode(', ', array_map(static fn ($value): string => match (true) { + is_object($value) => 'Object(' . $value::class . ')', + is_array($value) => $value !== [] ? '[...]' : '[]', + $value === null => 'null', // return the lowercased version + default => var_export($value, true), + }, array_values($error['args'] ?? []))); + + $function .= '(' . $args . ')'; + + CLI::write($function); + CLI::newLine(); + } +} diff --git a/app/Views/errors/cli/production.php b/app/Views/errors/cli/production.php new file mode 100644 index 0000000..7db744e --- /dev/null +++ b/app/Views/errors/cli/production.php @@ -0,0 +1,5 @@ + + + + + <?= lang('Errors.badRequest') ?> + + + + +
+

400

+ +

+ + + + + +

+
+ + diff --git a/app/Views/errors/html/error_404.php b/app/Views/errors/html/error_404.php new file mode 100644 index 0000000..e506f08 --- /dev/null +++ b/app/Views/errors/html/error_404.php @@ -0,0 +1,84 @@ + + + + + <?= lang('Errors.pageNotFound') ?> + + + + +
+

404

+ +

+ + + + + +

+
+ + diff --git a/app/Views/errors/html/error_exception.php b/app/Views/errors/html/error_exception.php new file mode 100644 index 0000000..2c4e009 --- /dev/null +++ b/app/Views/errors/html/error_exception.php @@ -0,0 +1,429 @@ + + + + + + + + <?= esc($title) ?> + + + + + + + +
+
+ Displayed at — + PHP: — + CodeIgniter: -- + Environment: +
+
+

getCode() ? ' #' . $exception->getCode() : '') ?>

+

+ getMessage())) ?> + getMessage())) ?>" + rel="noreferrer" target="_blank">search → +

+
+
+ + +
+

at line

+ + +
+ +
+ +
+ +
+ getPrevious()) { + $last = $prevException; + ?> + +
+    Caused by:
+    getCode() ? ' #' . $prevException->getCode() : '') ?>
+
+    getMessage())) ?>
+    getMessage())) ?>"
+       rel="noreferrer" target="_blank">search →
+    getFile()) . ':' . $prevException->getLine()) ?>
+    
+ + +
+ + +
+ + + +
+ + +
+ +
    + $row) : ?> + +
  1. +

    + + + + + {PHP internal code} + + + + +   —   + + + ( arguments ) +

    + + + getParameters(); + } + + foreach ($row['args'] as $key => $value) : ?> + + + + + + +
    name : "#{$key}") ?>
    +
    + + () + + + + +   —   () + +

    + + + +
    + +
    + +
  2. + + +
+ +
+ + +
+ + + +

$

+ + + + + + + + + + $value) : ?> + + + + + + +
KeyValue
+ + + +
+ +
+ + + + + + +

Constants

+ + + + + + + + + + $value) : ?> + + + + + + +
KeyValue
+ + + +
+ +
+ +
+ + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
PathgetUri()) ?>
HTTP MethodgetMethod()) ?>
IP AddressgetIPAddress()) ?>
Is AJAX Request?isAJAX() ? 'yes' : 'no' ?>
Is CLI Request?isCLI() ? 'yes' : 'no' ?>
Is Secure Request?isSecure() ? 'yes' : 'no' ?>
User AgentgetUserAgent()->getAgentString()) ?>
+ + + + + + + + +

$

+ + + + + + + + + + $value) : ?> + + + + + + +
KeyValue
+ + + +
+ +
+ + + + + +
+ No $_GET, $_POST, or $_COOKIE Information to show. +
+ + + + headers(); ?> + + +

Headers

+ + + + + + + + + + $value) : ?> + + + + + + +
HeaderValue
+ getValueLine(), 'html'); + } else { + foreach ($value as $i => $header) { + echo ' ('. $i+1 . ') ' . esc($header->getValueLine(), 'html'); + } + } + ?> +
+ + +
+ + + setStatusCode(http_response_code()); + ?> +
+ + + + + +
Response StatusgetStatusCode() . ' - ' . $response->getReasonPhrase()) ?>
+ + headers(); ?> + +

Headers

+ + + + + + + + + + $value) : ?> + + + + + + +
HeaderValue
+ getHeaderLine($name), 'html'); + } else { + foreach ($value as $i => $header) { + echo ' ('. $i+1 . ') ' . esc($header->getValueLine(), 'html'); + } + } + ?> +
+ + +
+ + +
+ + +
    + +
  1. + +
+
+ + +
+ + + + + + + + + + + + + + + + +
Memory Usage
Peak Memory Usage:
Memory Limit:
+ +
+ +
+ +
+ + + + diff --git a/app/Views/errors/html/production.php b/app/Views/errors/html/production.php new file mode 100644 index 0000000..2f59a8d --- /dev/null +++ b/app/Views/errors/html/production.php @@ -0,0 +1,25 @@ + + + + + + + <?= lang('Errors.whoops') ?> + + + + + +
+ +

+ +

+ +
+ + + + diff --git a/app/Views/medical/company_edit.php b/app/Views/medical/company_edit.php new file mode 100644 index 0000000..11f9d20 --- /dev/null +++ b/app/Views/medical/company_edit.php @@ -0,0 +1,70 @@ +id ?? 0); + $companyName = (string) ($row->company_name ?? ''); + $contactPersonName = (string) ($row->contact_person_name ?? ''); + $contactPhoneNo = (string) ($row->contact_phone_no ?? ''); +} +?> + +
+
Company
+
+
+ +
+ + + +
+ + +
+
+ + +
+ +
+ + +
+ +
+ +
+
+
+
+ + diff --git a/app/Views/medical/company_master.php b/app/Views/medical/company_master.php new file mode 100644 index 0000000..7e6f993 --- /dev/null +++ b/app/Views/medical/company_master.php @@ -0,0 +1,17 @@ +
+
+
+
Company Master
+ +
+ +
+
+
+ $med_company ?? []]) ?> +
+
+
+
+
+
diff --git a/app/Views/medical/company_master_sub.php b/app/Views/medical/company_master_sub.php new file mode 100644 index 0000000..4e92991 --- /dev/null +++ b/app/Views/medical/company_master_sub.php @@ -0,0 +1,34 @@ + + + + + + + + + + + + + + + + + +
Company NamePerson/PhoneAction
company_name ?? '') ?>contact_person_name ?? '') . '/' . ($row->contact_phone_no ?? '')) ?> + +
+ + diff --git a/app/Views/medical/counter_sale_form.php b/app/Views/medical/counter_sale_form.php new file mode 100644 index 0000000..b5554af --- /dev/null +++ b/app/Views/medical/counter_sale_form.php @@ -0,0 +1,127 @@ +
+
+
Walk-in Customer Details
+ +
+ + +
+ + +
+ +
+ + +
+ +
+ + +
+ + + +
+ + +
+
+
+
+ + diff --git a/app/Views/medical/dashboard.php b/app/Views/medical/dashboard.php new file mode 100644 index 0000000..07f755e --- /dev/null +++ b/app/Views/medical/dashboard.php @@ -0,0 +1,40 @@ +
+

Medical Store

+ +
+ +
+ + +
+
diff --git a/app/Views/medical/drug_master_list.php b/app/Views/medical/drug_master_list.php new file mode 100644 index 0000000..84b749b --- /dev/null +++ b/app/Views/medical/drug_master_list.php @@ -0,0 +1,27 @@ +
+
+ +
+ +
+
+ +
+
+ +
+
+ +
+
+ + diff --git a/app/Views/medical/expiry_stock_list.php b/app/Views/medical/expiry_stock_list.php new file mode 100644 index 0000000..506565b --- /dev/null +++ b/app/Views/medical/expiry_stock_list.php @@ -0,0 +1,139 @@ + 0, + 'd30' => 0, + 'd60' => 0, + 'later' => 0, +]; + +foreach ($rows as $summaryRow) { + $expiryTs = strtotime((string) ($summaryRow->expiry_date ?? '')); + if ($expiryTs === false) { + $expirySummary['later']++; + continue; + } + + $daysToExpiry = (int) floor(($expiryTs - $todayTs) / 86400); + if ($daysToExpiry < 0) { + $expirySummary['expired']++; + } elseif ($daysToExpiry <= 30) { + $expirySummary['d30']++; + } elseif ($daysToExpiry <= 60) { + $expirySummary['d60']++; + } else { + $expirySummary['later']++; + } +} +?> + +
+
+
+
Nearest Expiry / Expired Medicine Stock
+ +
+ +
+ Expired + Expiring in 30 days + Expiring in 2 months + Above 2 months +
+ +
+
+
+
Expired
+
+
+
+
+
+
Expiring in 30 days
+
+
+
+
+
+
Expiring in 2 months
+
+
+
+
+
+
Above 2 months
+
+
+
+
+ +
+ + + + + + + + + + + + + + + + + expiry_date ?? ''); + $expiryTs = strtotime($expiryDateRaw); + $daysToExpiry = null; + + if ($expiryTs !== false) { + $daysToExpiry = (int) floor(($expiryTs - $todayTs) / 86400); + + if ($daysToExpiry < 0) { + $statusLabel = 'Expired'; + $statusClass = 'table-danger'; + } elseif ($daysToExpiry <= 30) { + $statusLabel = 'Expiring in 30 days'; + $statusClass = 'table-warning'; + } elseif ($daysToExpiry <= 60) { + $statusLabel = 'Expiring in 2 months'; + $statusClass = 'table-info'; + } + } + ?> + + + + + + + + + + + + + + +
#ItemSupplierPur. DateBatchExp. DtRateQtyC.QtyStatus
item_name ?? $row->Item_name ?? '') ?>name_supplier ?? '') ?>str_date_of_invoice ?? '') ?>batch_no ?? '') ?>exp_date ?? '') ?>mrp ?? 0), 2)) ?>tqty ?? 0), 2)) ?>cur_qty ?? 0), 2)) ?> + + + ( days) + +
+
+
+
diff --git a/app/Views/medical/expiry_stock_pdf.php b/app/Views/medical/expiry_stock_pdf.php new file mode 100644 index 0000000..327f96a --- /dev/null +++ b/app/Views/medical/expiry_stock_pdf.php @@ -0,0 +1,119 @@ + 0, + 'd30' => 0, + 'd60' => 0, + 'later' => 0, +]; + +foreach ($rows as $summaryRow) { + $expiryTs = strtotime((string) ($summaryRow->expiry_date ?? '')); + if ($expiryTs === false) { + $expirySummary['later']++; + continue; + } + + $daysToExpiry = (int) floor(($expiryTs - $todayTs) / 86400); + if ($daysToExpiry < 0) { + $expirySummary['expired']++; + } elseif ($daysToExpiry <= 30) { + $expirySummary['d30']++; + } elseif ($daysToExpiry <= 60) { + $expirySummary['d60']++; + } else { + $expirySummary['later']++; + } +} +?> + + + +

Expiry Medicine Report

+
Generated:
+ + + + + + + + + + + + + + +
ExpiredExpiring in 30 daysExpiring in 2 monthsAbove 2 months
+ + + + + + + + + + + + + + + + + + + expiry_date ?? '')); + if ($expiryTs !== false) { + $daysToExpiry = (int) floor(($expiryTs - $todayTs) / 86400); + $daysText = ' (' . $daysToExpiry . ' days)'; + + if ($daysToExpiry < 0) { + $statusLabel = 'Expired'; + $rowClass = 'expired-row'; + } elseif ($daysToExpiry <= 30) { + $statusLabel = 'Expiring in 30 days'; + $rowClass = 'd30-row'; + } elseif ($daysToExpiry <= 60) { + $statusLabel = 'Expiring in 2 months'; + $rowClass = 'd60-row'; + } + } + ?> + + + + + + + + + + + + + + +
#ItemSupplierPur. DateBatchExp. DtRateQtyC.QtyStatus
item_name ?? $row->Item_name ?? '')) ?>name_supplier ?? '')) ?>str_date_of_invoice ?? '')) ?>batch_no ?? '')) ?>exp_date ?? '')) ?>mrp ?? 0), 2)) ?>tqty ?? 0), 2)) ?>cur_qty ?? 0), 2)) ?>
diff --git a/app/Views/medical/invoice_edit.php b/app/Views/medical/invoice_edit.php new file mode 100644 index 0000000..6b732f6 --- /dev/null +++ b/app/Views/medical/invoice_edit.php @@ -0,0 +1,778 @@ +ipd_id ?? 0) > 0); ?> + +
+
+
+
+
Medical Invoice No. inv_med_code ?? ('M' . date('ym') . str_pad(substr((string) ((int)($invoice->id ?? 0)), -7, 7), 7, '0', STR_PAD_LEFT))) ?>
+
+ ipd_id ?? 0) > 0): ?> + + + + +
+
+
+ + +
+ + + + + +
Invoice is finalized. Edit actions are locked.
+ + +
+ Name : inv_name ?? '-') ?> / + P Code : patient_code ?? '-') ?> / + ipd_id ?? 0) > 0): ?> + IPD ID : ipd_id ?? 0))) ?> / + + Invoice No. : inv_med_code ?? ('M' . date('ym') . str_pad(substr((string) ((int)($invoice->id ?? 0)), -7, 7), 7, '0', STR_PAD_LEFT))) ?> / + Date : inv_date) ? date('d/m/Y', strtotime((string)$invoice->inv_date)) : '-') ?> +
+ + +
+ + +
+ + +
+
+ + +
+
+ + +
+ + + + + + + + + + + + + + + + + item_code ?? ''); + if ($codeKey !== '') { + $itemCodeCounts[$codeKey] = ($itemCodeCounts[$codeKey] ?? 0) + 1; + } + } + } + ?> + + $item): ?> + sale_return ?? 0) === 1) + || ((float) ($item->amount ?? 0) < 0) + || ((float) ($item->tamount ?? 0) < 0) + || ((float) ($item->twdisc_amount ?? 0) < 0); + + if ($isReturnRow) { + $rowStyle = 'background:orange;'; + } + + $expiryDays = 1000; + if (!empty($item->expiry)) { + $expiryTs = strtotime((string) $item->expiry); + if ($expiryTs !== false) { + $expiryDays = (int) floor(($expiryTs - strtotime(date('Y-m-d'))) / 86400); + } + } + + if ($expiryDays < 90) { + $rowStyle = 'color:red;'; + } + + $sQty = (float) ($item->s_qty ?? 0); + if ($sQty < 6) { + $rowStyle = 'color:red;'; + } + + $itemCode = (string) ($item->item_code ?? ''); + if ($itemCode !== '' && (int) ($itemCodeCounts[$itemCode] ?? 0) > 1) { + $itemNameStyle = 'color:green;'; + } + ?> + > + + >item_Name ?? '-') ?> + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
#Item NameBatch NoExp.RateS.Qty.QtyDisc.AmountAction
batch_no ?? '-') ?>expiry) ? date('Y-m-d', strtotime((string)$item->expiry)) : '-') ?>price ?? 0), 2)) ?>qty ?? 0), 0, '.', '')) ?> + sale_return ?? 0) === 0): ?> +
+ + + + + +
+ + qty ?? 0), 2)) ?> + +
disc_amount ?? 0), 2)) ?>tamount ?? 0), 2)) ?> + +
+ + + + +
+ + Locked + +
No items in invoice.
Gross Totalgross ?? 0), 2)) ?>
Net Totalnet ?? 0), 2)) ?>
+
+ + +
+
Product Search
+
+
+
+
+ + +
+
+ +
+
+ + + + + + +

+ + + + +

+ +
+ + + + +
+ + +
+
+ + +
+
+ + +
+
+ +
+
+
+
+ + +
+ + + + + + + + + + + + + + + + + + + + + + + +
ItemBatchExp.S.QtyRateAdd
item_name ?? '-') ?>batch_no ?? '-') ?>expiry_date ?? '-') ?>current_qty ?? 0) ?>selling_unit_rate ?? 0), 2)) ?> +
+ + + + + + +
+
+
+ +
No stock items found for search.
+ +
+ + + +
+
+
+ + +
+
+
+
+
Sale Medicine
+
+ + +
+
+
+
+ + + patient_id) && !empty($oldInvoices)): ?> +
+ + id ?? 0); ?> + + + + + + + + + + + + + + + + + + + _items)): ?> + _items as $n => $oldItem): ?> + + + + + + + + + + + + + + + +
#inv_med_code ?? ('M' . date('ym') . str_pad(substr((string) $oldInvId, -7, 7), 7, '0', STR_PAD_LEFT))) ?>inv_date) ? date('Y-m-d', strtotime((string)$old->inv_date)) : '-') ?> + Show Bill +
#ItemBat.Exp.DtQtyR.Qty
item_Name ?? '-') ?>batch_no ?? '-') ?>expiry) ? date('m-Y', strtotime((string)$oldItem->expiry)) : '-') ?>qty ?? 0), 0)) ?> + id)): ?> +
+ + + + + +
+ + - + +
No item rows.
+ +
+ patient_id)): ?> +
No old invoices for this patient.
+ +
Walk-in invoice. Previous patient history is unavailable.
+ +
+
+
+ +
+ + diff --git a/app/Views/medical/invoice_item_log.php b/app/Views/medical/invoice_item_log.php new file mode 100644 index 0000000..713f2a8 --- /dev/null +++ b/app/Views/medical/invoice_item_log.php @@ -0,0 +1,62 @@ + + +
+
+
+
Medical Invoice Item Log
+ Back to Master +
+ +
+
+ + +
+
+ + + +
+
+ +
+
+ +
+
+
+ + diff --git a/app/Views/medical/invoice_item_log_data.php b/app/Views/medical/invoice_item_log_data.php new file mode 100644 index 0000000..b630b5b --- /dev/null +++ b/app/Views/medical/invoice_item_log_data.php @@ -0,0 +1,112 @@ +
+ + + + + + + + + + + + + + + + + + + + + + + + + +
#Invoice CodeInvoice DateNameItem DeletedPayment LogUpdate Log
inv_med_code ?? '') ?>inv_date ?? '') ?>inv_name ?? '') ?> + del_item_list ?? ''))); + $itemAmountTotal = 0.0; + ?> + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Item NameQtyPriceAmountDelete By
Total Amount
+ + No Item Deleted + +
+ payment_log ?? ''))); ?> + + + + + + + + + + + + + + + + + + +
Payment TypeAmountPayment By
+ + No Payment Log + +
log ?? '')) ?>
+
+ + diff --git a/app/Views/medical/invoice_master_edit.php b/app/Views/medical/invoice_master_edit.php new file mode 100644 index 0000000..214b2dd --- /dev/null +++ b/app/Views/medical/invoice_master_edit.php @@ -0,0 +1,438 @@ +
+
+
+ Medical Invoice Master Edit : + + Back to Invoice + +
+
+ + +
+ + +
+ + + + + + + +
+
+

+ Name : inv_name ?? '-') ?> + / P Code : patient_code ?? '-') ?> + / Invoice No. : inv_med_code ?? ('M' . date('ym') . str_pad(substr((string) ((int)($invoice->id ?? 0)), -7, 7), 7, '0', STR_PAD_LEFT))) ?> + / Date : inv_date) ? date('d/m/Y', strtotime((string) $invoice->inv_date)) : '-') ?> + ipd_code)): ?> + / IPD Code : ipd_code) ?> + + case_id)): ?> + / Org. Case : case_id) ?> + +

+
+
+
+
+ + +
+
+ +
+
+ +
+ ipd_id ?? 0) > 0): ?> +
+ +
+ ipd_credit ?? 0) === 0) ? 'checked' : '' ?>> + +
+
+ ipd_credit ?? 0) === 1) ? 'checked' : '' ?>> + +
+
+
+ +
+ case_id ?? 0) > 0): ?> +
+ +
+ case_credit ?? 0) === 0) ? 'checked' : '' ?>> + +
+
+ case_credit ?? 0) === 1) ? 'checked' : '' ?>> + +
+
+ +
+
+
+ +
+
+

Change Name : Current Name : inv_name ?? '-') ?>

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

Change UHID : Current UHID : patient_code ?? '-') ?>

+
+
+
+
+ + +
+
+ +
inv_name ?? '-') ?> / inv_phone_number ?? '-') ?>
+
+
+ +
+
+
+
+ +
+
+

Change IPD : ipd_credit ?? 0) > 0): ?>Current IPD : ipd_code ?? '-') ?>

+
+
+
+
+ + +
+
+ +
inv_name ?? '-') ?>
+
+
+ +
+
+
+
+ +
+
+

Change Org. Case : case_credit ?? 0) > 0): ?>Current Org. Case : case_id ?? '-') ?>

+
+
+
+
+ + +
+
+ +
inv_name ?? '-') ?>
+
+
+ +
+
+
+
+ +
+
+
+ + + + +
+
+ + Cancel +
+
+
+
+
+ + diff --git a/app/Views/medical/invoice_med_draft.php b/app/Views/medical/invoice_med_draft.php new file mode 100644 index 0000000..5a9250e --- /dev/null +++ b/app/Views/medical/invoice_med_draft.php @@ -0,0 +1,115 @@ +
+
+
Invoice Draft List
+ + +
+ + +
+ Draft + All +
+ +
+ + + + + + +
+ + +
+
+ + +
+
+ + +
+
+ + Reset +
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + +
Invoice CodeNameUHID / Patient IDIPD No.DateNet AmountAmt.PaidBalance / Status
+
+
+
+ + diff --git a/app/Views/medical/invoice_print.php b/app/Views/medical/invoice_print.php new file mode 100644 index 0000000..5ada468 --- /dev/null +++ b/app/Views/medical/invoice_print.php @@ -0,0 +1,116 @@ + + + + + + Medical Invoice <?= esc($invoice->inv_med_code ?? ('M' . date('ym') . str_pad(substr((string) ((int)($invoice->id ?? 0)), -7, 7), 7, '0', STR_PAD_LEFT))) ?> + + + + + +
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))) ?>
+ +
+
+
Date: inv_date ?? '-') ?>
+
Patient: inv_name ?? '-') ?>
+
Patient Code: patient_code ?? '-') ?>
+
+
+
Doctor: doc_name ?? '-') ?>
+
Phone: inv_phone_number ?? ($patient->mphone1 ?? '-')) ?>
+
Type: ipd_credit ?? 0) === 1) ? 'Credit' : 'Cash' ?>
+
+
+ + + + + + + + + + + + + + + + + + $item): ?> + amount ?? 0); + $rowDisc = (float) ($item->disc_amount ?? 0); + $rowNet = (float) ($item->tamount ?? 0); + $gross += $rowGross; + $discount += $rowDisc; + $net += $rowNet; + ?> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
#ItemBatchQtyRateDiscountAmountNet
item_Name ?? '-') ?>formulation) ? ' / ' . esc($item->formulation) : '' ?>batch_no ?? '-') ?>qty ?? 0), 2)) ?>price ?? 0), 2)) ?>
No items found.
Grossgross_amount ?? $gross), 2)) ?>
Discountdisc_amount ?? $discount), 2)) ?>
Net Amountnet_amount ?? $net), 2)) ?>
+ +
+
Prepared By: _____________________
+
Authorized Sign: _____________________
+
+ + diff --git a/app/Views/medical/invoice_print_pdf.php b/app/Views/medical/invoice_print_pdf.php new file mode 100644 index 0000000..e399d53 --- /dev/null +++ b/app/Views/medical/invoice_print_pdf.php @@ -0,0 +1,194 @@ +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 : ''; + +$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 ?? '')); + +$grossTotal = 0.0; +$discountTotal = 0.0; +$cgstTotal = 0.0; +$sgstTotal = 0.0; +$netTotal = 0.0; + +$compact = in_array((int) ($printFormat ?? 0), [1, 2, 3], true); +$baseFont = $compact ? '10px' : '11px'; +$titleFont = $compact ? '16px' : '20px'; +$thPad = $compact ? '5px 4px' : '6px 5px'; +$tdPad = $compact ? '4px 4px' : '5px 5px'; +?> + + + + + + + +
+
+
+
+ + | Phone: + | GSTIN: +
+
TAX INVOICE
+
+ + + + + + +
+
Bill To
+
+
Patient Code:
+
Phone:
+
Doctor:
+
+
Invoice Details
+
Invoice No:
+
Date:
+
Payment Type: ipd_credit ?? 0) === 1 || (int) ($invoice->case_credit ?? 0) === 1) ? 'Credit' : 'Cash' ?>
+
IPD/Case: ipd_code ?? $invoice->case_id ?? '-')) ?>
+
+ + + + + + + + + + + + + + + + + + + + $item): ?> + amount ?? 0); + $disc = (float) ($item->disc_amount ?? ($item->twdisc_amount ?? 0)); + $net = (float) ($item->twdisc_amount ?? $item->tamount ?? ($item->net_amount ?? 0)); + + $cgstPer = (float) ($item->CGST_per ?? 0); + $sgstPer = (float) ($item->SGST_per ?? 0); + $gstPerTotal = $cgstPer + $sgstPer; + + $cgst = (float) ($item->CGST ?? ($item->c_gst_amt ?? 0)); + $sgst = (float) ($item->SGST ?? ($item->s_gst_amt ?? 0)); + + if (($cgst <= 0 || $sgst <= 0) && $gstPerTotal > 0 && $net > 0) { + $taxableFromInclusive = $net * 100 / (100 + $gstPerTotal); + $taxTotal = $net - $taxableFromInclusive; + $cgst = $taxTotal * ($cgstPer / $gstPerTotal); + $sgst = $taxTotal * ($sgstPer / $gstPerTotal); + } elseif (($cgst <= 0 || $sgst <= 0) && $gstPerTotal > 0 && $gross > 0) { + $cgst = $gross * $cgstPer / 100; + $sgst = $gross * $sgstPer / 100; + } + + $grossTotal += $gross; + $discountTotal += $disc; + $cgstTotal += $cgst; + $sgstTotal += $sgst; + $netTotal += $net; + ?> + + + + + + + + + + + + + + + + + + + + +
#CodeItem NameBatchExp.QtyRateGrossDiscInc. GSTNet
item_code ?? '-')) ?>item_Name ?? '-')) ?>batch_no ?? '-')) ?>expiry ?? '-')) ?>qty ?? 0), 2)) ?>price ?? 0), 2)) ?>
No items available.
+ + gross_amount ?? $grossTotal); + $discFinal = (float) ($invoice->disc_amount ?? $discountTotal); + $netFinal = (float) ($invoice->net_amount ?? $netTotal); + ?> + + + + + + + + + + + + + + + + + + +
Gross Total₹ Discount Total₹
Inc. GST Total₹
Net Amount₹
+ + + + + + + + +
Customer SignatureAuthorized Signatory
+
+ + diff --git a/app/Views/medical/ipd_org_list.php b/app/Views/medical/ipd_org_list.php new file mode 100644 index 0000000..ae2e766 --- /dev/null +++ b/app/Views/medical/ipd_org_list.php @@ -0,0 +1,87 @@ +
+
+
+
IPD List (Current Admit)
+ + High Balance: + +
+ +
+ + + + + + + + + + + + + + + + + + id ?? 0); + $ipdCode = (string) ($row->ipd_code ?? ('IPD-' . $ipdId)); + $patientCode = (string) ($row->p_code ?? '-'); + $patientName = (string) ($row->p_fname ?? '-'); + $patientRelative = (string) ($row->p_rname ?? ''); + $bedDesc = (string) ($row->Bed_Desc ?? ($row->bed_desc ?? '-')); + $regDate = (string) ($row->str_register_date ?? ''); + if ($regDate === '' && !empty($row->register_date)) { + $ts = strtotime((string) $row->register_date); + $regDate = $ts ? date('d-m-Y', $ts) : (string) $row->register_date; + } + $noDays = (string) ($row->no_days ?? '-'); + $docName = (string) ($row->doc_name ?? '-'); + $admitType = (string) ($row->admit_type ?? '-'); + $orgStatus = (string) ($row->Org_Status ?? ($row->org_status ?? '')); + $medAmount = (float) ($row->med_amount ?? 0); + ?> + + + + + + + + + + + + + + + + + + +
IPD CodeName / Patient CodeBed No.[Type]Register DateNo. of DaysDr. NameAdmit TypeAmountAction
[] ' . esc($patientRelative) : '' ?>' . esc($orgStatus) : '' ?>M: + Open Invoices +
No currently admitted IPD records found.
+
+
+
+ + diff --git a/app/Views/medical/ipd_print_report.php b/app/Views/medical/ipd_print_report.php new file mode 100644 index 0000000..47c20cf --- /dev/null +++ b/app/Views/medical/ipd_print_report.php @@ -0,0 +1,607 @@ + 'IPD Medical Invoice (Cash)', + 'cash-return' => 'IPD Medical Invoice (Cash With Return)', + 'credit' => 'IPD Medical Invoice (Credit)', + 'package' => 'IPD Medical Invoice (Package)', + 'med-list' => 'Consolidated Medicine List', + 'med-list-date' => 'Medicine List Datewise', + 'pagewise' => 'IPD Medical Invoice (Page Wise)', + 'return-list' => 'Return Medicine List', +]; + +$title = $modeTitleMap[$mode] ?? 'IPD Medical Print'; +$ipdCode = (string) ($ipd->ipd_code ?? ('IPD-' . (int) ($ipdId ?? 0))); +$isPdf = (bool) ($isPdf ?? false); + +$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 : ''; +$pharmacyEmail = defined('H_Email') ? (string) H_Email : ''; +$pharmacyGst = defined('H_Med_GST') ? (string) H_Med_GST : ''; +$pharmacyLic = defined('M_LIC') ? (string) M_LIC : ''; + +$patientName = trim((string) ($patient->p_fname ?? ($ipd->p_name ?? '-'))); +$patientCode = trim((string) ($patient->p_code ?? '-')); +$doctorName = trim((string) ($ipd->doc_name ?? '-')); +$orgCode = trim((string) ($orgCase->case_id_code ?? '-')); +$orgName = trim((string) ($orgCase->insurance_company_name ?? '-')); + +$invoiceMap = []; +foreach (($invoices ?? []) as $inv) { + $invoiceMap[(int) ($inv->id ?? 0)] = $inv; +} + +$itemsByInvoice = $itemsByInvoice ?? []; +$invoiceItemTotals = $invoiceItemTotals ?? []; +$invoiceTotals = $invoiceTotals ?? ['gross' => 0, 'discount' => 0, 'net' => 0, 'balance' => 0]; +$itemTotals = $itemTotals ?? ['qty' => 0, 'amount' => 0]; +$itemsByDate = $itemsByDate ?? []; +$paymentHistory = $paymentHistory ?? []; +$paymentSummary = $paymentSummary ?? [ + 'total_received' => 0.0, + 'balance' => (float) ($invoiceTotals['net'] ?? 0), +]; + +$abs = static function ($value): float { + return abs((float) $value); +}; + +$fmtDate = static function ($value, string $format = 'd-m-Y'): string { + if (empty($value)) { + return '-'; + } + $ts = strtotime((string) $value); + return $ts ? date($format, $ts) : '-'; +}; + +$fmtMoney = static function ($value): string { + return number_format((float) $value, 2); +}; + +$docType = in_array($mode, ['med-list', 'med-list-date', 'return-list'], true) ? 'LIST REPORT' : 'TAX INVOICE'; +?> + + + + + + + + + +
+
+
+ + | Phone: + | Email:
+ GST: + | L.No: +
+
+
+ + + + + + + + + + + + + + + + + + org_id ?? 0) > 0): ?> + + + + + + + + + + + + + +
Patient:
UHID:
IPD Code:
Refer By:
Org. Code:
Org. Name:
Printed On:
+
+
+
+ + + + + + + +
IPD: | UHID: Page {PAGENO}/{nbpg}
+
+ + +
+
()
+
+ + Back +
+
+ + + + + + + + + + +
Document Type
Invoice Count
Total Qty
Total Net
₹
Balance
₹
+ + + + $dateItems): ?> +
Date:
+ + + + + + + + + + + + + + + + $item): ?> + inv_med_id ?? 0); + $inv = $invoiceMap[$invId] ?? null; + $invCode = (string) ($inv->inv_med_code ?? ('M' . date('ym') . str_pad(substr((string) $invId, -7, 7), 7, '0', STR_PAD_LEFT))); + $amt = (float) ($item->tamount ?? $item->amount ?? 0); + $dateAmount += $amt; + ?> + + + + + + + + + + + + + + + + +
#InvoiceItem NameBatchExp.QtyRateAmount
item_Name ?? '-') . ' ' . ($item->formulation ?? '')))) ?>batch_no ?? '-')) ?>expiry, 'm-Y')) ?>qty ?? 0)) ?>price ?? 0)) ?>
Date Total
+ + + + + + + + + + + + + + + + + + + $item): ?> + inv_med_id ?? 0); + $inv = $invoiceMap[$invId] ?? null; + $invCode = (string) ($inv->inv_med_code ?? ('M' . date('ym') . str_pad(substr((string) $invId, -7, 7), 7, '0', STR_PAD_LEFT))); + $invDate = $inv->inv_date ?? null; + $amount = (float) ($item->tamount ?? $item->amount ?? 0); + if ($mode === 'return-list') { + $amount = -1 * $abs($amount); + } + ?> + + + + + + + + + + + + + + + + + + + + + + + + +
#InvoiceDateItem NameBatchExp.QtyRateAmount
item_Name ?? '-') . ' ' . ($item->formulation ?? '')))) ?>batch_no ?? '-')) ?>expiry, 'm-Y')) ?>qty ?? 0)) ?>price ?? 0)) ?>
No rows found.
Total
+ + + + $invoice): ?> + id ?? 0); + $invoiceCode = (string) ($invoice->inv_med_code ?? ('M' . date('ym') . str_pad(substr((string) $invoiceId, -7, 7), 7, '0', STR_PAD_LEFT))); + $invoiceDate = $fmtDate($invoice->inv_date ?? null); + $invoiceItems = $itemsByInvoice[$invoiceId] ?? []; + $invTotals = $invoiceItemTotals[$invoiceId] ?? ['qty' => 0, 'gross' => 0, 'discount' => 0, 'gst' => 0, 'net' => 0]; + $netAmount = (float) ($invoice->net_amount ?? $invTotals['net']); + ?> +
+
+ Invoice: + Date: | Type: ipd_credit ?? 0) > 0) ? 'Credit' : 'Cash' ?> +
+ + + + + + + + + + + + + + + + + + + $item): ?> + amount ?? 0); + $disc = (float) (($item->disc_amount ?? 0) + ($item->disc_whole ?? 0)); + if ($disc == 0.0) { + $disc = (float) ($item->twdisc_amount ?? 0) > 0 ? ($gross - (float) ($item->twdisc_amount ?? 0)) : 0.0; + } + $net = (float) ($item->twdisc_amount ?? ($item->tamount ?? $gross)); + + $cgstPer = (float) ($item->CGST_per ?? 0); + $sgstPer = (float) ($item->SGST_per ?? 0); + $gstPer = $cgstPer + $sgstPer; + $cgst = (float) ($item->CGST ?? 0); + $sgst = (float) ($item->SGST ?? 0); + + if (($cgst + $sgst) <= 0.0 && $gstPer > 0.0 && $net > 0.0) { + $taxableFromInclusive = $net * 100 / (100 + $gstPer); + $taxTotal = $net - $taxableFromInclusive; + $cgst = $taxTotal * ($cgstPer / $gstPer); + $sgst = $taxTotal * ($sgstPer / $gstPer); + } + + $rowIsReturn = ((float) ($item->amount ?? 0) < 0) + || ((float) ($item->tamount ?? 0) < 0) + || ((int) ($item->sale_return ?? 0) === 1); + ?> + + + + + + + + + + + + + + + + + + + + + + + + + + +
#Item NameBatchExp.QtyRateGrossDisc.Inc. GSTNet
item_Name ?? '-') . ' ' . ($item->formulation ?? '')))) ?>batch_no ?? '-')) ?>expiry, 'm-Y')) ?>qty ?? 0)) ?>price ?? 0)) ?>
No item rows available.
Invoice Total
+ + + + + + + + + + + + + + +
Gross Amount₹ gross_amount ?? $invTotals['gross'])) ?>Discount₹ disc_amount ?? 0) + ($invoice->discount_amount ?? 0)))) ?>Inc. GST₹
Net Amount₹
+
+ + +
+ + + +
Grand Summary
+ + + + + + + + + + + + + + + + + + + +
Gross Total₹ Discount Total₹
Net Total₹ Total Payment Received₹
Balance Total₹
+ +
No invoices found for selected print mode.
+ + + + +
Payment Details
+ + + + + + + + + + + + + + + + payment_mode ?? 1) === 2) ? 'Bank Card' : 'Cash'; + if ((int) ($pay->payment_mode ?? 0) > 2) { + $payMode = 'Other'; + } + if ((int) ($pay->credit_debit ?? 0) > 0) { + $payMode .= ' Return'; + } + $signed = (float) ($pay->paid_amount ?? $pay->amount ?? 0); + $payTotal += $signed; + ?> + + + + + + + + + + + + + + + +
#DateModeRef NoRemarkAmountSigned Amount
id ?? '-')) ?>payment_date ?? $pay->entry_date ?? null, 'd-m-Y H:i')) ?>card_trans_id ?? $pay->card_tran_id ?? '-')) ?>payment_desc ?? $pay->payment_remark ?? '-')) ?>amount ?? 0)) ?>
Total Paid (Signed)
+ + +
+ This is a computer-generated document. Please verify medicine name, batch, and quantity at issue time. +
+ + + + + + +
Patient/Relative SignatureFor (Authorized Signatory)
diff --git a/app/Views/medical/ipd_return_medicine.php b/app/Views/medical/ipd_return_medicine.php new file mode 100644 index 0000000..c06fc93 --- /dev/null +++ b/app/Views/medical/ipd_return_medicine.php @@ -0,0 +1,143 @@ +id ?? 0); + $ipdCode = (string) ($ipd->ipd_code ?? ('IPD-' . $ipdId)); + $patientName = (string) ($patient->p_fname ?? '-'); + $patientCode = (string) ($patient->p_code ?? '-'); + $modeLabel = (string) ($modeLabel ?? 'Medicine Reurn'); + + $totalInvoices = !empty($invoices) ? count($invoices) : 0; + $totalItems = 0; + $totalReturnedItems = 0; + foreach (($invoices ?? []) as $invRow) { + $invId = (int) ($invRow->id ?? 0); + $totalItems += (int) ($itemCountMap[$invId] ?? 0); + $totalReturnedItems += (int) ($returnCountMap[$invId] ?? 0); + } + $pendingItems = max(0, $totalItems - $totalReturnedItems); +?> + +
+
+
Medical Return Items
+ +
+ +
+
+ Patient Code : / + Customer Name : / + IPD Code : + +
+ +
+ + +
+ +
+
+
+
Invoices
+
+
+
+
+
+
Total Items
+
+
+
+
+
+
Returned Items
+
+
+
+
+
+
Pending
+
+
+
+
+ +
+ + + + + + + + + + + + + + + + $row): ?> + id ?? 0); + $totalItems = (int) ($itemCountMap[$invId] ?? 0); + $returnedItems = (int) ($returnCountMap[$invId] ?? 0); + $pendingForInvoice = max(0, $totalItems - $returnedItems); + ?> + + + + + + + + + + + + + + + + + +
#Invoice IDDateTotal ItemsReturned ItemsStatusNet AmountAction
inv_med_code ?? ('M' . date('ym') . str_pad(substr((string) $invId, -7, 7), 7, '0', STR_PAD_LEFT))) ?>inv_date) ? date('Y-m-d', strtotime((string)$row->inv_date)) : '-') ?> + 0): ?> + Pending + + Completed + + net_amount ?? 0), 2)) ?> + Open Bill For Return + Final View +
No invoices found for this IPD.
+
+ +
+ Open bill for return, then use right-side R.Qty flow to add return items. +
+
+
+ + diff --git a/app/Views/medical/main_store_dashboard.php b/app/Views/medical/main_store_dashboard.php new file mode 100644 index 0000000..d32e480 --- /dev/null +++ b/app/Views/medical/main_store_dashboard.php @@ -0,0 +1,69 @@ +
+

Store Main Panel

+
+ +
+ + +
+
diff --git a/app/Views/medical/master.php b/app/Views/medical/master.php new file mode 100644 index 0000000..154016b --- /dev/null +++ b/app/Views/medical/master.php @@ -0,0 +1,123 @@ +
+

Pharmacy Master Panel

+ +
+ +
+ + +
+
diff --git a/app/Views/medical/master_report.php b/app/Views/medical/master_report.php new file mode 100644 index 0000000..f338164 --- /dev/null +++ b/app/Views/medical/master_report.php @@ -0,0 +1,35 @@ +
+
+ + + +
+ + + +
+ + + + + + + + + + + + + + + + + +
+
+ +
+
diff --git a/app/Views/medical/med_model_payment.php b/app/Views/medical/med_model_payment.php new file mode 100644 index 0000000..aad4e09 --- /dev/null +++ b/app/Views/medical/med_model_payment.php @@ -0,0 +1,219 @@ +id ?? 0); + $patientName = (string) ($patient->p_fname ?? '-'); + $patientRelative = (string) ($patient->p_rname ?? ''); + $patientCode = (string) ($patient->p_code ?? '-'); + $genderValue = (string) ($patient->xgender ?? ($patient->gender ?? '')); + if ($genderValue === '1') { + $genderValue = 'Male'; + } elseif ($genderValue === '0' || $genderValue === '2') { + $genderValue = 'Female'; + } + $patientAge = ''; + if (!empty($patient)) { + $patientAge = get_age_1( + $patient->dob ?? null, + $patient->age ?? '', + $patient->age_in_month ?? '', + $patient->estimate_dob ?? '', + $ipd->register_date ?? null + ); + } + $ipdCode = (string) ($ipd->ipd_code ?? ('IPD-' . $ipdId)); + $groupId = (int) ($group->med_group_id ?? 0); + $netAmount = (float) ($paymentSummary['net_amount'] ?? ($group->net_amount ?? 0)); + $paidAmount = (float) ($paymentSummary['paid_amount'] ?? ($group->payment_received ?? 0)); + $balanceAmount = (float) ($paymentSummary['balance_amount'] ?? ($group->payment_balance ?? ($netAmount - $paidAmount))); +?> + +
+
+
IPD Payment : IPD Code :
+ Back to Invoice List +
+ +
+
+ Name : / + Age : / + Gender : / + Patient Code / UHID : / + IPD Code : +
+ +
+
+
+
Add Payment
+
+
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+
+ +
+
Cash
+ +
+ +
+
Credit / Debit Card
+
+
+ + +
+
+ + +
+
+ +
+
+
+ +
Use Debit/Return when refunding amount.
+
+
+
+ +
+
+
Summary
+
+
Pharmacy Bill Amount: Rs.
+
Total Amount Paid: Rs.
+
Balance Amount: Rs.
+
+
+ +
+
Payment Details
+
+
+ + + + + + + + + + + + + + + + + + + + + + + +
Pay.No.ModeDateAmount
id ?? '')) ?>Payment_type_str ?? '-') ?>payment_date) ? date('d-m-Y', strtotime((string) $row->payment_date)) : '-') ?>paid_amount ?? 0), 2)) ?>
No payment entries.
+
+
+
+
+
+
+
+ + diff --git a/app/Views/medical/medical_final_invoice.php b/app/Views/medical/medical_final_invoice.php new file mode 100644 index 0000000..d397af4 --- /dev/null +++ b/app/Views/medical/medical_final_invoice.php @@ -0,0 +1,419 @@ +id ?? 0); + $balance = (float) ($paymentSummary['balance'] ?? 0); + $net = (float) ($paymentSummary['net'] ?? ($invoice->net_amount ?? 0)); + $paid = (float) ($paymentSummary['paid'] ?? ($invoice->payment_received ?? 0)); + $deduction = (float) ($paymentSummary['extra_discount'] ?? ($invoice->discount_amount ?? 0)); + $deductionRemark = (string) ($paymentSummary['discount_remark'] ?? ($invoice->discount_remark ?? '')); + $allowPaymentMode = ((int) ($invoice->ipd_credit ?? 0) === 0) && ((int) ($invoice->case_credit ?? 0) === 0) && ((int) ($invoice->group_invoice_id ?? 0) === 0); +?> + +
+
+
Medical Invoice No. : inv_med_code ?? ('M' . date('ym') . str_pad(substr((string) $invoiceId, -7, 7), 7, '0', STR_PAD_LEFT))) ?>
+
+ id)): ?> + IPD Bills + id)): ?> + Org Bills + + All Bills + + + Print + + + Print + +
+
+ +
+ +
+ +
+ +
+ Name : inv_name ?? '-') ?> / + P Code : patient_code ?? '-') ?> / + Invoice No. : inv_med_code ?? ('M' . date('ym') . str_pad(substr((string) $invoiceId, -7, 7), 7, '0', STR_PAD_LEFT))) ?> / + Date : inv_date) ? date('d/m/Y', strtotime((string)$invoice->inv_date)) : '-') ?> + ipd_code)): ?> / IPD : ipd_code) ?> + case_id_code)): ?> / Org Case : case_id_code) ?> + + Open Bill For Edit + + + Open Bill For Edit + +
+ +
+ +
+ + + + + + + + + + + + + + + + + + + + + + $item): ?> + twdisc_amount ?? $item->tamount ?? $item->amount ?? 0); + $lineBase = (float) ($item->amount ?? 0); + $cgstPer = (float) ($item->CGST_per ?? 0); + $sgstPer = (float) ($item->SGST_per ?? 0); + + $cgstValue = (float) ($item->CGST ?? ($item->c_gst_amt ?? 0)); + $sgstValue = (float) ($item->SGST ?? ($item->s_gst_amt ?? 0)); + + $gstPerTotal = $cgstPer + $sgstPer; + if (($cgstValue <= 0 || $sgstValue <= 0) && $gstPerTotal > 0 && $lineNet > 0) { + $taxableFromInclusive = $lineNet * 100 / (100 + $gstPerTotal); + $taxTotal = $lineNet - $taxableFromInclusive; + $cgstValue = $taxTotal * ($cgstPer / $gstPerTotal); + $sgstValue = $taxTotal * ($sgstPer / $gstPerTotal); + } elseif (($cgstValue <= 0 || $sgstValue <= 0) && $gstPerTotal > 0 && $lineBase > 0) { + $cgstValue = $lineBase * $cgstPer / 100; + $sgstValue = $lineBase * $sgstPer / 100; + } + + $rowCgstTotal += (float) $cgstValue; + $rowSgstTotal += (float) $sgstValue; + ?> + + + + + + + + + + + + + + + + + + + + + + CGST_Tamount ?? 0); + $invoiceSgstTotal = (float) ($invoice->SGST_Tamount ?? 0); + if ($invoiceCgstTotal <= 0 && $rowCgstTotal > 0) { + $invoiceCgstTotal = $rowCgstTotal; + } + if ($invoiceSgstTotal <= 0 && $rowSgstTotal > 0) { + $invoiceSgstTotal = $rowSgstTotal; + } + ?> + + + + + + + + + + +
#Item codeItem NameFormulationBatch NoExp.RateQty.GrossDisc.HSNCODE/GST%Inc. GSTNet Amount
item_code ?? '-') ?>item_Name ?? '-') ?>formulation ?? '-') ?>batch_no ?? '-') ?>expiry) ? date('Y-m-d', strtotime((string)$item->expiry)) : '-') ?>price ?? 0), 2)) ?>qty ?? 0), 2)) ?>amount ?? 0), 2)) ?>disc_whole ?? $item->disc_amount ?? 0), 2)) ?>HSNCODE ?? '-') . '/' . number_format((float) (($item->CGST_per ?? 0) + ($item->SGST_per ?? 0)), 2)) ?>twdisc_amount ?? $item->tamount ?? 0), 2)) ?>
No item rows.
#Gross Totalgross_amount ?? 0), 2)) ?>disc_amount ?? 0), 2)) ?>
+
+ +
+ + + + + + + + +
#Deduction
+
+ +
+ + + + + + + +
#Amount received :
+ + + [id ?? '-') ?>:Payment_type_str ?? '-') ?>:paid_amount ?? 0), 2)) ?>:payment_date ?? '-') ?>]
+ + +
Balance Amount : Net Amount :
+
+ + 0.0001): ?> +
+ + +
+ + +
+ + 0): ?> +
+
Cash
+
+ +
+
+ +
+
Credit / Debit Card
+
+
+
+ + +
+
+ + +
+
+ +
+
+
+
+ +
+
Cash Return
+
+ +
+
+ +
+ + + + +
+
+ +
+ + diff --git a/app/Views/medical/medical_invoice_list.php b/app/Views/medical/medical_invoice_list.php new file mode 100644 index 0000000..f53039c --- /dev/null +++ b/app/Views/medical/medical_invoice_list.php @@ -0,0 +1,298 @@ +id ?? 0); + $ipdCode = (string) ($ipd->ipd_code ?? ('IPD-' . $ipdId)); + $patientName = (string) ($patient->p_fname ?? '-'); + $patientRelative = (string) ($patient->p_rname ?? ''); + $patientCode = (string) ($patient->p_code ?? '-'); + $age = ''; + if (!empty($patient)) { + $age = get_age_1( + $patient->dob ?? null, + $patient->age ?? '', + $patient->age_in_month ?? '', + $patient->estimate_dob ?? '', + $ipd->register_date ?? null + ); + } + $genderValue = (string) ($patient->xgender ?? ($patient->gender ?? '')); + if ($genderValue === '1') { + $genderValue = 'Male'; + } elseif ($genderValue === '0' || $genderValue === '2') { + $genderValue = 'Female'; + } + + $admitDate = ''; + if (!empty($ipd->register_date)) { + $ts = strtotime((string) $ipd->register_date); + $admitDate = $ts ? date('d-m-Y H:i', $ts) : (string) $ipd->register_date; + } + + $dischargeDate = ''; + if (!empty($ipd->discharge_date)) { + $ts = strtotime((string) $ipd->discharge_date); + $dischargeDate = $ts ? date('d-m-Y H:i', $ts) : (string) $ipd->discharge_date; + } + + $noDays = 0; + if (!empty($ipd->register_date)) { + $noDays = max(1, (int) floor((time() - strtotime((string) $ipd->register_date)) / 86400)); + } + + $docName = (string) ($ipd->doc_name ?? '-'); + $status = ((int) ($ipd->ipd_status ?? 0) === 0) ? 'Admit' : 'Discharge'; + $lockMedical = (int) ($ipd->lock_medical ?? 0); +?> + +
+
+

IPD Code :

+ +
+ Add New + + Refresh + +
+
+ +
+
+
+ Name : + / Age : + / Gender : + / P Code : +
+ +
+ IPD Code : + Admit Date : + / Discharge Date : + / No. of Days : + / Status : +
+ +
+ + + + + + + + + + + + + + + + $row): ?> + id ?? 0); + $ipdCredit = (int)($row->ipd_credit ?? 0); + $groupInvoiceId = (int)($row->group_invoice_id ?? 0); + $creditText = ($ipdCredit > 0) ? 'Credit' : 'CASH'; + $packageText = ($ipdCredit > 0 && $groupInvoiceId > 0) ? 'Yes' : 'No'; + $editMeta = $invoiceEditMeta[$invoiceId] ?? ['can_edit' => true, 'reason' => '']; + $canEditRow = !empty($editMeta['can_edit']); + $editReason = (string) ($editMeta['reason'] ?? 'Invoice is view-only.'); + ?> + + + + + + + + + + + + + + + + + + + + + + + + +
#Invoice ID.Inv.DateInv.DescCredit/CashPackageAmountAction
inv_med_code ?? ('M' . date('ym') . str_pad(substr((string) $invoiceId, -7, 7), 7, '0', STR_PAD_LEFT))) ?>inv_date) ? date('Y-m-d', strtotime((string)$row->inv_date)) : '-') ?>remark_ipd ?? '-') ?>net_amount ?? 0), 2)) ?> + + Edit + + Edit + + + PDF + + PDF + +
No invoices found for this IPD.
Total Cash : + + / Total Balance : + / Total CASH Discount : + + + Total Credit : + / Total Package : + / Total Amount : +
+
+ +
+ + + + + + + + + + + +
Medicine ReurnMedicine Reurn New
Payment Add + + + +
+
+ + +
+
+ +
+ + diff --git a/app/Views/medical/medical_org_invoicelist.php b/app/Views/medical/medical_org_invoicelist.php new file mode 100644 index 0000000..cd85f15 --- /dev/null +++ b/app/Views/medical/medical_org_invoicelist.php @@ -0,0 +1,106 @@ +id ?? 0); +$orgCode = (string) ($orgcase->case_id_code ?? ('ORG-' . $orgId)); +$patientName = (string) ($orgcase->p_fname ?? '-'); +$patientRel = (string) ($orgcase->p_rname ?? ''); +$patientCode = (string) ($orgcase->p_code ?? '-'); +$insuranceName = (string) ($orgcase->insurance_company_name ?? '-'); +$amountTotal = (float) ($totals['amount_total'] ?? 0); +$balanceTotal = (float) ($totals['balance_total'] ?? 0); +$hasRows = !empty($invoices); +?> + +
+
+
Org Case:
+ +
+ +
+
+ Name : + / P Code : + / Insurance : +
+ +
+ + + + + + + + + + + + + + + + $row): ?> + id ?? 0); ?> + + + + + + + + + + + + + + + + + + + + + + + + +
#Invoice IDInv.DateInv.DescCredit/CashAmountBalanceAction
inv_med_code ?? ('M' . date('ym') . str_pad((string) $invoiceId, 7, '0', STR_PAD_LEFT)))) ?>inv_date) ? date('d-m-Y', strtotime((string) $row->inv_date)) : '-') ?>remark_ipd ?? '-')) ?>case_credit ?? 0) > 0) ? 'CREDIT' : 'CASH' ?>net_amount ?? 0), 2)) ?>payment_balance ?? 0), 2)) ?> + Edit + PDF +
No org credit invoices found for this case.
+
+ +
+ Total Amount: + / Total Balance: +
+
+
+ + diff --git a/app/Views/medical/medicine_category_edit.php b/app/Views/medical/medicine_category_edit.php new file mode 100644 index 0000000..ff25214 --- /dev/null +++ b/app/Views/medical/medicine_category_edit.php @@ -0,0 +1,57 @@ +id ?? 0); + $medCatDesc = (string) ($row->med_cat_desc ?? ''); +} +?> + +
+
Medicine Category
+
+
+ +
+ + + +
+ + +
+ +
+ +
+
+
+
+ + diff --git a/app/Views/medical/medicine_category_master.php b/app/Views/medical/medicine_category_master.php new file mode 100644 index 0000000..117fa1f --- /dev/null +++ b/app/Views/medical/medicine_category_master.php @@ -0,0 +1,17 @@ +
+
+
+
Medicine Category Master
+ +
+ +
+
+
+ $med_product_cat_master ?? []]) ?> +
+
+
+
+
+
diff --git a/app/Views/medical/medicine_category_sub.php b/app/Views/medical/medicine_category_sub.php new file mode 100644 index 0000000..f730898 --- /dev/null +++ b/app/Views/medical/medicine_category_sub.php @@ -0,0 +1,32 @@ + + + + + + + + + + + + + + + +
Category NameAction
med_cat_desc ?? '') ?> + +
+ + diff --git a/app/Views/medical/merge_product.php b/app/Views/medical/merge_product.php new file mode 100644 index 0000000..ee1cff3 --- /dev/null +++ b/app/Views/medical/merge_product.php @@ -0,0 +1,152 @@ +
+
+
+
Product Merge
+ Back to Master +
+ + + +
+
+ + + +
+
+
+
+ +
+ + + +
+
+
+
+ +
+ +
+
+ +
+
Recent Product Merge Logs
+
+ + + + + + + + + + + + +
IDSummaryByAt
Loading...
+
+
+
+ + diff --git a/app/Views/medical/mini_invoice.php b/app/Views/medical/mini_invoice.php new file mode 100644 index 0000000..21b2db0 --- /dev/null +++ b/app/Views/medical/mini_invoice.php @@ -0,0 +1,130 @@ +
+
+
+
+
Already Created Today
+ Add New Invoice +
+ +
+ + + + + + + + + + + + + $inv): ?> + id ?? 0); + $editMeta = $invoiceEditMeta[$invId] ?? ['can_edit' => true, 'reason' => '']; + $canEditRow = !empty($editMeta['can_edit']); + $editReason = (string) ($editMeta['reason'] ?? 'Invoice is view-only.'); + ?> + + + + + + + + + + + + + + + + + +
#InvoiceDateNet AmountAction
inv_med_code ?? ('M' . date('ym') . str_pad(substr((string) $invId, -7, 7), 7, '0', STR_PAD_LEFT))) ?>inv_date ?? '-') ?>net_amount ?? 0), 2)) ?> + + Edit + + Edit + +
+ + + + + + + + + + + + + + + $item): ?> + + + + + + + + + + + + + + + +
#ItemBatch/Exp.RateQtyNet Amt.
item_Name ?? '-') ?>batch_no ?? '-') ?> / expiry) ? date('m-Y', strtotime((string)$item->expiry)) : '-') ?>price ?? 0), 2)) ?>qty ?? 0), 2)) ?>twdisc_amount ?? $item->tamount ?? 0), 2)) ?>
No items in this invoice.
+
No invoice found for today.
+
+
+
+ + diff --git a/app/Views/medical/new_purchase_invoice.php b/app/Views/medical/new_purchase_invoice.php new file mode 100644 index 0000000..f5b595f --- /dev/null +++ b/app/Views/medical/new_purchase_invoice.php @@ -0,0 +1,60 @@ +
+
New Purchase Invoice
+
+
+ + +
+ + +
+ +
+ + +
+ +
+ + +
+ +
+ + +
+ +
+ +
+
+
+
+ + diff --git a/app/Views/medical/org_list.php b/app/Views/medical/org_list.php new file mode 100644 index 0000000..877c1b4 --- /dev/null +++ b/app/Views/medical/org_list.php @@ -0,0 +1,60 @@ +
+
+
ORG List
+ +
+ + + + + + + + + + + + + + org_id ?? 0); + $orgCode = (string) ($row->case_id_code ?? ('ORG-' . $orgId)); + ?> + + + + + + + + + + + + + + +
ORG CodeName / Patient CodeRegister DateInsurance CompanyAction
[p_code ?? '-') ?>] p_fname ?? '-') ?>p_rname) ? '
' . esc($row->p_rname) : '' ?>
str_register_date ?? '-') ?>insurance_company_name ?? '-') ?> + Open Invoices +
No active organization credit records found.
+
+
+
+ + diff --git a/app/Views/medical/patient_search_result.php b/app/Views/medical/patient_search_result.php new file mode 100644 index 0000000..4bb768a --- /dev/null +++ b/app/Views/medical/patient_search_result.php @@ -0,0 +1,41 @@ +
+
+
Result
+
+ + + + + + + + + + + + + + + $row): ?> + + + + + + + + + + + + + + + + +
Sr.No.Patient/UHID CodeNameAgeLast VisitPhone No.Action
{$codeField} ?? '-') : '-') ?>{$nameField} ?? '-') : '-') ?>{$ageField} ?? '-') : '-') ?>{$lastVisitField} ?? '-') : '-') ?>{$phoneField} ?? '-') : '-') ?> + Sale +
No patient records found.
+
+
+
diff --git a/app/Views/medical/payment_edit.php b/app/Views/medical/payment_edit.php new file mode 100644 index 0000000..d4c0d8f --- /dev/null +++ b/app/Views/medical/payment_edit.php @@ -0,0 +1,126 @@ + + +
+
+
Payment ID :
+ +
+
Invoice Type :
+
IPD/OPD No :
+
Invoice To :
+
Amount : Rs.
+
Mode of Payment. :
+
+ + + +
+
+
Payment Mode Correction
+
+
+ +
+ + +
+
+ + +
+
+ +
+ +
+ + +
+
+ +
+ +
+
+ +
+
+
Change User
+
+
+
+ + +
+
+ +
+
+
+ +
+
+
Change/Correct Amount
+
+
+
+ + +
+
+ +
+
+
+
+
+ + diff --git a/app/Views/medical/payment_log.php b/app/Views/medical/payment_log.php new file mode 100644 index 0000000..8167787 --- /dev/null +++ b/app/Views/medical/payment_log.php @@ -0,0 +1,71 @@ +
+

Med. Payment Edit Logs Panel

+
+ +
+
+
+
+
+
+ + +
+
+ + + +
+
+ +
+
+
+ +
+
+
+
+ + diff --git a/app/Views/medical/payment_log_data.php b/app/Views/medical/payment_log_data.php new file mode 100644 index 0000000..c94054b --- /dev/null +++ b/app/Views/medical/payment_log_data.php @@ -0,0 +1,66 @@ + + +
+ Date Range: to + Total Logs: +
+ + +
No payment logs found for selected date range.
+ +
+ + + + + + + + + + + + + + + + + $row): ?> + + + + + + + + + + + + + + +
#Bill NoInvoice CodeBill TypeInsert Date TimeLog InsertUpdate LogAmount / New AmountLog TypeUpdate By
+
+ + + diff --git a/app/Views/medical/payment_search.php b/app/Views/medical/payment_search.php new file mode 100644 index 0000000..18bcb5b --- /dev/null +++ b/app/Views/medical/payment_search.php @@ -0,0 +1,113 @@ +
+
+
Med. Payment Edit
+ +
+
+ +
+ + diff --git a/app/Views/medical/placeholder.php b/app/Views/medical/placeholder.php new file mode 100644 index 0000000..42b22ee --- /dev/null +++ b/app/Views/medical/placeholder.php @@ -0,0 +1,8 @@ +
+
+
+ +
+
diff --git a/app/Views/medical/print_bill_on_uhid.php b/app/Views/medical/print_bill_on_uhid.php new file mode 100644 index 0000000..51a7309 --- /dev/null +++ b/app/Views/medical/print_bill_on_uhid.php @@ -0,0 +1,80 @@ +
+

Report Panel

+
+ +
+
+
+
+
+ + +
+
+ + + +
+
+ + +
+
+ +
+
+ +
+
+
+
+
+
+
+
+ + diff --git a/app/Views/medical/product_edit.php b/app/Views/medical/product_edit.php new file mode 100644 index 0000000..ca0732a --- /dev/null +++ b/app/Views/medical/product_edit.php @@ -0,0 +1,160 @@ +id ?? 0); +$selectedCatIds = array_map('intval', (array) ($selected_cat_ids ?? [])); + +$formulationValue = (string) ($product->formulation ?? ''); +$itemName = (string) ($product->item_name ?? ''); +$genericName = (string) ($product->genericname ?? ''); +$packing = (string) ($product->packing ?? ''); +$reOrderQty = (string) ($product->re_order_qty ?? ''); +$hsnCode = (string) ($product->HSNCODE ?? ''); +$cgst = (string) ($product->CGST_per ?? ''); +$sgst = (string) ($product->SGST_per ?? ''); +$rackNo = (string) ($product->rack_no ?? ''); +$shelfNo = (string) ($product->shelf_no ?? ''); +$coldStorage = (string) ($product->cold_storage ?? ''); +$companyId = (int) ($product->company_id ?? 0); +$relatedDrugId = (int) ($product->related_drug_id ?? 0); + +$flag = static function ($v): string { + return ((int) $v === 1) ? 'checked' : ''; +}; +?> + +
+
Product 0 ? '#' . $productId . '' : '' ?>
+
+
+ +
+ + + + +
+ + +
+
+ + +
+
+ + +
+ +
+ + +
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+ +
+ + +
+
+ + +
+
+ + +
+
+ + +
+ +
+
+
ban_flag_id ?? 0) ?>>
+
batch_applicable ?? 0) ?>>
+
exp_date_applicable ?? 0) ?>>
+
is_continue ?? 0) ?>>
+
narcotic ?? 0) ?>>
+
schedule_h ?? 0) ?>>
+
schedule_h1 ?? 0) ?>>
+
schedule_x ?? 0) ?>>
+
schedule_g ?? 0) ?>>
+
high_risk ?? 0) ?>>
+
+
+ +
+ + +
+
+
+
+ + diff --git a/app/Views/medical/product_search_result.php b/app/Views/medical/product_search_result.php new file mode 100644 index 0000000..b55eed7 --- /dev/null +++ b/app/Views/medical/product_search_result.php @@ -0,0 +1,42 @@ +
+ + + + + + + + + + + + + + + + + + + + + + + +
Prod. IDNameFormulationGeneric NamePacking TypeAction
id ?? 0) ?>item_name ?? '') ?>formulation ?? '') ?>genericname ?? '') ?>packing ?? '') ?> + +
+
+ + diff --git a/app/Views/medical/purchase_challan_list.php b/app/Views/medical/purchase_challan_list.php new file mode 100644 index 0000000..9b2e9e4 --- /dev/null +++ b/app/Views/medical/purchase_challan_list.php @@ -0,0 +1,32 @@ +
+ +

No challan items available for this supplier.

+ + + + + id ?? 0)): ?> + + + + + + + + + + + + + + + + + + + id ?? 0); ?> + + +
Challan No: Invoice_no ?? '')) ?> / Date: str_date_of_invoice ?? '')) ?> / Net Amount: tamount ?? 0)) ?>
Item NameQty + FreeMRPAdd
Item_name ?? '') ?>qty ?? 0)) ?> + qty_free ?? 0)) ?>mrp ?? 0)) ?>Add
+ +
diff --git a/app/Views/medical/purchase_invoice_edit.php b/app/Views/medical/purchase_invoice_edit.php new file mode 100644 index 0000000..f56b3f7 --- /dev/null +++ b/app/Views/medical/purchase_invoice_edit.php @@ -0,0 +1,428 @@ + + + + +
Purchase invoice not found.
+ +
+
+
Purchase Invoice Information
+ + Supplier: name_supplier ?? '-') ?> | + ischallan ?? 0) === 1) ? 'Challan No.' : 'Invoice No.' ?>: Invoice_no ?? '')) ?> | + Invoice Date: str_date_of_invoice ?? '')) ?> + + + +
+
+
+ + + +
+ + inv_status ?? 0) === 0): ?> +
+
+ + + +
+
+ + +
+
+ +
+
+
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+ +
+ + +
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+ +
+ + +
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+ +
+ + +
+
+ + +
+
+ + +
+ +
+ + +
+
+ +
+
+
+
+
+
Select a product to view last 5 purchase orders.
+
+
+ +
+
+
+ + + diff --git a/app/Views/medical/purchase_invoice_item.php b/app/Views/medical/purchase_invoice_item.php new file mode 100644 index 0000000..b47d078 --- /dev/null +++ b/app/Views/medical/purchase_invoice_item.php @@ -0,0 +1,62 @@ + + + + + + + + + + + + + + + + + + + + + + + + + item_return ?? 0) === 1) ? 'style="color:red;"' : '' ?>> + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
#RecNoItem NameBatch NoExp.MRPQty.RateAmountDisc.Tax AmountCGSTSGSTNet Amount
id ?? 0) ?>Item_name ?? '') ?>batch_no ?? '') ?>exp_date_str ?? '') ?>mrp ?? 0)) ?>qty ?? 0)) ?> + qty_free ?? 0)) ?>purchase_price ?? 0)) ?>amount ?? 0)) ?>discount ?? 0)) ?>taxable_amount ?? 0)) ?>CGST_per ?? 0)) ?>SGST_per ?? 0)) ?>net_amount ?? 0)) ?> + inv_status ?? 0) === 0): ?> + + + old_purchase_id ?? 0) > 0): ?> + + + +
TotalTaxable_Amt ?? 0)) ?>CGST_Amt ?? 0)) ?>SGST_Amt ?? 0)) ?>T_Net_Amount ?? 0)) ?>
diff --git a/app/Views/medical/purchase_invoice_master_edit.php b/app/Views/medical/purchase_invoice_master_edit.php new file mode 100644 index 0000000..f0d1f81 --- /dev/null +++ b/app/Views/medical/purchase_invoice_master_edit.php @@ -0,0 +1,156 @@ +Purchase invoice not found.'; + return; +} + +$invStatus = (int) ($inv->inv_status ?? 0); +$canUpdatePurchaseStatus = (bool) ($can_update_purchase_status ?? false); +?> + +
+
Purchase Master Edit
+
+
+ + + + +
+ + +
+
+ + +
+
+ + +
+
+ + +
+
+ +
+ +
+ +
name_supplier ?? '-') ?>
+
+
+ +
Invoice_no ?? '')) ?>
+
+
+ +
date_of_invoice) ? esc(date('d/m/Y', strtotime((string) $inv->date_of_invoice))) : '' ?>
+
+ +
+ +
+ + + + + + + + + + + + + + + + + + + + + item_return ?? 0) === 1) ? 'style="color:red;"' : '' ?>> + + + + + + + + + + + + + + + + + + + + + + + +
#Item NameBatch NoExp.MRPQty.RateAmountDisc.Tax AmountCGSTSGSTNet Amount
Item_name ?? '') ?>batch_no ?? '') ?>expiry_date ?? '')) ?>mrp ?? 0)) ?>qty ?? 0)) ?>+qty_free ?? 0)) ?>purchase_price ?? 0)) ?>amount ?? 0)) ?>discount ?? 0)) ?>taxable_amount ?? 0)) ?>CGST_per ?? 0)) ?>SGST_per ?? 0)) ?>net_amount ?? 0)) ?>
TotalTaxable_Amt ?? 0)) ?>CGST_Amt ?? 0)) ?>SGST_Amt ?? 0)) ?>T_Net_Amount ?? 0)) ?>
+
+ +
+ +
+ +
+ + +
+ +
+
+ +
+ +
+ +
+
+ +
+
+
+ + diff --git a/app/Views/medical/purchase_item_old.php b/app/Views/medical/purchase_item_old.php new file mode 100644 index 0000000..2616fcf --- /dev/null +++ b/app/Views/medical/purchase_item_old.php @@ -0,0 +1,39 @@ +Item_name ?? ''); +} +?> + + +

No purchase history found for selected product.

+ + +

Item : Last 5 Purchase Orders

+ + + + + + + + + + + + + + + + + + + + + + + + + + +
DateMRPQtyRateSCH/DiscP.U.RateSupplier/Invoice
date_of_invoice_str ?? '') ?>mrp ?? 0)) ?>qty ?? 0)) ?> + qty_free ?? 0)) ?>purchase_price ?? 0)) ?>sch_disc_per ?? 0)) ?> / discount ?? 0)) ?>purchase_unit_rate ?? 0)) ?>name_supplier ?? '-') . '/' . ($row->Invoice_no ?? '')) ?>
diff --git a/app/Views/medical/purchase_supp_list.php b/app/Views/medical/purchase_supp_list.php new file mode 100644 index 0000000..10ff1ed --- /dev/null +++ b/app/Views/medical/purchase_supp_list.php @@ -0,0 +1,57 @@ +
+ + + + + + + + + + + + + ischallan ?? 0) === 1) ? 'style="color:red;"' : '' ?>> + + + + + + + + +
Invoice IDSupplierDateAmountAction
Invoice_no ?? '')) ?>name_supplier ?? '') ?>str_date_of_invoice ?? $row->date_of_invoice ?? '')) ?>tamount ?? 0)) ?> + + tamount ?? 0) == 0.0): ?> + + +
+
+ + diff --git a/app/Views/medical/purchase_supplier_list.php b/app/Views/medical/purchase_supplier_list.php new file mode 100644 index 0000000..3ea5f6b --- /dev/null +++ b/app/Views/medical/purchase_supplier_list.php @@ -0,0 +1,27 @@ +
+
+ +
+ +
+
+ +
+
+ +
+
+ +
+
+ + diff --git a/app/Views/medical/report_company_med_sale.php b/app/Views/medical/report_company_med_sale.php new file mode 100644 index 0000000..709f951 --- /dev/null +++ b/app/Views/medical/report_company_med_sale.php @@ -0,0 +1,108 @@ +
+

Company Wise Medicine Sale Report

+
+ +
+
+
+
+
+ + +
+
+ + + +
+
+ + +
+
+
+ + + +
+
+
+ +
+
+
+
+
+
+
+
+ + diff --git a/app/Views/medical/report_company_med_sale_data.php b/app/Views/medical/report_company_med_sale_data.php new file mode 100644 index 0000000..2fe0429 --- /dev/null +++ b/app/Views/medical/report_company_med_sale_data.php @@ -0,0 +1,114 @@ + + + +
Date range: to
+ + +
+ + + + + + + + + + + + + + + + + + $row): ?> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
#Item CodeItem NameSale QtySale AmtPur. AmtSale GSTReturn QtyReturn AmtReturn Pur. Amt
No records found for selected filters.
#Total SaleTotal Return
+
+ +
Total Margin (Sale - Purchase - Return + ReturnPurchase - NetGST): Rs.
+
Net GST = Sale GST () - Return GST ()
+ + + + diff --git a/app/Views/medical/report_daily_med_sale.php b/app/Views/medical/report_daily_med_sale.php new file mode 100644 index 0000000..2a2bdf6 --- /dev/null +++ b/app/Views/medical/report_daily_med_sale.php @@ -0,0 +1,99 @@ +
+

Daily Medicine Sale Report

+
+ +
+
+
+
+
+ + +
+
+ + + +
+
+
+ + + +
+
+
+ +
+
+
+
+
+
+
+
+ + diff --git a/app/Views/medical/report_daily_med_sale_data.php b/app/Views/medical/report_daily_med_sale_data.php new file mode 100644 index 0000000..a93f539 --- /dev/null +++ b/app/Views/medical/report_daily_med_sale_data.php @@ -0,0 +1,117 @@ + + + +
Date range: to
+ + +
+ + + + + + + + + + + + + + + + + + + $row): ?> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
#Item CodeItem NameSale QtySale AmtPur. AmtSale GSTReturn QtyReturn AmtReturn Pur. AmtCur.Qty
No records found for selected date range.
#Total SaleTotal Return
+
+ +
Total Margin (Sale - Purchase - Return + ReturnPurchase - NetGST): Rs.
+
Net GST = Sale GST () - Return GST ()
+ + + + diff --git a/app/Views/medical/report_daily_med_sale_doc.php b/app/Views/medical/report_daily_med_sale_doc.php new file mode 100644 index 0000000..ff72df2 --- /dev/null +++ b/app/Views/medical/report_daily_med_sale_doc.php @@ -0,0 +1,109 @@ +
+

Daily Medicine Sale Report

+
+ +
+
+
+
+
+ + +
+
+ + + +
+
+ + +
+
+
+ + + +
+
+
+ +
+
+
+
+
+
+
+
+ + diff --git a/app/Views/medical/report_daily_med_sale_doc_data.php b/app/Views/medical/report_daily_med_sale_doc_data.php new file mode 100644 index 0000000..ef6a252 --- /dev/null +++ b/app/Views/medical/report_daily_med_sale_doc_data.php @@ -0,0 +1,104 @@ + + + +
Date range: to
+ + +
+ + + + + + + + + + + + + + + + + $row): ?> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
#Doc. NameItem CodeItem NameSale QtySale AmtPur. AmtSale GSTCur.Qty
No records found for selected filters.
#Total Sale
+
+ +
Total Margin (Sale - Purchase - SaleGST): Rs.
+ + + + diff --git a/app/Views/medical/report_gst_invoice_hsn_data.php b/app/Views/medical/report_gst_invoice_hsn_data.php new file mode 100644 index 0000000..45ba1cb --- /dev/null +++ b/app/Views/medical/report_gst_invoice_hsn_data.php @@ -0,0 +1,65 @@ + + + +
Date range: to
+ + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
HSN CodeItem QtyTax Per.Tot.Amt.Tot.Tax.AmtTax.Amt.5%CGST 2.5%SGST 2.5%Tax.Amt.12%CGST 6%SGST 6%Tax.Amt.18%CGST 9%SGST 9%Tax.Amt.28%CGST 14%SGST 14%Tax.Amt.0%
No records found.
+
diff --git a/app/Views/medical/report_gst_invoice_list.php b/app/Views/medical/report_gst_invoice_list.php new file mode 100644 index 0000000..eabb520 --- /dev/null +++ b/app/Views/medical/report_gst_invoice_list.php @@ -0,0 +1,144 @@ +
+

GST Invoice List Panel

+
+ +
+
+
+
+
+ +
+
+ +
+
+ +
+
+ +
+
+
+ + + +
+
+
+
+ + + +
+
+
+ +
+
+
+
+
+
+
+
+ + diff --git a/app/Views/medical/report_gst_invoice_list_data.php b/app/Views/medical/report_gst_invoice_list_data.php new file mode 100644 index 0000000..2450ca7 --- /dev/null +++ b/app/Views/medical/report_gst_invoice_list_data.php @@ -0,0 +1,69 @@ + + + +
Date range: to
+ + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Invoice IDInv.DateInv.NameInvoice TypeQtyTot.Amt.Tot.Tax.AmtTax.Amt.5%CGST 2.5%SGST 2.5%Tax.Amt.12%CGST 6%SGST 6%Tax.Amt.18%CGST 9%SGST 9%Tax.Amt.28%CGST 14%SGST 14%Tax.Amt.0%
No records found.
+
diff --git a/app/Views/medical/report_gst_sale.php b/app/Views/medical/report_gst_sale.php new file mode 100644 index 0000000..8d9c7b2 --- /dev/null +++ b/app/Views/medical/report_gst_sale.php @@ -0,0 +1,132 @@ +
+

Sale GST Report Panel

+
+ +
+
+
+ +
+ `H_Med_GST` is empty. Please set GSTIN in constants before using GSTR1 JSON export. +
+ + +
+
+ +
+
+ +
+
+ +
+
+ +
+
+ + +
+
+
+ + + + +
+
+
+ +
+
+
+
+
+
+
+
+ + diff --git a/app/Views/medical/report_gst_sale_data.php b/app/Views/medical/report_gst_sale_data.php new file mode 100644 index 0000000..36883e1 --- /dev/null +++ b/app/Views/medical/report_gst_sale_data.php @@ -0,0 +1,54 @@ + + + +
Date range: to
+ + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
#CGST PerT. CGSTSGST PerT. SGSTTotal GSTTaxable AmountAmountItem Qty
Grand Total :' : esc((string) ($row['cgst_per'] ?? '-')) ?>
No records found.
+
diff --git a/app/Views/medical/report_gst_sale_data_pdf.php b/app/Views/medical/report_gst_sale_data_pdf.php new file mode 100644 index 0000000..d1cc48f --- /dev/null +++ b/app/Views/medical/report_gst_sale_data_pdf.php @@ -0,0 +1,70 @@ + + + + + + + + +
Sale GST Report
+
Date range: to
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
#CGST PerT. CGSTSGST PerT. SGSTTotal GSTTaxable AmountAmountItem Qty
No records found.
+ + diff --git a/app/Views/medical/report_ipd_credit.php b/app/Views/medical/report_ipd_credit.php new file mode 100644 index 0000000..60fda88 --- /dev/null +++ b/app/Views/medical/report_ipd_credit.php @@ -0,0 +1,116 @@ +
+

IPD Invoice Panel

+
+ +
+
+
+
+
+ + +
+
+ + + +
+
+ + +
+
+
+ + + +
+
+
+ +
+
+
+
+
+
+
+
+ + diff --git a/app/Views/medical/report_ipd_credit_data.php b/app/Views/medical/report_ipd_credit_data.php new file mode 100644 index 0000000..db8e9fa --- /dev/null +++ b/app/Views/medical/report_ipd_credit_data.php @@ -0,0 +1,115 @@ + (string) ($row['ipd_code'] ?? '-'), + 'patient_code' => (string) ($row['patient_code'] ?? '-'), + 'patient_name' => (string) ($row['patient_name'] ?? '-'), + 'tpa_name' => (string) ($row['tpa_name'] ?? '-'), + 'items' => [], + 'subtotal' => 0.0, + ]; + } + + $amount = (float) ($row['ipd_total_amount'] ?? 0); + $grouped[$ipdId]['items'][] = $row; + $grouped[$ipdId]['subtotal'] += $amount; + $grandTotal += $amount; +} +?> + + +
Discharge date range: to
+ + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
IPD CodePatient CodePatient NameTPA Name
Inv.No.Inv.DateAmountType
Total
Grand Total
No records found for selected filters.
+
+ + + + diff --git a/app/Views/medical/report_ipd_discharge.php b/app/Views/medical/report_ipd_discharge.php new file mode 100644 index 0000000..d4bd7b3 --- /dev/null +++ b/app/Views/medical/report_ipd_discharge.php @@ -0,0 +1,103 @@ +
+

IPD Discharge Report Panel

+
+ +
+
+
+
+
+ + +
+
+ + + +
+
+
+ + + +
+
+
+ +
+
+
+
+
+
+
+
+ + diff --git a/app/Views/medical/report_ipd_discharge_data.php b/app/Views/medical/report_ipd_discharge_data.php new file mode 100644 index 0000000..74becc2 --- /dev/null +++ b/app/Views/medical/report_ipd_discharge_data.php @@ -0,0 +1,100 @@ + + +
Date range: to
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
IPD CodePatient CodePatient NameAdmit Dt.Discharge Dt.TPA NameCashPaid Amt.Cash BalanceCreditPackage
No discharged IPD records found for selected date range.
Total
+
+ + diff --git a/app/Views/medical/report_ipd_sale.php b/app/Views/medical/report_ipd_sale.php new file mode 100644 index 0000000..d7836ce --- /dev/null +++ b/app/Views/medical/report_ipd_sale.php @@ -0,0 +1,103 @@ +
+

IPD Invoice Panel

+
+ +
+
+
+
+
+ + +
+
+ + + +
+
+
+ + + +
+
+
+ +
+
+
+
+
+
+
+
+ + diff --git a/app/Views/medical/report_ipd_sale_data.php b/app/Views/medical/report_ipd_sale_data.php new file mode 100644 index 0000000..d23d657 --- /dev/null +++ b/app/Views/medical/report_ipd_sale_data.php @@ -0,0 +1,123 @@ + 0.0, + 'credit' => 0.0, + 'package' => 0.0, + 'total' => 0.0, +]; + +foreach ($rows as $row) { + $ipdId = (string) ($row['ipd_id'] ?? '0'); + if (!isset($grouped[$ipdId])) { + $grouped[$ipdId] = [ + 'ipd_code' => (string) ($row['ipd_code'] ?? '-'), + 'patient_code' => (string) ($row['patient_code'] ?? '-'), + 'patient_name' => (string) ($row['patient_name'] ?? '-'), + 'tpa_name' => (string) ($row['tpa_name'] ?? '-'), + 'items' => [], + ]; + } + + $grouped[$ipdId]['items'][] = $row; + $totals['cash'] += (float) ($row['ipd_cash_amount'] ?? 0); + $totals['credit'] += (float) ($row['ipd_credit_amount'] ?? 0); + $totals['package'] += (float) ($row['ipd_package_amount'] ?? 0); + $totals['total'] += (float) ($row['ipd_total_amount'] ?? 0); +} +?> + + +
Discharge date range: to
+ + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
IPD CodePatient CodePatient NameTPA Name
Inv.No.Inv.DateCashCreditPackageTotal
IPD Total
No records found for selected date range.
+
+ + + + diff --git a/app/Views/medical/report_med_patient.php b/app/Views/medical/report_med_patient.php new file mode 100644 index 0000000..f04f9af --- /dev/null +++ b/app/Views/medical/report_med_patient.php @@ -0,0 +1,154 @@ +
+

Report Drug Sale to Patient Panel

+
+ +
+
+
+
+
+ + +
+
+ + + +
+
+ + +
+
+ + +
+
+
+
+
+ + + +
+
+
+
+
+
+
+
+
+
+
+ + diff --git a/app/Views/medical/report_med_patient_data.php b/app/Views/medical/report_med_patient_data.php new file mode 100644 index 0000000..0e4081e --- /dev/null +++ b/app/Views/medical/report_med_patient_data.php @@ -0,0 +1,81 @@ + (string) ($row['shed_x_h'] ?? ''), + 'rows' => [], + 'total_qty' => 0.0, + ]; + } + + $qty = (float) ($row['t_qty'] ?? 0); + $groups[$itemName]['rows'][] = $row; + $groups[$itemName]['total_qty'] += $qty; + + if ($groups[$itemName]['head'] === '' && !empty($row['shed_x_h'])) { + $groups[$itemName]['head'] = (string) $row['shed_x_h']; + } +} +?> + +
+ Date Range: to + Total Items: +
+ + +
No records found for selected filters.
+ +
+ + + + + + + + + + + + + + $group): ?> + + + + + + + + + + + + + + + + + + + + +
Inv.No.Inv.DateIPD No.P Code/NameExp. DateBatchQty
+ + + [ ] + +
/
Total Qty ()
+
+ diff --git a/app/Views/medical/report_med_patient_pdf.php b/app/Views/medical/report_med_patient_pdf.php new file mode 100644 index 0000000..01da6dd --- /dev/null +++ b/app/Views/medical/report_med_patient_pdf.php @@ -0,0 +1,114 @@ + (string) ($row['shed_x_h'] ?? ''), + 'rows' => [], + 'total_qty' => 0.0, + ]; + } + + $qty = (float) ($row['t_qty'] ?? 0); + $groups[$itemName]['rows'][] = $row; + $groups[$itemName]['total_qty'] += $qty; + + if ($groups[$itemName]['head'] === '' && !empty($row['shed_x_h'])) { + $groups[$itemName]['head'] = (string) $row['shed_x_h']; + } +} + +$pharmacyName = defined('M_store') ? (string) M_store : 'Medical Store'; +?> + + + + + + + +
+
Drug Sale Customer Wise Report
+
+ Date Range: to + + | Drug/Batch: + + + | Schedule Filter: + + | Total Items: +
+ + + + +
No records found for selected filters.
+ + + + + + + + + + + + + + + $group): ?> + + + + + + + + + + + + + + + + + + + + +
Inv.No.Inv.DateIPD No.P Code/NameExp. DateBatchQty
+ + + [ ] + +
/
Total Qty ()
+ + +
Generated on
+ + diff --git a/app/Views/medical/report_org_bills.php b/app/Views/medical/report_org_bills.php new file mode 100644 index 0000000..563f9db --- /dev/null +++ b/app/Views/medical/report_org_bills.php @@ -0,0 +1,113 @@ +
+

Org. Invoice Panel

+
+ +
+
+
+
+
+ + +
+
+ + + +
+
+ + +
+
+
+ + + +
+
+
+ +
+
+
+
+
+
+
+
+ + diff --git a/app/Views/medical/report_org_bills_data.php b/app/Views/medical/report_org_bills_data.php new file mode 100644 index 0000000..7638bde --- /dev/null +++ b/app/Views/medical/report_org_bills_data.php @@ -0,0 +1,79 @@ + + + +
Invoice date range: to
+ + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Inv. IDOrg.CodeP CodeP NameAmountOrg. Name
Total
No records found for selected filters.
+
+ + + + diff --git a/app/Views/medical/report_purchase_invoice.php b/app/Views/medical/report_purchase_invoice.php new file mode 100644 index 0000000..0d65314 --- /dev/null +++ b/app/Views/medical/report_purchase_invoice.php @@ -0,0 +1,233 @@ +
+

Report Purchase Invoice Panel

+
+ +
+
+
+ +
+ `H_Med_GST` is empty. Please set GSTIN in constants before using GSTR-2B/GSTR-3B export. +
+ + +
+
+ + +
+
+ + + +
+
+ + +
+
+ + +
+
+ +
+ +
+
+
+ +
+
+
+
+
+
+
+
+ + diff --git a/app/Views/medical/report_purchase_invoice_data.php b/app/Views/medical/report_purchase_invoice_data.php new file mode 100644 index 0000000..e7e445a --- /dev/null +++ b/app/Views/medical/report_purchase_invoice_data.php @@ -0,0 +1,108 @@ +' + . '#' + . 'Total of : ' . esc($supplierName) . '' + . '' . esc(number_format($taxable, 2)) . '' + . '' . esc(number_format($gst, 2)) . '' + . '' . esc(number_format($amount, 0, '.', '')) . '' + . ''; +}; +?> + +
+ Date: to +
+ +
+ + + + + + + '; + } + + $currentSupplier = $supplierName; + $currentGst = $gstNo; + $currentState = $state; + $supplierSr = 0; + $supplierTaxable = 0.0; + $supplierGst = 0.0; + $supplierAmount = 0.0; + ?> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
_
_
/ GST No. / State :
#Purchase. Inv. IDInv. DateTaxable AmtTax AmtInv. Amount
#Grand Total
+
diff --git a/app/Views/medical/report_purchase_invoice_data_gst.php b/app/Views/medical/report_purchase_invoice_data_gst.php new file mode 100644 index 0000000..fbec376 --- /dev/null +++ b/app/Views/medical/report_purchase_invoice_data_gst.php @@ -0,0 +1,66 @@ + +
+ Date: to +
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
#InvoiceSupplierDateTaxable AmtGST AmtInv Amount0%5%12%18%28%CGSTSGST/IGST
Total
+
diff --git a/app/Views/medical/report_purchase_invoice_data_gst_pdf.php b/app/Views/medical/report_purchase_invoice_data_gst_pdf.php new file mode 100644 index 0000000..6a8e11d --- /dev/null +++ b/app/Views/medical/report_purchase_invoice_data_gst_pdf.php @@ -0,0 +1,108 @@ + + + + + + + + +
Purchase Invoice GST Rate Report
+
Date: to
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
#InvoiceSupplierDateTaxableGSTAmount0%5%12%18%28%CGSTSGST/IGST
Total
+ + diff --git a/app/Views/medical/report_purchase_invoice_data_pdf.php b/app/Views/medical/report_purchase_invoice_data_pdf.php new file mode 100644 index 0000000..dc09120 --- /dev/null +++ b/app/Views/medical/report_purchase_invoice_data_pdf.php @@ -0,0 +1,118 @@ +' + . '#' + . 'Total of : ' . esc($supplierName) . '' + . '' . esc(number_format($taxable, 2)) . '' + . '' . esc(number_format($gst, 2)) . '' + . '' . esc(number_format($amount, 0, '.', '')) . '' + . ''; +}; +?> + + + + + + + +
Purchase Invoice Report
+
Date: to
+ + + + + + '; + } + + $currentSupplier = $supplierName; + $currentGst = $gstNo; + $currentState = $state; + $supplierSr = 0; + $supplierTaxable = 0.0; + $supplierGst = 0.0; + $supplierAmount = 0.0; + ?> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
_
_
/ GST No. / State :
#Purchase. Inv. IDInv. DateTaxable AmtTax AmtInv. Amount
#Grand Total
+ + diff --git a/app/Views/medical/report_short_medicine.php b/app/Views/medical/report_short_medicine.php new file mode 100644 index 0000000..90174e2 --- /dev/null +++ b/app/Views/medical/report_short_medicine.php @@ -0,0 +1,119 @@ +
+

Medicine Short Report

+
+ +
+
+
+
+
+ + +
+
+ + + +
+
+ + +
Blank = All formulations
+
+
+
+ + + +
+
+
+ +
+
+
+
+
+
+
+
+ + diff --git a/app/Views/medical/report_short_medicine_data.php b/app/Views/medical/report_short_medicine_data.php new file mode 100644 index 0000000..1cae003 --- /dev/null +++ b/app/Views/medical/report_short_medicine_data.php @@ -0,0 +1,69 @@ + + + +
Date range: to
+ + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
IDDateItem NameFormulationQtySupplier
No records found for selected filters.
+
+ + + + diff --git a/app/Views/medical/search_customer.php b/app/Views/medical/search_customer.php new file mode 100644 index 0000000..af64d2e --- /dev/null +++ b/app/Views/medical/search_customer.php @@ -0,0 +1,62 @@ +
+
+
OPD Sale - Patient Search
+ +
+ +
+ +
+
+ + New Counter Sale +
+
+
+
+
+ + diff --git a/app/Views/medical/stock_statement.php b/app/Views/medical/stock_statement.php new file mode 100644 index 0000000..a0fde10 --- /dev/null +++ b/app/Views/medical/stock_statement.php @@ -0,0 +1,109 @@ + + +
+
+
+
Item Stock Statement
+ Back to Master +
+ +
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+
+ +
+
+ + +
+
+ +
+
+
+ + diff --git a/app/Views/medical/stock_statement_data.php b/app/Views/medical/stock_statement_data.php new file mode 100644 index 0000000..28f0c65 --- /dev/null +++ b/app/Views/medical/stock_statement_data.php @@ -0,0 +1,100 @@ +
+ +
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Item NamePur Pak.Pur CostCurrent Pak.Current Unit QtyTotal Sale Pak.Total Sale Unit QtyLost UnitPackage/Re-Order Qty
item_name ?? '') ?>total_pak_qty ?? 0), 2)) ?>purchase_cost ?? 0), 2)) ?>C_Pak_Qty ?? 0), 2)) ?>C_Unit_Stock_Qty ?? 0), 2)) ?>C_Pak_Sale_Qty ?? 0), 2)) ?>sale_unit ?? 0), 2)) ?>total_lost_unit ?? 0), 2)) ?>packing ?? 0)) ?>/re_order_qty ?? 0)) ?>
+
+ + diff --git a/app/Views/medical/stock_transfer.php b/app/Views/medical/stock_transfer.php new file mode 100644 index 0000000..dfabe2a --- /dev/null +++ b/app/Views/medical/stock_transfer.php @@ -0,0 +1,174 @@ +
+
+
+
Purchase Item Transfer
+ Back to Master +
+ + + +
+
+ + + + +
+
+
+
+ +
+ + + + +
+
+
+
+ +
+ + +
+
+ +
+
+ +
+
Recent Transfer Logs
+
+ + + + + + + + + + + + +
IDSummaryByAt
Loading...
+
+
+
+ + diff --git a/app/Views/medical/store_stock_result.php b/app/Views/medical/store_stock_result.php new file mode 100644 index 0000000..94119c1 --- /dev/null +++ b/app/Views/medical/store_stock_result.php @@ -0,0 +1,478 @@ + 0, 'd0_30' => 0, 'd31_60' => 0, 'd61_90' => 0]; +$topSaleRows = $top_sale_rows ?? []; +$topSaleLabels = $top_sale_labels ?? []; +$topSaleValues = $top_sale_values ?? []; +$ratioRows = $ratio_rows ?? []; +$ratioLabels = $ratio_labels ?? []; +$ratioValues = $ratio_values ?? []; +?> + +
+
+
+
Total Items
+
+
+
+
+
+
Low Stock Items
+
+
+
+
+ +
+
+
Pharmacy Stock Graph (Top 10 by Current Unit Qty)
+
+ +
+
+
+ +
+
+
+
Expired Units
+
+
+
+
+
+
Due 0-30 Days
+
+
+
+
+
+
Due 31-60 Days
+
+
+
+
+
+
Due 61-90 Days
+
+
+
+
+ +
+
+
Near Expiry Graph (Current Units)
+
+ +
+
+
+ +
+
+
+
+
Highest Sale Medicines (Last 30 Days)
+
+ +
+
+ + + + + + + + + + + + + + + + + + + + + +
MedicineSale Qty (30d)
No sale data found for last 30 days.
+
+
+
+
+ +
+
+
+
High Stock / Low Sale Ratio
+
+ +
+
+ + + + + + + + + + + + + + + + + + + + + + + + + +
MedicineCurrent StockSale Qty (30d)Ratio
No stock ratio data found.
+
+
+
+
+
+ +
+ +
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Item NameGeneric NameCurrent Pak.Current Unit QtyTotal Sale Pak.Total Sale Unit QtyLost UnitPackage/Re-Order Qty
item_name ?? '') ?>genericname ?? '') ?>C_Pak_Qty ?? 0)) ?>C_Unit_Stock_Qty ?? 0), 2)) ?>C_Pak_Sale_Qty ?? 0), 2)) ?>sale_unit ?? 0), 2)) ?>total_lost_unit ?? 0), 2)) ?>packing ?? 0)) ?>/re_order_qty ?? 0)) ?>
No stock items found for selected filters.
+
+ + diff --git a/app/Views/medical/store_stock_search.php b/app/Views/medical/store_stock_search.php new file mode 100644 index 0000000..3e3ae98 --- /dev/null +++ b/app/Views/medical/store_stock_search.php @@ -0,0 +1,146 @@ +
+
+
+
Store Stock : Pharmacy
+ Datewise Statement +
+ +
+
+ + +
+
+
+ + +
+
+
+ + +
+
+ +
+ + + + +
+
+
+ +
+
+
+ + diff --git a/app/Views/medical/supplier_account.php b/app/Views/medical/supplier_account.php new file mode 100644 index 0000000..a5ccd53 --- /dev/null +++ b/app/Views/medical/supplier_account.php @@ -0,0 +1,51 @@ +
+
+
+
Supplier List
+ Back to Master +
+ +
+ + + + + + + + + + + + + Tot_Balance ?? 0); ?> + + + + + + + + + +
NameBalanceLast Inv. DateLast Payment Date
name_supplier ?? '') ?> Dr' : 'Cr' ?>Last_InvDate ?? '') ?>Last_Payment ?? '') ?> + Open +
+
+
+
+ + diff --git a/app/Views/medical/supplier_account_add_entry.php b/app/Views/medical/supplier_account_add_entry.php new file mode 100644 index 0000000..865b046 --- /dev/null +++ b/app/Views/medical/supplier_account_add_entry.php @@ -0,0 +1,51 @@ + + + +
+ + +
+ + + +
+ + +
+ +
+ + +
+ +
+ + +
+ +
+ + +
+ +
+ + +
+ +
+ +
+
diff --git a/app/Views/medical/supplier_account_detail.php b/app/Views/medical/supplier_account_detail.php new file mode 100644 index 0000000..c5a4aae --- /dev/null +++ b/app/Views/medical/supplier_account_detail.php @@ -0,0 +1,256 @@ +sid ?? 0); +$today = date('Y-m-d'); +$defaultDateFrom = (string) ($default_date_from ?? $today); +$defaultDateTo = (string) ($default_date_to ?? $today); +?> + +
+
+
+
+ Ledger Account: name_supplier ?? '-') ?> + Balance: Tot_Balance ?? 0), 2)) ?> +
+
+ + Back to List +
+
+ +
+
+ + +
+
+ + +
+
+ + +
+
+ +
+
+
+
+ + + + diff --git a/app/Views/medical/supplier_account_edit_entry.php b/app/Views/medical/supplier_account_edit_entry.php new file mode 100644 index 0000000..fa1dff3 --- /dev/null +++ b/app/Views/medical/supplier_account_edit_entry.php @@ -0,0 +1,52 @@ + + + +
+ + +
+ + + + +
+ + +
+ +
+ + +
+ +
+ + +
+ +
+ + +
+ +
+ + +
+ +
+ +
+
diff --git a/app/Views/medical/supplier_account_ledger_data.php b/app/Views/medical/supplier_account_ledger_data.php new file mode 100644 index 0000000..cca5668 --- /dev/null +++ b/app/Views/medical/supplier_account_ledger_data.php @@ -0,0 +1,35 @@ +
+ Opening Balance: + | Total Credit: + | Total Debit: + | Closing Balance: +
+ +
+ + + + + + + + + + + + + + + + + + + + + + + +
IDDate TranDescriptionCreditDebitActions
tran_date) ? date('d-m-Y', strtotime((string) $row->tran_date)) : '') ?>mode_desc ?? '') . ' ' . ($row->tran_desc ?? '')))) ?>credit_debit ?? 0) === 0 ? esc(number_format((float) ($row->amount ?? 0), 2)) : '' ?>credit_debit ?? 0) === 1 ? esc(number_format((float) ($row->amount ?? 0), 2)) : '' ?> + +
+
diff --git a/app/Views/medical/supplier_account_ledger_pdf.php b/app/Views/medical/supplier_account_ledger_pdf.php new file mode 100644 index 0000000..3e30cef --- /dev/null +++ b/app/Views/medical/supplier_account_ledger_pdf.php @@ -0,0 +1,119 @@ + + + + + Supplier Ledger + + + + + +
+
+
+
+ + Phone: + + | + + GST No.: + +
+
+ +

Supplier Ledger: name_supplier ?? '-') ?>

+ {$addrField} ?? '')) { + $supplierAddress = trim((string) $supplier->{$addrField}); + break; + } + } + + $supplierCity = trim((string) ($supplier->city ?? '')); + $supplierState = trim((string) ($supplier->state ?? '')); + $supplierPhone = trim((string) ($supplier->contact_no ?? '')); + $supplierGst = trim((string) ($supplier->gst_no ?? '')); + + $supplierAddressLine = $supplierAddress; + if ($supplierCity !== '') { + $supplierAddressLine .= ($supplierAddressLine !== '' ? ', ' : '') . $supplierCity; + } + if ($supplierState !== '') { + $supplierAddressLine .= ($supplierAddressLine !== '' ? ', ' : '') . $supplierState; + } + ?> +
+ + Supplier Address:
+ + + Supplier Phone: + + | + + Supplier GST No.: + +
+
Date Range: to
+ +
+ Opening Balance: + | Total Credit: + | Total Debit: + | Closing Balance: +
+ + + + + + + + + + + + + + + + + + + + + + +
#Date TranDescriptionCreditDebit
tran_date) ? date('d-m-Y', strtotime((string) $row->tran_date)) : '') ?>mode_desc ?? '') . ' ' . ($row->tran_desc ?? '')))) ?>credit_debit ?? 0) === 0 ? esc(number_format((float) ($row->amount ?? 0), 2)) : '' ?>credit_debit ?? 0) === 1 ? esc(number_format((float) ($row->amount ?? 0), 2)) : '' ?>
+ + diff --git a/app/Views/medical/supplier_edit.php b/app/Views/medical/supplier_edit.php new file mode 100644 index 0000000..e5da5bb --- /dev/null +++ b/app/Views/medical/supplier_edit.php @@ -0,0 +1,103 @@ +sid ?? 0); + $nameSupplier = (string) ($row->name_supplier ?? ''); + $shortName = (string) ($row->short_name ?? ''); + $contactNo = (string) ($row->contact_no ?? ''); + $gstNo = (string) ($row->gst_no ?? ''); + $city = (string) ($row->city ?? ''); + $state = (string) ($row->state ?? ''); + $active = (int) ($row->active ?? 1); +} +?> + +
+
Supplier
+
+
+ +
+ + + +
+ + +
+
+ + +
+ +
+ + +
+
+ + +
+ +
+ + +
+
+ + +
+ +
+
+ > + +
+
+ +
+ +
+
+
+
+ + diff --git a/app/Views/medical/supplier_master.php b/app/Views/medical/supplier_master.php new file mode 100644 index 0000000..2d4f773 --- /dev/null +++ b/app/Views/medical/supplier_master.php @@ -0,0 +1,17 @@ +
+
+
+
Supplier Master
+ +
+ +
+
+
+ $supplier_data ?? []]) ?> +
+
+
+
+
+
diff --git a/app/Views/medical/supplier_master_sub.php b/app/Views/medical/supplier_master_sub.php new file mode 100644 index 0000000..f5f337c --- /dev/null +++ b/app/Views/medical/supplier_master_sub.php @@ -0,0 +1,34 @@ + + + + + + + + + + + + + + + + + +
NameGSTAction
name_supplier ?? '') ?>gst_no ?? '') ?> + +
+ + diff --git a/app/Views/medical/uhid_report_pdf.php b/app/Views/medical/uhid_report_pdf.php new file mode 100644 index 0000000..997d560 --- /dev/null +++ b/app/Views/medical/uhid_report_pdf.php @@ -0,0 +1,155 @@ + 0, 'paid' => 0, 'balance' => 0]; + +$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 : ''; +$pharmacyGst = defined('H_Med_GST') ? (string) H_Med_GST : ''; + +$patientName = (string) ($patient->p_fname ?? '-'); +$patientCode = (string) ($patient->p_code ?? $searchUhid ?: '-'); +?> + + + + + + + +
+
+ + | Phone: + | GST:
+ Print Bill on UHID | Date Range: to | UHID: | Patient: +
+ + + + +
No record found.
+ + + id ?? 0); + $invoiceCode = (string) ($invoice->inv_med_code ?? ('M' . date('ym') . str_pad(substr((string) $invoiceId, -7, 7), 7, '0', STR_PAD_LEFT))); + $invoiceDate = !empty($invoice->inv_date) ? date('d-m-Y', strtotime((string) $invoice->inv_date)) : '-'; + $docName = trim((string) ($invoice->doc_name ?? '-')); + $itemRows = $itemsByInvoice[$invoiceId] ?? []; + $paymentRows = $paymentsByInvoice[$invoiceId] ?? []; + ?> + +
Invoice: | Date: | Doctor:
+ + + + + + + + + + + + + + + + + + + + + $item): ?> + amount ?? 0); + $disc = (float) (($item->disc_amount ?? 0) + ($item->disc_whole ?? 0)); + $net = (float) ($item->twdisc_amount ?? $item->tamount ?? $gross); + $cgst = (float) ($item->CGST ?? 0); + $sgst = (float) ($item->SGST ?? 0); + ?> + + + + + + + + + + + + + + + + + + + + + + + + +
#Item NameBatchExp.QtyRateGrossDisc.Inc. GSTNet
No items
item_Name ?? $item->item_name ?? '-') . ' ' . ($item->formulation ?? '')))) ?>batch_no ?? '-')) ?>expiry) ? date('m-Y', strtotime((string) $item->expiry)) : '-') ?>qty ?? 0), 2)) ?>price ?? 0), 2)) ?>
Invoice Totalgross_amount ?? 0), 2)) ?>disc_amount ?? 0) + ($invoice->discount_amount ?? 0)), 2)) ?>CGST_Tamount ?? 0) + ($invoice->SGST_Tamount ?? 0)), 2)) ?>net_amount ?? 0), 2)) ?>
+ + + + + + +
Payment Details: + + payment_mode ?? 1) === 2) ? 'Bank Card' : 'Cash'; + if ((int) ($pay->payment_mode ?? 0) > 2) { + $mode = 'Other'; + } + if ((int) ($pay->credit_debit ?? 0) > 0) { + $mode .= ' Return'; + } + ?> + [id ?? '-')) ?>::amount ?? 0), 2)) ?>] + +
+ + +
+ + + + + + + + + + + + + +
Total Net AmountPaid AmountBalance Amount
+ + + diff --git a/app/Views/org_packing/cases_list.php b/app/Views/org_packing/cases_list.php new file mode 100644 index 0000000..6d08eee --- /dev/null +++ b/app/Views/org_packing/cases_list.php @@ -0,0 +1,66 @@ + +
+ No cases added to this packing yet. Use the search above to add cases. +
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Sr.Case CodeUHIDPatient NameAgeTypeInsurance Co.Insurance NoAction
case_id_code) ?>p_code) ?>p_fname) ?>age) ?> + ipd_opd == 'OPD'): ?> + OPD + + IPD + + insurance_company_name) ?> + insurance_no) ?> + insurance_no_1)): ?> +
insurance_no_1) ?> + +
+ +
+ Total Cases: +
+
+ diff --git a/app/Views/org_packing/create.php b/app/Views/org_packing/create.php new file mode 100644 index 0000000..8b434fe --- /dev/null +++ b/app/Views/org_packing/create.php @@ -0,0 +1,122 @@ + + + + Create New Packing + + + + + +
+
+
+
+
+
+ Create New Packing +
+
+
+
+
+
+ + +
+
+ + +
+
+ +
+
+ + +
+
+ +
+
+ + + Cancel + +
+
+
+
+
+
+
+
+ + + + + + diff --git a/app/Views/org_packing/edit.php b/app/Views/org_packing/edit.php new file mode 100644 index 0000000..5765cd5 --- /dev/null +++ b/app/Views/org_packing/edit.php @@ -0,0 +1,231 @@ + + + + Edit Packing + + + + + + + +
+
+
+
+
+
+ Edit Packing: label_no) ?> +
+
+
+ +
+
Packing Details
+
+ +
+
+
+ + +
+
+ + +
+
+ + +
+
+ +
+
+ + + Back to List + + + Print List + +
+
+
+ +
+ + +
+
Add Cases to Packing
+
+ +
+
+ + +
+
+ +
+
+ +
+ + +
+
Cases in this Packing
+
+ +
+ $cases, 'packing_id' => $packing_id]) ?> +
+
+
+
+
+
+ + + + + + + diff --git a/app/Views/org_packing/index.php b/app/Views/org_packing/index.php new file mode 100644 index 0000000..973215e --- /dev/null +++ b/app/Views/org_packing/index.php @@ -0,0 +1,130 @@ + + + + Organization Packing Management + + + + + +
+
+
+
+
+
+ Organization Packing Management +
+
+
+ + +
+
+
+
+ + +
+
+
+
+ +
+ +
+
+ Enter search term or leave blank to show recent packings +
+
+
+
+
+
+
+ + + + + + diff --git a/app/Views/org_packing/print_ipd.php b/app/Views/org_packing/print_ipd.php new file mode 100644 index 0000000..a40bf4f --- /dev/null +++ b/app/Views/org_packing/print_ipd.php @@ -0,0 +1,137 @@ + + + + IPD Packing List - <?= esc($packing->label_no) ?> + + + + +
+ +
+ + +
+ + +
+

IPD TPA PACKING LIST

+

Label No: label_no) ?> | + Date: date_of_create)) ?>

+
+ + +
+
+
+ Total Cases: +
+
+ Type: IPD TPA Cases +
+
+
+ + + + + + + + + + + + + + + + + + + + claim_amt; + ?> + + + + + + + + + + + + + + + + + + + + +
Sr.Case CodeIPD CodeUHIDPatient NameAgeAdmit DateDischarge DateInsurance NoClaim Amount
case_id_code) ?>ipd_code ?? '-') ?>p_code) ?>p_fname) ?>age) ?>admit_date ?? '-') ?>discharge_date ?? '-') ?> + insurance_no) ?> + insurance_no_1)): ?> +
insurance_no_1) ?> + +
claim_amt, 2) ?>
Total Claim Amount:
+ +
No cases in this packing
+ + + +
+
+ Prepared By
+ +
+
+ Verified By +
+
+ Approved By +
+
+
+ + + + diff --git a/app/Views/org_packing/print_opd.php b/app/Views/org_packing/print_opd.php new file mode 100644 index 0000000..212060e --- /dev/null +++ b/app/Views/org_packing/print_opd.php @@ -0,0 +1,133 @@ + + + + OPD Packing List - <?= esc($packing->label_no) ?> + + + + +
+ +
+ + +
+ + +
+

OPD ORGANIZATION PACKING LIST

+

Label No: label_no) ?> | + Date: date_of_create)) ?>

+
+ + +
+
+
+ Total Cases: +
+
+ Type: OPD Organization Cases +
+
+
+ + + + + + + + + + + + + + + + + + claim_amt; + ?> + + + + + + + + + + + + + + + + + + +
Sr.Case CodeUHIDPatient NameAgeOPD DateInsurance NoClaim Amount
case_id_code) ?>p_code) ?>p_fname) ?>age) ?>opd_date ?? '-') ?> + insurance_no) ?> + insurance_no_1)): ?> +
insurance_no_1) ?> + +
claim_amt, 2) ?>
Total Claim Amount:
+ +
No cases in this packing
+ + + +
+
+ Prepared By
+ +
+
+ Verified By +
+
+ Approved By +
+
+
+ + + + diff --git a/app/Views/org_packing/search_result.php b/app/Views/org_packing/search_result.php new file mode 100644 index 0000000..1b1aaf7 --- /dev/null +++ b/app/Views/org_packing/search_result.php @@ -0,0 +1,67 @@ + +
+ No packing records found +
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + +
Sr.Label NoDate CreatedTypeNo. of CasesStatusActions
label_no) ?>date_created) ?> + list_type == 'OPD'): ?> + list_type ?> + + list_type ?> + + no_records ?> + files_status == 1): ?> + Completed + + Pending + + + +
+
+
+ Showing packing record(s) +
+ diff --git a/app/Views/partials/header.php b/app/Views/partials/header.php new file mode 100644 index 0000000..a091ba8 --- /dev/null +++ b/app/Views/partials/header.php @@ -0,0 +1,78 @@ + \ No newline at end of file diff --git a/app/Views/partials/sidebar.php b/app/Views/partials/sidebar.php new file mode 100644 index 0000000..5cba00d --- /dev/null +++ b/app/Views/partials/sidebar.php @@ -0,0 +1,215 @@ +user() : null; +$canTemplate = false; +if ($user && method_exists($user, 'can')) { + $canTemplate = $user->can('template.pathology') + || $user->can('template.ultrasound') + || $user->can('template.xray') + || $user->can('template.ct') + || $user->can('template.mri') + || $user->can('template.echo') + || $user->can('template.*'); +} + +if (! $canTemplate && $user && method_exists($user, 'inGroup')) { + $canTemplate = $user->inGroup('superadmin', 'admin', 'developer'); +} + +$canIpdBilling = $user && method_exists($user, 'can') + ? ($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.access')) + : false; + +$canPharmacy = true; +if ($user && method_exists($user, 'can')) { + $canPharmacy = $user->can('pharmacy.access') + || $user->can('billing.access'); +} + +if (! $canPharmacy && $user && method_exists($user, 'inGroup')) { + $canPharmacy = $user->inGroup('superadmin', 'admin', 'developer'); +} +?> + \ No newline at end of file diff --git a/app/Views/report/collection_report.php b/app/Views/report/collection_report.php new file mode 100644 index 0000000..020c4b3 --- /dev/null +++ b/app/Views/report/collection_report.php @@ -0,0 +1,116 @@ + +
+
+
+
Collection Report
+
+
+
+
+ +
+ + +
+
+
+ + +
+
+ + +
+
+ +
+ + +
+
+
+ +
+
+
Select filters and click Show.
+
+
+
+ + diff --git a/app/Views/report/collection_report_table.php b/app/Views/report/collection_report_table.php new file mode 100644 index 0000000..6b58758 --- /dev/null +++ b/app/Views/report/collection_report_table.php @@ -0,0 +1,59 @@ + + +

Date(YYYY-MM-DD h:m) between and

+ + +
No records found for the selected filters.
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
PayIDDateType of PaymentOPD/IPD/In. CodePay ModeAmt (Cr.)Amt (Dr.)Bank/SourceRemarkEmployee
pay_id ?? '') ?>str_payment_date ?? '') ?>pay_type ?? '') ?>payof_code ?? '') . ' ' . ($row->patient_name ?? '')) ?>pay_mode ?? '') ?>cr_amount ?? 0), 2)) ?>dr_amount ?? 0), 2)) ?>bank_name ?? '') . ' ' . ($row->bank_type ?? ''))) ?>remark ?? '') ?>update_by ?? '') ?>
Total
+ +

Total Amount :

+ diff --git a/app/Views/report/diagnosis_report.php b/app/Views/report/diagnosis_report.php new file mode 100644 index 0000000..eaf7273 --- /dev/null +++ b/app/Views/report/diagnosis_report.php @@ -0,0 +1,116 @@ + +
+
+
+
Diagnosis Report
+
+
+
+
+ +
+ + +
+
+
+ + +
+
+ + +
+
+ +
+ + +
+
+
+ +
+
+
Select filters and click Show.
+
+
+
+ + diff --git a/app/Views/report/diagnosis_report_table.php b/app/Views/report/diagnosis_report_table.php new file mode 100644 index 0000000..eeaeba9 --- /dev/null +++ b/app/Views/report/diagnosis_report_table.php @@ -0,0 +1,111 @@ + + +
+

Date Range: to

+

Invoice Type:

+
+ + +
No data found for the selected criteria.
+ + + + + + + + + + + + + + group_desc ?? ''; + $itemName = $row->item_name ?? ''; + $noQty = (float) ($row->no_qty ?? 0); + $totalAmount = (float) ($row->total_amount ?? 0); + $totalActAmount = (float) ($row->total_act_amount ?? 0); + + // Diagnosis group header + if ($groupDesc !== $diagnosisHead) { + // Show previous group total if not first group + if ($diagnosisHead !== '') { + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + + $diagnosisHeadTotal = 0.0; + $diagnosisActHeadTotal = 0.0; + $diagnosisQtyTotal = 0.0; + } + + echo ''; + echo ''; + echo ''; + $diagnosisHead = $groupDesc; + } + + // Item row + $rowNum++; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + + // Update totals + $diagnosisHeadTotal += $totalAmount; + $diagnosisActHeadTotal += $totalActAmount; + $diagnosisQtyTotal += $noQty; + $grandTotal += $totalAmount; + $grandActTotal += $totalActAmount; + $grandQtyTotal += $noQty; + } + + // Show last group total + if ($diagnosisHead !== '' && $rowCount > 0) { + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + } + ?> + + + + + + + + + +
#Diagnosis GroupTest NameNo. of QtyAmountCost Amt
Total of ' . esc($diagnosisHead) . '' . number_format($diagnosisQtyTotal, 0) . '' . number_format($diagnosisHeadTotal, 2) . '' . number_format($diagnosisActHeadTotal, 2) . '
' . esc($groupDesc) . '
' . $rowNum . '' . esc($itemName) . '' . number_format($noQty, 0) . '' . number_format($totalAmount, 2) . '' . number_format($totalActAmount, 2) . '
Total of ' . esc($diagnosisHead) . '' . number_format($diagnosisQtyTotal, 0) . '' . number_format($diagnosisHeadTotal, 2) . '' . number_format($diagnosisActHeadTotal, 2) . '
Grand Total
+ diff --git a/app/Views/report/insurance_combined_report.php b/app/Views/report/insurance_combined_report.php new file mode 100644 index 0000000..5778ebb --- /dev/null +++ b/app/Views/report/insurance_combined_report.php @@ -0,0 +1,111 @@ + +
+
+
+
+ Combined Insurance Summary Report +
+ +
+
+
+
+ +
+ + +
+
+
+ + +
+
+ + +
+
+ +
+
+ +
+ +
+
+
+ +
+
+
+
+ +

Select filters and click Show to generate report

+
+
+
+
+
+ + diff --git a/app/Views/report/insurance_combined_report_table.php b/app/Views/report/insurance_combined_report_table.php new file mode 100644 index 0000000..b000ce4 --- /dev/null +++ b/app/Views/report/insurance_combined_report_table.php @@ -0,0 +1,186 @@ + + +
+

Date Range: to

+
+ + +
No data found for the selected criteria.
+ + + +
+ OPD Organization Cases Summary +
+ + + + + + + + + + + + + $row) { + $cases = (int) ($row->total_cases ?? 0); + $charge = (float) ($row->total_charge ?? 0); + $med = (float) ($row->total_med ?? 0); + $net = (float) ($row->total_net ?? 0); + + $opdTotalCases += $cases; + $opdTotalCharge += $charge; + $opdTotalMed += $med; + $opdTotalNet += $net; + + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + } + ?> + + + + + + + + + + +
#Insurance CompanyTotal CasesTotal ChargeTotal MedicineTotal Net
' . ($index + 1) . '' . esc($row->insurance_company ?? '') . '' . number_format($cases) . '' . number_format($charge, 2) . '' . number_format($med, 2) . '' . number_format($net, 2) . '
OPD Total:
+ + + +
+ IPD TPA Cases Summary +
+ + + + + + + + + + + + + + + + + $row) { + $cases = (int) ($row->total_cases ?? 0); + $charge = (float) ($row->total_charge ?? 0); + $med = (float) ($row->total_med ?? 0); + $discount = (float) ($row->total_discount ?? 0); + $net = (float) ($row->total_net ?? 0); + $received = (float) ($row->total_received ?? 0); + $deducted = (float) ($row->total_deducted ?? 0); + $balance = $net - $received; + + $ipdTotalCases += $cases; + $ipdTotalCharge += $charge; + $ipdTotalMed += $med; + $ipdTotalDiscount += $discount; + $ipdTotalNet += $net; + $ipdTotalReceived += $received; + $ipdTotalDeducted += $deducted; + + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + } + ?> + + + + + + + + + + + + + + +
#Insurance CompanyCasesChargeMedicineDiscountNetReceivedDeductedBalance
' . ($index + 1) . '' . esc($row->insurance_company ?? '') . '' . number_format($cases) . '' . number_format($charge, 2) . '' . number_format($med, 2) . '' . number_format($discount, 2) . '' . number_format($net, 2) . '' . number_format($received, 2) . '' . number_format($deducted, 2) . '' . number_format($balance, 2) . '
IPD Total:
+ + + +
+
+
+ Grand Summary +
+
+
+ + + + + + + + + +
Total Cases (OPD + IPD):
Total Net Amount:
+
+
+ + + + + + + + + +
IPD Amount Received:
IPD Balance Pending:
+
+
+
+
+ + + diff --git a/app/Views/report/insurance_credit_main.php b/app/Views/report/insurance_credit_main.php new file mode 100644 index 0000000..1f270ed --- /dev/null +++ b/app/Views/report/insurance_credit_main.php @@ -0,0 +1,100 @@ +
+
+
+
Insurance Credit Reports
+
+
+

Select a report type to view insurance credit details

+ +
+ +
+
+
+
+ +
+
OPD Organization Cases
+

+ View OPD cases submitted to insurance organizations +

+ +
+
+
+ + +
+
+
+
+ +
+
IPD TPA Cases
+

+ View IPD cases submitted to TPA/Insurance companies +

+ +
+
+
+ + +
+
+
+
+ +
+
Combined Summary
+

+ View combined OPD & IPD insurance summary +

+ +
+
+
+
+ +
+
+
+
+
+ Report Information +
+
    +
  • OPD Organization Cases: Shows outpatient cases with insurance coverage (case_type = 0)
  • +
  • IPD TPA Cases: Shows inpatient cases with TPA/insurance coverage (case_type = 1)
  • +
  • Combined Summary: Consolidated view of all insurance cases with totals
  • +
  • Status Types: Pending (0), Bill Complete (1), Submitted to Organization (2)
  • +
+
+
+
+
+
+
+
+ + diff --git a/app/Views/report/insurance_ipd_report.php b/app/Views/report/insurance_ipd_report.php new file mode 100644 index 0000000..36fe945 --- /dev/null +++ b/app/Views/report/insurance_ipd_report.php @@ -0,0 +1,112 @@ + +
+
+
+
+ IPD TPA Cases Report +
+ +
+
+
+
+ +
+ + +
+
+
+ + +
+
+ + +
+
+ +
+
+ +
+ +
+
+
+ +
+
+
+
+ +

Select filters and click Show to generate report

+
+
+
+
+
+ + diff --git a/app/Views/report/insurance_ipd_report_table.php b/app/Views/report/insurance_ipd_report_table.php new file mode 100644 index 0000000..ffde03c --- /dev/null +++ b/app/Views/report/insurance_ipd_report_table.php @@ -0,0 +1,100 @@ + + +
+

Date Range: to

+

Type: TPA Cases

+
+ + +
No data found for the selected criteria.
+ + + + + + + + + + + + + + + + + + + + + + + $row) { + $chargeAmt = (float) ($row->charge_amount ?? 0); + $medAmt = (float) ($row->med_amount ?? 0); + $discount = (float) ($row->discount ?? 0); + $netAmt = (float) ($row->net_amount ?? 0); + $received = (float) ($row->amount_recived ?? 0); + $deducted = (float) ($row->amount_deduction ?? 0); + + $totalCharge += $chargeAmt; + $totalMed += $medAmt; + $totalDiscount += $discount; + $totalNet += $netAmt; + $totalReceived += $received; + $totalDeducted += $deducted; + + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + } + ?> + + + + + + + + + + + + + + + + + + + + +
#Case InfoIPD CodeUHIDPatient NameInsuranceStatusAdmit DateDischargeChargeMedDisc.Net AmtReceivedDeducted
' . ($index + 1) . '' . esc($row->case_info ?? '') . '' . esc($row->ipd_code ?? '') . '' . esc($row->p_code ?? '') . '' . esc($row->p_fname ?? '') . '' . esc($row->insurance_company ?? '') . '' . esc($row->org_submit_status ?? '') . '' . esc($row->str_register_date ?? '') . '' . esc($row->str_discharge_date ?? '-') . '' . number_format($chargeAmt, 2) . '' . number_format($medAmt, 2) . '' . number_format($discount, 2) . '' . number_format($netAmt, 2) . '' . number_format($received, 2) . '' . number_format($deducted, 2) . '
Total:
Total Cases:
Balance (Net - Received):
+ diff --git a/app/Views/report/insurance_opd_report.php b/app/Views/report/insurance_opd_report.php new file mode 100644 index 0000000..1348f0c --- /dev/null +++ b/app/Views/report/insurance_opd_report.php @@ -0,0 +1,112 @@ + +
+
+
+
+ OPD Organization Cases Report +
+ +
+
+
+
+ +
+ + +
+
+
+ + +
+
+ + +
+
+ +
+
+ +
+ +
+
+
+ +
+
+
+
+ +

Select filters and click Show to generate report

+
+
+
+
+
+ + diff --git a/app/Views/report/insurance_opd_report_table.php b/app/Views/report/insurance_opd_report_table.php new file mode 100644 index 0000000..259d458 --- /dev/null +++ b/app/Views/report/insurance_opd_report_table.php @@ -0,0 +1,78 @@ + + +
+

Date Range: to

+

Type: Organization Cases

+
+ + +
No data found for the selected criteria.
+ + + + + + + + + + + + + + + + + + + + $row) { + $chargeAmt = (float) ($row->charge_amount ?? 0); + $medAmt = (float) ($row->med_amount ?? 0); + $netAmt = (float) ($row->net_amount ?? 0); + + $totalCharge += $chargeAmt; + $totalMed += $medAmt; + $totalNet += $netAmt; + + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + } + ?> + + + + + + + + + + + + + +
#Bill No.Case InfoOrg. CodeUHIDPatient NameInsurance CompanyDateStatusCharge AmtMed AmtNet Amt
' . ($index + 1) . '' . esc($row->id ?? '') . '' . esc($row->case_info ?? '') . '' . esc($row->case_id_code ?? '') . '' . esc($row->p_code ?? '') . '' . esc($row->p_fname ?? '') . '' . esc($row->insurance_company ?? '') . '' . esc($row->str_date_registration ?? '') . '' . esc($row->org_submit_status ?? '') . '' . number_format($chargeAmt, 2) . '' . number_format($medAmt, 2) . '' . number_format($netAmt, 2) . '
Total:
Total Cases:
+ diff --git a/app/Views/welcome_message.php b/app/Views/welcome_message.php new file mode 100644 index 0000000..9e36c00 --- /dev/null +++ b/app/Views/welcome_message.php @@ -0,0 +1,264 @@ + + + + + + + + Welcome + + + + + + + + + + + + + + + + + + + + + + + + + + + + user(); ?> + + + + + +
+ +
+ + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/index.html b/app/index.html new file mode 100644 index 0000000..69df4e1 --- /dev/null +++ b/app/index.html @@ -0,0 +1,11 @@ + + + + 403 Forbidden + + + +

Directory access is forbidden.

+ + + diff --git a/builds b/builds new file mode 100644 index 0000000..cc2ca08 --- /dev/null +++ b/builds @@ -0,0 +1,125 @@ +#!/usr/bin/env php + 'vcs', + 'url' => GITHUB_URL, + ]; + } + + $array['require']['codeigniter4/codeigniter4'] = 'dev-develop'; + unset($array['require']['codeigniter4/framework']); + } else { + unset($array['minimum-stability']); + + if (isset($array['repositories'])) { + foreach ($array['repositories'] as $i => $repository) { + if ($repository['url'] === GITHUB_URL) { + unset($array['repositories'][$i]); + break; + } + } + + if (empty($array['repositories'])) { + unset($array['repositories']); + } + } + + $array['require']['codeigniter4/framework'] = LATEST_RELEASE; + unset($array['require']['codeigniter4/codeigniter4']); + } + + file_put_contents($file, json_encode($array, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES) . PHP_EOL); + + $modified[] = $file; + } else { + echo 'Warning: Unable to decode composer.json! Skipping...' . PHP_EOL; + } + } else { + echo 'Warning: Unable to read composer.json! Skipping...' . PHP_EOL; + } +} + +$files = [ + __DIR__ . DIRECTORY_SEPARATOR . 'app/Config/Paths.php', + __DIR__ . DIRECTORY_SEPARATOR . 'phpunit.xml.dist', + __DIR__ . DIRECTORY_SEPARATOR . 'phpunit.xml', +]; + +foreach ($files as $file) { + if (is_file($file)) { + $contents = file_get_contents($file); + + if ($dev) { + $contents = str_replace('vendor/codeigniter4/framework', 'vendor/codeigniter4/codeigniter4', $contents); + } else { + $contents = str_replace('vendor/codeigniter4/codeigniter4', 'vendor/codeigniter4/framework', $contents); + } + + file_put_contents($file, $contents); + + $modified[] = $file; + } +} + +if ($modified === []) { + echo 'No files modified.' . PHP_EOL; +} else { + echo 'The following files were modified:' . PHP_EOL; + + foreach ($modified as $file) { + echo " * {$file}" . PHP_EOL; + } + + echo 'Run `composer update` to sync changes with your vendor folder.' . PHP_EOL; +} diff --git a/composer.json b/composer.json new file mode 100644 index 0000000..94c54ff --- /dev/null +++ b/composer.json @@ -0,0 +1,46 @@ +{ + "name": "codeigniter4/appstarter", + "description": "CodeIgniter4 starter app", + "license": "MIT", + "type": "project", + "homepage": "https://codeigniter.com", + "support": { + "forum": "https://forum.codeigniter.com/", + "source": "https://github.com/codeigniter4/CodeIgniter4", + "slack": "https://codeigniterchat.slack.com" + }, + "require": { + "php": "^8.2", + "codeigniter4/framework": "^4.7", + "codeigniter4/shield": "^1.2", + "mpdf/mpdf": "^8.2", + "mpdf/qrcode": "^1.2" + }, + "require-dev": { + "fakerphp/faker": "^1.9", + "mikey179/vfsstream": "^1.6", + "phpunit/phpunit": "^10.5.16" + }, + "autoload": { + "psr-4": { + "App\\": "app/", + "Config\\": "app/Config/" + }, + "exclude-from-classmap": [ + "**/Database/Migrations/**" + ] + }, + "autoload-dev": { + "psr-4": { + "Tests\\Support\\": "tests/_support" + } + }, + "config": { + "optimize-autoloader": true, + "preferred-install": "dist", + "sort-packages": true + }, + "scripts": { + "test": "phpunit" + } +} diff --git a/composer.lock b/composer.lock new file mode 100644 index 0000000..d933b6e --- /dev/null +++ b/composer.lock @@ -0,0 +1,2656 @@ +{ + "_readme": [ + "This file locks the dependencies of your project to a known state", + "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", + "This file is @generated automatically" + ], + "content-hash": "b1a7e3eeff0fc159e79f74e5ddedf77e", + "packages": [ + { + "name": "codeigniter4/framework", + "version": "v4.7.0", + "source": { + "type": "git", + "url": "https://github.com/codeigniter4/framework.git", + "reference": "e7753bc03f8b74af428f46b5e2bb74925487c930" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/codeigniter4/framework/zipball/e7753bc03f8b74af428f46b5e2bb74925487c930", + "reference": "e7753bc03f8b74af428f46b5e2bb74925487c930", + "shasum": "" + }, + "require": { + "ext-intl": "*", + "ext-mbstring": "*", + "laminas/laminas-escaper": "^2.18", + "php": "^8.2", + "psr/log": "^3.0" + }, + "require-dev": { + "codeigniter/coding-standard": "^1.7", + "fakerphp/faker": "^1.24", + "friendsofphp/php-cs-fixer": "^3.47.1", + "kint-php/kint": "^6.1", + "mikey179/vfsstream": "^1.6.12", + "nexusphp/cs-config": "^3.6", + "phpunit/phpunit": "^10.5.16 || ^11.2", + "predis/predis": "^3.0" + }, + "suggest": { + "ext-apcu": "If you use Cache class ApcuHandler", + "ext-curl": "If you use CURLRequest class", + "ext-dom": "If you use TestResponse", + "ext-exif": "If you run Image class tests", + "ext-fileinfo": "Improves mime type detection for files", + "ext-gd": "If you use Image class GDHandler", + "ext-imagick": "If you use Image class ImageMagickHandler", + "ext-libxml": "If you use TestResponse", + "ext-memcache": "If you use Cache class MemcachedHandler with Memcache", + "ext-memcached": "If you use Cache class MemcachedHandler with Memcached", + "ext-mysqli": "If you use MySQL", + "ext-oci8": "If you use Oracle Database", + "ext-pcntl": "If you use Signals", + "ext-pgsql": "If you use PostgreSQL", + "ext-posix": "If you use Signals", + "ext-readline": "Improves CLI::input() usability", + "ext-redis": "If you use Cache class RedisHandler", + "ext-simplexml": "If you format XML", + "ext-sodium": "If you use Encryption SodiumHandler", + "ext-sqlite3": "If you use SQLite3", + "ext-sqlsrv": "If you use SQL Server", + "ext-xdebug": "If you use CIUnitTestCase::assertHeaderEmitted()" + }, + "type": "project", + "autoload": { + "psr-4": { + "CodeIgniter\\": "system/" + }, + "exclude-from-classmap": [ + "**/Database/Migrations/**" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "description": "The CodeIgniter framework v4", + "homepage": "https://codeigniter.com", + "support": { + "forum": "https://forum.codeigniter.com/", + "slack": "https://codeigniterchat.slack.com", + "source": "https://github.com/codeigniter4/CodeIgniter4" + }, + "time": "2026-02-01T20:39:35+00:00" + }, + { + "name": "codeigniter4/settings", + "version": "v2.2.0", + "source": { + "type": "git", + "url": "https://github.com/codeigniter4/settings.git", + "reference": "2748f2b4572d44a940f98c31847d65272cac5666" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/codeigniter4/settings/zipball/2748f2b4572d44a940f98c31847d65272cac5666", + "reference": "2748f2b4572d44a940f98c31847d65272cac5666", + "shasum": "" + }, + "require": { + "php": "^7.4 || ^8.0" + }, + "require-dev": { + "codeigniter4/devkit": "^1.1.2", + "codeigniter4/framework": "^4.2.3", + "rector/rector": "0.18.13" + }, + "type": "library", + "autoload": { + "psr-4": { + "CodeIgniter\\Settings\\": "src" + }, + "exclude-from-classmap": [ + "**/Database/Migrations/**" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Lonnie Ezell", + "email": "lonnieje@gmail.com", + "role": "Developer" + } + ], + "description": "Settings library for CodeIgniter 4", + "homepage": "https://github.com/codeigniter4/settings", + "keywords": [ + "Settings", + "codeigniter", + "codeigniter4" + ], + "support": { + "issues": "https://github.com/codeigniter4/settings/issues", + "source": "https://github.com/codeigniter4/settings/tree/v2.2.0" + }, + "time": "2024-01-06T07:10:58+00:00" + }, + { + "name": "codeigniter4/shield", + "version": "v1.2.0", + "source": { + "type": "git", + "url": "https://github.com/codeigniter4/shield.git", + "reference": "2d1b2177a914dcd490f54a6706792eacabd9e3e8" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/codeigniter4/shield/zipball/2d1b2177a914dcd490f54a6706792eacabd9e3e8", + "reference": "2d1b2177a914dcd490f54a6706792eacabd9e3e8", + "shasum": "" + }, + "require": { + "codeigniter4/settings": "^2.1", + "php": "^8.1" + }, + "provide": { + "codeigniter4/authentication-implementation": "1.0" + }, + "require-dev": { + "codeigniter/phpstan-codeigniter": "^1.3", + "codeigniter4/devkit": "^1.3", + "codeigniter4/framework": ">=4.3.5 <4.5.0 || ^4.5.1", + "firebase/php-jwt": "^6.4", + "mikey179/vfsstream": "^1.6.7", + "mockery/mockery": "^1.0", + "phpstan/phpstan-strict-rules": "^2.0" + }, + "suggest": { + "ext-curl": "Required to use the password validation rule via PwnedValidator class.", + "ext-openssl": "Required to use the JWT Authenticator." + }, + "type": "library", + "autoload": { + "psr-4": { + "CodeIgniter\\Shield\\": "src" + }, + "exclude-from-classmap": [ + "**/Database/Migrations/**" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Lonnie Ezell", + "email": "lonnieje@gmail.com", + "role": "Developer" + } + ], + "description": "Authentication and Authorization for CodeIgniter 4", + "homepage": "https://github.com/codeigniter4/shield", + "keywords": [ + "Authentication", + "authorization", + "codeigniter", + "codeigniter4" + ], + "support": { + "docs": "https://codeigniter4.github.io/shield/", + "forum": "https://github.com/codeigniter4/shield/discussions", + "issues": "https://github.com/codeigniter4/shield/issues", + "slack": "https://codeigniterchat.slack.com", + "source": "https://github.com/codeigniter4/shield" + }, + "time": "2025-07-14T10:26:03+00:00" + }, + { + "name": "laminas/laminas-escaper", + "version": "2.18.0", + "source": { + "type": "git", + "url": "https://github.com/laminas/laminas-escaper.git", + "reference": "06f211dfffff18d91844c1f55250d5d13c007e18" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/laminas/laminas-escaper/zipball/06f211dfffff18d91844c1f55250d5d13c007e18", + "reference": "06f211dfffff18d91844c1f55250d5d13c007e18", + "shasum": "" + }, + "require": { + "ext-ctype": "*", + "ext-mbstring": "*", + "php": "~8.2.0 || ~8.3.0 || ~8.4.0 || ~8.5.0" + }, + "conflict": { + "zendframework/zend-escaper": "*" + }, + "require-dev": { + "infection/infection": "^0.31.0", + "laminas/laminas-coding-standard": "~3.1.0", + "phpunit/phpunit": "^11.5.42", + "psalm/plugin-phpunit": "^0.19.5", + "vimeo/psalm": "^6.13.1" + }, + "type": "library", + "autoload": { + "psr-4": { + "Laminas\\Escaper\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "description": "Securely and safely escape HTML, HTML attributes, JavaScript, CSS, and URLs", + "homepage": "https://laminas.dev", + "keywords": [ + "escaper", + "laminas" + ], + "support": { + "chat": "https://laminas.dev/chat", + "docs": "https://docs.laminas.dev/laminas-escaper/", + "forum": "https://discourse.laminas.dev", + "issues": "https://github.com/laminas/laminas-escaper/issues", + "rss": "https://github.com/laminas/laminas-escaper/releases.atom", + "source": "https://github.com/laminas/laminas-escaper" + }, + "funding": [ + { + "url": "https://funding.communitybridge.org/projects/laminas-project", + "type": "community_bridge" + } + ], + "time": "2025-10-14T18:31:13+00:00" + }, + { + "name": "mpdf/mpdf", + "version": "v8.2.7", + "source": { + "type": "git", + "url": "https://github.com/mpdf/mpdf.git", + "reference": "b59670a09498689c33ce639bac8f5ba26721dab3" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/mpdf/mpdf/zipball/b59670a09498689c33ce639bac8f5ba26721dab3", + "reference": "b59670a09498689c33ce639bac8f5ba26721dab3", + "shasum": "" + }, + "require": { + "ext-gd": "*", + "ext-mbstring": "*", + "mpdf/psr-http-message-shim": "^1.0 || ^2.0", + "mpdf/psr-log-aware-trait": "^2.0 || ^3.0", + "myclabs/deep-copy": "^1.7", + "paragonie/random_compat": "^1.4|^2.0|^9.99.99", + "php": "^5.6 || ^7.0 || ~8.0.0 || ~8.1.0 || ~8.2.0 || ~8.3.0 || ~8.4.0 || ~8.5.0", + "psr/http-message": "^1.0 || ^2.0", + "psr/log": "^1.0 || ^2.0 || ^3.0", + "setasign/fpdi": "^2.1" + }, + "require-dev": { + "mockery/mockery": "^1.3.0", + "mpdf/qrcode": "^1.1.0", + "squizlabs/php_codesniffer": "^3.5.0", + "tracy/tracy": "~2.5", + "yoast/phpunit-polyfills": "^1.0" + }, + "suggest": { + "ext-bcmath": "Needed for generation of some types of barcodes", + "ext-xml": "Needed mainly for SVG manipulation", + "ext-zlib": "Needed for compression of embedded resources, such as fonts" + }, + "type": "library", + "autoload": { + "files": [ + "src/functions.php" + ], + "psr-4": { + "Mpdf\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "GPL-2.0-only" + ], + "authors": [ + { + "name": "Matěj Humpál", + "role": "Developer, maintainer" + }, + { + "name": "Ian Back", + "role": "Developer (retired)" + } + ], + "description": "PHP library generating PDF files from UTF-8 encoded HTML", + "homepage": "https://mpdf.github.io", + "keywords": [ + "pdf", + "php", + "utf-8" + ], + "support": { + "docs": "https://mpdf.github.io", + "issues": "https://github.com/mpdf/mpdf/issues", + "source": "https://github.com/mpdf/mpdf" + }, + "funding": [ + { + "url": "https://www.paypal.me/mpdf", + "type": "custom" + } + ], + "time": "2025-12-01T10:18:02+00:00" + }, + { + "name": "mpdf/psr-http-message-shim", + "version": "v2.0.1", + "source": { + "type": "git", + "url": "https://github.com/mpdf/psr-http-message-shim.git", + "reference": "f25a0153d645e234f9db42e5433b16d9b113920f" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/mpdf/psr-http-message-shim/zipball/f25a0153d645e234f9db42e5433b16d9b113920f", + "reference": "f25a0153d645e234f9db42e5433b16d9b113920f", + "shasum": "" + }, + "require": { + "psr/http-message": "^2.0" + }, + "type": "library", + "autoload": { + "psr-4": { + "Mpdf\\PsrHttpMessageShim\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Mark Dorison", + "email": "mark@chromatichq.com" + }, + { + "name": "Kristofer Widholm", + "email": "kristofer@chromatichq.com" + }, + { + "name": "Nigel Cunningham", + "email": "nigel.cunningham@technocrat.com.au" + } + ], + "description": "Shim to allow support of different psr/message versions.", + "support": { + "issues": "https://github.com/mpdf/psr-http-message-shim/issues", + "source": "https://github.com/mpdf/psr-http-message-shim/tree/v2.0.1" + }, + "time": "2023-10-02T14:34:03+00:00" + }, + { + "name": "mpdf/psr-log-aware-trait", + "version": "v3.0.0", + "source": { + "type": "git", + "url": "https://github.com/mpdf/psr-log-aware-trait.git", + "reference": "a633da6065e946cc491e1c962850344bb0bf3e78" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/mpdf/psr-log-aware-trait/zipball/a633da6065e946cc491e1c962850344bb0bf3e78", + "reference": "a633da6065e946cc491e1c962850344bb0bf3e78", + "shasum": "" + }, + "require": { + "psr/log": "^3.0" + }, + "type": "library", + "autoload": { + "psr-4": { + "Mpdf\\PsrLogAwareTrait\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Mark Dorison", + "email": "mark@chromatichq.com" + }, + { + "name": "Kristofer Widholm", + "email": "kristofer@chromatichq.com" + } + ], + "description": "Trait to allow support of different psr/log versions.", + "support": { + "issues": "https://github.com/mpdf/psr-log-aware-trait/issues", + "source": "https://github.com/mpdf/psr-log-aware-trait/tree/v3.0.0" + }, + "time": "2023-05-03T06:19:36+00:00" + }, + { + "name": "mpdf/qrcode", + "version": "v1.2.2", + "source": { + "type": "git", + "url": "https://github.com/mpdf/qrcode.git", + "reference": "d4fa19117a7241c30ac84902b6236a02c7a3f268" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/mpdf/qrcode/zipball/d4fa19117a7241c30ac84902b6236a02c7a3f268", + "reference": "d4fa19117a7241c30ac84902b6236a02c7a3f268", + "shasum": "" + }, + "require": { + "paragonie/random_compat": "^1.4|^2.0|^9.99.99", + "php": "^5.6 || ^7.0 || ^8.0" + }, + "require-dev": { + "mockery/mockery": "^0.9.5 || ^1.0", + "squizlabs/php_codesniffer": "^3.4", + "tracy/tracy": "^2.5", + "yoast/phpunit-polyfills": "^1.0" + }, + "suggest": { + "ext-gd": "To output QR codes to PNG files", + "ext-simplexml": "To output QR codes to SVG files" + }, + "type": "library", + "autoload": { + "psr-4": { + "Mpdf\\QrCode\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "LGPL-2.1-or-later" + ], + "authors": [ + { + "name": "Matěj Humpál", + "role": "maintainer" + }, + { + "name": "Laurent Minguet", + "role": "author" + } + ], + "description": "QR code generator for mPDF", + "keywords": [ + "mpdf", + "pdf", + "php", + "qr", + "qrcode" + ], + "support": { + "issues": "https://github.com/mpdf/qrcode/issues", + "source": "https://github.com/mpdf/qrcode/tree/v1.2.2" + }, + "funding": [ + { + "url": "https://www.paypal.me/mpdf", + "type": "custom" + } + ], + "time": "2025-12-19T16:21:49+00:00" + }, + { + "name": "myclabs/deep-copy", + "version": "1.13.4", + "source": { + "type": "git", + "url": "https://github.com/myclabs/DeepCopy.git", + "reference": "07d290f0c47959fd5eed98c95ee5602db07e0b6a" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/myclabs/DeepCopy/zipball/07d290f0c47959fd5eed98c95ee5602db07e0b6a", + "reference": "07d290f0c47959fd5eed98c95ee5602db07e0b6a", + "shasum": "" + }, + "require": { + "php": "^7.1 || ^8.0" + }, + "conflict": { + "doctrine/collections": "<1.6.8", + "doctrine/common": "<2.13.3 || >=3 <3.2.2" + }, + "require-dev": { + "doctrine/collections": "^1.6.8", + "doctrine/common": "^2.13.3 || ^3.2.2", + "phpspec/prophecy": "^1.10", + "phpunit/phpunit": "^7.5.20 || ^8.5.23 || ^9.5.13" + }, + "type": "library", + "autoload": { + "files": [ + "src/DeepCopy/deep_copy.php" + ], + "psr-4": { + "DeepCopy\\": "src/DeepCopy/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "description": "Create deep copies (clones) of your objects", + "keywords": [ + "clone", + "copy", + "duplicate", + "object", + "object graph" + ], + "support": { + "issues": "https://github.com/myclabs/DeepCopy/issues", + "source": "https://github.com/myclabs/DeepCopy/tree/1.13.4" + }, + "funding": [ + { + "url": "https://tidelift.com/funding/github/packagist/myclabs/deep-copy", + "type": "tidelift" + } + ], + "time": "2025-08-01T08:46:24+00:00" + }, + { + "name": "paragonie/random_compat", + "version": "v9.99.100", + "source": { + "type": "git", + "url": "https://github.com/paragonie/random_compat.git", + "reference": "996434e5492cb4c3edcb9168db6fbb1359ef965a" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/paragonie/random_compat/zipball/996434e5492cb4c3edcb9168db6fbb1359ef965a", + "reference": "996434e5492cb4c3edcb9168db6fbb1359ef965a", + "shasum": "" + }, + "require": { + "php": ">= 7" + }, + "require-dev": { + "phpunit/phpunit": "4.*|5.*", + "vimeo/psalm": "^1" + }, + "suggest": { + "ext-libsodium": "Provides a modern crypto API that can be used to generate random bytes." + }, + "type": "library", + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Paragon Initiative Enterprises", + "email": "security@paragonie.com", + "homepage": "https://paragonie.com" + } + ], + "description": "PHP 5.x polyfill for random_bytes() and random_int() from PHP 7", + "keywords": [ + "csprng", + "polyfill", + "pseudorandom", + "random" + ], + "support": { + "email": "info@paragonie.com", + "issues": "https://github.com/paragonie/random_compat/issues", + "source": "https://github.com/paragonie/random_compat" + }, + "time": "2020-10-15T08:29:30+00:00" + }, + { + "name": "psr/http-message", + "version": "2.0", + "source": { + "type": "git", + "url": "https://github.com/php-fig/http-message.git", + "reference": "402d35bcb92c70c026d1a6a9883f06b2ead23d71" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/php-fig/http-message/zipball/402d35bcb92c70c026d1a6a9883f06b2ead23d71", + "reference": "402d35bcb92c70c026d1a6a9883f06b2ead23d71", + "shasum": "" + }, + "require": { + "php": "^7.2 || ^8.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.0.x-dev" + } + }, + "autoload": { + "psr-4": { + "Psr\\Http\\Message\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "PHP-FIG", + "homepage": "https://www.php-fig.org/" + } + ], + "description": "Common interface for HTTP messages", + "homepage": "https://github.com/php-fig/http-message", + "keywords": [ + "http", + "http-message", + "psr", + "psr-7", + "request", + "response" + ], + "support": { + "source": "https://github.com/php-fig/http-message/tree/2.0" + }, + "time": "2023-04-04T09:54:51+00:00" + }, + { + "name": "psr/log", + "version": "3.0.2", + "source": { + "type": "git", + "url": "https://github.com/php-fig/log.git", + "reference": "f16e1d5863e37f8d8c2a01719f5b34baa2b714d3" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/php-fig/log/zipball/f16e1d5863e37f8d8c2a01719f5b34baa2b714d3", + "reference": "f16e1d5863e37f8d8c2a01719f5b34baa2b714d3", + "shasum": "" + }, + "require": { + "php": ">=8.0.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "3.x-dev" + } + }, + "autoload": { + "psr-4": { + "Psr\\Log\\": "src" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "PHP-FIG", + "homepage": "https://www.php-fig.org/" + } + ], + "description": "Common interface for logging libraries", + "homepage": "https://github.com/php-fig/log", + "keywords": [ + "log", + "psr", + "psr-3" + ], + "support": { + "source": "https://github.com/php-fig/log/tree/3.0.2" + }, + "time": "2024-09-11T13:17:53+00:00" + }, + { + "name": "setasign/fpdi", + "version": "v2.6.4", + "source": { + "type": "git", + "url": "https://github.com/Setasign/FPDI.git", + "reference": "4b53852fde2734ec6a07e458a085db627c60eada" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/Setasign/FPDI/zipball/4b53852fde2734ec6a07e458a085db627c60eada", + "reference": "4b53852fde2734ec6a07e458a085db627c60eada", + "shasum": "" + }, + "require": { + "ext-zlib": "*", + "php": "^7.1 || ^8.0" + }, + "conflict": { + "setasign/tfpdf": "<1.31" + }, + "require-dev": { + "phpunit/phpunit": "^7", + "setasign/fpdf": "~1.8.6", + "setasign/tfpdf": "~1.33", + "squizlabs/php_codesniffer": "^3.5", + "tecnickcom/tcpdf": "^6.8" + }, + "suggest": { + "setasign/fpdf": "FPDI will extend this class but as it is also possible to use TCPDF or tFPDF as an alternative. There's no fixed dependency configured." + }, + "type": "library", + "autoload": { + "psr-4": { + "setasign\\Fpdi\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Jan Slabon", + "email": "jan.slabon@setasign.com", + "homepage": "https://www.setasign.com" + }, + { + "name": "Maximilian Kresse", + "email": "maximilian.kresse@setasign.com", + "homepage": "https://www.setasign.com" + } + ], + "description": "FPDI is a collection of PHP classes facilitating developers to read pages from existing PDF documents and use them as templates in FPDF. Because it is also possible to use FPDI with TCPDF, there are no fixed dependencies defined. Please see suggestions for packages which evaluates the dependencies automatically.", + "homepage": "https://www.setasign.com/fpdi", + "keywords": [ + "fpdf", + "fpdi", + "pdf" + ], + "support": { + "issues": "https://github.com/Setasign/FPDI/issues", + "source": "https://github.com/Setasign/FPDI/tree/v2.6.4" + }, + "funding": [ + { + "url": "https://tidelift.com/funding/github/packagist/setasign/fpdi", + "type": "tidelift" + } + ], + "time": "2025-08-05T09:57:14+00:00" + } + ], + "packages-dev": [ + { + "name": "fakerphp/faker", + "version": "v1.24.1", + "source": { + "type": "git", + "url": "https://github.com/FakerPHP/Faker.git", + "reference": "e0ee18eb1e6dc3cda3ce9fd97e5a0689a88a64b5" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/FakerPHP/Faker/zipball/e0ee18eb1e6dc3cda3ce9fd97e5a0689a88a64b5", + "reference": "e0ee18eb1e6dc3cda3ce9fd97e5a0689a88a64b5", + "shasum": "" + }, + "require": { + "php": "^7.4 || ^8.0", + "psr/container": "^1.0 || ^2.0", + "symfony/deprecation-contracts": "^2.2 || ^3.0" + }, + "conflict": { + "fzaninotto/faker": "*" + }, + "require-dev": { + "bamarni/composer-bin-plugin": "^1.4.1", + "doctrine/persistence": "^1.3 || ^2.0", + "ext-intl": "*", + "phpunit/phpunit": "^9.5.26", + "symfony/phpunit-bridge": "^5.4.16" + }, + "suggest": { + "doctrine/orm": "Required to use Faker\\ORM\\Doctrine", + "ext-curl": "Required by Faker\\Provider\\Image to download images.", + "ext-dom": "Required by Faker\\Provider\\HtmlLorem for generating random HTML.", + "ext-iconv": "Required by Faker\\Provider\\ru_RU\\Text::realText() for generating real Russian text.", + "ext-mbstring": "Required for multibyte Unicode string functionality." + }, + "type": "library", + "autoload": { + "psr-4": { + "Faker\\": "src/Faker/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "François Zaninotto" + } + ], + "description": "Faker is a PHP library that generates fake data for you.", + "keywords": [ + "data", + "faker", + "fixtures" + ], + "support": { + "issues": "https://github.com/FakerPHP/Faker/issues", + "source": "https://github.com/FakerPHP/Faker/tree/v1.24.1" + }, + "time": "2024-11-21T13:46:39+00:00" + }, + { + "name": "mikey179/vfsstream", + "version": "v1.6.12", + "source": { + "type": "git", + "url": "https://github.com/bovigo/vfsStream.git", + "reference": "fe695ec993e0a55c3abdda10a9364eb31c6f1bf0" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/bovigo/vfsStream/zipball/fe695ec993e0a55c3abdda10a9364eb31c6f1bf0", + "reference": "fe695ec993e0a55c3abdda10a9364eb31c6f1bf0", + "shasum": "" + }, + "require": { + "php": ">=7.1.0" + }, + "require-dev": { + "phpunit/phpunit": "^7.5||^8.5||^9.6", + "yoast/phpunit-polyfills": "^2.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.6.x-dev" + } + }, + "autoload": { + "psr-0": { + "org\\bovigo\\vfs\\": "src/main/php" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Frank Kleine", + "homepage": "http://frankkleine.de/", + "role": "Developer" + } + ], + "description": "Virtual file system to mock the real file system in unit tests.", + "homepage": "http://vfs.bovigo.org/", + "support": { + "issues": "https://github.com/bovigo/vfsStream/issues", + "source": "https://github.com/bovigo/vfsStream/tree/master", + "wiki": "https://github.com/bovigo/vfsStream/wiki" + }, + "time": "2024-08-29T18:43:31+00:00" + }, + { + "name": "nikic/php-parser", + "version": "v5.7.0", + "source": { + "type": "git", + "url": "https://github.com/nikic/PHP-Parser.git", + "reference": "dca41cd15c2ac9d055ad70dbfd011130757d1f82" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/nikic/PHP-Parser/zipball/dca41cd15c2ac9d055ad70dbfd011130757d1f82", + "reference": "dca41cd15c2ac9d055ad70dbfd011130757d1f82", + "shasum": "" + }, + "require": { + "ext-ctype": "*", + "ext-json": "*", + "ext-tokenizer": "*", + "php": ">=7.4" + }, + "require-dev": { + "ircmaxell/php-yacc": "^0.0.7", + "phpunit/phpunit": "^9.0" + }, + "bin": [ + "bin/php-parse" + ], + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "5.x-dev" + } + }, + "autoload": { + "psr-4": { + "PhpParser\\": "lib/PhpParser" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Nikita Popov" + } + ], + "description": "A PHP parser written in PHP", + "keywords": [ + "parser", + "php" + ], + "support": { + "issues": "https://github.com/nikic/PHP-Parser/issues", + "source": "https://github.com/nikic/PHP-Parser/tree/v5.7.0" + }, + "time": "2025-12-06T11:56:16+00:00" + }, + { + "name": "phar-io/manifest", + "version": "2.0.4", + "source": { + "type": "git", + "url": "https://github.com/phar-io/manifest.git", + "reference": "54750ef60c58e43759730615a392c31c80e23176" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/phar-io/manifest/zipball/54750ef60c58e43759730615a392c31c80e23176", + "reference": "54750ef60c58e43759730615a392c31c80e23176", + "shasum": "" + }, + "require": { + "ext-dom": "*", + "ext-libxml": "*", + "ext-phar": "*", + "ext-xmlwriter": "*", + "phar-io/version": "^3.0.1", + "php": "^7.2 || ^8.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.0.x-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Arne Blankerts", + "email": "arne@blankerts.de", + "role": "Developer" + }, + { + "name": "Sebastian Heuer", + "email": "sebastian@phpeople.de", + "role": "Developer" + }, + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de", + "role": "Developer" + } + ], + "description": "Component for reading phar.io manifest information from a PHP Archive (PHAR)", + "support": { + "issues": "https://github.com/phar-io/manifest/issues", + "source": "https://github.com/phar-io/manifest/tree/2.0.4" + }, + "funding": [ + { + "url": "https://github.com/theseer", + "type": "github" + } + ], + "time": "2024-03-03T12:33:53+00:00" + }, + { + "name": "phar-io/version", + "version": "3.2.1", + "source": { + "type": "git", + "url": "https://github.com/phar-io/version.git", + "reference": "4f7fd7836c6f332bb2933569e566a0d6c4cbed74" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/phar-io/version/zipball/4f7fd7836c6f332bb2933569e566a0d6c4cbed74", + "reference": "4f7fd7836c6f332bb2933569e566a0d6c4cbed74", + "shasum": "" + }, + "require": { + "php": "^7.2 || ^8.0" + }, + "type": "library", + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Arne Blankerts", + "email": "arne@blankerts.de", + "role": "Developer" + }, + { + "name": "Sebastian Heuer", + "email": "sebastian@phpeople.de", + "role": "Developer" + }, + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de", + "role": "Developer" + } + ], + "description": "Library for handling version information and constraints", + "support": { + "issues": "https://github.com/phar-io/version/issues", + "source": "https://github.com/phar-io/version/tree/3.2.1" + }, + "time": "2022-02-21T01:04:05+00:00" + }, + { + "name": "phpunit/php-code-coverage", + "version": "10.1.16", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/php-code-coverage.git", + "reference": "7e308268858ed6baedc8704a304727d20bc07c77" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/php-code-coverage/zipball/7e308268858ed6baedc8704a304727d20bc07c77", + "reference": "7e308268858ed6baedc8704a304727d20bc07c77", + "shasum": "" + }, + "require": { + "ext-dom": "*", + "ext-libxml": "*", + "ext-xmlwriter": "*", + "nikic/php-parser": "^4.19.1 || ^5.1.0", + "php": ">=8.1", + "phpunit/php-file-iterator": "^4.1.0", + "phpunit/php-text-template": "^3.0.1", + "sebastian/code-unit-reverse-lookup": "^3.0.0", + "sebastian/complexity": "^3.2.0", + "sebastian/environment": "^6.1.0", + "sebastian/lines-of-code": "^2.0.2", + "sebastian/version": "^4.0.1", + "theseer/tokenizer": "^1.2.3" + }, + "require-dev": { + "phpunit/phpunit": "^10.1" + }, + "suggest": { + "ext-pcov": "PHP extension that provides line coverage", + "ext-xdebug": "PHP extension that provides line coverage as well as branch and path coverage" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-main": "10.1.x-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de", + "role": "lead" + } + ], + "description": "Library that provides collection, processing, and rendering functionality for PHP code coverage information.", + "homepage": "https://github.com/sebastianbergmann/php-code-coverage", + "keywords": [ + "coverage", + "testing", + "xunit" + ], + "support": { + "issues": "https://github.com/sebastianbergmann/php-code-coverage/issues", + "security": "https://github.com/sebastianbergmann/php-code-coverage/security/policy", + "source": "https://github.com/sebastianbergmann/php-code-coverage/tree/10.1.16" + }, + "funding": [ + { + "url": "https://github.com/sebastianbergmann", + "type": "github" + } + ], + "time": "2024-08-22T04:31:57+00:00" + }, + { + "name": "phpunit/php-file-iterator", + "version": "4.1.0", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/php-file-iterator.git", + "reference": "a95037b6d9e608ba092da1b23931e537cadc3c3c" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/php-file-iterator/zipball/a95037b6d9e608ba092da1b23931e537cadc3c3c", + "reference": "a95037b6d9e608ba092da1b23931e537cadc3c3c", + "shasum": "" + }, + "require": { + "php": ">=8.1" + }, + "require-dev": { + "phpunit/phpunit": "^10.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-main": "4.0-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de", + "role": "lead" + } + ], + "description": "FilterIterator implementation that filters files based on a list of suffixes.", + "homepage": "https://github.com/sebastianbergmann/php-file-iterator/", + "keywords": [ + "filesystem", + "iterator" + ], + "support": { + "issues": "https://github.com/sebastianbergmann/php-file-iterator/issues", + "security": "https://github.com/sebastianbergmann/php-file-iterator/security/policy", + "source": "https://github.com/sebastianbergmann/php-file-iterator/tree/4.1.0" + }, + "funding": [ + { + "url": "https://github.com/sebastianbergmann", + "type": "github" + } + ], + "time": "2023-08-31T06:24:48+00:00" + }, + { + "name": "phpunit/php-invoker", + "version": "4.0.0", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/php-invoker.git", + "reference": "f5e568ba02fa5ba0ddd0f618391d5a9ea50b06d7" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/php-invoker/zipball/f5e568ba02fa5ba0ddd0f618391d5a9ea50b06d7", + "reference": "f5e568ba02fa5ba0ddd0f618391d5a9ea50b06d7", + "shasum": "" + }, + "require": { + "php": ">=8.1" + }, + "require-dev": { + "ext-pcntl": "*", + "phpunit/phpunit": "^10.0" + }, + "suggest": { + "ext-pcntl": "*" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-main": "4.0-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de", + "role": "lead" + } + ], + "description": "Invoke callables with a timeout", + "homepage": "https://github.com/sebastianbergmann/php-invoker/", + "keywords": [ + "process" + ], + "support": { + "issues": "https://github.com/sebastianbergmann/php-invoker/issues", + "source": "https://github.com/sebastianbergmann/php-invoker/tree/4.0.0" + }, + "funding": [ + { + "url": "https://github.com/sebastianbergmann", + "type": "github" + } + ], + "time": "2023-02-03T06:56:09+00:00" + }, + { + "name": "phpunit/php-text-template", + "version": "3.0.1", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/php-text-template.git", + "reference": "0c7b06ff49e3d5072f057eb1fa59258bf287a748" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/php-text-template/zipball/0c7b06ff49e3d5072f057eb1fa59258bf287a748", + "reference": "0c7b06ff49e3d5072f057eb1fa59258bf287a748", + "shasum": "" + }, + "require": { + "php": ">=8.1" + }, + "require-dev": { + "phpunit/phpunit": "^10.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-main": "3.0-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de", + "role": "lead" + } + ], + "description": "Simple template engine.", + "homepage": "https://github.com/sebastianbergmann/php-text-template/", + "keywords": [ + "template" + ], + "support": { + "issues": "https://github.com/sebastianbergmann/php-text-template/issues", + "security": "https://github.com/sebastianbergmann/php-text-template/security/policy", + "source": "https://github.com/sebastianbergmann/php-text-template/tree/3.0.1" + }, + "funding": [ + { + "url": "https://github.com/sebastianbergmann", + "type": "github" + } + ], + "time": "2023-08-31T14:07:24+00:00" + }, + { + "name": "phpunit/php-timer", + "version": "6.0.0", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/php-timer.git", + "reference": "e2a2d67966e740530f4a3343fe2e030ffdc1161d" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/php-timer/zipball/e2a2d67966e740530f4a3343fe2e030ffdc1161d", + "reference": "e2a2d67966e740530f4a3343fe2e030ffdc1161d", + "shasum": "" + }, + "require": { + "php": ">=8.1" + }, + "require-dev": { + "phpunit/phpunit": "^10.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-main": "6.0-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de", + "role": "lead" + } + ], + "description": "Utility class for timing", + "homepage": "https://github.com/sebastianbergmann/php-timer/", + "keywords": [ + "timer" + ], + "support": { + "issues": "https://github.com/sebastianbergmann/php-timer/issues", + "source": "https://github.com/sebastianbergmann/php-timer/tree/6.0.0" + }, + "funding": [ + { + "url": "https://github.com/sebastianbergmann", + "type": "github" + } + ], + "time": "2023-02-03T06:57:52+00:00" + }, + { + "name": "phpunit/phpunit", + "version": "10.5.63", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/phpunit.git", + "reference": "33198268dad71e926626b618f3ec3966661e4d90" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/33198268dad71e926626b618f3ec3966661e4d90", + "reference": "33198268dad71e926626b618f3ec3966661e4d90", + "shasum": "" + }, + "require": { + "ext-dom": "*", + "ext-json": "*", + "ext-libxml": "*", + "ext-mbstring": "*", + "ext-xml": "*", + "ext-xmlwriter": "*", + "myclabs/deep-copy": "^1.13.4", + "phar-io/manifest": "^2.0.4", + "phar-io/version": "^3.2.1", + "php": ">=8.1", + "phpunit/php-code-coverage": "^10.1.16", + "phpunit/php-file-iterator": "^4.1.0", + "phpunit/php-invoker": "^4.0.0", + "phpunit/php-text-template": "^3.0.1", + "phpunit/php-timer": "^6.0.0", + "sebastian/cli-parser": "^2.0.1", + "sebastian/code-unit": "^2.0.0", + "sebastian/comparator": "^5.0.5", + "sebastian/diff": "^5.1.1", + "sebastian/environment": "^6.1.0", + "sebastian/exporter": "^5.1.4", + "sebastian/global-state": "^6.0.2", + "sebastian/object-enumerator": "^5.0.0", + "sebastian/recursion-context": "^5.0.1", + "sebastian/type": "^4.0.0", + "sebastian/version": "^4.0.1" + }, + "suggest": { + "ext-soap": "To be able to generate mocks based on WSDL files" + }, + "bin": [ + "phpunit" + ], + "type": "library", + "extra": { + "branch-alias": { + "dev-main": "10.5-dev" + } + }, + "autoload": { + "files": [ + "src/Framework/Assert/Functions.php" + ], + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de", + "role": "lead" + } + ], + "description": "The PHP Unit Testing framework.", + "homepage": "https://phpunit.de/", + "keywords": [ + "phpunit", + "testing", + "xunit" + ], + "support": { + "issues": "https://github.com/sebastianbergmann/phpunit/issues", + "security": "https://github.com/sebastianbergmann/phpunit/security/policy", + "source": "https://github.com/sebastianbergmann/phpunit/tree/10.5.63" + }, + "funding": [ + { + "url": "https://phpunit.de/sponsors.html", + "type": "custom" + }, + { + "url": "https://github.com/sebastianbergmann", + "type": "github" + }, + { + "url": "https://liberapay.com/sebastianbergmann", + "type": "liberapay" + }, + { + "url": "https://thanks.dev/u/gh/sebastianbergmann", + "type": "thanks_dev" + }, + { + "url": "https://tidelift.com/funding/github/packagist/phpunit/phpunit", + "type": "tidelift" + } + ], + "time": "2026-01-27T05:48:37+00:00" + }, + { + "name": "psr/container", + "version": "2.0.2", + "source": { + "type": "git", + "url": "https://github.com/php-fig/container.git", + "reference": "c71ecc56dfe541dbd90c5360474fbc405f8d5963" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/php-fig/container/zipball/c71ecc56dfe541dbd90c5360474fbc405f8d5963", + "reference": "c71ecc56dfe541dbd90c5360474fbc405f8d5963", + "shasum": "" + }, + "require": { + "php": ">=7.4.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.0.x-dev" + } + }, + "autoload": { + "psr-4": { + "Psr\\Container\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "PHP-FIG", + "homepage": "https://www.php-fig.org/" + } + ], + "description": "Common Container Interface (PHP FIG PSR-11)", + "homepage": "https://github.com/php-fig/container", + "keywords": [ + "PSR-11", + "container", + "container-interface", + "container-interop", + "psr" + ], + "support": { + "issues": "https://github.com/php-fig/container/issues", + "source": "https://github.com/php-fig/container/tree/2.0.2" + }, + "time": "2021-11-05T16:47:00+00:00" + }, + { + "name": "sebastian/cli-parser", + "version": "2.0.1", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/cli-parser.git", + "reference": "c34583b87e7b7a8055bf6c450c2c77ce32a24084" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/cli-parser/zipball/c34583b87e7b7a8055bf6c450c2c77ce32a24084", + "reference": "c34583b87e7b7a8055bf6c450c2c77ce32a24084", + "shasum": "" + }, + "require": { + "php": ">=8.1" + }, + "require-dev": { + "phpunit/phpunit": "^10.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-main": "2.0-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de", + "role": "lead" + } + ], + "description": "Library for parsing CLI options", + "homepage": "https://github.com/sebastianbergmann/cli-parser", + "support": { + "issues": "https://github.com/sebastianbergmann/cli-parser/issues", + "security": "https://github.com/sebastianbergmann/cli-parser/security/policy", + "source": "https://github.com/sebastianbergmann/cli-parser/tree/2.0.1" + }, + "funding": [ + { + "url": "https://github.com/sebastianbergmann", + "type": "github" + } + ], + "time": "2024-03-02T07:12:49+00:00" + }, + { + "name": "sebastian/code-unit", + "version": "2.0.0", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/code-unit.git", + "reference": "a81fee9eef0b7a76af11d121767abc44c104e503" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/code-unit/zipball/a81fee9eef0b7a76af11d121767abc44c104e503", + "reference": "a81fee9eef0b7a76af11d121767abc44c104e503", + "shasum": "" + }, + "require": { + "php": ">=8.1" + }, + "require-dev": { + "phpunit/phpunit": "^10.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-main": "2.0-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de", + "role": "lead" + } + ], + "description": "Collection of value objects that represent the PHP code units", + "homepage": "https://github.com/sebastianbergmann/code-unit", + "support": { + "issues": "https://github.com/sebastianbergmann/code-unit/issues", + "source": "https://github.com/sebastianbergmann/code-unit/tree/2.0.0" + }, + "funding": [ + { + "url": "https://github.com/sebastianbergmann", + "type": "github" + } + ], + "time": "2023-02-03T06:58:43+00:00" + }, + { + "name": "sebastian/code-unit-reverse-lookup", + "version": "3.0.0", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/code-unit-reverse-lookup.git", + "reference": "5e3a687f7d8ae33fb362c5c0743794bbb2420a1d" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/code-unit-reverse-lookup/zipball/5e3a687f7d8ae33fb362c5c0743794bbb2420a1d", + "reference": "5e3a687f7d8ae33fb362c5c0743794bbb2420a1d", + "shasum": "" + }, + "require": { + "php": ">=8.1" + }, + "require-dev": { + "phpunit/phpunit": "^10.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-main": "3.0-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de" + } + ], + "description": "Looks up which function or method a line of code belongs to", + "homepage": "https://github.com/sebastianbergmann/code-unit-reverse-lookup/", + "support": { + "issues": "https://github.com/sebastianbergmann/code-unit-reverse-lookup/issues", + "source": "https://github.com/sebastianbergmann/code-unit-reverse-lookup/tree/3.0.0" + }, + "funding": [ + { + "url": "https://github.com/sebastianbergmann", + "type": "github" + } + ], + "time": "2023-02-03T06:59:15+00:00" + }, + { + "name": "sebastian/comparator", + "version": "5.0.5", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/comparator.git", + "reference": "55dfef806eb7dfeb6e7a6935601fef866f8ca48d" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/comparator/zipball/55dfef806eb7dfeb6e7a6935601fef866f8ca48d", + "reference": "55dfef806eb7dfeb6e7a6935601fef866f8ca48d", + "shasum": "" + }, + "require": { + "ext-dom": "*", + "ext-mbstring": "*", + "php": ">=8.1", + "sebastian/diff": "^5.0", + "sebastian/exporter": "^5.0" + }, + "require-dev": { + "phpunit/phpunit": "^10.5" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-main": "5.0-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de" + }, + { + "name": "Jeff Welch", + "email": "whatthejeff@gmail.com" + }, + { + "name": "Volker Dusch", + "email": "github@wallbash.com" + }, + { + "name": "Bernhard Schussek", + "email": "bschussek@2bepublished.at" + } + ], + "description": "Provides the functionality to compare PHP values for equality", + "homepage": "https://github.com/sebastianbergmann/comparator", + "keywords": [ + "comparator", + "compare", + "equality" + ], + "support": { + "issues": "https://github.com/sebastianbergmann/comparator/issues", + "security": "https://github.com/sebastianbergmann/comparator/security/policy", + "source": "https://github.com/sebastianbergmann/comparator/tree/5.0.5" + }, + "funding": [ + { + "url": "https://github.com/sebastianbergmann", + "type": "github" + }, + { + "url": "https://liberapay.com/sebastianbergmann", + "type": "liberapay" + }, + { + "url": "https://thanks.dev/u/gh/sebastianbergmann", + "type": "thanks_dev" + }, + { + "url": "https://tidelift.com/funding/github/packagist/sebastian/comparator", + "type": "tidelift" + } + ], + "time": "2026-01-24T09:25:16+00:00" + }, + { + "name": "sebastian/complexity", + "version": "3.2.0", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/complexity.git", + "reference": "68ff824baeae169ec9f2137158ee529584553799" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/complexity/zipball/68ff824baeae169ec9f2137158ee529584553799", + "reference": "68ff824baeae169ec9f2137158ee529584553799", + "shasum": "" + }, + "require": { + "nikic/php-parser": "^4.18 || ^5.0", + "php": ">=8.1" + }, + "require-dev": { + "phpunit/phpunit": "^10.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-main": "3.2-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de", + "role": "lead" + } + ], + "description": "Library for calculating the complexity of PHP code units", + "homepage": "https://github.com/sebastianbergmann/complexity", + "support": { + "issues": "https://github.com/sebastianbergmann/complexity/issues", + "security": "https://github.com/sebastianbergmann/complexity/security/policy", + "source": "https://github.com/sebastianbergmann/complexity/tree/3.2.0" + }, + "funding": [ + { + "url": "https://github.com/sebastianbergmann", + "type": "github" + } + ], + "time": "2023-12-21T08:37:17+00:00" + }, + { + "name": "sebastian/diff", + "version": "5.1.1", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/diff.git", + "reference": "c41e007b4b62af48218231d6c2275e4c9b975b2e" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/diff/zipball/c41e007b4b62af48218231d6c2275e4c9b975b2e", + "reference": "c41e007b4b62af48218231d6c2275e4c9b975b2e", + "shasum": "" + }, + "require": { + "php": ">=8.1" + }, + "require-dev": { + "phpunit/phpunit": "^10.0", + "symfony/process": "^6.4" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-main": "5.1-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de" + }, + { + "name": "Kore Nordmann", + "email": "mail@kore-nordmann.de" + } + ], + "description": "Diff implementation", + "homepage": "https://github.com/sebastianbergmann/diff", + "keywords": [ + "diff", + "udiff", + "unidiff", + "unified diff" + ], + "support": { + "issues": "https://github.com/sebastianbergmann/diff/issues", + "security": "https://github.com/sebastianbergmann/diff/security/policy", + "source": "https://github.com/sebastianbergmann/diff/tree/5.1.1" + }, + "funding": [ + { + "url": "https://github.com/sebastianbergmann", + "type": "github" + } + ], + "time": "2024-03-02T07:15:17+00:00" + }, + { + "name": "sebastian/environment", + "version": "6.1.0", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/environment.git", + "reference": "8074dbcd93529b357029f5cc5058fd3e43666984" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/environment/zipball/8074dbcd93529b357029f5cc5058fd3e43666984", + "reference": "8074dbcd93529b357029f5cc5058fd3e43666984", + "shasum": "" + }, + "require": { + "php": ">=8.1" + }, + "require-dev": { + "phpunit/phpunit": "^10.0" + }, + "suggest": { + "ext-posix": "*" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-main": "6.1-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de" + } + ], + "description": "Provides functionality to handle HHVM/PHP environments", + "homepage": "https://github.com/sebastianbergmann/environment", + "keywords": [ + "Xdebug", + "environment", + "hhvm" + ], + "support": { + "issues": "https://github.com/sebastianbergmann/environment/issues", + "security": "https://github.com/sebastianbergmann/environment/security/policy", + "source": "https://github.com/sebastianbergmann/environment/tree/6.1.0" + }, + "funding": [ + { + "url": "https://github.com/sebastianbergmann", + "type": "github" + } + ], + "time": "2024-03-23T08:47:14+00:00" + }, + { + "name": "sebastian/exporter", + "version": "5.1.4", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/exporter.git", + "reference": "0735b90f4da94969541dac1da743446e276defa6" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/exporter/zipball/0735b90f4da94969541dac1da743446e276defa6", + "reference": "0735b90f4da94969541dac1da743446e276defa6", + "shasum": "" + }, + "require": { + "ext-mbstring": "*", + "php": ">=8.1", + "sebastian/recursion-context": "^5.0" + }, + "require-dev": { + "phpunit/phpunit": "^10.5" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-main": "5.1-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de" + }, + { + "name": "Jeff Welch", + "email": "whatthejeff@gmail.com" + }, + { + "name": "Volker Dusch", + "email": "github@wallbash.com" + }, + { + "name": "Adam Harvey", + "email": "aharvey@php.net" + }, + { + "name": "Bernhard Schussek", + "email": "bschussek@gmail.com" + } + ], + "description": "Provides the functionality to export PHP variables for visualization", + "homepage": "https://www.github.com/sebastianbergmann/exporter", + "keywords": [ + "export", + "exporter" + ], + "support": { + "issues": "https://github.com/sebastianbergmann/exporter/issues", + "security": "https://github.com/sebastianbergmann/exporter/security/policy", + "source": "https://github.com/sebastianbergmann/exporter/tree/5.1.4" + }, + "funding": [ + { + "url": "https://github.com/sebastianbergmann", + "type": "github" + }, + { + "url": "https://liberapay.com/sebastianbergmann", + "type": "liberapay" + }, + { + "url": "https://thanks.dev/u/gh/sebastianbergmann", + "type": "thanks_dev" + }, + { + "url": "https://tidelift.com/funding/github/packagist/sebastian/exporter", + "type": "tidelift" + } + ], + "time": "2025-09-24T06:09:11+00:00" + }, + { + "name": "sebastian/global-state", + "version": "6.0.2", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/global-state.git", + "reference": "987bafff24ecc4c9ac418cab1145b96dd6e9cbd9" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/global-state/zipball/987bafff24ecc4c9ac418cab1145b96dd6e9cbd9", + "reference": "987bafff24ecc4c9ac418cab1145b96dd6e9cbd9", + "shasum": "" + }, + "require": { + "php": ">=8.1", + "sebastian/object-reflector": "^3.0", + "sebastian/recursion-context": "^5.0" + }, + "require-dev": { + "ext-dom": "*", + "phpunit/phpunit": "^10.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-main": "6.0-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de" + } + ], + "description": "Snapshotting of global state", + "homepage": "https://www.github.com/sebastianbergmann/global-state", + "keywords": [ + "global state" + ], + "support": { + "issues": "https://github.com/sebastianbergmann/global-state/issues", + "security": "https://github.com/sebastianbergmann/global-state/security/policy", + "source": "https://github.com/sebastianbergmann/global-state/tree/6.0.2" + }, + "funding": [ + { + "url": "https://github.com/sebastianbergmann", + "type": "github" + } + ], + "time": "2024-03-02T07:19:19+00:00" + }, + { + "name": "sebastian/lines-of-code", + "version": "2.0.2", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/lines-of-code.git", + "reference": "856e7f6a75a84e339195d48c556f23be2ebf75d0" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/lines-of-code/zipball/856e7f6a75a84e339195d48c556f23be2ebf75d0", + "reference": "856e7f6a75a84e339195d48c556f23be2ebf75d0", + "shasum": "" + }, + "require": { + "nikic/php-parser": "^4.18 || ^5.0", + "php": ">=8.1" + }, + "require-dev": { + "phpunit/phpunit": "^10.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-main": "2.0-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de", + "role": "lead" + } + ], + "description": "Library for counting the lines of code in PHP source code", + "homepage": "https://github.com/sebastianbergmann/lines-of-code", + "support": { + "issues": "https://github.com/sebastianbergmann/lines-of-code/issues", + "security": "https://github.com/sebastianbergmann/lines-of-code/security/policy", + "source": "https://github.com/sebastianbergmann/lines-of-code/tree/2.0.2" + }, + "funding": [ + { + "url": "https://github.com/sebastianbergmann", + "type": "github" + } + ], + "time": "2023-12-21T08:38:20+00:00" + }, + { + "name": "sebastian/object-enumerator", + "version": "5.0.0", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/object-enumerator.git", + "reference": "202d0e344a580d7f7d04b3fafce6933e59dae906" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/object-enumerator/zipball/202d0e344a580d7f7d04b3fafce6933e59dae906", + "reference": "202d0e344a580d7f7d04b3fafce6933e59dae906", + "shasum": "" + }, + "require": { + "php": ">=8.1", + "sebastian/object-reflector": "^3.0", + "sebastian/recursion-context": "^5.0" + }, + "require-dev": { + "phpunit/phpunit": "^10.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-main": "5.0-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de" + } + ], + "description": "Traverses array structures and object graphs to enumerate all referenced objects", + "homepage": "https://github.com/sebastianbergmann/object-enumerator/", + "support": { + "issues": "https://github.com/sebastianbergmann/object-enumerator/issues", + "source": "https://github.com/sebastianbergmann/object-enumerator/tree/5.0.0" + }, + "funding": [ + { + "url": "https://github.com/sebastianbergmann", + "type": "github" + } + ], + "time": "2023-02-03T07:08:32+00:00" + }, + { + "name": "sebastian/object-reflector", + "version": "3.0.0", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/object-reflector.git", + "reference": "24ed13d98130f0e7122df55d06c5c4942a577957" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/object-reflector/zipball/24ed13d98130f0e7122df55d06c5c4942a577957", + "reference": "24ed13d98130f0e7122df55d06c5c4942a577957", + "shasum": "" + }, + "require": { + "php": ">=8.1" + }, + "require-dev": { + "phpunit/phpunit": "^10.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-main": "3.0-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de" + } + ], + "description": "Allows reflection of object attributes, including inherited and non-public ones", + "homepage": "https://github.com/sebastianbergmann/object-reflector/", + "support": { + "issues": "https://github.com/sebastianbergmann/object-reflector/issues", + "source": "https://github.com/sebastianbergmann/object-reflector/tree/3.0.0" + }, + "funding": [ + { + "url": "https://github.com/sebastianbergmann", + "type": "github" + } + ], + "time": "2023-02-03T07:06:18+00:00" + }, + { + "name": "sebastian/recursion-context", + "version": "5.0.1", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/recursion-context.git", + "reference": "47e34210757a2f37a97dcd207d032e1b01e64c7a" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/recursion-context/zipball/47e34210757a2f37a97dcd207d032e1b01e64c7a", + "reference": "47e34210757a2f37a97dcd207d032e1b01e64c7a", + "shasum": "" + }, + "require": { + "php": ">=8.1" + }, + "require-dev": { + "phpunit/phpunit": "^10.5" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-main": "5.0-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de" + }, + { + "name": "Jeff Welch", + "email": "whatthejeff@gmail.com" + }, + { + "name": "Adam Harvey", + "email": "aharvey@php.net" + } + ], + "description": "Provides functionality to recursively process PHP variables", + "homepage": "https://github.com/sebastianbergmann/recursion-context", + "support": { + "issues": "https://github.com/sebastianbergmann/recursion-context/issues", + "security": "https://github.com/sebastianbergmann/recursion-context/security/policy", + "source": "https://github.com/sebastianbergmann/recursion-context/tree/5.0.1" + }, + "funding": [ + { + "url": "https://github.com/sebastianbergmann", + "type": "github" + }, + { + "url": "https://liberapay.com/sebastianbergmann", + "type": "liberapay" + }, + { + "url": "https://thanks.dev/u/gh/sebastianbergmann", + "type": "thanks_dev" + }, + { + "url": "https://tidelift.com/funding/github/packagist/sebastian/recursion-context", + "type": "tidelift" + } + ], + "time": "2025-08-10T07:50:56+00:00" + }, + { + "name": "sebastian/type", + "version": "4.0.0", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/type.git", + "reference": "462699a16464c3944eefc02ebdd77882bd3925bf" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/type/zipball/462699a16464c3944eefc02ebdd77882bd3925bf", + "reference": "462699a16464c3944eefc02ebdd77882bd3925bf", + "shasum": "" + }, + "require": { + "php": ">=8.1" + }, + "require-dev": { + "phpunit/phpunit": "^10.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-main": "4.0-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de", + "role": "lead" + } + ], + "description": "Collection of value objects that represent the types of the PHP type system", + "homepage": "https://github.com/sebastianbergmann/type", + "support": { + "issues": "https://github.com/sebastianbergmann/type/issues", + "source": "https://github.com/sebastianbergmann/type/tree/4.0.0" + }, + "funding": [ + { + "url": "https://github.com/sebastianbergmann", + "type": "github" + } + ], + "time": "2023-02-03T07:10:45+00:00" + }, + { + "name": "sebastian/version", + "version": "4.0.1", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/version.git", + "reference": "c51fa83a5d8f43f1402e3f32a005e6262244ef17" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/version/zipball/c51fa83a5d8f43f1402e3f32a005e6262244ef17", + "reference": "c51fa83a5d8f43f1402e3f32a005e6262244ef17", + "shasum": "" + }, + "require": { + "php": ">=8.1" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-main": "4.0-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de", + "role": "lead" + } + ], + "description": "Library that helps with managing the version number of Git-hosted PHP projects", + "homepage": "https://github.com/sebastianbergmann/version", + "support": { + "issues": "https://github.com/sebastianbergmann/version/issues", + "source": "https://github.com/sebastianbergmann/version/tree/4.0.1" + }, + "funding": [ + { + "url": "https://github.com/sebastianbergmann", + "type": "github" + } + ], + "time": "2023-02-07T11:34:05+00:00" + }, + { + "name": "symfony/deprecation-contracts", + "version": "v3.6.0", + "source": { + "type": "git", + "url": "https://github.com/symfony/deprecation-contracts.git", + "reference": "63afe740e99a13ba87ec199bb07bbdee937a5b62" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/deprecation-contracts/zipball/63afe740e99a13ba87ec199bb07bbdee937a5b62", + "reference": "63afe740e99a13ba87ec199bb07bbdee937a5b62", + "shasum": "" + }, + "require": { + "php": ">=8.1" + }, + "type": "library", + "extra": { + "thanks": { + "url": "https://github.com/symfony/contracts", + "name": "symfony/contracts" + }, + "branch-alias": { + "dev-main": "3.6-dev" + } + }, + "autoload": { + "files": [ + "function.php" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Nicolas Grekas", + "email": "p@tchwork.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "A generic function and convention to trigger deprecation notices", + "homepage": "https://symfony.com", + "support": { + "source": "https://github.com/symfony/deprecation-contracts/tree/v3.6.0" + }, + "funding": [ + { + "url": "https://symfony.com/sponsor", + "type": "custom" + }, + { + "url": "https://github.com/fabpot", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", + "type": "tidelift" + } + ], + "time": "2024-09-25T14:21:43+00:00" + }, + { + "name": "theseer/tokenizer", + "version": "1.3.1", + "source": { + "type": "git", + "url": "https://github.com/theseer/tokenizer.git", + "reference": "b7489ce515e168639d17feec34b8847c326b0b3c" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/theseer/tokenizer/zipball/b7489ce515e168639d17feec34b8847c326b0b3c", + "reference": "b7489ce515e168639d17feec34b8847c326b0b3c", + "shasum": "" + }, + "require": { + "ext-dom": "*", + "ext-tokenizer": "*", + "ext-xmlwriter": "*", + "php": "^7.2 || ^8.0" + }, + "type": "library", + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Arne Blankerts", + "email": "arne@blankerts.de", + "role": "Developer" + } + ], + "description": "A small library for converting tokenized PHP source code into XML and potentially other formats", + "support": { + "issues": "https://github.com/theseer/tokenizer/issues", + "source": "https://github.com/theseer/tokenizer/tree/1.3.1" + }, + "funding": [ + { + "url": "https://github.com/theseer", + "type": "github" + } + ], + "time": "2025-11-17T20:03:58+00:00" + } + ], + "aliases": [], + "minimum-stability": "stable", + "stability-flags": {}, + "prefer-stable": false, + "prefer-lowest": false, + "platform": { + "php": "^8.2" + }, + "platform-dev": {}, + "plugin-api-version": "2.6.0" +} diff --git a/env b/env new file mode 100644 index 0000000..f359ec2 --- /dev/null +++ b/env @@ -0,0 +1,69 @@ +#-------------------------------------------------------------------- +# Example Environment Configuration file +# +# This file can be used as a starting point for your own +# custom .env files, and contains most of the possible settings +# available in a default install. +# +# By default, all of the settings are commented out. If you want +# to override the setting, you must un-comment it by removing the '#' +# at the beginning of the line. +#-------------------------------------------------------------------- + +#-------------------------------------------------------------------- +# ENVIRONMENT +#-------------------------------------------------------------------- + +# CI_ENVIRONMENT = production + +#-------------------------------------------------------------------- +# APP +#-------------------------------------------------------------------- + +# app.baseURL = '' +# If you have trouble with `.`, you could also use `_`. +# app_baseURL = '' +# app.forceGlobalSecureRequests = false +# app.CSPEnabled = false + +#-------------------------------------------------------------------- +# DATABASE +#-------------------------------------------------------------------- + +# database.default.hostname = localhost +# database.default.database = ci4 +# database.default.username = root +# database.default.password = root +# database.default.DBDriver = MySQLi +# database.default.DBPrefix = +# database.default.port = 3306 + +# If you use MySQLi as tests, first update the values of Config\Database::$tests. +# database.tests.hostname = localhost +# database.tests.database = ci4_test +# database.tests.username = root +# database.tests.password = root +# database.tests.DBDriver = MySQLi +# database.tests.DBPrefix = +# database.tests.charset = utf8mb4 +# database.tests.DBCollat = utf8mb4_general_ci +# database.tests.port = 3306 + +#-------------------------------------------------------------------- +# ENCRYPTION +#-------------------------------------------------------------------- + +# encryption.key = + +#-------------------------------------------------------------------- +# SESSION +#-------------------------------------------------------------------- + +# session.driver = 'CodeIgniter\Session\Handlers\FileHandler' +# session.savePath = null + +#-------------------------------------------------------------------- +# LOGGER +#-------------------------------------------------------------------- + +# logger.threshold = 4 diff --git a/old_code_ci3/controllers/Auth.php b/old_code_ci3/controllers/Auth.php new file mode 100644 index 0000000..937e659 --- /dev/null +++ b/old_code_ci3/controllers/Auth.php @@ -0,0 +1,825 @@ +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'); + } + + // redirect if needed, otherwise display the user list + public function index() + { + + if (!$this->ion_auth->logged_in()) + { + // redirect them to the login page + redirect('auth/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/index', $this->data); + } + } + + // 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/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/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/login', 'refresh'); + } + + // change password + public function change_password() + { + $this->form_validation->set_rules('old', $this->lang->line('change_password_validation_old_password_label'), 'required'); + $this->form_validation->set_rules('new', $this->lang->line('change_password_validation_new_password_label'), 'required|min_length[' . $this->config->item('min_password_length', 'ion_auth') . ']|max_length[' . $this->config->item('max_password_length', 'ion_auth') . ']|matches[new_confirm]'); + $this->form_validation->set_rules('new_confirm', $this->lang->line('change_password_validation_new_password_confirm_label'), 'required'); + + if (!$this->ion_auth->logged_in()) + { + redirect('auth/login', 'refresh'); + } + + $user = $this->ion_auth->user()->row(); + + if ($this->form_validation->run() == false) + { + // display the form + // set the flash data error message if there is one + $this->data['message'] = (validation_errors()) ? validation_errors() : $this->session->flashdata('message'); + + $this->data['min_password_length'] = $this->config->item('min_password_length', 'ion_auth'); + $this->data['old_password'] = array( + 'name' => 'old', + 'id' => 'old', + 'type' => 'password', + ); + $this->data['new_password'] = array( + 'name' => 'new', + 'id' => 'new', + 'type' => 'password', + 'pattern' => '^.{'.$this->data['min_password_length'].'}.*$', + ); + $this->data['new_password_confirm'] = array( + 'name' => 'new_confirm', + 'id' => 'new_confirm', + 'type' => 'password', + 'pattern' => '^.{'.$this->data['min_password_length'].'}.*$', + ); + $this->data['user_id'] = array( + 'name' => 'user_id', + 'id' => 'user_id', + 'type' => 'hidden', + 'value' => $user->id, + ); + + // render + $this->_render_page('auth/change_password', $this->data); + } + else + { + $identity = $this->session->userdata('identity'); + + $change = $this->ion_auth->change_password($identity, $this->input->post('old'), $this->input->post('new')); + + if ($change) + { + //if the password was successfully changed + $this->session->set_flashdata('message', $this->ion_auth->messages()); + $this->logout(); + } + else + { + $this->session->set_flashdata('message', $this->ion_auth->errors()); + redirect('auth/change_password', 'refresh'); + } + } + } + + // forgot password + public function forgot_password() + { + // setting validation rules by checking whether identity is username or email + if($this->config->item('identity', 'ion_auth') != 'email' ) + { + $this->form_validation->set_rules('identity', $this->lang->line('forgot_password_identity_label'), 'required'); + } + else + { + $this->form_validation->set_rules('identity', $this->lang->line('forgot_password_validation_email_label'), 'required|valid_email'); + } + + + if ($this->form_validation->run() == false) + { + $this->data['type'] = $this->config->item('identity','ion_auth'); + // setup the input + $this->data['identity'] = array('name' => 'identity', + 'id' => 'identity', + ); + + if ( $this->config->item('identity', 'ion_auth') != 'email' ){ + $this->data['identity_label'] = $this->lang->line('forgot_password_identity_label'); + } + else + { + $this->data['identity_label'] = $this->lang->line('forgot_password_email_identity_label'); + } + + // set any errors and display the form + $this->data['message'] = (validation_errors()) ? validation_errors() : $this->session->flashdata('message'); + $this->_render_page('auth/forgot_password', $this->data); + } + else + { + $identity_column = $this->config->item('identity','ion_auth'); + $identity = $this->ion_auth->where($identity_column, $this->input->post('identity'))->users()->row(); + + if(empty($identity)) { + + if($this->config->item('identity', 'ion_auth') != 'email') + { + $this->ion_auth->set_error('forgot_password_identity_not_found'); + } + else + { + $this->ion_auth->set_error('forgot_password_email_not_found'); + } + + $this->session->set_flashdata('message', $this->ion_auth->errors()); + redirect("auth/forgot_password", 'refresh'); + } + + // run the forgotten password method to email an activation code to the user + $forgotten = $this->ion_auth->forgotten_password($identity->{$this->config->item('identity', 'ion_auth')}); + + if ($forgotten) + { + // if there were no errors + $this->session->set_flashdata('message', $this->ion_auth->messages()); + redirect("auth/login", 'refresh'); //we should display a confirmation page here instead of the login page + } + else + { + $this->session->set_flashdata('message', $this->ion_auth->errors()); + redirect("auth/forgot_password", 'refresh'); + } + } + } + + // reset password - final step for forgotten password + public function reset_password($code = NULL) + { + if (!$code) + { + show_404(); + } + + $user = $this->ion_auth->forgotten_password_check($code); + + if ($user) + { + // if the code is valid then display the password reset form + + $this->form_validation->set_rules('new', $this->lang->line('reset_password_validation_new_password_label'), 'required|min_length[' . $this->config->item('min_password_length', 'ion_auth') . ']|max_length[' . $this->config->item('max_password_length', 'ion_auth') . ']|matches[new_confirm]'); + $this->form_validation->set_rules('new_confirm', $this->lang->line('reset_password_validation_new_password_confirm_label'), 'required'); + + if ($this->form_validation->run() == false) + { + // display the form + + // set the flash data error message if there is one + $this->data['message'] = (validation_errors()) ? validation_errors() : $this->session->flashdata('message'); + + $this->data['min_password_length'] = $this->config->item('min_password_length', 'ion_auth'); + $this->data['new_password'] = array( + 'name' => 'new', + 'id' => 'new', + 'type' => 'password', + 'pattern' => '^.{'.$this->data['min_password_length'].'}.*$', + ); + $this->data['new_password_confirm'] = array( + 'name' => 'new_confirm', + 'id' => 'new_confirm', + 'type' => 'password', + 'pattern' => '^.{'.$this->data['min_password_length'].'}.*$', + ); + $this->data['user_id'] = array( + 'name' => 'user_id', + 'id' => 'user_id', + 'type' => 'hidden', + 'value' => $user->id, + ); + $this->data['csrf'] = $this->_get_csrf_nonce(); + $this->data['code'] = $code; + + // render + $this->_render_page('auth/reset_password', $this->data); + } + else + { + // do we have a valid request? + if ($this->_valid_csrf_nonce() === FALSE || $user->id != $this->input->post('user_id')) + { + + // something fishy might be up + $this->ion_auth->clear_forgotten_password_code($code); + + show_error($this->lang->line('error_csrf')); + + } + else + { + // finally change the password + $identity = $user->{$this->config->item('identity', 'ion_auth')}; + + $change = $this->ion_auth->reset_password($identity, $this->input->post('new')); + + if ($change) + { + // if the password was successfully changed + $this->session->set_flashdata('message', $this->ion_auth->messages()); + redirect("auth/login", 'refresh'); + } + else + { + $this->session->set_flashdata('message', $this->ion_auth->errors()); + redirect('auth/reset_password/' . $code, 'refresh'); + } + } + } + } + else + { + // if the code is invalid then send them back to the forgot password page + $this->session->set_flashdata('message', $this->ion_auth->errors()); + redirect("auth/forgot_password", 'refresh'); + } + } + + // activate the user + public function activate($id, $code=false) + { + if ($code !== false) + { + $activation = $this->ion_auth->activate($id, $code); + } + else if ($this->ion_auth->is_admin()) + { + $activation = $this->ion_auth->activate($id); + } + + if ($activation) + { + // redirect them to the auth page + $this->session->set_flashdata('message', $this->ion_auth->messages()); + redirect("auth", 'refresh'); + } + else + { + // redirect them to the forgot password page + $this->session->set_flashdata('message', $this->ion_auth->errors()); + redirect("auth/forgot_password", 'refresh'); + } + } + + // deactivate the user + public function deactivate($id = NULL) + { + if (!$this->ion_auth->logged_in() || !$this->ion_auth->is_admin()) + { + // 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.'); + } + + $id = (int) $id; + + $this->load->library('form_validation'); + $this->form_validation->set_rules('confirm', $this->lang->line('deactivate_validation_confirm_label'), 'required'); + $this->form_validation->set_rules('id', $this->lang->line('deactivate_validation_user_id_label'), 'required|alpha_numeric'); + + if ($this->form_validation->run() == FALSE) + { + // insert csrf check + $this->data['csrf'] = $this->_get_csrf_nonce(); + $this->data['user'] = $this->ion_auth->user($id)->row(); + + $this->_render_page('auth/deactivate_user', $this->data); + } + else + { + // do we really want to deactivate? + if ($this->input->post('confirm') == 'yes') + { + // do we have a valid request? + if ($this->_valid_csrf_nonce() === FALSE || $id != $this->input->post('id')) + { + show_error($this->lang->line('error_csrf')); + } + + // do we have the right userlevel? + if ($this->ion_auth->logged_in() && $this->ion_auth->is_admin()) + { + $this->ion_auth->deactivate($id); + } + } + + // redirect them back to the auth page + redirect('auth', 'refresh'); + } + } + + // create a new user + public function create_user() + { + $this->data['title'] = $this->lang->line('create_user_heading'); + + if (!$this->ion_auth->logged_in() || !$this->ion_auth->is_admin()) + { + redirect('auth', '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", 'refresh'); + + } + 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'))); + + $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/create_user', $this->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', 'refresh'); + } + + $user = $this->ion_auth->user($id)->row(); + $groups=$this->ion_auth->groups()->result_array(); + $currentGroups = $this->ion_auth->get_users_groups($id)->result(); + + // 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'); + $this->form_validation->set_rules('company', $this->lang->line('edit_user_validation_company_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'), + 'company' => $this->input->post('company'), + '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() ); + if ($this->ion_auth->is_admin()) + { + redirect('auth', 'refresh'); + } + else + { + redirect('/', '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() ); + if ($this->ion_auth->is_admin()) + { + redirect('auth', 'refresh'); + } + else + { + redirect('/', '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', + 'value' => $this->form_validation->set_value('first_name', $user->first_name), + ); + $this->data['last_name'] = array( + 'name' => 'last_name', + 'id' => 'last_name', + 'type' => 'text', + 'value' => $this->form_validation->set_value('last_name', $user->last_name), + ); + $this->data['company'] = array( + 'name' => 'company', + 'id' => 'company', + 'type' => 'text', + 'value' => $this->form_validation->set_value('company', $user->company), + ); + $this->data['phone'] = array( + 'name' => 'phone', + 'id' => 'phone', + 'type' => 'text', + 'value' => $this->form_validation->set_value('phone', $user->phone), + ); + $this->data['password'] = array( + 'name' => 'password', + 'id' => 'password', + 'type' => 'password' + ); + $this->data['password_confirm'] = array( + 'name' => 'password_confirm', + 'id' => 'password_confirm', + 'type' => 'password' + ); + + $this->_render_page('auth/edit_user', $this->data); + } + + // create a new group + 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', '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()); + redirect("auth", 'refresh'); + } + } + 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/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')); + } + else + { + $this->session->set_flashdata('message', $this->ion_auth->errors()); + } + redirect("auth", 'refresh'); + } + } + + // 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/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 + } + +} diff --git a/old_code_ci3/controllers/Auth_dst copy.php b/old_code_ci3/controllers/Auth_dst copy.php new file mode 100644 index 0000000..89337e9 --- /dev/null +++ b/old_code_ci3/controllers/Auth_dst copy.php @@ -0,0 +1,796 @@ +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_dst/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_dst/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_dst/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_dst', '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_dst", '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_dst/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_dst', '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_dst", '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_dst/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_dst/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_dst/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_dst/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_dst/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_dst/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_dst/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(); + + + } + 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(); + $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_dst/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_dst/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_dst/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_dst/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_dst/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_dst/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_dst/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_dst/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_dst.php b/old_code_ci3/controllers/Auth_dst.php new file mode 100644 index 0000000..89fdf72 --- /dev/null +++ b/old_code_ci3/controllers/Auth_dst.php @@ -0,0 +1,813 @@ +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_dst/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_dst/login', $this->data); + } + } + + public function activate_status($user_id,$status) + { + $data = array( + 'active' => $status, + ); + + $this->ion_auth->update($user_id, $data); + redirect('Auth_dst/search'); + + } + // 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_dst/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_dst', '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_dst", '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_dst/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_dst', '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_dst", '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_dst/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(); + + $sql = "SELECT g.*,m.module_name + FROM groups g JOIN module_master m ON g.head_group=m.id order by m.id"; + $query = $this->db->query($sql); + $this->data['groups_data']= $query->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_dst/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_dst/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_dst/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_dst/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_dst/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_dst/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(); + + + } + 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(); + $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_dst/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_dst/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_dst/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_dst/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_dst/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_dst/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_dst/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_dst/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/C_test.php b/old_code_ci3/controllers/C_test.php new file mode 100644 index 0000000..6277aa1 --- /dev/null +++ b/old_code_ci3/controllers/C_test.php @@ -0,0 +1,95 @@ +load->library("Pdf"); + } + + public function create_pdf() { + + + // 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('TCPDF Example 001'); + $pdf->SetSubject('TCPDF Tutorial'); + $pdf->SetKeywords('TCPDF, PDF, example, test, 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 = << + This is the first example of Report. + +

Please check the source code documentation and other examples for further information.

+ +EOD; + + // Print text using writeHTMLCell() + $pdf->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('example_002.pdf', 'I'); + + //============================================================+ + // END OF FILE + //============================================================+ + } +} + +/* 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/Dashboard.php b/old_code_ci3/controllers/Dashboard.php new file mode 100644 index 0000000..8e94a84 --- /dev/null +++ b/old_code_ci3/controllers/Dashboard.php @@ -0,0 +1,133 @@ +1,i.ins_company_name,\'Direct\') as Ins_name, + if(o.insurance_id>1,i.short_name,\'Direct\') as Ins_short_name, + count(o.opd_id) as No_OPD + from opd_master o left join hc_insurance i on o.insurance_id=i.id + where date(o.apointment_date) =curdate() and (payment_mode>0 or running_opd=1) + group by o.insurance_id'; + + $query = $this->db->query($sql); + $data['opd_count']= $query->result(); + + $sql='select count(*) as T_opd + from opd_master o left join hc_insurance i on o.insurance_id=i.id + where date(o.apointment_date) =curdate() and (payment_mode>0 or running_opd=1) '; + + $query = $this->db->query($sql); + $data['opd_count_total']= $query->result(); + + $sql="select v.doc_name,v.doc_list,count(v.id) as No_patient, + sum(if(v.ipd_status=0,1,0)) as Admit_Current, + sum(if(v.discharge_date=curdate(),1,0)) as Discharge_Day, + sum(if(v.register_date=curdate(),1,0)) as Admit_Day + from v_ipd_list v + where curdate() between v.register_date and if(v.discharge_date is null,sysdate(),v.discharge_date) + group by v.doc_list + order by v.doc_name"; + $query = $this->db->query($sql); + $data['ipd_doc_total']= $query->result(); + + + $sql="select d.id as doc_id, d.p_fname,count(DISTINCT o.opd_id) as No_opd, + sum(if(o.payment_mode=4,1,0)) as Org_OPD, + sum(if(o.payment_mode IN (1,2),1,0)) as Direct_OPD, + MOD(d.id,5) as color_code + from (doctor_master d + join opd_master o on d.id=o.doc_id and o.apointment_date =CURDATE()) + group by d.id + having count(DISTINCT o.opd_id)>0 + order by d.p_fname"; + $query = $this->db->query($sql); + $data['opd_doc_wise']= $query->result(); + + if (stristr(PHP_OS, 'win')) { + $load = "3"; + $memory_usage="4"; + $disksize=""; + $disksizetotal=""; + $bytesPer=""; + } else { + //Disk Size Status + $bytes = disk_free_space("."); + $bytestotal=disk_total_space("."); + + $si_prefix = array( 'B', 'KB', 'MB', 'GB', 'TB', 'EB', 'ZB', 'YB' ); + $base = 1024; + $class = min((int)log($bytes , $base) , count($si_prefix) - 1); + + $bytesPer=round($bytes*100/$bytestotal,2); + + $disksize= sprintf('%1.2f' , $bytes / pow($base,$class)) . ' ' . $si_prefix[$class] . '
'; + $disksizetotal= sprintf('%1.2f' , $bytestotal / pow($base,$class)) . ' ' . $si_prefix[$class] . '
'; + + + $free = shell_exec('free'); + $free = (string)trim($free); + $free_arr = explode("\n", $free); + $mem = explode(" ", $free_arr[1]); + $mem = array_filter($mem); + $mem = array_merge($mem); + $memory_usage = round($mem[2]/$mem[1]*100,2); + + $sys_load = sys_getloadavg(); + $load = $sys_load[0]; + + } + + $data['load'] = $load; + $data['mem'] = $memory_usage ; + $data['dsize'] = $disksize ; + $data['dsizetot'] = $disksizetotal ; + $data['bytesPer'] = $bytesPer ; + + $sql="select count(*) as no_rec from ipd_master where ipd_status=0"; + $query = $this->db->query($sql); + $data['ipd_count']= $query->result(); + + $data['no_admit_ipd']=$data['ipd_count'][0]->no_rec; + + $sql="select count(*) as no_rec from ipd_master where ipd_status=1 and discharge_date=Date(sysdate())"; + $query = $this->db->query($sql); + $data['ipd_count']= $query->result(); + + $data['no_admit_ipd_discharge']=$data['ipd_count'][0]->no_rec; + + $sql="select count(*) as no_rec from ipd_master where register_date=Date(sysdate())"; + $query = $this->db->query($sql); + $data['ipd_count']= $query->result(); + + $data['no_admit_ipd_admit']=$data['ipd_count'][0]->no_rec; + + $sql="select count(*) as no_rec from ipd_master where ipd_status=0 and case_id>0"; + $query = $this->db->query($sql); + $data['ipd_count']= $query->result(); + + $data['no_admit_ipd_org']=$data['ipd_count'][0]->no_rec; + + $sql="select o.insurance_id, + i.ins_company_name , + i.short_name, + count(o.id) as No_IPD + from (organization_case_master o join hc_insurance i on o.insurance_id=i.id) + join ipd_master m on o.id=m.case_id + where ipd_status=0 and m.case_id>0 and o.insurance_id>0 + group by o.insurance_id"; + $query = $this->db->query($sql); + $data['ipd_org_list']= $query->result(); + + $this->load->view('dashboard/dash1',$data); + } + + +} \ No newline at end of file diff --git a/old_code_ci3/controllers/Data.php b/old_code_ci3/controllers/Data.php new file mode 100644 index 0000000..e6abe35 --- /dev/null +++ b/old_code_ci3/controllers/Data.php @@ -0,0 +1,156 @@ +load->database(); + } + + public function index() + { + $sql="select * from payment_mode"; + $query = $this->db->query($sql); + $data['pay_mode']= $query->result(); + + $this->load->view('Report/opd_report_v',$data); + } + + public function getTable() + { + + $requestData= $_REQUEST; + + $columns = array( + // datatable column index => database column name + 0 =>'opd_code', + 1 => 'P_name', + 2 => 'p_code', + 3=> 'App_Date', + 4=> 'doc_name', + 5=> 'Inv_Type', + 6=> 'PaymentMode', + 7=> 'opd_fee_amount' + ); + + // getting total number records without any search + $sql_f_all = "select o.opd_code,o.P_name,o.p_id,Date_Format(o.apointment_date,'%d-%m-%Y') as App_Date, + o.doc_name,if(o.insurance_id>1,'Org.','Direct') as Inv_Type,p_code, + o.insurance_id,o.insurance_credit, + m.mode_desc as PaymentMode,o.payment_mode, + o.opd_fee_gross_amount,o.opd_discount,o.opd_fee_amount,o.apointment_date,o.payment_mode"; + + $sql_count="Select count(*) as no_rec,sum(o.opd_fee_amount) as t_opd_fee_amount "; + + $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"; + + $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']) ){ //name + $sql_where.=" AND o.opd_code LIKE '%".$requestData['columns'][0]['search']['value']."%' "; + $sql_where_flag=1; + } + + if( !empty($requestData['columns'][1]['search']['value']) ){ //salary + $sql_where.=" AND o.P_name LIKE '%".$requestData['columns'][1]['search']['value']."%' "; + $sql_where_flag=1; + } + + if( !empty($requestData['columns'][3]['search']['value']) ){ //salary + $sql_where.=" AND o.doc_name LIKE '%".$requestData['columns'][3]['search']['value']."%' "; + $sql_where_flag=1; + } + + if( !empty($requestData['columns'][2]['search']['value']) ){ //salary + $sql_where.=" AND p_code LIKE '%".$requestData['columns'][2]['search']['value']."%' "; + $sql_where_flag=1; + } + + if( !empty($requestData['columns'][4]['search']['value']) ){ //age + + if($requestData['columns'][4]['search']['value']=='1') + { + $sql_where.=" AND o.insurance_id<=1 "; + }else + { + $sql_where.=" AND o.insurance_id>1 "; + } + $sql_where_flag=1; + } + + if( !empty($requestData['columns'][5]['search']['value'])){ //age + $sql_where.=" AND o.payment_mode=".$requestData['columns'][5]['search']['value']; + $sql_where_flag=1; + }elseif($requestData['columns'][5]['search']['value']=='0') + { + $sql_where.=" AND o.payment_mode=".$requestData['columns'][5]['search']['value']; + $sql_where_flag=1; + } + + if( !empty($requestData['columns'][6]['search']['value']) ) + { //OPD Date Range + $rangeArray = explode("/",$requestData['columns'][6]['search']['value']); + $minRange = $rangeArray[0]; + $maxRange = $rangeArray[1]; + $sql_where.=" AND ( Date(o.apointment_date) between '".$minRange."' AND '".$maxRange."' ) "; + $sql_where_flag=1; + } + + if($sql_where_flag==0) + { + $sql_where.=" AND Date(o.apointment_date) = curdate() "; + } + + $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; + $foot_t_sum=$data['total_rec_filter'][0]->t_opd_fee_amount; + + $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(), + "foot_t_sum" => $foot_t_sum, + "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 + + } + +} +?> \ No newline at end of file diff --git a/old_code_ci3/controllers/Doc_Admin.php b/old_code_ci3/controllers/Doc_Admin.php new file mode 100644 index 0000000..39eb8d1 --- /dev/null +++ b/old_code_ci3/controllers/Doc_Admin.php @@ -0,0 +1,348 @@ +db->query($sql); + $data['doc_master']= $query->result(); + + $this->load->view('DocAdmin/doc_list',$data); + } + + public function docedit_load($doc_id=0) + { + $sql="select * from doc_format_master where df_id=".$doc_id; + $query = $this->db->query($sql); + $data['doc_master']= $query->result(); + + $sql="select m.df_id,m.doc_name,s.input_name,s.input_code,s.short_order,s.id as item_id + from (doc_format_master m join doc_format_sub s on m.df_id=s.doc_format_id) + where m.df_id=".$doc_id. " order by s.short_order" ; + $query = $this->db->query($sql); + $data['doc_Item_List']= $query->result(); + + $sql="select * from doc_pre_input"; + $query = $this->db->query($sql); + $data['doc_pre_input']= $query->result(); + + + $sql="select * from color "; + $query = $this->db->query($sql); + $data['color_name']= $query->result(); + + $this->load->view('DocAdmin/doc_master_edit',$data); + } + + public function report_insert() + { + if (!$this->input->is_ajax_request()) { exit('no valid req.'); } + + $this->load->model('DocFormat_M'); + + $FormRules = array( + array( + 'field' => 'input_docname', + 'label' => 'Name', + 'rules' => 'required|min_length[1]|max_length[100]|is_unique[lab_repo.Title]' + ) + ); + + $this->form_validation->set_rules($FormRules); + + $insertid=0; + $showcontent=""; + if ($this->form_validation->run() == TRUE) + { + $id_key=$this->input->post('df_id'); + $data = array( + 'doc_name'=> $this->input->post('input_docname'), + 'doc_desc'=> $this->input->post('input_doc_desc'), + 'doc_raw_format'=> $this->input->post('HTMLData') + ); + $insertid=$this->DocFormat_M->insert_master($data); + $showcontent=Show_Alert('success','Saved','Data Saved successfully'); + + + }else{ + $showcontent =Show_Alert('danger','Error',validation_errors()); + } + + $rvar=array( + 'insertid' => $insertid, + 'showcontent'=> $showcontent + ); + + $encode_data = json_encode($rvar); + echo $encode_data; + + } + + public function report_update() + { + if (!$this->input->is_ajax_request()) { exit('no valid req.'); } + + $this->load->model('DocFormat_M'); + + $id_key=$this->input->post('df_id'); + + $update_record=0; + + $FormRules = array( + array( + 'field' => 'input_docname', + 'label' => 'Name', + 'rules' => 'required|min_length[1]|max_length[100]|is_unique[lab_repo.Title]' + ) + ); + + $this->form_validation->set_rules($FormRules); + + if ($this->form_validation->run() == TRUE) + { + $data = array( + 'doc_name'=> $this->input->post('input_docname'), + 'doc_desc'=> $this->input->post('input_doc_desc'), + 'doc_raw_format'=> $this->input->post('HTMLData') + ); + + $this->DocFormat_M->update_master($data,$id_key); + + $update_record=1; + + $showcontent=Show_Alert('success','Saved','Data Saved successfully'); + }else{ + $showcontent =Show_Alert('danger','Error',validation_errors()); + } + + + $rvar=array( + 'update_record' => $update_record, + 'showcontent' => $showcontent + ); + + $encode_data = json_encode($rvar); + echo $encode_data; + } + + public function doc_input_list($doc_id) + { + $sql="select m.df_id,s.id,m.doc_name,s.input_name,s.input_code,s.short_order,s.id as item_id + from (doc_format_master m join doc_format_sub s on m.df_id=s.doc_format_id) + where m.df_id=".$doc_id. " order by s.short_order" ; + $query = $this->db->query($sql); + $data['doc_Item_List']= $query->result(); + + $data['doc_id']=$doc_id; + + $this->load->view('DocAdmin/doc_input_list',$data); + } + + public function input_parameter_load($item_id,$doc_id) + { + $sql="select m.df_id,s.id,m.doc_name,s.input_name,s.input_code,s.short_order,s.id as item_id,s.input_type,s.input_default_value + from (doc_format_master m join doc_format_sub s on m.df_id=s.doc_format_id) + where m.df_id=".$doc_id. " and s.id=".$item_id." order by s.short_order" ; + $query = $this->db->query($sql); + $data['input_parameter']= $query->result(); + + $data['doc_id']=$doc_id; + + $this->load->view('DocAdmin/doc_item_edit',$data); + } + + public function input_parameter_edit() + { + if (!$this->input->is_ajax_request()) { exit('no valid req.'); } + + $this->load->model('DocFormat_M'); + + $doc_id=$this->input->post('doc_id'); + $doc_sub_id=$this->input->post('doc_sub_id'); + $input_input_code=$this->input->post('input_input_code'); + + $sql="select * from doc_format_sub where id=".$doc_sub_id." and input_code='".$input_input_code."' and doc_format_id=".$doc_id; + $query = $this->db->query($sql); + $doc_input_list= $query->result(); + + $FormRules = array( + array( + 'field' => 'input_input_name', + 'label' => 'Input Name', + 'rules' => 'required|min_length[1]|max_length[30]' + ), + array( + 'field' => 'input_input_code', + 'label' => 'Input Code', + 'rules' => 'required|min_length[1]|max_length[30]' + ) + ); + + $this->form_validation->set_rules($FormRules); + + $update_value=1; + $showcontent=""; + if ($this->form_validation->run() == TRUE) + { + $udata = array( + 'doc_format_id'=> $this->input->post('doc_id'), + 'input_name'=> $this->input->post('input_input_name'), + 'input_code'=> $this->input->post('input_input_code'), + 'input_type'=> $this->input->post('input_type'), + 'input_default_value'=> $this->input->post('input_default_value') + ); + + $this->DocFormat_M->update_sub($udata,$doc_sub_id); + + $showcontent=Show_Alert('success','Saved','Data Saved successfully'); + }else{ + $update_value=0; + + if(count($doc_input_list)>0) + { + $showcontent =Show_Alert('danger','Error','Already Exist'); + }else{ + $showcontent =Show_Alert('danger','Error',validation_errors()); + } + + } + + $rvar=array( + 'update_value' => $update_value, + 'showcontent'=> $showcontent + ); + + $encode_data = json_encode($rvar); + echo $encode_data; + + } + + public function input_parameter_add() + { + if (!$this->input->is_ajax_request()) { exit('no valid req.'); } + + $this->load->model('DocFormat_M'); + + $doc_id=$this->input->post('doc_id'); + $input_input_code=$this->input->post('input_input_code'); + + $sql="select * from doc_format_sub where input_code='".$input_input_code."' and doc_format_id=".$doc_id; + $query = $this->db->query($sql); + $doc_input_list= $query->result(); + + $FormRules = array( + array( + 'field' => 'input_input_name', + 'label' => 'Input Name', + 'rules' => 'required|min_length[1]|max_length[30]' + ), + array( + 'field' => 'input_input_code', + 'label' => 'Input Code', + 'rules' => 'required|min_length[1]|max_length[30]' + ) + ); + + $this->form_validation->set_rules($FormRules); + + $insert_id=0; + $showcontent=""; + if ($this->form_validation->run() == TRUE && count($doc_input_list)==0 ) + { + $sql="select max(short_order) as max_short_order from doc_format_sub where doc_format_id=".$doc_id; + $query = $this->db->query($sql); + $doc_short_order= $query->result(); + + $MEOrder=0; + if(count($doc_short_order)>0) + { + $MEOrder=$doc_short_order[0]->max_short_order; + } + + if($MEOrder === NULL) + { + $MEOrder=1; + }else{ + $MEOrder=$MEOrder+1; + } + + $udata = array( + 'doc_format_id'=> $this->input->post('doc_id'), + 'input_name'=> $this->input->post('input_input_name'), + 'input_code'=> $this->input->post('input_input_code'), + 'input_type'=> $this->input->post('input_type'), + 'input_default_value'=> $this->input->post('input_default_value') , + 'short_order'=> $MEOrder + ); + + $insert_id=$this->DocFormat_M->insert_sub($udata); + + $showcontent=Show_Alert('success','Saved','Data Saved successfully'); + }else{ + $insert_id=0; + if(count($doc_input_list)>0) + { + $showcontent =Show_Alert('danger','Error','Already Exist'); + }else{ + $showcontent =Show_Alert('danger','Error',validation_errors()); + } + + } + + + $rvar=array( + 'insert_id' => $insert_id, + 'showcontent'=> $showcontent + ); + + $encode_data = json_encode($rvar); + echo $encode_data; + + } + + public function change_sort_item($doc_id,$option_id,$current,$change_option_id,$change) + { + $this->load->model('DocFormat_M'); + + $udata = array( + 'short_order'=> 0 + ); + $this->DocFormat_M->update_sub($udata,$option_id); + + $udata = array( + 'short_order'=> $current + ); + $this->DocFormat_M->update_sub($udata,$change_option_id); + + $udata = array( + 'short_order'=> $change + ); + $this->DocFormat_M->update_sub($udata,$option_id); + + $sql="select m.df_id,m.doc_name,s.input_name,s.input_code,s.short_order,s.id as item_id + from (doc_format_master m join doc_format_sub s on m.df_id=s.doc_format_id) + where m.df_id=".$doc_id. " order by s.short_order" ; + $query = $this->db->query($sql); + $data['doc_Item_List']= $query->result(); + + $data['doc_id']=$doc_id; + + $this->load->view('DocAdmin/doc_input_list',$data); + + } + + public function remove_input_item($doc_id,$doc_sub_id) + { + $this->db->delete("doc_format_sub", "doc_format_id=".$doc_id." and id=".$doc_sub_id); + + } + + +} \ No newline at end of file diff --git a/old_code_ci3/controllers/Doctor.php b/old_code_ci3/controllers/Doctor.php new file mode 100644 index 0000000..daac2e7 --- /dev/null +++ b/old_code_ci3/controllers/Doctor.php @@ -0,0 +1,303 @@ +load->view('Doctor_Profile/Doctor_V'); + } + + public function search() + { + + $sql = "SELECT * FROM doctor_master "; + $query = $this->db->query($sql); + $data['data']= $query->result(); + + $this->load->view('Doctor_Profile/Doctor_Search_V',$data); + + } + + function doctor_record($pno) + { + + $sql="select * from doctor_master where id=$pno"; + $query = $this->db->query($sql); + $data['data']= $query->result(); + + $sql="select m.SpecName,m.id,d.doc_id,d.med_spec_id,d.id as doc_spec_id + from med_spec m join doc_spec d on m.id =d.med_spec_id where d.doc_id=".$pno; + $query = $this->db->query($sql); + $data['doc_spec_a']= $query->result(); + + $sql="select * from med_spec order by SpecName"; + $query = $this->db->query($sql); + $data['doc_spec_l']= $query->result(); + + $sql="select * from doc_fee_type order by fee_type"; + $query = $this->db->query($sql); + $data['doc_fee_type']= $query->result(); + + $sql="select d.id ,f.fee_type ,d.doc_fee_desc,d.amount + from doc_opd_fee d right join doc_fee_type f on d.doc_fee_type=f.id and d.doc_id=".$pno; + $query = $this->db->query($sql); + $data['doc_fee_list']= $query->result(); + + + $this->load->view('Doctor_Profile/Doctor_profile_V',$data); + } + + function doctor_record_spec() + { + + $this->load->model('Doctor_M'); + + if($this->input->post('isadd')==1) + { + $sql="select * from doc_spec where doc_id='".$this->input->post('doc_id')."' and med_spec_id='".$this->input->post('doc_spec')."'"; + $query = $this->db->query($sql); + $no_rec= $query->num_rows(); + if($no_rec==0) + { + $data = array( + 'doc_id' => $this->input->post('doc_id'), + 'med_spec_id' => $this->input->post('doc_spec') + ); + $inser_id=$this->Doctor_M->insert_spec($data); + $rvar=array( + 'insertid' =>$inser_id + ); + } + + }else{ + + $this->db->delete("doc_spec", "id=".$this->input->post('doc_spec_id')); + } + + + $sql="select m.SpecName,m.id,d.doc_id,d.med_spec_id,d.id as doc_spec_id from med_spec m join doc_spec d on m.id =d.med_spec_id where d.doc_id=".$this->input->post('doc_id'); + $query = $this->db->query($sql); + $data['doc_spec_a']= $query->result(); + + $show_Specility_list=""; + + foreach($data['doc_spec_a'] as $row) + { + + $show_Specility_list.= '
'; + $show_Specility_list.= ' '; + $show_Specility_list.= ' '; + $show_Specility_list.= ' '; + $show_Specility_list.= '
'; + } + + $rvar=array( + 'update' =>1, + 'csrfName' => $this->security->get_csrf_token_name(), + 'csrfHash' => $this->security->get_csrf_hash(), + 'show_Specility_list' => $show_Specility_list + ); + + $encode_data = json_encode($rvar); + echo $encode_data; + + + } + + public function UpdateRecord() + { + if (!$this->input->is_ajax_request()) { exit('no valid req.'); } + + $this->load->model('Doctor_M'); + $data = array( + 'p_title' => $this->input->post('select_title'), + 'mphone1' => $this->input->post('input_mphone1'), + 'p_fname' => $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'), + 'doc_sign' => $this->input->post('txt_doc_sign'), + 'email1' => $this->input->post('input_email') + ); + $old_id=$this->input->post('doc_id'); + $update=$this->Doctor_M->update($data,$old_id); + + if($update>0) + { + $rvar=array( + 'update' =>1, + 'showcontent'=> Show_Alert('success','Saved','Data Saved successfully') + ); + $encode_data = json_encode($rvar); + echo $encode_data; + } + + } + + public function AddNew() + { + if (!$this->input->is_ajax_request()) { exit('no valid req.'); } + + $this->load->library('form_validation'); + + $this->form_validation->set_rules('p_fname','Dr. Name','alpha_numeric_spaces|'); + $this->form_validation->set_rules('email1','Email','valid_email'); + $this->form_validation->set_rules('mphone1','MPhone','numeric'); + + $this->load->model('Doctor_M'); + + if($this->form_validation->run()) + { + $data = array( + 'p_title' => $this->input->post('select_title'), + 'mphone1' => $this->input->post('input_mphone1'), + 'p_fname' => $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'), + 'email1' => $this->input->post('input_email') + ); + + $inser_id=$this->Doctor_M->insert($data); + + redirect('Doctor/doctor_record/'.$inser_id); + + }else{ + $this->load->view('Doctor_Profile/Doctor_V'); + } + } + + public function remove_fee() + { + $this->load->model('Doctor_M'); + + $old_id=$this->input->post('rid'); + $update=$this->Doctor_M->delete_fee($old_id); + + $sql="select d.id ,f.fee_type ,d.doc_fee_desc,d.amount + from doc_opd_fee d join doc_fee_type f on d.doc_fee_type=f.id and d.doc_id=".$this->input->post('doc_id');; + $query = $this->db->query($sql); + $data['doc_fee_list']= $query->result(); + + $table_property = array('table_open' => ''); + $this->table->set_template($table_property); + $this->table->set_heading('Fee Type', 'description', 'Amount'); + foreach($data['doc_fee_list'] as $row) + { + if($row->id=='') + { + $button_code=' Not Define'; + }else{ + $button_code='Remove'; + } + + $this->table->add_row($row->fee_type, $row->doc_fee_desc, $row->amount,$button_code); + } + $show_fee_list= $this->table->generate(); + + if($update>0) + { + $rvar=array( + 'update' =>1, + 'csrfName' => $this->security->get_csrf_token_name(), + 'csrfHash' => $this->security->get_csrf_hash(), + 'showcontent'=> Show_Alert('success','Remove','Fee Removed successfully'), + 'show_fee_list' => $show_fee_list + ); + $encode_data = json_encode($rvar); + echo $encode_data; + }else{ + $rvar=array( + 'update' =>0, + 'csrfName' => $this->security->get_csrf_token_name(), + 'csrfHash' => $this->security->get_csrf_hash(), + 'showcontent'=> Show_Alert('danger','Error','Please Check') + ); + $encode_data = json_encode($rvar); + echo $encode_data; + } + } + + public function AddNew_fee() + { + if (!$this->input->is_ajax_request()) { exit('no valid req.'); } + $this->load->model('Doctor_M'); + $data = array( + 'doc_id' => $this->input->post('doc_id'), + 'doc_fee_desc' => $this->input->post('input_fee_desc'), + 'doc_fee_type' => $this->input->post('fee_type'), + 'amount' => $this->input->post('input_fee_amount') + ); + + + $sql="select * from doc_opd_fee where + doc_id=".$this->input->post('doc_id'). " and doc_fee_type = ".$this->input->post('fee_type'); + $query = $this->db->query($sql); + $doc_fee_update= $query->result(); + + if(count($doc_fee_update)>0) + { + $old_id=$doc_fee_update[0]->id; + $update=$this->Doctor_M->delete_fee($old_id); + } + + $inser_id=$this->Doctor_M->insert_fee($data); + + $sql="select d.id ,f.fee_type ,d.doc_fee_desc,d.amount + from doc_opd_fee d join doc_fee_type f on d.doc_fee_type=f.id + and d.doc_id=".$this->input->post('doc_id')." order by f.id"; + $query = $this->db->query($sql); + $data['doc_fee_list']= $query->result(); + + $table_property = array('table_open' => '
'); + $this->table->set_template($table_property); + $this->table->set_heading('Fee Type', 'description', 'Amount'); + foreach($data['doc_fee_list'] as $row) + { + if($row->id=='') + { + $button_code=' Not Define'; + }else{ + $button_code='Remove'; + } + + $this->table->add_row($row->fee_type, $row->doc_fee_desc, $row->amount,$button_code); + + } + + $show_fee_list= $this->table->generate(); + + if($inser_id>0) + { + $rvar=array( + 'inser_id' =>1, + 'csrfName' => $this->security->get_csrf_token_name(), + 'csrfHash' => $this->security->get_csrf_hash(), + 'showcontent'=> Show_Alert('success','Added','Fee added successfully'), + 'show_fee_list' => $show_fee_list + ); + $encode_data = json_encode($rvar); + echo $encode_data; + }else{ + $rvar=array( + 'inser_id' =>0, + 'csrfName' => $this->security->get_csrf_token_name(), + 'csrfHash' => $this->security->get_csrf_hash(), + 'showcontent'=> Show_Alert('danger','Error','Please Check') + ); + $encode_data = json_encode($rvar); + echo $encode_data; + } + } + + + + +} + diff --git a/old_code_ci3/controllers/Document_Patient.php b/old_code_ci3/controllers/Document_Patient.php new file mode 100644 index 0000000..5bd89b6 --- /dev/null +++ b/old_code_ci3/controllers/Document_Patient.php @@ -0,0 +1,418 @@ +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; + $query = $this->db->query($sql); + $data['person_info'] = $query->result(); + + $sql = "select * from doc_format_master where active=1 "; + $query = $this->db->query($sql); + $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 + 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; + + + $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; + $query = $this->db->query($sql); + $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(); + + $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); + + 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); + } + } + + $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();; + + 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'], + ); + + $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; + $query = $this->db->query($sql); + $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; + + $sql = "Select * from doc_format_master where df_id=" . $document_format_id; + $query = $this->db->query($sql); + $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(); + + $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); + + 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); + } + } + + $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; + $query = $this->db->query($sql); + $data['patient_doc'] = $query->result(); + + $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 + 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; + $query = $this->db->query($sql); + $data['doc_format_sub'] = $query->result(); + + $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; + $query = $this->db->query($sql); + $data['person_info'] = $query->result(); + + $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; + $query = $this->db->query($sql); + $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; + $query = $this->db->query($sql); + $data_value_pending = $query->result(); + + if (count($data_value_pending) > 0) { + $rvar = array( + 'update' => 0, + 'error_text' => 'Some Field Pending', + ); + + $encode_data = json_encode($rvar); + echo $encode_data; + } else { + $sql = "Select * from patient_doc where id=" . $p_doc_id; + $query = $this->db->query($sql); + $data_report_format = $query->result(); + + 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; + $query = $this->db->query($sql); + $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); + } + } + + $udata = array( + 'raw_data' => $Report_string, + 'update_pre_value' => 1, + ); + + $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; + } + } + + + + function load_doc($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; + } + + $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); + } + + 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; + $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; + $query = $this->db->query($sql); + $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 = '
+ + + + + + +
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; + } + + $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"; + + $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 + ); + + $this->load->model('File_M'); + + $this->File_M->insert($udata); + + //load mPDF library + $this->load->library('m_pdf'); + + //$this->m_pdf->pdf->SetProtection(array(), '1234567', '277395'); + + if ($print_on_type == 1) { + $this->m_pdf->pdf->SetWatermarkText(H_Name); + $this->m_pdf->pdf->showWatermarkText = true; + } + + $doc_content = $this->load->view('DocAdmin/doc_letterhead_print', $data, TRUE); + + //echo $content; + + //generate the PDF from the given html + $this->m_pdf->pdf->WriteHTML($doc_content); + + //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()); + } + + $rvar = array( + 'update_value' => $update_value, + 'showcontent' => $showcontent + ); + + $encode_data = json_encode($rvar); + echo $encode_data; + } +} diff --git a/old_code_ci3/controllers/DotPrint.php b/old_code_ci3/controllers/DotPrint.php new file mode 100644 index 0000000..64f6f2a --- /dev/null +++ b/old_code_ci3/controllers/DotPrint.php @@ -0,0 +1,165 @@ +db->query($sql); + $invoiceDetails= $query->result(); + + $sql="select sum(item_amount) as Gtotal from invoice_item where inv_master_id=".$invoice_id; + $query = $this->db->query($sql); + $invoiceGtotal= $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); + $invoice_master= $query->result(); + + $sql="select *,if(gender=1,'Male','FeMale') as xgender,if(age is null,Get_Age(dob),Concat(age,' ',age_in)) AS age from patient_master where id=".$invoice_master[0]->attach_id; + $query = $this->db->query($sql); + $patient_master= $query->result(); + + $sql="select *,(case payment_mode when 1 then 'Cash' when 2 then 'Bank Card' when 3 then 'Return Cash ' when 4 then 'Bank Return' else 'Other' end) as Payment_type_str from payment_history where payof_type=2 and payof_id=".$invoice_id; + $query = $this->db->query($sql); + $payment_history= $query->result(); + + $PrintData=' SOBAN SINGH JEEN BASE HOSPITAL , HALDWANI'.PHP_EOL; + $PrintData.='------------------------------------------------------------------------------'.PHP_EOL; + + $PatientID= 'Patient ID : '.$patient_master[0]->p_code; + $PatientName='Patient Name : '.$patient_master[0]->p_fname; + $PatientGA='Gender / Age : '.$patient_master[0]->xgender.'/'.$patient_master[0]->age; + $InoviceID= 'Invoice ID : '.$invoice_master[0]->invoice_code; + + + $PrintData.=str_pad($PatientID,35,' ',STR_PAD_RIGHT); + $PrintData.=str_pad($PatientName,35,' ',STR_PAD_RIGHT).PHP_EOL; + + $PrintData.=str_pad($InoviceID,35,' ',STR_PAD_RIGHT); + $PrintData.=str_pad($PatientGA,35,' ',STR_PAD_RIGHT).PHP_EOL; + + $PrintData.='------------------------------------------------------------------------------'.PHP_EOL; + $PrintData.=' '.PHP_EOL; + $PrintData.='# LAB Charge Name Rate Qty Amount '.PHP_EOL; + $PrintData.='------------------------------------------------------------------------------'.PHP_EOL; + + $srno=1; + foreach($invoiceDetails as $row) + { + $line=''; + $line.=str_pad($srno,3,' ',STR_PAD_RIGHT); + $line.=str_pad($row->group_desc,12,' ',STR_PAD_RIGHT); + $line.=str_pad($row->item_name,35,' ',STR_PAD_RIGHT); + $line.=str_pad($row->item_rate,10,' ',STR_PAD_LEFT); + $line.=str_pad($row->item_qty,7,' ',STR_PAD_LEFT); + $line.=str_pad($row->item_amount,10,' ',STR_PAD_LEFT); + + $srno=$srno+1; + $PrintData.=$line.PHP_EOL; + } + + $PrintData.='------------------------------------------------------------------------------'.PHP_EOL; + + $PrintData.=str_pad('Gross Total : '.$invoiceGtotal[0]->Gtotal,77,' ',STR_PAD_LEFT).PHP_EOL; + + if($invoice_master[0]->discount_amount>0) + { + $PrintData.=PHP_EOL; + $PrintData.=str_pad('Gross Total : '.$invoice_master[0]->discount_amount,77,' ',STR_PAD_LEFT).PHP_EOL ; + } + + if($invoice_master[0]->ipd_id<1) { + + $PrintData.=str_pad('Received Amt.:'.$invoice_master[0]->payment_part_received,26,' ',STR_PAD_RIGHT); + $PrintData.=str_pad('Balance Amt : '.$invoice_master[0]->payment_part_balance,26,' ',STR_PAD_RIGHT); + $PrintData.=str_pad('Net Amt : '.$invoice_master[0]->net_amount,26,' ',STR_PAD_LEFT).PHP_EOL; + } + + if($invoice_master[0]->correction_amount>0) + { + $PrintData.=str_pad('Correction : '.$invoice_master[0]->correction_remark,44,' ',STR_PAD_RIGHT); + $PrintData.=str_pad('Correction Amt : '.$invoice_master[0]->correction_amount,22,' ',STR_PAD_Left); + + $PrintData.=str_pad('Final Amount : '.$invoice_master[0]->correction_net_amount,77,' ',STR_PAD_LEFT).PHP_EOL; + } + + + $folder_name='uploads/printtemp'; + + if (!file_exists($folder_name)) { + mkdir($folder_name, 0777, true); + chmod($folder_name, 0777); + } + + $user = $this->ion_auth->user()->row(); + $user_id = $user->id; + $user_name = $user->first_name.''. $user->last_name; + + $output_dir = $folder_name; + $filename=date('Ymdhis').$invoice_master[0]->invoice_code.'.TXT'; + $PrintData.=PHP_EOL; + if($invoice_master[0]->payment_mode>2) { + $PrintData.='Payment Details : '.$invoice_master[0]->Payment_type_str.' '.PHP_EOL; + }else{ + $PrintData.='Payment Details :'; + + foreach($payment_history as $row) + { + $PrintData.='['.$row->id.':'.$row->Payment_type_str.':'.$row->amount.']/'; + } + $PrintData.=' '.PHP_EOL .PHP_EOL .PHP_EOL ; + } + + $PrintData.=str_pad('Prepared By : '.$invoice_master[0]->prepared_by,40,' ',STR_PAD_RIGHT).' '; + $PrintData.=str_pad(' Signature ',35,' ',STR_PAD_LEFT).' '.PHP_EOL; + + $myfile = fopen($output_dir.'/'.$filename, "w") or die("Unable to open file!"); + fwrite($myfile, $PrintData); + fclose($myfile); + + $this->load->model('DotPrint_M'); + + $insertdata = array( + 'created_by'=> $user_id, + 'file_type'=> 'TEXT', + 'file_name'=> $filename, + 'file_location'=>$folder_name + ); + + $inser_id=$this->DotPrint_M->insert( $insertdata); + + echo 'File Send To DotMatrix Printer / File ID : '.$inser_id; + } + + function read_dot_date($userid) + { + $user_id=str_replace('S',',',$userid); + + $sql="select id,file_type,file_name,file_location from dot_printer where print_status=0 and created_by in (".$user_id.")"; + $query = $this->db->query($sql); + $file_list= $query->result(); + + header('Content-type: application/json'); + echo json_encode($file_list); + } + + function printdone_dot($fileid,$print_by) + { + $this->load->model('DotPrint_M'); + + $updatedata = array( + 'print_status'=> '1', + 'print_by'=> $print_by + ); + + $updatestatus=$this->DotPrint_M->update( $updatedata,$fileid); + echo $updatestatus; + } + +} \ No newline at end of file diff --git a/old_code_ci3/controllers/IPD_Nursing.php b/old_code_ci3/controllers/IPD_Nursing.php new file mode 100644 index 0000000..97352d0 --- /dev/null +++ b/old_code_ci3/controllers/IPD_Nursing.php @@ -0,0 +1,139 @@ +db->query($sql); + $data['data']= $query->result(); + + $this->load->view('IPD_Nursing/IPDList_V',$data); + } + + public function ipd_panel($ipdcode,$stype=0) + { + + if($stype > 0) + { + $sql="select id from ipd_master where ipd_code='".$ipdcode."' "; + $query = $this->db->query($sql); + $get_ipd_no= $query->result(); + + $ipdno=$get_ipd_no[0]->id; + }else{ + $ipdno=$ipdcode; + } + + //calculate_IPD + + $this->load->model('Ipd_M'); + $this->Ipd_M->calculate_IPD($ipdno); + + $sql="select * from v_ipd_list where id='".$ipdno."' "; + $query = $this->db->query($sql); + $data['ipd_info']= $query->result(); + + $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 + from patient_master where id='".$p_id."' "; + $query = $this->db->query($sql); + $data['person_info']= $query->result(); + + $sql="select * + from ipd_master_doc_list i join doctor_master d on i.doc_id = d.id + where ipd_id='".$ipdno."' "; + $query = $this->db->query($sql); + $data['ipd_doc_list']= $query->result(); + + $sql="select * + from organization_case_master + where status=0 and case_type=1 and ipd_id=$ipdno and p_id=".$p_id; + $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 + from payment_history + where payof_type=4 and payof_id='".$ipdno."' "; + $query = $this->db->query($sql); + $data['ipd_payment_history']= $query->result(); + + $this->load->view('IPD_Nursing/IPD_Panel',$data); + } + + public function ipd_main_panel($ipdno) + { + $sql="select *,if(ipd_status=0,DATEDIFF(sysdate(),register_date),DATEDIFF(discharge_date,register_date)) as no_days from ipd_master where id='".$ipdno."' "; + $query = $this->db->query($sql); + $data['ipd_info']= $query->result(); + + $sql="select * from v_ipd_list where id='".$ipdno."' "; + $query = $this->db->query($sql); + $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."' "; + $query = $this->db->query($sql); + $data['person_info']= $query->result(); + + $sql="select *,concat_ws(' ','Dr.',p_fname,p_mname,p_lname) as doc_name from doctor_master where id='".$data['ipd_info'][0]->r_doc_id."' "; + $query = $this->db->query($sql); + $data['doc_info']= $query->result(); + + $sql="select i.id,d.p_fname,d.id as doc_id from ipd_master_doc_list i join doctor_master d on i.doc_id = d.id where ipd_id='".$ipdno."' "; + $query = $this->db->query($sql); + $data['ipd_doc_list']= $query->result(); + + $sql="select * from organization_case_master + where id=".$data['ipd_info'][0]->case_id; + $query = $this->db->query($sql); + $data['case_master']= $query->result(); + + $sql="select * from organization_case_master + where status=0 and case_type=1 and ipd_id=0 and p_id=".$data['ipd_info'][0]->p_id; + $query = $this->db->query($sql); + $data['case_master_open']= $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 * from org_approved_status "; + $query = $this->db->query($sql); + $data['org_approved_status']= $query->result(); + + $sql="select * from refer_master "; + $query = $this->db->query($sql); + $data['refer_master']= $query->result(); + + + + $this->load->view('IPD_Nursing/ipd_main_panel',$data); + } + + function ipd_treatment($ipd_id) + { + $sql="select * from ipd_treatment_chart where ipd_id=$ipd_id order by t_datetime"; + $query = $this->db->query($sql); + $data['ipd_treatment_chart']= $query->result(); + + + $this->load->view('IPD_Nursing/ipd_treatment',$data); + } + + +} \ No newline at end of file diff --git a/old_code_ci3/controllers/Insurance.php b/old_code_ci3/controllers/Insurance.php new file mode 100644 index 0000000..1e53d71 --- /dev/null +++ b/old_code_ci3/controllers/Insurance.php @@ -0,0 +1,98 @@ +1 "; + $query = $this->db->query($sql); + $data['data']= $query->result(); + $this->load->view('insurance/insurance_search_v',$data); + } + + function insurance_record($id) + { + + $sql="select * from hc_insurance where id=".$id; + $query = $this->db->query($sql); + $data['data_insurance']= $query->result(); + + $this->load->view('insurance/insurance_profile_V',$data); + } + + public function UpdateRecord() + { + if (!$this->input->is_ajax_request()) { exit('no valid req.'); } + + $this->load->model('insurance_M'); + $data = array( + 'ins_company_name' => $this->input->post('input_comp_name'), + 'short_name' => $this->input->post('input_short_name'), + 'ins_contact_number' => $this->input->post('input_mphone1'), + 'ins_contact_person_name' => $this->input->post('input_cname'), + 'ins_email' => $this->input->post('input_email'), + 'active' => $this->input->post('chk_active'), + 'opd_allowed' => $this->input->post('chk_opd_allowed'), + 'opd_fee' => $this->input->post('input_opd_fee'), + 'opd_rate_direct' => $this->input->post('optionsRadios_opd_rate_direct'), + 'opd_desc' => $this->input->post('input_opd_fee_desc'), + 'opd_master_rate_discount' => $this->input->post('input_opd_master_rate_discount'), + 'opd_credit' => $this->input->post('chk_opd_credit'), + 'opd_cash' => $this->input->post('chk_opd_cash'), + 'charge_credit' => $this->input->post('chk_charge_credit'), + 'charge_rate_direct' => $this->input->post('optionsRadios_charge_rate_direct'), + 'charge_rate_dicount' => $this->input->post('input_charge_rate_dicount'), + 'med_credit' => $this->input->post('chk_med_credit'), + + ); + $old_id=$this->input->post('p_id'); + $update=$this->insurance_M->update($data,$old_id); + + if($update>0) + { + $rvar=array( + 'update' =>1, + 'showcontent'=> Show_Alert('success','Saved','Data Saved successfully') + ); + $encode_data = json_encode($rvar); + echo $encode_data; + } + + } + + public function AddRecord() + { + $this->load->view('insurance/insurance_create_V'); + } + + public function CreateRecord() + { + if (!$this->input->is_ajax_request()) { exit('no valid req.'); } + + $this->load->model('insurance_M'); + $data = array( + 'ins_company_name' => $this->input->post('input_comp_name'), + 'ins_contact_number' => $this->input->post('input_mphone1'), + 'ins_contact_person_name' => $this->input->post('input_cname'), + 'ins_email' => $this->input->post('input_email') + ); + + $inser_id=$this->insurance_M->insert($data); + + if($inser_id>0) + { + + $rvar=array( + 'insertid' =>$inser_id + ); + $encode_data = json_encode($rvar); + echo $encode_data; + } + + } +} \ No newline at end of file diff --git a/old_code_ci3/controllers/Invoice.php b/old_code_ci3/controllers/Invoice.php new file mode 100644 index 0000000..f387cca --- /dev/null +++ b/old_code_ci3/controllers/Invoice.php @@ -0,0 +1,879 @@ +load->view('Invoice/Invoice_opd'); + } + + public function chargeslist() + { + $this->load->view('Invoice/Invoice_charges'); + } + + public function search_opd() + { + $sdata=$this->input->post('txtsearch'); + + $sdata = preg_replace('/[^A-Za-z0-9_ \-]/', '', $sdata); + + $sql = "select o.opd_id, o.doc_name,o.opd_code,o.P_name,o.p_id,Date_Format(o.apointment_date,'%d-%m-%Y') as App_Date, + p.p_code,p.mphone1,p.email1 ,if(o.insurance_id>1,'Org.','Direct') as Inv_Type, + if(o.payment_status=1,m.mode_desc,'Pending') as PaymentMode,o.payment_mode + from (opd_master o join patient_master p on o.p_id=p.id ) join payment_mode m on o.payment_mode=m.id + WHERE opd_code like '%".$sdata."' or p_code like '%".$sdata."' or P_name like '%".$sdata."%' or + mphone1 = '".$sdata."' or email1 = '".$sdata."' order by o.opd_id desc limit 100"; + + $query = $this->db->query($sql); + $data['opd_list']= $query->result(); + + $this->load->view('Invoice/Invoice_opd_list',$data); + } + + public function search_charges() + { + $sdata=$this->input->post('txtsearch'); + + $sdata = preg_replace('/[^A-Za-z0-9_\-]/', '', $sdata); + + $sql = "select i.id as inv_id, i.refer_by_other,i.invoice_code,p.p_fname,i.attach_id, + Date_Format(i.inv_date,'%d-%m-%Y') as Inv_Date,p.p_code,p.mphone1,p.email1, + if(i.insurance_id>1,'Org.','Direct') as Inv_Type,i.invoice_status, + m.mode_desc as PaymentMode,i.payment_mode,i.payment_part_balance,i.net_amount + from invoice_master i join patient_master p join payment_mode m + on i.attach_id=p.id and i.attach_type=0 and i.payment_mode=m.id + WHERE invoice_code like '%".$sdata."' or p_code like '%".$sdata."' or p_fname like '%".$sdata."%' or + mphone1 = '".$sdata."' or email1 = '".$sdata."' order by i.id desc limit 100"; + + $query = $this->db->query($sql); + $data['charges_list']= $query->result(); + + $this->load->view('Invoice/Invoice_charges_list',$data); + } + + public function opdinvoice($opdid) + { + $sql="select *,(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); + $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."' "; + + $query = $this->db->query($sql); + $data['patient_master']= $query->result(); + + $sql="select * from ipd_master where ipd_status=0 and p_id=".$data['opd_master'][0]->p_id; + $query = $this->db->query($sql); + $data['ipd_master']= $query->result(); + + $sql="select * from organization_case_master where status=0 and p_id=".$data['patient_master'][0]->id; + $query = $this->db->query($sql); + $data['case_master']= $query->result(); + + $sql="select * from hc_insurance where id=".$data['opd_master'][0]->insurance_id; + $query = $this->db->query($sql); + $data['insurance']= $query->result(); + + + $this->load->view('Invoice/Invoice_opd_correction',$data); + } + + + public function showinvoice($invoice_id) + { + $sql="select i.*,t.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 *,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; + $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; + $query = $this->db->query($sql); + $data['ipd_master']= $query->result(); + + $this->load->view('Invoice/Invoice_Charges_correction',$data); + } + + + public function update_correction() + { + $oid=$this->input->post('oid'); + + $user = $this->ion_auth->user()->row(); + $user_id = $user->id; + $user_name = $user->first_name.''. $user->last_name; + + $opd_correction=$this->input->post('input_corr_amt'); + + $sql="select * from opd_master where opd_id=".$oid; + $query = $this->db->query($sql); + $data['opd_master']= $query->result(); + + $flag=true; + + if($this->input->post('optionsRadios_crdr')==1) + { + if($opd_correction>0 && $data['opd_master'][0]->opd_fee_gross_amount>=$opd_correction) + { + $opd_fee_amount=$data['opd_master'][0]->opd_fee_gross_amount-$opd_correction; + $opd_fee_amount=$opd_fee_amount-$data['opd_master'][0]->opd_discount; + }else{ + $flag=false; + } + }else{ + $opd_fee_amount=$data['opd_master'][0]->opd_fee_gross_amount+$opd_correction; + $opd_fee_amount=$opd_fee_amount-$data['opd_master'][0]->opd_discount; + } + + if($flag) + { + $dataupdate = array( + 'opd_correction_amount' => $this->input->post('input_corr_amt'), + 'opd_correction_remark' => $this->input->post('input_corr_desc'), + 'opd_correction_user' => $user_name, + 'opd_correction_crdr' => $this->input->post('optionsRadios_crdr'), + 'opd_correction_datetime' => date('Y-m-d H:i:s'), + 'opd_fee_amount' => $opd_fee_amount + ); + + $this->load->model('Opd_M'); + $this->Opd_M->update($dataupdate,$oid); + + $this->load->model('Payment_M'); + + if($this->input->post('optionsRadios_crdr')==1) + { + $credit_debit=1; + } + else{ + $credit_debit=0; + } + + $paydata = array( + 'payment_mode'=> '1', + 'payof_type'=>'1', + 'payof_id'=>$oid, + 'payof_code'=>$data['opd_master'][0]->opd_code, + 'credit_debit'=>$credit_debit, + 'amount'=>$this->input->post('input_corr_amt'), + 'payment_date'=>date('Y-m-d H:i:s'), + 'remark'=>$this->input->post('input_corr_desc'), + 'update_by'=>$user_name.'['.$user_id.']', + 'update_by_id'=>$user_id + ); + + $insert_id=$this->Payment_M->insert($paydata); + }else{ + + } + } + + + public function update_correction_charges() + { + $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; + + $correction=$this->input->post('input_corr_amt'); + + $sql="select * from invoice_master where id=".$invoice_id; + $query = $this->db->query($sql); + $data['invoice_master']= $query->result(); + + $flag=true; + + if($correction>0 && $data['invoice_master'][0]->net_amount>=$correction) + { + $net_amount=$data['invoice_master'][0]->net_amount-$correction; + }else{ + $flag=false; + } + + if($flag) + { + $dataupdate = array( + 'correction_amount' => $this->input->post('input_corr_amt'), + 'correction_remark' => $this->input->post('input_corr_desc'), + 'correction_user' => $user_name, + 'correction_crdr' => $this->input->post('optionsRadios_crdr'), + 'correction_datetime' => date('Y-m-d H:i:s'), + 'correction_net_amount' => $fee_amount, + 'invoice_status' => '3' + ); + + $this->load->model('Invoice_M'); + $this->Invoice_M->update($dataupdate,$invoice_id); + + $this->load->model('Payment_M'); + + $paydata = array( + 'payment_mode'=> '3', + 'payof_type'=>'2', + 'payof_id'=>$invoice_id, + 'payof_code'=>$data['invoice_master'][0]->invoice_code, + 'credit_debit'=>1, + 'amount'=>$this->input->post('input_corr_amt'), + 'payment_date'=>date('Y-m-d H:i:s'), + 'remark'=>$this->input->post('input_corr_desc'), + 'update_by'=>$user_name.'['.$user_id.']', + 'update_by_id'=>$user_id + ); + $insert_id=$this->Payment_M->insert($paydata); + } + + } + + + + public function list_refund() + { + $this->load->view('Invoice/refund_invoice'); + } + + + + public function getRequestTable() + { + + $requestData= $_REQUEST; + + $columns = array( + // datatable column index => database column name + 0 =>'id', + 1 => 'org_code', + 2 => 'patient_name', + 3 => 'org_date_str', + 4=> 'payment_amount', + 5=> 'payment_process_str' + ); + + // getting total number records without any search + $sql_f_all = "select *, + date_format(payment_request_datetime,'%d-%m-%Y %h:%i:%s') as org_date_str, + if(payment_process=0,'Pending','Complete') as payment_process_str " ; + + $sql_count="Select count(*) as no_rec "; + + $sql_from=" from org_payment_request "; + + $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']) ){ //CaseCode-InsuranceCard-ClaimNo + $sql_where.=" AND id = '".$requestData['columns'][0]['search']['value']."' "; + $sql_where_flag=1; + } + + // getting records as per search parameters + if( !empty($requestData['columns'][1]['search']['value']) ){ //CaseCode-InsuranceCard-ClaimNo + $sql_where.=" AND org_code LIKE '%".$requestData['columns'][1]['search']['value']."' "; + $sql_where_flag=1; + } + + if( !empty($requestData['columns'][2]['search']['value']) ){ //p_code-P-Name + $sql_where.=" AND ( patient_name 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 ". $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 getRefundTable() + { + + $requestData= $_REQUEST; + + $columns = array( + // datatable column index => database column name + 0 =>'id', + 1 => 'refund_type_code', + 2 => 'refund_type_str', + 3 => 'patient_name', + 4=> 'approved_datetime', + 5=> 'refund_amount', + 6=> 'refund_process_str' + ); + + // getting total number records without any search + $sql_f_all = "select *, + (case refund_type when 1 then 'OPD' when 2 then 'Charge' when 3 then 'Org.Inv.' else 'Other' end ) as refund_type_str , + if(refund_process<1,'Pending','Complete') as refund_process_str"; + + $sql_count="Select count(*) as no_rec "; + + $sql_from=" from refund_order "; + + $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']) ){ //CaseCode-InsuranceCard-ClaimNo + $sql_where.=" AND refund_type_code LIKE '%".$requestData['columns'][0]['search']['value']."%' "; + $sql_where_flag=1; + } + + if( !empty($requestData['columns'][1]['search']['value']) ){ //p_code-P-Name + $sql_where.=" AND ( patient_name LIKE '%".$requestData['columns'][1]['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 refund_form($rid) + { + $sql="select * from refund_order where id=".$rid; + $query = $this->db->query($sql); + $data['refund_order']= $query->result(); + + $this->load->view('Invoice/refund_amount_panel',$data); + } + + + + public function refund_process() + { + $r_id=$this->input->post('r_id'); + $r_name=$this->input->post('r_name'); + $r_phone=$this->input->post('r_phone'); + + $this->load->model('Invoice_M'); + $this->load->model('Payment_M'); + + $user = $this->ion_auth->user()->row(); + $user_id = $user->id; + $user_name = $user->first_name.' '. $user->last_name; + + $sql="select * from refund_order where id=".$r_id; + $query = $this->db->query($sql); + $refund_order= $query->result(); + + if(count($refund_order)>0) + { + if($refund_order[0]->refund_process>0) + { + $showcontent='Already Done '; + $rvar=array( + 'update' =>0, + 'showcontent'=>$showcontent + ); + $encode_data = json_encode($rvar); + }else{ + + if($refund_order[0]->refund_type==2) + { + $paydata = array( + 'payment_mode'=> '1', + 'payof_type'=>'2', + 'payof_id'=>$refund_order[0]->refund_type_id, + 'payof_code'=>$refund_order[0]->refund_type_code, + 'credit_debit'=>'1', + 'amount'=>$refund_order[0]->refund_amount, + 'payment_date'=>date('Y-m-d H:i:s'), + 'remark'=>$refund_order[0]->refund_type_reason, + 'update_by'=>$user_name.'['.$user_id.']', + 'update_by_id'=>$user_id + ); + + $insert_id=$this->Payment_M->insert($paydata); + + $inv_id=$refund_order[0]->refund_type_id; + + $data = array( + 'refund_process'=> '1', + 'refund_by'=>$user_name.'['.$user_id.']', + 'refund_by_id'=>$user_id, + 'refund_datetime'=>date('Y-m-d H:i:s'), + 'pay_id'=>$insert_id + ); + + $this->Payment_M->update_refundorder($data,$r_id); + + $showcontent='Refund Update'; + + $rvar=array( + 'update' =>1, + 'showcontent'=>$showcontent + ); + $encode_data = json_encode($rvar); + + $this->Invoice_M->update_invoice_final($refund_order[0]->refund_type_id); + } + + if($refund_order[0]->refund_type==1) + { + $paydata = array( + 'payment_mode'=> '1', + 'payof_type'=>'1', + 'payof_id'=>$refund_order[0]->refund_type_id, + 'payof_code'=>$refund_order[0]->refund_type_code, + 'credit_debit'=>'1', + 'amount'=>$refund_order[0]->refund_amount, + 'payment_date'=>date('Y-m-d H:i:s'), + 'remark'=>$refund_order[0]->refund_type_reason, + 'update_by'=>$user_name.'['.$user_id.']', + 'update_by_id'=>$user_id + ); + + $insert_id=$this->Payment_M->insert($paydata); + + $inv_id=$refund_order[0]->refund_type_id; + + $data = array( + 'refund_process'=> '1', + 'refund_by'=>$user_name.'['.$user_id.']', + 'refund_by_id'=>$user_id, + 'refund_datetime'=>date('Y-m-d H:i:s'), + 'pay_id'=>$insert_id + ); + + $this->Payment_M->update_refundorder($data,$r_id); + + $showcontent='Refund Update'; + + $rvar=array( + 'update' =>1, + 'showcontent'=>$showcontent + ); + $encode_data = json_encode($rvar); + } + + if($refund_order[0]->refund_type==3) + { + $paydata = array( + 'payment_mode'=> '1', + 'payof_type'=>'3', + 'payof_id'=>$refund_order[0]->refund_type_id, + 'payof_code'=>$refund_order[0]->refund_type_code, + 'credit_debit'=>'1', + 'amount'=>$refund_order[0]->refund_amount, + 'payment_date'=>date('Y-m-d H:i:s'), + 'remark'=>$refund_order[0]->refund_type_reason, + 'update_by'=>$user_name.'['.$user_id.']', + 'update_by_id'=>$user_id + ); + + $insert_id=$this->Payment_M->insert($paydata); + + $inv_id=$refund_order[0]->refund_type_id; + + $data = array( + 'refund_process'=> '1', + 'refund_by'=>$user_name.'['.$user_id.']', + 'refund_by_id'=>$user_id, + 'refund_datetime'=>date('Y-m-d H:i:s'), + 'pay_id'=>$insert_id + ); + + $this->Payment_M->update_refundorder($data,$r_id); + + $showcontent='Refund Update'; + + $rvar=array( + 'update' =>1, + 'showcontent'=>$showcontent + ); + $encode_data = json_encode($rvar); + } + } + }else{ + $showcontent='No Record Found '; + + $rvar=array( + 'update' =>0, + 'showcontent'=>$showcontent + ); + $encode_data = json_encode($rvar); + } + + echo $encode_data; + } + + public function list_req_payment() + { + $this->load->view('Invoice/payment_request_list'); + } + + public function req_payment_process() + { + $mode=$this->input->post('mode'); + $amount=$this->input->post('amount'); + $req_payment_id=$this->input->post('req_payment_id'); + $cash_remark=$this->input->post('cash_remark'); + + $input_card_mac=$this->input->post('input_card_mac'); + $input_card_bank=$this->input->post('input_card_bank'); + $input_card_digit=$this->input->post('input_card_digit'); + $input_card_tran=$this->input->post('input_card_tran'); + + $this->load->model('Invoice_M'); + $this->load->model('Payment_M'); + + $user = $this->ion_auth->user()->row(); + $user_id = $user->id; + $user_name = $user->first_name.' '. $user->last_name; + + $sql="select * from org_payment_request where id=".$req_payment_id; + $query = $this->db->query($sql); + $org_payment_request= $query->result(); + + if(count($org_payment_request)>0) + { + if($org_payment_request[0]->payment_process>0) + { + $showcontent='Already Done : Print Invoice '; + $rvar=array( + 'update' =>0, + 'showcontent'=>$showcontent + ); + + }else{ + + $paydata = array( + 'payment_mode'=> $mode, + 'payof_type'=>'3', + 'payof_id'=>$org_payment_request[0]->org_id, + 'payof_code'=>$org_payment_request[0]->org_code, + 'credit_debit'=>'0', + 'amount'=>$org_payment_request[0]->payment_amount, + 'payment_date'=>date('Y-m-d H:i:s'), + 'remark'=>$cash_remark, + 'update_by'=>$user_name.'['.$user_id.']', + 'update_by_id'=>$user_id, + 'card_bank'=>$input_card_mac, + 'card_remark'=>$input_card_bank, + 'cust_card'=>$input_card_digit, + 'card_tran_id'=>$input_card_tran, + ); + + $insert_id=$this->Payment_M->insert($paydata); + + if($insert_id>0) + { + $data = array( + 'payment_process'=> '1', + 'payment_accept_by'=>$user_name.'['.$user_id.']', + 'payment_accept_by_id'=>$user_id, + 'payment_datetime'=>date('Y-m-d H:i:s'), + 'pay_id'=>$insert_id + ); + + $this->Payment_M->update_org_payment($data,$req_payment_id); + + $showcontent='Amount Receipt : Print Invoice '; + + $rvar=array( + 'update' =>1, + 'showcontent'=>$showcontent, + 'payid'=>$insert_id, + ); + } + + + + } + }else{ + $showcontent='No Record Found '; + + $rvar=array( + 'update' =>0, + 'showcontent'=>$showcontent, + 'payid'=>0, + ); + + } + + $encode_data = json_encode($rvar); + + echo $encode_data; + } + + public function payment_form($req_id) + { + $sql="select * from org_payment_request where id=".$req_id; + $query = $this->db->query($sql); + $data['req_payment_order']= $query->result(); + + if(count($data['req_payment_order'])>0) + { + $sql="select * from organization_case_master + where id='".$data['req_payment_order'][0]->org_id."' "; + $query = $this->db->query($sql); + $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."' "; + $query = $this->db->query($sql); + $data['person_info']= $query->result(); + + if($data['req_payment_order'][0]->payment_process>0){ + $showcontent='Amount Receipt : Print Payment Reciept '; + echo $showcontent; + + }else{ + $this->load->view('Invoice/payment_req_panel',$data); + } + }else{ + echo 'No Record Found'; + } + } + + public function getReqPaymentTable() + { + + $requestData= $_REQUEST; + + $columns = array( + // datatable column index => database column name + 0 =>'id', + 1 => 'org_code', + 2 => 'payment_type_str', + 3 => 'patient_name', + 4=> 'payment_request_datetime', + 5=> 'payment_amount', + 6=> 'payment_process_str' + ); + + // getting total number records without any search + $sql_f_all = "select *, + (case payment_type when 1 then 'ORG' else 'Other' end ) as payment_type_str , + if(payment_process<1,'Pending','Complete') as payment_process_str"; + + $sql_count="Select count(*) as no_rec "; + + $sql_from=" from org_payment_request "; + + $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']) ){ //CaseCode-InsuranceCard-ClaimNo + $sql_where.=" AND org_code LIKE '%".$requestData['columns'][0]['search']['value']."%' "; + $sql_where_flag=1; + } + + if( !empty($requestData['columns'][1]['search']['value']) ){ //p_code-P-Name + $sql_where.=" AND ( patient_name LIKE '%".$requestData['columns'][1]['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 print_org_payment_invoice($req_id) + { + $sql="select *, + date_format(payment_datetime,'%d-%m-%Y %h:%i:%s') as payment_date_str + from org_payment_request where id=".$req_id; + $query = $this->db->query($sql); + $data['req_payment_order']= $query->result(); + + if(count($data['req_payment_order'])>0) + { + $sql="select * from organization_case_master where id='".$data['req_payment_order'][0]->org_id."' "; + $query = $this->db->query($sql); + $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."' "; + $query = $this->db->query($sql); + $data['patient_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='Invoice-Org-'.date('Ymdhis').".pdf"; + + $filepath=$file_name; + $content=$this->load->view('Invoice/Invoice_org_payment',$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"); + + }else{ + echo 'No Record Found'; + } + + + } + + +} \ No newline at end of file diff --git a/old_code_ci3/controllers/InvoiceShow.php b/old_code_ci3/controllers/InvoiceShow.php new file mode 100644 index 0000000..4722e7a --- /dev/null +++ b/old_code_ci3/controllers/InvoiceShow.php @@ -0,0 +1,60 @@ +db->query($sql); + $data['invoice_master']= $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(tamount) as Gtotal,sum(amount) as amt,sum(vamount) as vamt from inv_med_item where inv_med_id=".$inv_id; + $query = $this->db->query($sql); + $data['invoiceGtotal']= $query->result(); + + $sql="select * from ipd_master where ipd_status=0 and p_id=".$data['invoice_master'][0]->patient_id; + $query = $this->db->query($sql); + $data['ipd_master']= $query->result(); + + $sql="select * from organization_case_master where status=0 and p_id=".$data['invoice_master'][0]->patient_id; + $query = $this->db->query($sql); + $data['orgcase']= $query->result(); + + $this->load->view('invoiceshow/invoice_medical',$data); + } + + + public function invoice_charges($invoice_id) + { + $sql="select i.*,t.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 *,(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 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, + IFNULL(GET_AGE_BY_DOB(dob),age) AS age from patient_master where id=".$data['invoice_master'][0]->attach_id; + $query = $this->db->query($sql); + $data['patient_master']= $query->result(); + + $this->load->view('invoiceshow/invoice_charges',$data); + } + + + +} \ No newline at end of file diff --git a/old_code_ci3/controllers/Ipd.php b/old_code_ci3/controllers/Ipd.php new file mode 100644 index 0000000..29f1005 --- /dev/null +++ b/old_code_ci3/controllers/Ipd.php @@ -0,0 +1,2202 @@ +load->view('IPD/ipd_dashboard'); + } + + public function ipd_panel_payment($ipdno) + { + $sql="select * from ipd_master where id='".$ipdno."' "; + $query = $this->db->query($sql); + $data['ipd_master']= $query->result(); + + $discount=$data['ipd_master'][0]->Discount; + $discount2=$data['ipd_master'][0]->Discount2; + $discount3=$data['ipd_master'][0]->Discount3; + + $tdiscount=$discount+$discount2+$discount3; + + $charge1=$data['ipd_master'][0]->chargeamount1; + $charge2=$data['ipd_master'][0]->chargeamount2; + $tcharge=$charge1+$charge2; + + $sql="select *,Date_Format(pay_date,'%d-%M') as pay_date_str, + case payment_mode when 1 then 'Cash' + when 2 then 'Bank Card' + when 3 then 'Cash Return' + when 4 then 'Bank Return' + else 'Other' end as pay_mode from ipd_payment where ipd_id='".$ipdno."' "; + $query = $this->db->query($sql); + $data['ipd_payment']= $query->result(); + + $sql="select * from invoice_med_master where payment_status=1 and ipd_id = ".$ipdno; + $query = $this->db->query($sql); + $data['inv_med_master']= $query->result(); + + $sql="select i.id as inv_id,i.invoice_code,sum(t.item_amount) as amount,i.refer_by_other, + date_format(i.inv_date,'%d-%m-%Y') as str_date,i.ipd_include, + group_concat(distinct c.group_desc) as charge_list + from invoice_master i left join + (invoice_item t join hc_item_type c on t.item_type=c.itype_id) + on i.id =t.inv_master_id + where payment_status=1 and ipd_id = ".$ipdno." group by i.id "; + + $query = $this->db->query($sql); + $data['inv_master']= $query->result(); + + $total_med=0.00; + $total_charges=0.00; + + $sql="select sum(net_amount) as tnet_amount from invoice_med_master where payment_status=1 and ipd_id = ".$ipdno; + $query = $this->db->query($sql); + $data['inv_med_total']= $query->result(); + + $total_med=$data['inv_med_total'][0]->tnet_amount; + + $sql="select sum(total_amount) as tnet_amount from invoice_master where payment_status=1 and ipd_include=0 and ipd_id = ".$ipdno; + $query = $this->db->query($sql); + $data['inv_charge_not_total']= $query->result(); + + $sql="select sum(net_amount) as tnet_amount from invoice_master where payment_status=1 and ipd_include=1 and ipd_id = ".$ipdno; + $query = $this->db->query($sql); + $data['inv_charge_total']= $query->result(); + + $total_charges=$data['inv_charge_total'][0]->tnet_amount; + + $sql="select sum(if(credit_debit=0,amount,amount*-1)) as t_ipd_pay from ipd_payment where ipd_id='".$ipdno."' "; + $query = $this->db->query($sql); + $data['inv_payment_total']= $query->result(); + + $total_payment=$data['inv_payment_total'][0]->t_ipd_pay; + + $balance=$total_payment-($total_charges+$tcharge-$tdiscount); + + $data['inv_total']=array( + 'total_med' => $total_med, + 'total_charges' => $total_charges, + 'total_payment' => $total_payment, + 'ipd_id' => $ipdno, + 'discount' => $tdiscount, + 'balance' => $balance, + 'charge' => $tcharge + ); + + $this->load->view('IPD/ipd_payment',$data); + } + + public function ipd_panel_invoice_show() + { + $inv_id=$this->input->post('invid'); + $inv_type=$this->input->post('invtype'); + + if($inv_type == 0) + { + redirect('InvoiceShow/invoice_med/'.$inv_id); + }else{ + redirect('InvoiceShow/invoice_charges/'.$inv_id); + } + } + + public function show_account($ipdno) + { + $total_med=0.00; + $total_charges=0.00; + + $sql="select * from ipd_master where id='".$ipdno."' "; + $query = $this->db->query($sql); + $data['ipd_master']= $query->result(); + + $discount=$data['ipd_master'][0]->Discount; + $discount2=$data['ipd_master'][0]->Discount2; + $discount3=$data['ipd_master'][0]->Discount3; + + $tdiscount=$discount+$discount2+$discount3; + + $charge1=$data['ipd_master'][0]->chargeamount1; + $charge2=$data['ipd_master'][0]->chargeamount2; + $tcharge=$charge1+$charge2; + + $sql="select sum(net_amount) as tnet_amount from invoice_med_master where ipd_credit=1 and ipd_credit_type<2 and ipd_id = ".$ipdno; + $query = $this->db->query($sql); + $data['inv_med_total']= $query->result(); + + $total_med=$data['inv_med_total'][0]->tnet_amount; + + $sql="select sum(total_amount) as tnet_amount from invoice_master where payment_status=1 and ipd_id = ".$ipdno; + $query = $this->db->query($sql); + $data['inv_charge_total']= $query->result(); + + $total_charges=$data['inv_charge_total'][0]->tnet_amount; + + $sql="select sum(if(credit_debit>0,amount*-1,amount)) as tnet_amount from ipd_payment where ipd_id='".$ipdno."' "; + $query = $this->db->query($sql); + $data['inv_payment_total']= $query->result(); + + $total_payment=$data['inv_payment_total'][0]->tnet_amount; + + $total_balance_amount=$total_payment-($total_charges+$total_med+$tcharge-$tdiscount); + + $data['inv_total']=array( + 'total_med' => $total_med, + 'total_charges' => $total_charges, + 'total_payment' => $total_payment, + 'total_balance_amount' => $total_balance_amount, + 'discount' => $tdiscount, + 'charge' => $tcharge, + 'ipd_id' => $ipdno + ); + + $this->load->view('IPD/ipd_account_panel',$data); + + } + + public function ipd_complete_invoice($ipdno,$print=0) + { + $this->db->query("CALL p_cal_ipd_master(".$ipdno.")"); + $sql="select * from ipd_master where id=".$ipdno; + $query = $this->db->query($sql); + $data['ipdmaster']= $query->result(); + + $sql="select * from v_ipd_list where id=".$ipdno; + $query = $this->db->query($sql); + $data['ipd_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=".$ipdno." order by TDate desc"; + $query = $this->db->query($sql); + $data['bed_list']= $query->result(); + + $pno=$data['ipdmaster'][0]->p_id; + $case_id=$data['ipdmaster'][0]->case_id; + + $discount=$data['ipdmaster'][0]->Discount; + $discount2=$data['ipdmaster'][0]->Discount2; + $discount3=$data['ipdmaster'][0]->Discount3; + + $charge1=$data['ipdmaster'][0]->chargeamount1; + $charge2=$data['ipdmaster'][0]->chargeamount2; + $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."' "; + + $query = $this->db->query($sql); + $data['person_info']= $query->result(); + + $total_med=0.00; + $total_charges=0.00; + + if($data['ipdmaster'][0]->case_id>0) + { + $sql="select * from organization_case_master where id='".$data['ipdmaster'][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(); + } + + $sql="select * from v_ipd_bill_invoice v + where v.ipd_id=".$ipdno." order by v.Charge_type "; + + $query = $this->db->query($sql); + $data['showinvoice']= $query->result(); + + $sql="select * from invoice_med_master where ipd_credit=1 and ipd_credit_type=1 and ipd_id = ".$ipdno; + $query = $this->db->query($sql); + $data['inv_med_list']= $query->result(); + + $sql="select sum(net_amount) as tnet_amount from invoice_med_master + where ipd_credit=1 and ipd_credit_type=1 and ipd_id = ".$ipdno; + $query = $this->db->query($sql); + $data['inv_med_total']= $query->result(); + + $total_med=$data['inv_med_total'][0]->tnet_amount; + + $sql="select sum(total_amount) as tnet_amount from invoice_master + where payment_status=1 and ipd_include=1 and ipd_id = ".$ipdno; + $query = $this->db->query($sql); + $data['inv_charge_total']= $query->result(); + + $sql="select *,h.id as pay_id,Date_Format(pay_date,'%d-%M') as pay_date_str, + case p.payment_mode when 1 then 'Cash' + when 2 then 'Bank Card' + when 3 then 'Return Cash ' + when 4 then 'Bank Return' else 'Other' end as pay_mode + from ipd_payment p join payment_history h on p.payment_id=h.id and h.payof_type=4 where p.ipd_id='".$ipdno."' "; + $query = $this->db->query($sql); + $data['ipd_payment']= $query->result(); + + $sql="select sum(if(credit_debit=0,amount,amount*-1)) as t_ipd_pay + from ipd_payment where ipd_id='".$ipdno."' "; + $query = $this->db->query($sql); + $data['ipd_payment_total']= $query->result(); + + $total_charges=$data['inv_charge_total'][0]->tnet_amount; + + $total_payment=$data['ipd_payment_total'][0]->t_ipd_pay; + + $total_gross_amount=($total_charges+round($total_med,0)); + + $tdiscount=$discount+$discount2+$discount3; + + $net_amount=($total_gross_amount+$tcharge)-$tdiscount; + + $balance=$net_amount-$total_payment; + + $data['inv_total']=array( + 'total_med' => $total_med, + 'total_charges' => $total_gross_amount, + 'total_payment' => $total_payment, + 'ipd_id' => $ipdno, + 'discount' => $tdiscount, + 'charge'=>$tcharge, + 'balance' => $balance, + 'net_amount' => $net_amount + ); + + + $Check_Discount=1; + + if($print==1) + { + $this->load->view('IPD/Ipd_invoice_print_V',$data); + + }elseif($print==2){ + $this->load->view('IPD/ipd_invoice_print_wo_payment',$data); + }else{ + $this->load->view('IPD/Ipd_invoice_V',$data); + } + + } + + public function ipd_short_invoice($ipdno,$print=0) + { + $sql="select * from ipd_master where id=".$ipdno; + $query = $this->db->query($sql); + $data['ipdmaster']= $query->result(); + + $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."' "; + + $query = $this->db->query($sql); + $data['person_info']= $query->result(); + + if($data['ipdmaster'][0]->case_id>0) + { + $sql="select * from organization_case_master where id='".$data['ipdmaster'][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(); + } + + $sql="select * from v_ipd_invoice v + where v.ipd_id=".$ipdno." order by Charge_type,inv_date "; + $query = $this->db->query($sql); + $data['showinvoice']= $query->result(); + + $sql="select sum(amount) as GTotal from v_ipd_invoice v + where v.ipd_id=".$ipdno." "; + $query = $this->db->query($sql); + $data['invoiceGtotal']= $query->result(); + + $sql="select *,case payment_mode when 1 then 'Cash' when 2 then 'Bank Card' else 'Other' end as pay_mode from ipd_payment where ipd_id='".$ipdno."' "; + $query = $this->db->query($sql); + $data['ipd_payment']= $query->result(); + + + if($print>0) + { + $this->load->view('IPD/Ipd_invoice_print_V',$data); + + }else{ + $this->load->view('IPD/Ipd_invoice_V',$data); + } + } + + public function ipd_confirm_payment() + { + if (!$this->input->is_ajax_request()) { exit('no valid req.'); } + + $this->load->model('Ipd_M'); + $this->load->model('Payment_M'); + + $ipd_id=$this->input->post('ipd_id'); + $amount=$this->input->post('amount'); + + $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', + 'payof_type'=>'4', + 'payof_id'=>$ipd_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.']', + 'update_by_id'=>$user_id + ); + + $insert_id=$this->Payment_M->insert($paydata); + + $ipdpaymentdata = array( + 'payment_mode'=> '1', + 'payment_id'=>$insert_id, + 'payment_mode_desc'=>'Cash', + 'pay_date'=>$pay_datetime, + 'enter_pay_date' => date('Y-m-d H:i:s'), + 'ipd_id' => $ipd_id, + 'amount' => $amount, + 'remark'=>$pay_remark, + 'prepared_by'=>$user_name.'['.$user_id.']', + 'prepared_by_id'=>$user_id + ); + + $insert_ipdpay_id=$this->Ipd_M->insert_payment_ipd( $ipdpaymentdata); + + $rvar=array( + 'update' =>1, + 'ipd_id'=> $ipd_id, + 'payid' => $insert_ipdpay_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', + '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_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_mode_desc'=>'Bank Card', + '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_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 + ); + + $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; + } + } + + + 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 ipd_ded_payment() + { + if (!$this->input->is_ajax_request()) { exit('no valid req.'); } + + $this->load->model('Ipd_M'); + $this->load->model('Payment_M'); + + $ipd_id=$this->input->post('ipd_id'); + $amount=$this->input->post('amount'); + + $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'); + + if($this->input->post('mode')==3) + { + $paydata = array( + 'payment_mode'=> '1', + 'payof_type'=>'4', + 'payof_id'=>$ipd_id, + 'payof_code'=>$ipd_master[0]->ipd_code, + 'credit_debit'=>'1', + 'amount'=>$amount, + '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); + + $ipdpaymentdata = array( + 'payment_mode'=> '3', + 'payment_id'=>$insert_id, + 'payment_mode_desc'=>'Cash Return', + 'pay_date'=>date('Y-m-d H:i:s'), + 'ipd_id' => $ipd_id, + 'credit_debit'=>'1', + 'amount' => $amount, + 'remark'=>$pay_remark, + 'prepared_by'=>$user_name.'['.$user_id.']', + 'prepared_by_id'=>$user_id + ); + + $insert_ipdpay_id=$this->Ipd_M->insert_payment_ipd( $ipdpaymentdata); + + $rvar=array( + 'update' =>1, + 'ipd_id'=> $ipd_id, + 'payid' => $insert_ipdpay_id + ); + + $encode_data = json_encode($rvar); + echo $encode_data; + } + + + if($this->input->post('mode')==4) + { + $paydata = array( + 'payment_mode'=> '4', + 'payof_type'=>'4', + 'payof_id'=>$ipd_id, + 'payof_code'=>$ipd_master[0]->ipd_code, + 'credit_debit'=>'1', + 'amount'=>$amount, + '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); + + $ipdpaymentdata = array( + 'payment_mode'=> '4', + 'payment_id'=>$insert_id, + 'payment_mode_desc'=>'Bank Return', + 'pay_date'=>date('Y-m-d H:i:s'), + 'ipd_id' => $ipd_id, + 'credit_debit'=>'1', + 'amount' => $amount, + 'remark'=>$pay_remark, + 'prepared_by'=>$user_name.'['.$user_id.']', + 'prepared_by_id'=>$user_id + ); + + $insert_ipdpay_id=$this->Ipd_M->insert_payment_ipd( $ipdpaymentdata); + + $rvar=array( + 'update' =>1, + 'ipd_id'=> $ipd_id, + 'payid' => $insert_ipdpay_id + ); + + $encode_data = json_encode($rvar); + echo $encode_data; + } + + + } + + public function ipd_org_status_update() + { + 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; + + $this->load->model('Ocasemaster_M'); + $data['master'] = array( + 'org_approved_amount' => $this->input->post('amount'), + 'org_approved_status_id' => $this->input->post('org_status'), + 'org_status_update_by' => $user_name + ); + + $case_id=$this->input->post('case_id'); + $this->Ocasemaster_M->update($data['master'],$case_id); + + $rvar=array( + 'update' =>'1', + 'msg' => 'Update Done '.$case_id + ); + $encode_data = json_encode($rvar); + echo $encode_data; + + } + + public function ipd_main_panel($ipdno) + { + $sql="select *,if(ipd_status=0,DATEDIFF(sysdate(),register_date),DATEDIFF(discharge_date,register_date)) as no_days from ipd_master where id='".$ipdno."' "; + $query = $this->db->query($sql); + $data['ipd_info']= $query->result(); + + $sql="select * from v_ipd_list where id='".$ipdno."' "; + $query = $this->db->query($sql); + $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."' "; + $query = $this->db->query($sql); + $data['person_info']= $query->result(); + + $sql="select *,concat_ws(' ','Dr.',p_fname,p_mname,p_lname) as doc_name from doctor_master where id='".$data['ipd_info'][0]->r_doc_id."' "; + $query = $this->db->query($sql); + $data['doc_info']= $query->result(); + + $sql="select i.id,d.p_fname,d.id as doc_id from ipd_master_doc_list i join doctor_master d on i.doc_id = d.id where ipd_id='".$ipdno."' "; + $query = $this->db->query($sql); + $data['ipd_doc_list']= $query->result(); + + $sql="select * from organization_case_master where status=0 and p_id=".$data['ipd_info'][0]->p_id; + $query = $this->db->query($sql); + $data['case_master']= $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 * from org_approved_status "; + $query = $this->db->query($sql); + $data['org_approved_status']= $query->result(); + + $this->load->view('IPD/ipd_main_panel',$data); + } + + public function ipd_account_panel($ipdno) + { + + $sql="select * from ipd_master where id='".$ipdno."' "; + $query = $this->db->query($sql); + $data['ipd_info']= $query->result(); + + $discount=$data['ipd_info'][0]->Discount; + $discount2=$data['ipd_info'][0]->Discount2; + $discount3=$data['ipd_info'][0]->Discount3; + + $charge1=$data['ipd_info'][0]->chargeamount1; + $charge2=$data['ipd_info'][0]->chargeamount2; + $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."' "; + $query = $this->db->query($sql); + $data['person_info']= $query->result(); + + $sql="select *,concat_ws(' ','Dr.',p_fname,p_mname,p_lname) as doc_name from doctor_master where id='".$data['ipd_info'][0]->r_doc_id."' "; + $query = $this->db->query($sql); + $data['doc_info']= $query->result(); + + $sql="select * from ipd_master_doc_list i join doctor_master d on i.doc_id = d.id where ipd_id='".$ipdno."' "; + $query = $this->db->query($sql); + $data['ipd_doc_list']= $query->result(); + + $sql="select * from organization_case_master where status=0 and p_id=".$data['ipd_info'][0]->p_id; + $query = $this->db->query($sql); + $data['case_master']= $query->result(); + + $total_med=0.00; + $total_charges=0.00; + + $sql="select sum(net_amount) as tnet_amount from invoice_med_master where ipd_credit=1 and ipd_credit_type>0 and ipd_id = ".$ipdno; + $query = $this->db->query($sql); + $data['inv_med_total_credit']= $query->result(); + + $sql="select sum(net_amount) as tnet_amount,sum(payment_received) as t_payment_received from invoice_med_master where ipd_credit=0 and ipd_id = ".$ipdno; + $query = $this->db->query($sql); + $data['inv_med_total_cash']= $query->result(); + + $total_med_credit=$data['inv_med_total_credit'][0]->tnet_amount; + $total_med_cash=$data['inv_med_total_cash'][0]->tnet_amount; + $total_med_cash_paid=$data['inv_med_total_cash'][0]->t_payment_received; + + $sql="select sum(total_amount) as tnet_amount from invoice_master where payment_status=1 and ipd_include=1 and ipd_id = ".$ipdno; + $query = $this->db->query($sql); + $data['inv_charge_total']= $query->result(); + + $total_charges=$data['inv_charge_total'][0]->tnet_amount; + + $sql="select sum(if(credit_debit>0,amount*-1,amount)) as tnet_amount from ipd_payment where ipd_id='".$ipdno."' "; + $query = $this->db->query($sql); + $data['inv_payment_total']= $query->result(); + + $total_payment=$data['inv_payment_total'][0]->tnet_amount; + $tdiscount=$discount+$discount2+$discount3; + + $total_balance_amount=$total_payment-($total_charges+$total_med_credit+$tcharge-$tdiscount); + + $data['inv_total']=array( + 'total_med_credit' => $total_med_credit, + 'total_med_cash' => $total_med_cash, + 'total_med_cash_paid' => $total_med_cash_paid, + 'total_charges' => $total_charges, + 'total_payment' => $total_payment, + 'total_balance_amount' => $total_balance_amount, + 'discount' => $tdiscount, + 'charge' => $tcharge, + 'ipd_id' => $ipdno + ); + + + $this->load->view('IPD/ipd_account_panel',$data); + } + + public function ipd_panel($ipdcode,$stype=0) + { + if($stype > 0) + { + $sql="select *,if(ipd_status=0,DATEDIFF(sysdate(),register_date),DATEDIFF(discharge_date,register_date)) as no_days from ipd_master where ipd_code='".$ipdcode."' "; + }else{ + $sql="select *,if(ipd_status=0,DATEDIFF(sysdate(),register_date),DATEDIFF(discharge_date,register_date)) as no_days from ipd_master where id='".$ipdcode."' "; + } + + $query = $this->db->query($sql); + $data['ipd_info']= $query->result(); + + if($stype > 0) + { + $sql="select * from v_ipd_list where ipd_code='".$ipdcode."' "; + + }else{ + $sql="select * from v_ipd_list where id='".$ipdcode."' "; + } + + $query = $this->db->query($sql); + $data['ipd_list']= $query->result(); + + $discount=$data['ipd_info'][0]->Discount; + $discount2=$data['ipd_info'][0]->Discount2; + $discount3=$data['ipd_info'][0]->Discount3; + + $charge1=$data['ipd_info'][0]->chargeamount1; + $charge2=$data['ipd_info'][0]->chargeamount2; + $tcharge=$charge1+$charge2; + + $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."' "; + $query = $this->db->query($sql); + $data['person_info']= $query->result(); + + $sql="select *,concat_ws(' ','Dr.',p_fname,p_mname,p_lname) as doc_name from doctor_master where id='".$data['ipd_info'][0]->r_doc_id."' "; + $query = $this->db->query($sql); + $data['doc_info']= $query->result(); + + $sql="select * from ipd_master_doc_list i join doctor_master d on i.doc_id = d.id where ipd_id='".$ipdno."' "; + $query = $this->db->query($sql); + $data['ipd_doc_list']= $query->result(); + + $sql="select * from organization_case_master where status=0 and p_id=".$data['ipd_info'][0]->p_id; + $query = $this->db->query($sql); + $data['case_master']= $query->result(); + + $total_med=0.00; + $total_charges=0.00; + + $sql="select sum(net_amount) as tnet_amount from invoice_med_master where ipd_credit=1 and ipd_credit_type>0 and ipd_id = ".$ipdno; + $query = $this->db->query($sql); + $data['inv_med_total_credit']= $query->result(); + + $sql="select sum(net_amount) as tnet_amount,sum(payment_received) as t_payment_received from invoice_med_master where ipd_credit=0 and ipd_id = ".$ipdno; + $query = $this->db->query($sql); + $data['inv_med_total_cash']= $query->result(); + + $sql="select * from invoice_med_master where ipd_credit=1 and ipd_id = ".$ipdno; + $query = $this->db->query($sql); + $data['inv_master_credit']= $query->result(); + + $total_med_credit=$data['inv_med_total_credit'][0]->tnet_amount; + $total_med_cash=$data['inv_med_total_cash'][0]->tnet_amount; + $total_med_cash_paid=$data['inv_med_total_cash'][0]->t_payment_received; + + $sql="select sum(total_amount) as tnet_amount from invoice_master where payment_status=1 and ipd_include=1 and ipd_id = ".$ipdno; + $query = $this->db->query($sql); + $data['inv_charge_total']= $query->result(); + + $total_charges=$data['inv_charge_total'][0]->tnet_amount; + + $sql="select sum(if(credit_debit=0,amount,amount*-1)) as tnet_amount from ipd_payment where ipd_id='".$ipdno."' "; + $query = $this->db->query($sql); + $data['inv_payment_total']= $query->result(); + + $total_payment=$data['inv_payment_total'][0]->tnet_amount; + + $tdiscount=$discount+$discount2+$discount3; + + $total_balance_amount=$total_payment-($total_charges+$total_med_credit+$tcharge-($tdiscount)); + + $data['inv_total']=array( + 'total_med_credit' => $total_med_credit, + 'total_med_cash' => $total_med_cash, + 'total_med_cash_paid' => $total_med_cash_paid, + 'total_charges' => $total_charges, + 'total_payment' => $total_payment, + 'total_balance_amount' => $total_balance_amount, + 'discount' => $tdiscount, + 'charge' => $tcharge, + 'ipd_id' => $ipdno + ); + + $sql="select *,Date_Format(pay_date,'%d-%M') as pay_date_str,case payment_mode when 1 then 'Cash' when 2 then 'Bank Card' when 3 then 'Cash Return' else 'Other' end as pay_mode from ipd_payment where ipd_id='".$ipdno."' "; + $query = $this->db->query($sql); + $data['ipd_payment']= $query->result(); + + if ($this->ion_auth->in_group('admin1') || $this->ion_auth->in_group('IPDAdmit') ) { + if($data['ipd_info'][0]->ipd_status==0) + { + $this->load->view('IPD/Ipdpanel_V',$data); + }else{ + if($this->ion_auth->in_group('IPDReAdmit')) + { + $this->load->view('IPD/Ipdpanel_V',$data); + }else{ + $this->load->view('IPD/IPD_View',$data); + } + } + }else{ + $this->load->view('IPD/IPD_View',$data); + } + } + + public function IpdList() + { + $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('IPD2/IPDList_V',$data); + } + + public function ipd_room_status() + { + $sql="select b.room_name,b.room_rent,count(b.id) as Total_Bed,sum(if(b.bed_used_p_id=0,1,0)) as FreeBed + from hc_bed_master b group by b.room_name"; + $query = $this->db->query($sql); + $data['roomdata']= $query->result(); + + $this->load->view('IPD/ipd_bed_status',$data); + } + + public function add_remove_doc($ipd_doc_id) + { + if ($this->ion_auth->in_group('IPDAdmit')) { + $this->db->delete("ipd_master_doc_list", "id=".$ipd_doc_id); + } + } + + public function add_add_doc($ipd_id,$doc_id) + { + if ($this->ion_auth->in_group('IPDAdmit')) { + + if (!$this->input->is_ajax_request()) { exit('no valid req.'); } + + $this->load->model('Ipd_M'); + + $data = array( + 'ipd_id' => $ipd_id, + 'doc_id' => $doc_id + ); + $inser_id=$this->Ipd_M->add_ipd_doc($data); + } + } + + public function show_ipd_form1($ipdno) + { + $sql="select *,if(case_type=1,'MLC','Non MLC') as case_type_s, + Date_format(register_date,'%d-%m-%Y') as str_register_date , + Date_format(discharge_date,'%d-%m-%Y') as str_discharge_date + from ipd_master where id='".$ipdno."' "; + $query = $this->db->query($sql); + $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."' "; + $query = $this->db->query($sql); + $data['person_info']= $query->result(); + + $sql="select *,concat_ws(' ','Dr.',p_fname,p_mname,p_lname) as doc_name from doctor_master where id='".$data['ipd_info'][0]->r_doc_id."' "; + $query = $this->db->query($sql); + $data['doc_info']= $query->result(); + + $sql="select i.id,d.p_fname,d.id as doc_id from ipd_master_doc_list i join doctor_master d on i.doc_id = d.id where ipd_id='".$ipdno."' "; + $query = $this->db->query($sql); + $data['ipd_doc_list']= $query->result(); + + $sql="select * from organization_case_master where id='".$data['ipd_info'][0]->case_id."' "; + $query = $this->db->query($sql); + $data['case_master']= $query->result(); + + $d= $this->ion_auth->user()->row(); + + $data['user'] = $d; + + + + //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; + + + $file_name='Report-FaceForm-'.date('Ymdhis').".pdf"; + + $filepath=$file_name; + + //$this->load->view('Medical/medical_bill_print_format',$data); + $content=$this->load->view('IPD/print_ipd_form1',$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"); + + } + + public function addipd($pno) + { + $sql="select count(*) as no_ipd from ipd_master where ipd_status=0 and p_id=".$pno; + $query = $this->db->query($sql); + $data['ipd_master_rec']= $query->result(); + + if ($data['ipd_master_rec'][0]->no_ipd > 0) + { + $sql="select * from ipd_master where ipd_status=0 and p_id=".$pno; + $query = $this->db->query($sql); + $data['ipd_info']= $query->result(); + + 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."' "; + + $query = $this->db->query($sql); + $data['person_info']= $query->result(); + + $sql="select d.id ,d.p_fname ,group_concat(m.SpecName) as SpecName + from doctor_master d join doc_spec s join med_spec m on d.id =s.doc_id and s.med_spec_id =m.id + where d.active=1 group by d.id "; + $query = $this->db->query($sql); + $data['doc_spec_l']= $query->result(); + + $sql="select id,concat('Bed No:',bed_no,'/','[',room_name,']') as Bed_Desc from hc_bed_master where bed_used_p_id=0"; + $query = $this->db->query($sql); + $data['ipd_bed_list']= $query->result(); + + $sql="select * from hc_insurance "; + $query = $this->db->query($sql); + $data['insur_list']= $query->result(); + + $sql="select * from organization_case_master + where status=0 and ipd_id=0 and case_type=1 and p_id=".$pno; + $query = $this->db->query($sql); + $data['case_master']= $query->result(); + + $this->load->view('IPD/Ipd_Registration_V',$data); + } + + } + + public function ipd_bed_assign_list($ipdno) + { + $sql="select m.bed_no,m.room_name,b.Fdate,b.TDate,b.Remark + from ipd_bed_assign b join hc_bed_master m on b.bed_id=m.id where b.ipd_id=".$ipdno; + $query = $this->db->query($sql); + $data['ipd_bed_assign']= $query->result(); + + $sql="select id,concat('Bed No:',bed_no,'/','[',room_name,']') as Bed_Desc from hc_bed_master where bed_used_p_id=0"; + $query = $this->db->query($sql); + $data['ipd_bed_list']= $query->result(); + + + $this->load->view('IPD/ipd_bed_assign',$data); + + } + + public function ipd_cash_print($ipd_id,$payid,$print=0) + { + $sql="select * from ipd_payment where id=".$payid; + $query = $this->db->query($sql); + $data['ipd_payment']= $query->result(); + + $payment_id=$data['ipd_payment'][0]->payment_id; + + $sql="select * from ipd_master where id =".$data['ipd_payment'][0]->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, + IFNULL(GET_AGE_BY_DOB(dob),age) AS age from patient_master where id='".$pno."' "; + + $query = $this->db->query($sql); + $data['person_info']= $query->result(); + + if($print==0) + { + $this->load->view('IPD/print_payment_receipt_ipd',$data); + }else{ + redirect('IpdNew/ipd_cash_print_pdf/'.$ipd_id.'/'.$payment_id); + //$this->load->view('IPD/ipd_payment_receipt_print',$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, + IFNULL(GET_AGE_BY_DOB(dob),age) as str_age from patient_master where id='".$data['ipd_info'][0]->p_id."' "; + $query = $this->db->query($sql); + $data['person_info']= $query->result(); + + $this->load->view('IPD/ipd_model_payment_box',$data); + } + + public function ipd_bed_list() + { + $sql="select id,concat('Bed No:',bed_no,'/','[',room_name,']') as Bed_Desc from hc_bed_master where bed_used_p_id=0"; + + $query = $this->db->query($sql); + $ipd_bed_list= $query->result(); + + echo ''; + echo ''; + echo ''; + } + + public function load_model_ded_box() + { + $this->load->view('IPD/ipd_panel_deduction_payment'); + } + + public function AddNew() { + if (!$this->input->is_ajax_request()) { exit('no valid req.'); } + $this->load->model('Ipd_M'); + + $data['master'] = array( + 'p_id' => $this->input->post('pid'), + 'P_name' => $this->input->post('pname'), + 'relation' => $this->input->post('r_relation'), + 'contact_person_Name' => $this->input->post('rp_name'), + 'insurance_id' => $this->input->post('insur_list'), + 'policy_no' => $this->input->post('insur_no'), + 'register_date' => str_to_MysqlDate($this->input->post('res_date')), + 'problem' => $this->input->post('problem'), + 'remark' => $this->input->post('remark'), + 'P_mobile1' => $this->input->post('phone1'), + 'P_mobile2' => $this->input->post('phone2'), + 'case_type' => $this->input->post('optionsRadios_mlc'), + 'case_id' => $this->input->post('optionsRadios_org'), + 'reg_time' => $this->input->post('res_time') + ); + + $groupData = $this->input->post('doc_id'); + + if (isset($groupData) && !empty($groupData)) { + $data['doc_list']=$groupData; + + $inser_id=$this->Ipd_M->insert($data); + + $data['BedData'] = array( + 'ipd_id' => $inser_id, + 'Fdate' => date('Y-m-d h:i:s'), + 'TDate' => date('Y-m-d h:i:s'), + 'bed_id' => $this->input->post('room_list') + ); + + if($this->input->post('room_list')<>"") + { + $inser_bed_id=$this->Ipd_M->bedassign($data['BedData']); + } + } + else + { + $inser_id=0; + } + + $rvar=array( + 'insertid' =>$inser_id + ); + $encode_data = json_encode($rvar); + echo $encode_data; + } + + public function discharge_update() + { + if (!$this->input->is_ajax_request()) { exit('no valid req.'); } + $this->load->model('Ipd_M'); + $this->load->model('Ocasemaster_M'); + + $user = $this->ion_auth->user()->row(); + $user_id = $user->id; + $user_name = $user->first_name.''. $user->last_name; + + $discharge_by=$user_name.'['.$user_id.']'; + + $data['master'] = array( + 'discharge_by' => $discharge_by, + 'discharge_remark' => $this->input->post('discharge_remark'), + 'discharge_balance_user' => $this->input->post('input_bal_user'), + 'discharge_balance_remark' => $this->input->post('input_bal_remark'), + 'ipd_status' => '1', + 'discharge_date' => str_to_MysqlDate($this->input->post('dis_date')), + 'discharge_time' => $this->input->post('dis_time'), + 'discarge_patient_status' => $this->input->post('p_status') + ); + + $ipd_id=$this->input->post('Ipd_ID'); + $this->Ipd_M->update($data['master'],$ipd_id); + + //Update Org. Status Update + $sql="select * from ipd_master where id='".$ipd_id."' "; + $query = $this->db->query($sql); + $ipd_info= $query->result(); + + if($ipd_info[0]->case_id>0) + { + $case_id=$ipd_info[0]->case_id; + + $sql="select * from organization_case_master where id='".$case_id."'"; + $query = $this->db->query($sql); + $case_master= $query->result(); + + if(count($case_master)>0) + { + $log=$case_master[0]->log.'\nUpdate Status:'.$this->input->post('status').'-Upd By:'.$user_name.'['.$user_id.']'.date('d/m/Y H:m:s'); + + $data = array( + 'status'=> 1, + 'log'=>$log, + ); + + $this->Ocasemaster_M->update( $data,$case_id); + } + + } + + //Update Org. Stop + + $inser_id=1; + + $rvar=array( + 'insertid' =>$inser_id, + 'showcontent' => "Discharge Status Updated." + ); + + $encode_data = json_encode($rvar); + echo $encode_data; + } + + public function discharge_request() + { + 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; + + $discharge_by=$user_name.'['.$user_id.']'; + + $data['master'] = array( + 'ipd_status' => '0', + 'discharge_date' => str_to_MysqlDate($this->input->post('dis_date')), + 'discharge_time' => $this->input->post('dis_time'), + 'discarge_patient_status' => $this->input->post('p_status'), + 'dept_id' => $this->input->post('dept_id') + ); + + $ipd_id=$this->input->post('Ipd_ID'); + $this->Ipd_M->update($data['master'],$ipd_id); + + echo "Discharge Status Updated"; + } + + public function update_surgery() + { + 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'); + $issurgery=$this->input->post('issurgery'); + $surgery_name=$this->input->post('surgery_name'); + $surgery_date=$this->input->post('surgery_date'); + + + + $content=""; + + $dataupdate = array( + 'issurgery' => $issurgery, + 'surgery_name' => $surgery_name, + 'surgery_date' => str_to_MysqlDate($surgery_date) + ); + + $this->Ipd_M->update($dataupdate,$ipd_id); + + $content="Update Done"; + + + echo $content; + } + + + 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'); + + + $dataupdate = array( + 'isdelivery' => $isdelivery, + 'delivery_time' => $delivery_time, + 'delivery_date' => str_to_MysqlDate($delivery_date), + 'delivery_sex_of_baby' => $delivery_sex_of_baby + ); + + $this->Ipd_M->update($dataupdate,$ipd_id); + $content="Update Done"; + + echo $content; + } + + + public function update_ipdadmit_time() + { + 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; + + $discharge_by=$user_name.'['.$user_id.']'; + + $ipd_id=$this->input->post('Ipd_ID'); + + $data['master'] = array( + 'register_date' => str_to_MysqlDate($this->input->post('strdate')), + 'reg_time' => $this->input->post('strtime') + ); + + $ipd_id=$this->input->post('Ipd_ID'); + $this->Ipd_M->update($data['master'],$ipd_id); + + $inser_id=1; + + $rvar=array( + 'insertid' =>$inser_id, + 'showcontent' => "Admit Date Updated" + ); + + $encode_data = json_encode($rvar); + echo $encode_data; + } + + public function discharge_ipd($ipdno) + { + $sql="select * from ipd_master where id='".$ipdno."' "; + $query = $this->db->query($sql); + $data['ipd_info']= $query->result(); + + $sql="select * from ipd_discharg_status "; + $query = $this->db->query($sql); + $data['ipd_discharge_status']= $query->result(); + + $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."' "; + $query = $this->db->query($sql); + $data['person_info']= $query->result(); + + + if($data['ipd_info'][0]->ipd_status == 0 ) + { + $this->load->view('IPD/ipd_discharge',$data); + }else{ + $this->load->view('IPD/ipd_discharged_status',$data); + } + + + } + + public function getIpdTable() + { + + $requestData= $_REQUEST; + + $columns = array( + // datatable column index => database column name + 0 =>'ipd_code', + 1 => 'p_code', + 2 => 'p_fname', + 3=> 'P_mobile1', + 4=> 'doc_name', + 5=> 'Disstatus', + 6=> 'str_register_date', + 7=> 'str_discharge_date', + 8=> 'Disstatus' + ); + + // getting total number records without any search + $sql_f_all = "select * "; + + $sql_count="Select count(*) as no_rec "; + + $sql_from=" from v_ipd_list "; + + $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']) ){ //ipd_code + $sql_where.=" AND ipd_code LIKE '%".$requestData['columns'][0]['search']['value']."' "; + $sql_where_flag=1; + } + + if( !empty($requestData['columns'][1]['search']['value']) ){ //p_code + $sql_where.=" AND p_code LIKE '".$requestData['columns'][1]['search']['value']."%' "; + $sql_where_flag=1; + } + + if( !empty($requestData['columns'][2]['search']['value']) ){ //p_fname + $sql_where.=" AND p_fname LIKE '%".$requestData['columns'][2]['search']['value']."%' "; + $sql_where_flag=1; + } + + if( !empty($requestData['columns'][3]['search']['value']) ){ //P_mobile1 + $sql_where.=" AND P_mobile1 LIKE '%".$requestData['columns'][3]['search']['value']."%' "; + $sql_where_flag=1; + } + + if( !empty($requestData['columns'][4]['search']['value']) ){ //P_mobile1 + $sql_where.=" AND doc_name LIKE '%".$requestData['columns'][4]['search']['value']."%' "; + $sql_where_flag=1; + } + + if( !empty($requestData['columns'][7]['search']['value']) ) + { //IPD Admit Date Range + $rangeArray = explode("/",$requestData['columns'][7]['search']['value']); + $minRange = $rangeArray[0]; + $maxRange = $rangeArray[1]; + $admitType = $rangeArray[2]; + if($admitType==0){ + $sql_where.=" AND ( Date(register_date) between '".$minRange."' AND '".$maxRange."' ) "; + }elseif($admitType==1){ + $sql_where.=" AND ( Date(discharge_date) between '".$minRange."' AND '".$maxRange."' ) "; + }else{ + $sql_where.=" AND (( Date(register_date) between '".$minRange."' AND '".$maxRange."' ) "; + $sql_where.=" OR ( Date(discharge_date) between '".$minRange."' AND '".$maxRange."' )) "; + } + + $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 discount_update($dis_no) + { + 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; + + $Discount_By=$user_name.'['.$user_id.']'.date('d-m-Y'); + + if($dis_no==1) + { + $data['master'] = array( + 'Discount_By' => $Discount_By, + 'Discount_Remark' => $this->input->post('Discount_Remark'), + 'Discount' => $this->input->post('Discount') + ); + }elseif($dis_no==2){ + $data['master'] = array( + 'Discount_By2' => $Discount_By, + 'Discount_Remark2' => $this->input->post('Discount_Remark'), + 'Discount2' => $this->input->post('Discount') + ); + }elseif($dis_no==3){ + $data['master'] = array( + 'Discount_By3' => $Discount_By, + 'Discount_Remark3' => $this->input->post('Discount_Remark'), + 'Discount3' => $this->input->post('Discount') + ); + } + + $ipd_id=$this->input->post('Ipd_ID'); + $this->Ipd_M->update($data['master'],$ipd_id); + + $inser_id=1; + + $rvar=array( + 'insertid' =>$inser_id, + 'showcontent' => "Discount Status Updated." + ); + + $encode_data = json_encode($rvar); + echo $encode_data; + } + + public function charge_update($dis_no) + { + 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; + + $charge_by=$user_name.'['.$user_id.']'.date('d-m-Y'); + + if($dis_no==1) + { + $data['master'] = array( + 'charge_by1' => $charge_by, + 'charge1' => $this->input->post('input_charge_remark1'), + 'chargeamount1' => $this->input->post('input_charge_Amount1') + ); + }elseif($dis_no==2){ + $data['master'] = array( + 'charge_by2' => $charge_by, + 'charge2' => $this->input->post('input_charge_remark2'), + 'chargeamount2' => $this->input->post('input_charge_Amount2') + ); + } + + $ipd_id=$this->input->post('Ipd_ID'); + $this->Ipd_M->update($data['master'],$ipd_id); + + $inser_id=1; + + $rvar=array( + 'insertid' =>$inser_id, + 'showcontent' => "Charge Status Updated." + ); + + $encode_data = json_encode($rvar); + echo $encode_data; + } + + public function readmit($dis_no) + { + 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; + + $charge_by=$user_name.'['.$user_id.']'.date('d-m-Y'); + + if($dis_no==2) + { + $data['master'] = array( + 'ipd_status' => '0' + ); + } + + $ipd_id=$this->input->post('Ipd_ID'); + $this->Ipd_M->update($data['master'],$ipd_id); + + $inser_id=1; + + $rvar=array( + 'insertid' =>$inser_id, + 'showcontent' => "Status Updated." + ); + + $encode_data = json_encode($rvar); + echo $encode_data; + } + + public function add_bed_room() + { + $room_list=$this->input->post('room_list'); + $Ipd_ID=$this->input->post('Ipd_ID'); + + $this->load->model('Ipd_M'); + $data = array( + 'ipd_id' => $this->input->post('Ipd_ID'), + 'Fdate' => $this->input->post('start_datetime'), + 'TDate' => $this->input->post('end_datetime'), + 'bed_id' => $this->input->post('room_list') + ); + + $inser_id=$this->Ipd_M->bedassign($data); + + $sql="select m.bed_no,m.room_name,b.Fdate,b.TDate,b.Remark + from ipd_bed_assign b join hc_bed_master m on b.bed_id=m.id where b.ipd_id=".$Ipd_ID; + + $query = $this->db->query($sql); + $room_assign_info= $query->result(); + + $r_data='
+ + + + + + + + + + '; + + for ($i = 0; $i < count($room_assign_info); ++$i) { + $r_data=$r_data.' + + + + + '; + } + + $r_data=$r_data.'
Bed No.DescriptionDateVacant Date
'.$room_assign_info[$i]->bed_no.''.$room_assign_info[$i]->room_name.''.$room_assign_info[$i]->Fdate.''.$room_assign_info[$i]->TDate.'
'; + + $rvar=array( + 'insertid' =>$inser_id + ); + $encode_data = json_encode($rvar); + //echo $encode_data; + echo $r_data; + + } + + public function list_med_inv($ipd_id) + { + $sql="select * from invoice_med_master where ipd_credit=1 and ipd_id = ".$ipd_id; + $query = $this->db->query($sql); + $data['inv_master_credit']= $query->result(); + + $data['ipd_id']=$ipd_id; + + $this->load->view('IPD/IPD_Medical_Invoice_Panel',$data); + } + + public function list_med_inv_details($ipd_id,$inv_med_id) + { + $sql="select * from invoice_med_master where ipd_credit=1 and id='".$inv_med_id."' and ipd_id = ".$ipd_id; + $query = $this->db->query($sql); + $data['inv_master_credit']= $query->result(); + + $sql="select * from inv_med_item where inv_med_id='".$inv_med_id."'"; + $query = $this->db->query($sql); + $data['inv_master_credit_details']= $query->result(); + + $this->load->view('IPD/ipd_medical_invoice_short',$data); + } + + + public function Update_Invoice_ipd_credit_type() + { + $ipd_credit_type= $this->input->post('ipd_credit_type'); + $inv_id = $this->input->post('inv_id'); + + $dataupdate = array( + 'ipd_include' => $ipd_credit_type + ); + + $this->load->model('Invoice_M'); + $this->Invoice_M->update($dataupdate,$inv_id); + } + + + //Org. Update + + public function IPD_Invoice_Edit($IPD_ID) + { + $sql="select * from v_ipd_list + where id=".$IPD_ID; + $query = $this->db->query($sql); + $data['ipd_master']= $query->result(); + + $ins_comp_id=$data['ipd_master'][0]->insurance_id; + + $sql="select i.*,t.group_desc + from ipd_invoice_item i join ipd_item_type t on i.item_type=t.itype_id + where i.ipd_id=".$IPD_ID; + $query = $this->db->query($sql); + $data['invoiceDetails']= $query->result(); + + $sql="select sum(item_amount) as Gtotal from ipd_invoice_item where ipd_id=".$IPD_ID; + $query = $this->db->query($sql); + $data['invoiceGtotal']= $query->result(); + + $sql="select d.id ,d.p_fname ,concat(d.p_fname,' [',group_concat(m.SpecName),']') as DocSpecName + from doctor_master d join doc_spec s join med_spec m on d.id =s.doc_id and s.med_spec_id =m.id + where d.active=1 group by d.id order by d.p_fname"; + $query = $this->db->query($sql); + $data['doclist']= $query->result(); + + $sql="select * from med_spec order by SpecName"; + $query = $this->db->query($sql); + $data['med_spec']= $query->result(); + + $sql="select id,Concat(idesc,' : [',amount,']') as sdesc + from hc_items where itype=40 order by idesc "; + $query = $this->db->query($sql); + $data['item_list_1']= $query->result(); + + $sql="select id,Concat(idesc,' : [',amount,']') as sdesc + from hc_items where itype=34 order by idesc "; + $query = $this->db->query($sql); + $data['item_list_2']= $query->result(); + + $sql="select id,Concat(idesc,' : [',amount,']') as sdesc + from hc_items where itype=27 order by idesc "; + $query = $this->db->query($sql); + $data['item_list_5']= $query->result(); + + $sql="select id,Concat(idesc,' : [',amount,']') as sdesc + from hc_items where itype=26 order by idesc "; + $query = $this->db->query($sql); + $data['item_list_3']= $query->result(); + + $sql="select id,Concat(idesc,' : [',amount,']') as sdesc + from hc_items where itype=35 order by idesc "; + $query = $this->db->query($sql); + $data['item_list_6']= $query->result(); + + $sql="select id,Concat(idesc,' : [',amount,']') as sdesc + from hc_items where itype=43 order by idesc "; + $query = $this->db->query($sql); + $data['item_list_7']= $query->result(); + + $sql="select id,Concat(idesc,' : [',amount,']') as sdesc + from hc_items where itype=3 order by idesc "; + $query = $this->db->query($sql); + $data['item_list_8']= $query->result(); + + $this->load->view('IPD/ipd_invoice_items',$data); + } + + public function ipd_package($ipd_id) + { + $sql="select * from package where id>1 and active=1"; + $query = $this->db->query($sql); + $data['package_list']= $query->result(); + + $sql="select d.id ,d.p_fname ,concat(d.p_fname,' [',group_concat(m.SpecName),']') as DocSpecName + from doctor_master d join doc_spec s join med_spec m on d.id =s.doc_id and s.med_spec_id =m.id + where d.active=1 group by d.id order by d.p_fname"; + $query = $this->db->query($sql); + $data['doclist']= $query->result(); + + $this->load->view('IPD/ipd_package',$data); + } + + public function show_Package($ipd_id) + { + $sql="select * from ipd_package where ipd_id=".$ipd_id; + $query = $this->db->query($sql); + $data['ipd_package']= $query->result(); + + echo ' + + + + + + '; + $srno=0; + $head=1; + foreach($data['ipd_package'] as $row) + { + $srno=$srno+1; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + } + + echo '
#Package NameAmount
'.$srno.''.$row->package_name.'
'.$row->package_desc.'
'; + echo ''; + echo '
'; + + } + + public function ipd_package_showitem($type) + { + $this->load->model('Ipd_M'); + + $ipd_id=$this->input->post('ipd_id'); + $pack_id=$this->input->post('package_id'); + $package_name=$this->input->post('package_name'); + $comment=$this->input->post('comment'); + $package_desc=$this->input->post('comment'); + + $user = $this->ion_auth->user()->row(); + $user_id = $user->id; + $user_name = $user->first_name.''. $user->last_name.'['.$user_id.']'.' D:'.date('d-m-Y h:i:s'); + + if($type==1) + { + $sql="select * from package where id=".$pack_id; + $query = $this->db->query($sql); + $package= $query->result(); + + $item_custom_amount=$this->input->post('input_amount'); + $date_item=$this->input->post('date_item'); + + if($pack_id>1) + { + $package_desc=$package[0]->Pakage_description; + $package_name=$package[0]->ipd_pakage_name; + $item_amount=$package[0]->Pakage_Min_Amount; + } + + if($date_item=='') + { + $date_item=date('Y-m-d'); + } + + if($item_custom_amount>0) + { + $item_amount=$item_custom_amount; + } + + $data['insert_package'] = array( + 'ipd_id' => $ipd_id, + 'package_id' => $pack_id, + 'package_name' => $package_name, + 'package_desc' => $package_desc, + 'package_Amount' => $item_amount, + 'comment' => $comment, + 'update_by' => $user_name + ); + $inser_id=$this->Ipd_M->insert_package( $data['insert_package']); + + }elseif($type==2) + { + $amount_value=$this->input->post('input_amount'); + + $data['update_package'] = array( + 'item_amount' => $amount_value + ); + + $inser_id=$this->Ipd_M->update_package( $data['update_package'],$this->input->post('itemid')); + + }else{ + + echo $this->Ipd_M->deletepackage($this->input->post('itemid')); + //$this->db->delete("invoice_item", "id=".$this->input->post('itemid')); + } + + } + + public function doc_ipd_fee($doc_id) + { + $sql="select * from doc_ipd_fee where isdelete=0 and doc_id= ".$doc_id." order by doc_fee_desc "; + $query = $this->db->query($sql); + $doc_fee= $query->result(); + + foreach($doc_fee as $row) + { + echo ''; + } + + } + + public function ipd_items_bytype() + { + $tid=$this->input->post('itype_idv'); + + $sql="select id,Concat(idesc,' : [',amount,']') as sdesc from ipd_items where itype=".$tid." order by idesc "; + + $query = $this->db->query($sql); + $data['labitem']= $query->result(); + + echo '
+ +
'; + } + + public function ipd_showitem($type) + { + $this->load->model('Ipd_M'); + + $ipd_id=$this->input->post('ipd_id'); + + if($type==1) + { + + $sql="select * from ipd_items where id=".$this->input->post('itype_name_id'); + $query = $this->db->query($sql); + $data['itemlist']= $query->result(); + + $item_rate=$data['itemlist'][0]->amount; + + $item_custom_rate=$this->input->post('input_rate'); + $date_item=$this->input->post('date_item'); + if($date_item=='') + { + $date_item=date('Y-m-d'); + } + + if($item_custom_rate>0) + { + $item_rate=$item_custom_rate; + } + $amount_value=$this->input->post('input_qty')*$item_rate; + + $doc_id=$this->input->post('doc_id'); + + 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; + } + + $data['insert_invoice_item'] = array( + 'ipd_id' => $ipd_id, + 'item_type' => $this->input->post('itype_idv'), + 'item_id' => $this->input->post('itype_name_id'), + 'item_name' => $data['itemlist'][0]->idesc, + 'item_rate' => $item_rate, + 'item_added_date' => date('Y-m-d h:i:s'), + 'item_qty' => $this->input->post('input_qty'), + 'item_amount' => $amount_value, + 'doc_id' => $this->input->post('doc_id'), + 'doc_name' => $refername, + 'date_item' => $date_item, + 'comment' => $this->input->post('comment') + ); + $inser_id=$this->Ipd_M->insert_ipd_item( $data['insert_invoice_item']); + + }elseif($type==2) + { + $amount_value=$this->input->post('update_qty') * $this->input->post('item_rate'); + + $data['update_invoice_item'] = array( + 'item_added_date' => date('Y-m-d h:i:s'), + 'item_qty' => $this->input->post('update_qty'), + 'item_amount' => $amount_value + ); + + $inser_id=$this->Ipd_M->update_ipd_item( $data['update_invoice_item'],$this->input->post('itemid')); + + }else{ + + echo $this->Ipd_M->deleteIpdinvoiceitem($this->input->post('itemid')); + //$this->db->delete("invoice_item", "id=".$this->input->post('itemid')); + } + + } + + public function show_ipd_items($ipd_id) + { + $sql="select * from v_ipd_list where id=".$ipd_id; + $query = $this->db->query($sql); + $data['ipd_master']= $query->result(); + + $ins_comp_id=$data['ipd_master'][0]->insurance_id; + + $sql="select t.group_desc,i.*,sum(i.item_amount) as xAmount + from ipd_invoice_item i join ipd_item_type t on i.item_type=t.itype_id + where i.ipd_id=".$ipd_id." + group by i.item_type,i.id with rollup"; + $query = $this->db->query($sql); + $data['invoiceDetails']= $query->result(); + + $sql="select sum(item_amount) as Gtotal from ipd_invoice_item where ipd_id=".$ipd_id; + $query = $this->db->query($sql); + $data['invoiceGtotal']= $query->result(); + + echo ' + + + + + + + + '; + $srno=0; + $head=1; + foreach($data['invoiceDetails'] as $row) + { + if($head==1 && $row->item_type<>null) + { + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + $head=0; + } + + if($row->item_type==null || $row->item_type=='') + { + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + + }elseif($row->id==null || $row->id==''){ + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + $head=1; + }else{ + $srno=$srno+1; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + } + + + + } + echo '
#Charge NameRateQtyAmount
#'.$row->group_desc.'
#Total Amount'.$row->xAmount.'
#Sub Total'.$row->xAmount.'
'.$srno.''.$row->item_name.'
'.$row->comment.'
'.$row->item_rate.''.$row->item_amount.''; + echo ''; + echo '
'; + echo ''; + + + } + + + public function add_ipd_org($ipd_id,$org_id) + { + if (!$this->input->is_ajax_request()) { exit('no valid req.'); } + + $this->load->model('Ipd_M'); + + $update_ipd=array( + 'case_id'=>$org_id + ); + + $this->Ipd_M->update($update_ipd,$ipd_id); + } + + public function update_org_doc() + { + if (!$this->input->is_ajax_request()) { exit('no valid req.'); } + + $org_id=$this->input->post('org_id'); + $feild=$this->input->post('feild'); + $fvalue=$this->input->post('fvalue'); + + $this->load->model('Ocasemaster_M'); + + $update_ipd=array( + $feild=>$fvalue + ); + + $this->Ocasemaster_M->update($update_ipd,$org_id); + + } + + + + } \ No newline at end of file diff --git a/old_code_ci3/controllers/Ipd2.php b/old_code_ci3/controllers/Ipd2.php new file mode 100644 index 0000000..8cefac8 --- /dev/null +++ b/old_code_ci3/controllers/Ipd2.php @@ -0,0 +1,335 @@ +db->query($sql); + $ipdmaster= $query->result(); + + $pno=$ipdmaster[0]->p_id; + $case_id=$ipdmaster[0]->case_id; + + $sql="select * from v_ipd_list where id=".$ipdno; + $query = $this->db->query($sql); + $ipd_list= $query->result(); + + $sql="select *,if(gender=1,'Male','FeMale') as xgender,if(age is null, + Get_Age(dob),Concat(age,' ',age_in)) AS age + from patient_master where id='".$pno."' "; + $query = $this->db->query($sql); + $person_info= $query->result(); + + + $sql="select * from ipd_package + where ipd_id=".$ipdno; + $query = $this->db->query($sql); + $ipd_package= $query->result(); + + + + //Check Items in Package + $No_Pack_items=0; + + $sql1= 'Select count(*) as no_rec from ipd_invoice_item i + where i.package_id>0 and i.ipd_id='.$ipdno; + + $sql2= 'Select count(*) as no_rec from invoice_med_master + Where ipd_credit=1 and ipd_credit_type=0 and ipd_id = '.$ipdno; + + $sql3= 'Select count(*) as no_rec from v_ipd_invoice b + where b.ipd_id='.$ipdno.' and ipd_include=0'; + + $query = $this->db->query($sql1); + $Package_Items= $query->result(); + $No_Pack_items+=$Package_Items[0]->no_rec; + + $query = $this->db->query($sql2); + $Package_Items= $query->result(); + $No_Pack_items+=$Package_Items[0]->no_rec; + + $query = $this->db->query($sql3); + $Package_Items= $query->result(); + $No_Pack_items+=$Package_Items[0]->no_rec; + + if(count($ipd_package)>0) + { + $sql="select t.group_desc,i.*,sum(i.item_amount) as xAmount + from ipd_invoice_item i join ipd_item_type t on i.item_type=t.itype_id + where i.package_id=0 and i.ipd_id=".$ipdno." + group by i.item_type,i.id order by i.item_type"; + $query = $this->db->query($sql); + $ipd_invoice_item= $query->result(); + }else{ + $sql="select t.group_desc,i.*,sum(i.item_amount) as xAmount + from ipd_invoice_item i join ipd_item_type t on i.item_type=t.itype_id + where i.ipd_id=".$ipdno." + group by i.item_type,i.id order by i.item_type"; + $query = $this->db->query($sql); + $ipd_invoice_item= $query->result(); + } + + $sql="select * + from invoice_med_master + where ipd_credit=1 and ipd_credit_type=1 + and ipd_id = ".$ipdno; + $query = $this->db->query($sql); + $inv_med_list= $query->result(); + + $sql="select b.ipd_id AS ipd_id,b.Charge_type AS Charge_type,b.idesc AS idesc, + b.item_rate AS item_rate,b.orgcode AS orgcode,sum(b.item_qty) AS no_qty,sum(b.Amount) AS amount + from v_ipd_invoice b where b.ipd_id=".$ipdno." and ipd_include=1 + group by b.ipd_id,b.item_id,b.item_rate order by b.Charge_type "; + + $query = $this->db->query($sql); + $showinvoice= $query->result(); + + if($ipdmaster[0]->case_id>0) + { + $sql="select * from organization_case_master + where id='".$ipdmaster[0]->case_id."'"; + $query = $this->db->query($sql); + $orgcase= $query->result(); + + $ins_comp_id=$orgcase[0]->insurance_id; + $inc_card_id=$orgcase[0]->insurance_card_id; + + $sql="select * from hc_insurance_card where id='".$inc_card_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 sum(net_amount) as tnet_amount + from invoice_med_master + where ipd_credit=1 and ipd_credit_type=1 and ipd_id = ".$ipdno; + $query = $this->db->query($sql); + $inv_med_total= $query->result(); + + $total_med=$inv_med_total[0]->tnet_amount; + + $sql="select sum(total_amount) as tnet_amount from invoice_master + where payment_status=1 and ipd_include=1 and ipd_id = ".$ipdno; + $query = $this->db->query($sql); + $inv_charge_total= $query->result(); + + $sql="SELECT h.*,DATE_FORMAT(h.payment_date,'%d-%m-%Y') as pay_date_str, + concat(if(h.credit_debit=0,'','Return '),if(h.payment_mode=1,'CASH','BANK')) as pay_mode + from payment_history h where h.payof_type=4 AND h.payof_id='".$ipdno."' "; + $query = $this->db->query($sql); + $ipd_payment= $query->result(); + + + $PrintData='IPD ID : '.$ipdmaster[0]->ipd_code.' / PCode : '.$person_info[0]->p_code. ' / PName : '.$person_info[0]->p_fname .' / Age : '.$person_info[0]->age .PHP_EOL; + $PrintData.='----------------------------------------------------------------------------------------------------------'.PHP_EOL; + + $PrintData.=str_pad('Doctor Name : '. $ipd_list[0]->doc_name,35,' ',STR_PAD_RIGHT); + + if($ipdmaster[0]->case_id>0) { + $PrintData.=str_pad('Organisation : '.$insurance[0]->ins_company_name,35,' ',STR_PAD_RIGHT); + } + $PrintData.=PHP_EOL; + + $PrintData.=str_pad('Admit Date : '.$ipd_list[0]->str_register_date,35,' ',STR_PAD_RIGHT); + $PrintData.=str_pad('Discharge Date : '.$ipd_list[0]->str_discharge_date,35,' ',STR_PAD_RIGHT).PHP_EOL; + + $PrintData.='----------------------------------------------------------------------------------------------------------'.PHP_EOL; + $PrintData.=' '.PHP_EOL; + $PrintData.='# Description Rate Qty Amount '.PHP_EOL; + $PrintData.='----------------------------------------------------------------------------------------------------------'.PHP_EOL; + + $srno=1; + $headdesc=''; + + if(Count($ipd_package)>0){ + $PrintData.='Package'.PHP_EOL; + $headdesc='Package'; + for($i=0;$ipackage_name,60,' ',STR_PAD_RIGHT); + $line.=str_pad('',10,' ',STR_PAD_LEFT); + $line.=str_pad('',15,' ',STR_PAD_LEFT); + $line.=str_pad($ipd_package[$i]->package_Amount,15,' ',STR_PAD_LEFT); + $srno=$srno+1; + $PrintData.=$line.PHP_EOL; + } + } + + for($i=0;$igroup_desc) + { + $PrintData.=''. $ipd_invoice_item[$i]->group_desc .''.PHP_EOL; + $headdesc=$ipd_invoice_item[$i]->group_desc; + } + + $line=''; + $line.=str_pad($srno,3,' ',STR_PAD_RIGHT); + + $line.=str_pad($ipd_invoice_item[$i]->item_name.' '.$ipd_invoice_item[$i]->comment,60,' ',STR_PAD_RIGHT); + $line.=str_pad($ipd_invoice_item[$i]->item_qty,10,' ',STR_PAD_LEFT); + $line.=str_pad($ipd_invoice_item[$i]->item_rate,15,' ',STR_PAD_LEFT); + $line.=str_pad($ipd_invoice_item[$i]->item_amount,15,' ',STR_PAD_LEFT); + $srno=$srno+1; + $PrintData.=$line.PHP_EOL; + + } + + for($i=0;$iCharge_type) + { + $PrintData.=''. $showinvoice[$i]->Charge_type .''.PHP_EOL; + $headdesc=$showinvoice[$i]->Charge_type; + } + + $line=''; + $line.=str_pad($srno,3,' ',STR_PAD_RIGHT); + + $line.=str_pad($showinvoice[$i]->idesc,60,' ',STR_PAD_RIGHT); + $line.=str_pad($showinvoice[$i]->no_qty,10,' ',STR_PAD_LEFT); + $line.=str_pad($showinvoice[$i]->item_rate,15,' ',STR_PAD_LEFT); + $line.=str_pad($showinvoice[$i]->amount,15,' ',STR_PAD_LEFT); + $srno=$srno+1; + $PrintData.=$line.PHP_EOL; + } + + if(count($inv_med_list)>0) + { + $PrintData.='---------------------------- Medical Bill ----------------------------------------------------------'.PHP_EOL; + + $med_total=0.00; + foreach($inv_med_list as $row) + { + $line=''; + $line.=str_pad($srno,3,' ',STR_PAD_RIGHT); + $line.=str_pad($row->inv_med_code,40,' ',STR_PAD_RIGHT); + $line.=str_pad($row->net_amount,25,' ',STR_PAD_RIGHT); + + $srno=$srno+1; + $med_total +=$row->net_amount; + $PrintData.=$line.PHP_EOL; + } + } + + $PrintData.='----------------------------------------------------------------------------------------------------------'.PHP_EOL; + $PrintData.=str_pad('Gross Total : '.$ipdmaster[0]->gross_amount,100,' ',STR_PAD_LEFT).PHP_EOL; + + if($ipdmaster[0]->chargeamount1>0) + { + $PrintData.=PHP_EOL; + $PrintData.=str_pad('Charge : '.$ipdmaster[0]->charge1,90,' ',STR_PAD_RIGHT).PHP_EOL ; + $PrintData.=str_pad($ipdmaster[0]->chargeamount1,10,' ',STR_PAD_LEFT).PHP_EOL ; + } + + if($ipdmaster[0]->chargeamount2>0) + { + $PrintData.=PHP_EOL; + $PrintData.=str_pad('Charge : '.$ipdmaster[0]->charge2,90,' ',STR_PAD_RIGHT).PHP_EOL ; + $PrintData.=str_pad($ipdmaster[0]->chargeamount2,10,' ',STR_PAD_LEFT).PHP_EOL ; + } + + if($ipdmaster[0]->Discount>0) + { + $PrintData.=PHP_EOL; + $PrintData.=str_pad('Deduction : '.$ipdmaster[0]->Discount_Remark,90,' ',STR_PAD_RIGHT).PHP_EOL ; + $PrintData.=str_pad($ipdmaster[0]->Discount,10,' ',STR_PAD_LEFT).PHP_EOL ; + } + + if($ipdmaster[0]->Discount2>0) + { + $PrintData.=PHP_EOL; + $PrintData.=str_pad('Deduction : '.$ipdmaster[0]->Discount_Remark2,90,' ',STR_PAD_RIGHT).PHP_EOL ; + $PrintData.=str_pad($ipdmaster[0]->Discount2,10,' ',STR_PAD_LEFT).PHP_EOL ; + } + + if($ipdmaster[0]->Discount3>0) + { + $PrintData.=PHP_EOL; + $PrintData.=str_pad('Deduction : '.$ipdmaster[0]->Discount_Remark3,90,' ',STR_PAD_RIGHT).PHP_EOL ; + $PrintData.=str_pad($ipdmaster[0]->Discount3,10,' ',STR_PAD_LEFT).PHP_EOL ; + } + + $PrintData.='----------------------------------------------------------------------------------------------------------'.PHP_EOL; + $PrintData.=str_pad('Net Amount : '.$ipdmaster[0]->net_amount,100,' ',STR_PAD_LEFT).PHP_EOL; + $PrintData.=str_pad('Payment Recd : '.$ipdmaster[0]->total_paid_amount,100,' ',STR_PAD_LEFT).PHP_EOL; + $PrintData.=str_pad('Balance : '.$ipdmaster[0]->balance_amount,100,' ',STR_PAD_LEFT).PHP_EOL; + $PrintData.=str_pad('Balance Remark : '.$ipdmaster[0]->discharge_balance_remark,70,' ',STR_PAD_RIGHT); + $PrintData.=str_pad('Print Time : '.date('d-m-Y h:i:s'),30,' ',STR_PAD_LEFT).PHP_EOL; + + $PrintData.='xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx'.PHP_EOL .PHP_EOL .PHP_EOL; + + return $PrintData; + } + + + + function Ipd_invoice_print_list($daterange,$doc_name_id,$ipd_type,$ipd_status,$ipd_date,$output=0) + { + $rangeArray = explode("S",$daterange); + $minRange = $rangeArray[0]; + $maxRange = $rangeArray[1]; + + $where =" 1=1 " ; + + if($ipd_status>-1) + { + $where.=" and p.ipd_status=".$ipd_status; + } + + if($ipd_date==0) + { + $where.=" and p.register_date between '".$minRange."' and '".$maxRange."' " ; + }elseif($ipd_date==1) + { + $where.=" and p.discharge_date between '".$minRange."' and '".$maxRange."' " ; + } + + if($doc_name_id>0) + { + $where.=" and FIND_IN_SET('".$doc_name_id."',doc_list) "; + } + + if($ipd_type==6){ + $where.=" and (group_ins is null or group_ins=6)"; + }elseif($ipd_type==0){ + $where.=" "; + }else { + $where.=" and group_ins=$ipd_type "; + } + + + $sql="select p.id,p.ipd_code,p.p_fname,Date_Format(p.register_date,'%d-%m-%Y') as str_register_date, + Date_Format(p.discharge_date,'%d-%m-%Y') as str_discharge_date,p.admit_type,p.doc_name,p.Bed_Desc, + charge_amount,paid_amount + from v_ipd_list p where ".$where." group by p.id,p.doc_list order by id"; + + $query = $this->db->query($sql); + $dischargelist= $query->result(); + + $PrintData=''; + + foreach($dischargelist as $row) + { + $PrintData.=$this->Ipd_invoice_text($row->id); + } + + echo '
'.$PrintData.'
'; + + } + +} \ No newline at end of file diff --git a/old_code_ci3/controllers/IpdNew.php b/old_code_ci3/controllers/IpdNew.php new file mode 100644 index 0000000..a6e246b --- /dev/null +++ b/old_code_ci3/controllers/IpdNew.php @@ -0,0 +1,2241 @@ +load->model('Ipd_M'); + } + + public function IpdDashboard() + { + $this->load->view('IPD2/ipd_dashboard'); + } + + public function ipd_panel_payment($ipdno) + { + + $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 + from payment_history + where payof_type=4 and payof_id='".$ipdno."' "; + $query = $this->db->query($sql); + $data['ipd_payment_history']= $query->result(); + + $sql="select * from invoice_med_master where payment_status=1 and ipd_id = ".$ipdno; + $query = $this->db->query($sql); + $data['inv_med_master']= $query->result(); + + $this->load->view('IPD2/ipd_payment',$data); + } + + public function IPD_info(){ + + $IPDNO = $this->input->post('input_ipd_no'); + + $sql="select * from v_ipd_list where ipd_code='$IPDNO' "; + $query = $this->db->query($sql); + $data= $query->result(); + + if(count($data)>0) + { + $Patient_id=$data[0]->p_id; + $IPD_id=$data[0]->id; + $ipd_info=$data[0]->p_code.'/'.$data[0]->p_fname.' '.$data[0]->p_rname.' /Age :'.$data[0]->str_age.' /AdmitDate:'. + $data[0]->str_register_date.'/TPA:'.$data[0]->admit_type; + + }else{ + $Patient_id=0; + $ipd_info=''; + $IPD_id=0; + } + + $rvar=array( + 'IPD_id' =>$IPD_id, + 'ipd_info'=>$ipd_info + ); + + $encode_data = json_encode($rvar); + echo $encode_data; + + } + + public function ipd_Diagnosis($ipdno) + { + + $sql="select i.id as inv_id,i.invoice_code,sum(t.item_amount) as amount,i.refer_by_other, + date_format(i.inv_date,'%d-%m-%Y') as str_date,i.ipd_include, + group_concat(distinct c.group_desc) as charge_list + from invoice_master i left join + (invoice_item t join hc_item_type c on t.item_type=c.itype_id) + on i.id =t.inv_master_id + where payment_status=1 and ipd_id = ".$ipdno." group by i.id "; + + $query = $this->db->query($sql); + $data['inv_master']= $query->result(); + + $this->load->view('IPD2/ipd_diagnosis_charges',$data); + } + + public function ipd_panel_invoice_show($inv_id,$inv_type) + { + //$inv_id=$this->input->post('invid'); + //$inv_type=$this->input->post('invtype'); + + if($inv_type == 0) + { + redirect('InvoiceShow/invoice_med/'.$inv_id); + }else{ + redirect('InvoiceShow/invoice_charges/'.$inv_id); + } + } + + public function ipd_Diagnosis_invoice_show($invoice_id) + { + $sql="select i.*,t.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 *,(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 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_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(); + + $this->load->view('IPD2/ipd_diagnosis_invoice_items',$data); + + } + + public function Update_Invoice_ipd_itmes_package() + { + $ipd_item_package_type= $this->input->post('ipd_item_package_type'); + $ipd_item_id = $this->input->post('ipd_item_id'); + + $dataupdate = array( + 'package_id' => $ipd_item_package_type + ); + + + $this->Ipd_M->update_ipd_item($dataupdate,$ipd_item_id); + echo 'Value of '.$ipd_item_package_type.' is '.$ipd_item_id; + } + + public function show_account($ipdno) + { + $total_med=0.00; + $total_charges=0.00; + + $sql="select * from ipd_master where id='".$ipdno."' "; + $query = $this->db->query($sql); + $data['ipd_master']= $query->result(); + + $discount=$data['ipd_master'][0]->Discount; + $discount2=$data['ipd_master'][0]->Discount2; + $discount3=$data['ipd_master'][0]->Discount3; + + $tdiscount=$discount+$discount2+$discount3; + + $charge1=$data['ipd_master'][0]->chargeamount1; + $charge2=$data['ipd_master'][0]->chargeamount2; + $tcharge=$charge1+$charge2; + + $sql="select sum(net_amount) as tnet_amount from invoice_med_master where ipd_credit=1 and ipd_credit_type<2 and ipd_id = ".$ipdno; + $query = $this->db->query($sql); + $data['inv_med_total']= $query->result(); + + $total_med=$data['inv_med_total'][0]->tnet_amount; + + $sql="select sum(total_amount) as tnet_amount from invoice_master where payment_status=1 and ipd_id = ".$ipdno; + $query = $this->db->query($sql); + $data['inv_charge_total']= $query->result(); + + $total_charges=$data['inv_charge_total'][0]->tnet_amount; + + $sql="select sum(if(credit_debit>0,amount*-1,amount)) as tnet_amount from ipd_payment where ipd_id='".$ipdno."' "; + $query = $this->db->query($sql); + $data['inv_payment_total']= $query->result(); + + $total_payment=$data['inv_payment_total'][0]->tnet_amount; + + $total_balance_amount=$total_payment-($total_charges+$total_med+$tcharge-$tdiscount); + + $data['inv_total']=array( + 'total_med' => $total_med, + 'total_charges' => $total_charges, + 'total_payment' => $total_payment, + 'total_balance_amount' => $total_balance_amount, + 'discount' => $tdiscount, + 'charge' => $tcharge, + 'ipd_id' => $ipdno + ); + + $this->load->view('IPD2/ipd_account_panel',$data); + + } + + public function ipd_complete_invoice($ipdno,$print=0) + { + //calculate_IPD + + + + $this->Ipd_M->calculate_IPD($ipdno); + + $sql="select * from ipd_master where id=".$ipdno; + $query = $this->db->query($sql); + $data['ipdmaster']= $query->result(); + + $pno=$data['ipdmaster'][0]->p_id; + + $sql="select * from ipd_package where ipd_id=".$ipdno; + $query = $this->db->query($sql); + $data['ipd_package']= $query->result(); + + //Check Items in Package + $No_Pack_items=0; + + $sql1= 'Select count(*) as no_rec from ipd_invoice_item i + where i.package_id>0 and i.ipd_id='.$ipdno; + + $sql2= 'Select count(*) as no_rec from invoice_med_master + Where ipd_credit=1 and ipd_credit_type=0 and ipd_id = '.$ipdno; + + $sql3= 'Select count(*) as no_rec from v_ipd_invoice b + where b.ipd_id='.$ipdno.' and ipd_include=0'; + + $query = $this->db->query($sql1); + $Package_Items= $query->result(); + $No_Pack_items+=$Package_Items[0]->no_rec; + + $query = $this->db->query($sql2); + $Package_Items= $query->result(); + $No_Pack_items+=$Package_Items[0]->no_rec; + + $query = $this->db->query($sql3); + $Package_Items= $query->result(); + $No_Pack_items+=$Package_Items[0]->no_rec; + + $data['No_Pack_items']=$No_Pack_items; + + if(count($data['ipd_package'])>0) + { + $sql="select t.group_desc,i.*,sum(i.item_amount) as xAmount + from ipd_invoice_item i join ipd_item_type t on i.item_type=t.itype_id + where i.package_id=0 and i.ipd_id=".$ipdno." + group by i.item_type,i.id order by i.item_type"; + $query = $this->db->query($sql); + $data['ipd_invoice_item']= $query->result(); + }else{ + $sql="select t.group_desc,i.*,sum(i.item_amount) as xAmount + from ipd_invoice_item i join ipd_item_type t on i.item_type=t.itype_id + where i.ipd_id=".$ipdno." + group by i.item_type,i.id order by i.item_type"; + $query = $this->db->query($sql); + $data['ipd_invoice_item']= $query->result(); + } + + $sql="select * from invoice_med_master + where ipd_credit=1 and ipd_credit_type=1 and ipd_id = ".$ipdno; + $query = $this->db->query($sql); + $data['inv_med_list']= $query->result(); + + $sql="select b.ipd_id AS ipd_id,b.Charge_type AS Charge_type,b.idesc AS idesc, + b.item_rate AS item_rate,b.orgcode AS orgcode,sum(b.item_qty) AS no_qty,sum(b.Amount) AS amount + from v_ipd_invoice b where b.ipd_id=".$ipdno." and ipd_include=1 + group by b.ipd_id,b.item_id,b.item_rate order by b.Charge_type "; + + $query = $this->db->query($sql); + $data['showinvoice']= $query->result(); + + $sql="select * from v_ipd_list where id=".$ipdno; + $query = $this->db->query($sql); + $data['ipd_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=".$ipdno." order by TDate desc"; + $query = $this->db->query($sql); + $data['bed_list']= $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='".$pno."' "; + $query = $this->db->query($sql); + $data['person_info']= $query->result(); + + if($data['ipdmaster'][0]->case_id>0) + { + $sql="select * from organization_case_master where id='".$data['ipdmaster'][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(); + } + + $sql="SELECT h.*,DATE_FORMAT(h.payment_date,'%d-%m-%Y') as pay_date_str, + concat(if(h.credit_debit=0,'','Return '),if(h.payment_mode=1,'CASH','BANK')) as pay_mode + from payment_history h where h.payof_type=4 AND h.payof_id='".$ipdno."' "; + $query = $this->db->query($sql); + $data['ipd_payment']= $query->result(); + + if($print>0) + { + //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; + + $file_name='Report-IPDBill-'.$ipdno."-".date('Ymdhis').".pdf"; + + $filepath=$file_name; + + //$this->load->view('Medical/medical_bill_print_format',$data); + + if($print==1) + { + $content=$this->load->view('IPD2/Ipd_invoice_print_V',$data,TRUE); + }else if($print==2) + { + $content=$this->load->view('IPD2/ipd_invoice_print_wo_payment',$data,TRUE); + }else if($print==3) + { + $content=$this->load->view('IPD2/ipd_invoice_doc_wise',$data,TRUE); + }else if($print==4) + { + $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{ + $content='Blank'; + } + + + //echo $content; + + //generate the PDF from the given html + $this->m_pdf->pdf->WriteHTML($content); + + //download it. + $this->m_pdf->pdf->Output($filepath,"I"); + + + + }else{ + $this->load->view('IPD2/Ipd_invoice_V',$data); + } + + + + } + + public function ipd_short_invoice($ipdno,$print=0) + { + $sql="select * from ipd_master where id=".$ipdno; + $query = $this->db->query($sql); + $data['ipdmaster']= $query->result(); + + $pno=$data['ipdmaster'][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(); + + if($data['ipdmaster'][0]->case_id>0) + { + $sql="select * from organization_case_master where id='".$data['ipdmaster'][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(); + } + + $sql="select * from v_ipd_invoice v + where v.ipd_id=".$ipdno." order by Charge_type,inv_date "; + $query = $this->db->query($sql); + $data['showinvoice']= $query->result(); + + $sql="select sum(amount) as GTotal from v_ipd_invoice v + where v.ipd_id=".$ipdno." "; + $query = $this->db->query($sql); + $data['invoiceGtotal']= $query->result(); + + $sql="select *,case payment_mode when 1 then 'Cash' when 2 then 'Bank Card' else 'Other' end as pay_mode from ipd_payment where ipd_id='".$ipdno."' "; + $query = $this->db->query($sql); + $data['ipd_payment']= $query->result(); + + + if($print>0) + { + $this->load->view('IPD2/Ipd_invoice_print_V',$data); + + }else{ + $this->load->view('IPD2/Ipd_invoice_V',$data); + } + } + + public function ipd_confirm_payment() + { + if (!$this->input->is_ajax_request()) { exit('no valid req.'); } + + + $this->load->model('Payment_M'); + + $ipd_id=$this->input->post('ipd_id'); + $amount=$this->input->post('amount'); + + $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', + 'payof_type'=>'4', + 'payof_id'=>$ipd_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.']', + 'update_by_id'=>$user_id + ); + + $insert_id=$this->Payment_M->insert($paydata); + + $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', + '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.']', + 'pay_bank_id'=>$this->input->post('cbo_pay_type'), + 'card_tran_id'=>$this->input->post('input_card_tran'), + 'update_by_id'=>$user_id + ); + + $insert_id=$this->Payment_M->insert($paydata); + + $status='Bank Card'; + + + $rvar=array( + 'update' =>1, + 'ipd_id'=> $ipd_id, + 'payid' => $insert_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 ipd_ded_payment() + { + if (!$this->input->is_ajax_request()) { exit('no valid req.'); } + + + $this->load->model('Payment_M'); + + $ipd_id=$this->input->post('ipd_id'); + $amount=$this->input->post('amount'); + + $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'); + + if($this->input->post('mode')==3) + { + $paydata = array( + 'payment_mode'=> '1', + 'payof_type'=>'4', + 'payof_id'=>$ipd_id, + 'payof_code'=>$ipd_master[0]->ipd_code, + 'credit_debit'=>'1', + 'amount'=>$amount, + '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); + + $rvar=array( + 'update' =>1, + 'ipd_id'=> $ipd_id, + 'payid' => $insert_id + ); + + $encode_data = json_encode($rvar); + echo $encode_data; + } + + if($this->input->post('mode')==4) + { + $paydata = array( + 'payment_mode'=> '2', + 'payof_type'=>'4', + 'payof_id'=>$ipd_id, + 'payof_code'=>$ipd_master[0]->ipd_code, + 'credit_debit'=>'1', + 'amount'=>$amount, + '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); + + $rvar=array( + 'update' =>1, + 'ipd_id'=> $ipd_id, + 'payid' => $insert_id + ); + + $encode_data = json_encode($rvar); + echo $encode_data; + } + + } + + public function ipd_org_status_update() + { + 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; + + $this->load->model('Ocasemaster_M'); + $data['master'] = array( + 'org_approved_amount' => $this->input->post('amount'), + 'org_approved_status_id' => $this->input->post('org_status'), + 'org_status_update_by' => $user_name + ); + + $case_id=$this->input->post('case_id'); + $this->Ocasemaster_M->update($data['master'],$case_id); + + $rvar=array( + 'update' =>'1', + 'msg' => 'Update Done '.$case_id + ); + $encode_data = json_encode($rvar); + echo $encode_data; + + } + + public function ipd_main_panel($ipdno) + { + $sql="select *,if(ipd_status=0,DATEDIFF(sysdate(),register_date),DATEDIFF(discharge_date,register_date)) as no_days from ipd_master where id='".$ipdno."' "; + $query = $this->db->query($sql); + $data['ipd_info']= $query->result(); + + $sql="select * from v_ipd_list where id='".$ipdno."' "; + $query = $this->db->query($sql); + $data['ipd_list']= $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 *,concat_ws(' ','Dr.',p_fname,p_mname,p_lname) as doc_name from doctor_master where id='".$data['ipd_info'][0]->r_doc_id."' "; + $query = $this->db->query($sql); + $data['doc_info']= $query->result(); + + $sql="select i.id,d.p_fname,d.id as doc_id from ipd_master_doc_list i join doctor_master d on i.doc_id = d.id where ipd_id='".$ipdno."' "; + $query = $this->db->query($sql); + $data['ipd_doc_list']= $query->result(); + + $sql="select * from organization_case_master + where id=".$data['ipd_info'][0]->case_id; + $query = $this->db->query($sql); + $data['case_master']= $query->result(); + + $sql="select * from organization_case_master + where status=0 and case_type=1 and ipd_id=0 and p_id=".$data['ipd_info'][0]->p_id; + $query = $this->db->query($sql); + $data['case_master_open']= $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 * from org_approved_status "; + $query = $this->db->query($sql); + $data['org_approved_status']= $query->result(); + + $sql="SELECT m.id,CONCAT(m.title,' ',m.f_name,' [',t.type_desc,']') AS refer_name, t.type_desc + FROM refer_master m JOIN refer_type t ON m.refer_type=t.id order by t.type_desc,m.f_name"; + $query = $this->db->query($sql); + $data['refer_master']= $query->result(); + + $sql="SELECT i.id,CONCAT(m.title,' ',m.f_name,' [',t.type_desc,']') AS refer_name, t.type_desc + FROM (refer_master m JOIN refer_type t ON m.refer_type=t.id) + Join ipd_refer i on i.refer_by=m.id and i.ipd_id=$ipdno + order by t.type_desc,m.f_name"; + $query = $this->db->query($sql); + $data['refer_list']= $query->result(); + + + $this->load->view('IPD2/ipd_main_panel',$data); + } + + public function ipd_account_panel($ipdno) + { + //calculate_IPD + + + $this->Ipd_M->calculate_IPD($ipdno); + + $sql="select * from ipd_master where id='".$ipdno."' "; + $query = $this->db->query($sql); + $ipd_master= $query->result(); + + $data['ipd_master']=$ipd_master; + + $data['inv_total']=array( + 'total_med_credit' => $ipd_master[0]->med_amount+$ipd_master[0]->package_med_amount, + 'total_med_cash' => $ipd_master[0]->cash_med_amount, + 'total_med_cash_paid' => $ipd_master[0]->med_paid, + 'total_charge_amount' => $ipd_master[0]->charge_amount, + 'total_payment' => $ipd_master[0]->total_paid_amount, + 'total_balance_amount' => $ipd_master[0]->balance_amount, + 'net_amount' => $ipd_master[0]->net_amount, + 'ipd_id' => $ipdno + ); + + $this->load->view('IPD2/ipd_account_panel',$data); + } + + public function ipd_panel($ipdcode,$stype=0) + { + + if($stype > 0) + { + $sql="select id from ipd_master where ipd_code='".$ipdcode."' "; + $query = $this->db->query($sql); + $get_ipd_no= $query->result(); + + $ipdno=$get_ipd_no[0]->id; + }else{ + $ipdno=$ipdcode; + } + + //calculate_IPD + + + $this->Ipd_M->calculate_IPD($ipdno); + + $sql="select * from v_ipd_list where id='".$ipdno."' "; + $query = $this->db->query($sql); + $data['ipd_info']= $query->result(); + + $p_id=$data['ipd_info'][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='".$p_id."' "; + $query = $this->db->query($sql); + $data['person_info']= $query->result(); + + $sql="select * + from ipd_master_doc_list i join doctor_master d on i.doc_id = d.id + where ipd_id='".$ipdno."' "; + $query = $this->db->query($sql); + $data['ipd_doc_list']= $query->result(); + + $sql="select * + from organization_case_master + where status=0 and case_type=1 and ipd_id=$ipdno and p_id=".$p_id; + $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 + from payment_history + where payof_type=4 and payof_id='".$ipdno."' "; + $query = $this->db->query($sql); + $data['ipd_payment_history']= $query->result(); + + if ($this->ion_auth->in_group('admin1') || $this->ion_auth->in_group('IPDAdmit') ) { + if($data['ipd_info'][0]->ipd_status==0) + { + $this->load->view('IPD2/Ipdpanel_V',$data); + }else{ + if($this->ion_auth->in_group('IPDReAdmit')) + { + $this->load->view('IPD2/Ipdpanel_V',$data); + }else{ + $this->load->view('IPD2/IPD_View',$data); + } + } + }else{ + $this->load->view('IPD2/IPD_View',$data); + } + } + + public function load_model_TPA_Payment($ipd_id) + { + $sql="select *,if(case_type=1,'MLC','Non MLC') as case_type_s, + Date_format(register_date,'%d-%m-%Y') as str_register_date , + Date_format(discharge_date,'%d-%m-%Y') as str_discharge_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(); + + $data['ipd_id']=$ipd_id; + + $this->load->view('IPD2/TPA_Payment',$data); + } + + public function tpa_payment() + { + if (!$this->input->is_ajax_request()) { exit('no valid req.'); } + + + + $ipd_id=$this->input->post('hid_ipd_id'); + $payable_by_tpa=$this->input->post('input_payable_by_tpa'); + $discount_for_tpa=$this->input->post('input_discount_for_tpa'); + $discount_by_hospital=$this->input->post('input_discount_by_hospital'); + $discount_by_hospital_2=$this->input->post('input_discount_by_hospital_2'); + $discount_by_hospital_remark=$this->input->post('input_discount_by_hospital_remark'); + $discount_by_hospital_2_remark=$this->input->post('input_discount_by_hospital_2_remark'); + + $paydata = array( + 'payable_by_tpa'=> $payable_by_tpa, + 'discount_by_hospital'=>$discount_by_hospital, + 'discount_by_hospital_2'=>$discount_by_hospital_2, + 'discount_for_tpa'=>$discount_for_tpa, + 'discount_by_hospital_remark'=>$discount_by_hospital_remark, + 'discount_by_hospital_2_remark'=>$discount_by_hospital_2_remark, + ); + + $update=$this->Ipd_M->update($paydata,$ipd_id); + + $rvar=array( + 'update' =>1, + 'ipd_id'=> $ipd_id, + ); + + $encode_data = json_encode($rvar); + echo $encode_data; + + } + + public function IpdList() + { + $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('IPD2/IPDList_V',$data); + } + + public function ipd_room_status() + { + $sql="select b.room_name,b.room_rent,count(b.id) as Total_Bed,sum(if(b.bed_used_p_id=0,1,0)) as FreeBed + from hc_bed_master b group by b.room_name"; + $query = $this->db->query($sql); + $data['roomdata']= $query->result(); + + $this->load->view('IPD2/ipd_bed_status',$data); + } + + public function add_remove_doc($ipd_doc_id) + { + if ($this->ion_auth->in_group('IPDAdmit')) { + $this->db->delete("ipd_master_doc_list", "id=".$ipd_doc_id); + } + } + + public function add_add_doc($ipd_id,$doc_id) + { + if ($this->ion_auth->in_group('IPDAdmit')) { + + if (!$this->input->is_ajax_request()) { exit('no valid req.'); } + + + + $data = array( + 'ipd_id' => $ipd_id, + 'doc_id' => $doc_id + ); + $inser_id=$this->Ipd_M->add_ipd_doc($data); + } + } + + public function show_ipd_form($ipdno,$form_no=1) + { + $sql="select *,if(case_type=1,'MLC','Non MLC') as case_type_s, + Date_format(register_date,'%d-%m-%Y') as str_register_date , + Date_format(discharge_date,'%d-%m-%Y') as str_discharge_date + from ipd_master where id='".$ipdno."' "; + $query = $this->db->query($sql); + $data['ipd_info']= $query->result(); + + $sql="select * From v_ipd_list Where id='".$ipdno."' "; + $query = $this->db->query($sql); + $data['ipd_info_2']= $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 *,concat_ws(' ','Dr.',p_fname,p_mname,p_lname) as doc_name from doctor_master where id='".$data['ipd_info'][0]->r_doc_id."' "; + $query = $this->db->query($sql); + $data['doc_info']= $query->result(); + + $sql="select i.id,d.p_fname,d.id as doc_id from ipd_master_doc_list i join doctor_master d on i.doc_id = d.id where ipd_id='".$ipdno."' "; + $query = $this->db->query($sql); + $data['ipd_doc_list']= $query->result(); + + $sql="select * from organization_case_master where id='".$data['ipd_info'][0]->case_id."' "; + $query = $this->db->query($sql); + $data['case_master']= $query->result(); + + $d= $this->ion_auth->user()->row(); + + $data['user'] = $d; + + //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; + + $file_name='Report-FaceForm-'.date('Ymdhis').".pdf"; + + $filepath=$file_name; + + //$this->load->view('Medical/medical_bill_print_format',$data); + + if($form_no==1) + { + $content=$this->load->view('IPD2/print_ipd_form1',$data,TRUE); + }elseif($form_no==2){ + $content=$this->load->view('IPD2/print_ipd_form2',$data,TRUE); + }elseif($form_no==3){ + $content=$this->load->view('IPD2/print_ipd_form3',$data,TRUE); + }elseif($form_no==4){ + $content=$this->load->view('IPD2/ipd_dues_form',$data,TRUE); + }elseif($form_no==5){ + $this->m_pdf->pdf->showWatermarkText = false; + $content=$this->load->view('IPD_Format/form_admission_histroy_phusical_assessment',$data,TRUE); + }elseif($form_no==6){ + $this->m_pdf->pdf->showWatermarkText = false; + $content=$this->load->view('IPD_Format/form_treatment_chart',$data,TRUE); + }elseif($form_no==7){ + $this->m_pdf->pdf->showWatermarkText = false; + $content=$this->load->view('IPD_Format/form_vitals_chart',$data,TRUE); + }elseif($form_no==8){ + $this->m_pdf->pdf->showWatermarkText = false; + $content=$this->load->view('IPD_Format/form_progress_notes',$data,TRUE); + }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); + }else{ + $content=""; + } + + + //echo $content; + + //generate the PDF from the given html + $this->m_pdf->pdf->WriteHTML($content); + + //download it. + $this->m_pdf->pdf->Output($filepath,"I"); + } + + public function ipd_list() + { + $this->load->view('IPD2/ipd_all_list'); + } + + public function addipd($pno) + { + $sql="select count(*) as no_ipd from ipd_master where ipd_status=0 and p_id=".$pno; + $query = $this->db->query($sql); + $data['ipd_master_rec']= $query->result(); + + if ($data['ipd_master_rec'][0]->no_ipd > 0) + { + $sql="select * from ipd_master where ipd_status=0 and p_id=".$pno; + $query = $this->db->query($sql); + $data['ipd_info']= $query->result(); + + redirect('IpdNew/ipd_panel/'.$data['ipd_info'][0]->id); + }else{ + $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(); + + $sql="select d.id ,d.p_fname ,group_concat(m.SpecName) as SpecName + from doctor_master d join doc_spec s join med_spec m on d.id =s.doc_id and s.med_spec_id =m.id + where d.active=1 group by d.id "; + $query = $this->db->query($sql); + $data['doc_spec_l']= $query->result(); + + $sql="select id,concat('Bed No:',bed_no,'/','[',room_name,']') as Bed_Desc from hc_bed_master where bed_used_p_id=0"; + $query = $this->db->query($sql); + $data['ipd_bed_list']= $query->result(); + + $sql="select * from hc_insurance "; + $query = $this->db->query($sql); + $data['insur_list']= $query->result(); + + $sql="select * from organization_case_master + where status=0 and case_type=1 and ipd_id=0 and p_id=".$pno; + $query = $this->db->query($sql); + $data['case_master']= $query->result(); + + $sql="select * from refer_master where active=1"; + $query = $this->db->query($sql); + $data['refer_master']= $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'), + 'relation' => $this->input->post('r_relation'), + 'contact_person_Name' => $this->input->post('rp_name'), + 'insurance_id' => $this->input->post('insur_list'), + 'policy_no' => $this->input->post('insur_no'), + 'register_date' => str_to_MysqlDate($this->input->post('res_date')), + 'problem' => $this->input->post('problem'), + 'remark' => $this->input->post('remark'), + 'P_mobile1' => $this->input->post('phone1'), + 'P_mobile2' => $this->input->post('phone2'), + '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') + ); + + $groupData = $this->input->post('doc_id'); + + if (isset($groupData) && !empty($groupData)) { + $data['doc_list']=$groupData; + + $inser_id=$this->Ipd_M->insert($data); + + $data['BedData'] = array( + 'ipd_id' => $inser_id, + 'Fdate' => date('Y-m-d h:i:s'), + 'TDate' => date('Y-m-d h:i:s'), + 'bed_id' => $this->input->post('room_list') + ); + + if($this->input->post('room_list')<>"") + { + $inser_bed_id=$this->Ipd_M->bedassign($data['BedData']); + } + } + else + { + $inser_id=0; + } + + if($this->input->post('optionsRadios_org')>0 && $inser_id>0) + { + $org_data = array( + 'ipd_id' => $inser_id, + ); + + $this->load->model('Ocasemaster_M'); + $this->Ocasemaster_M->update($org_data,$this->input->post('optionsRadios_org')); + } + +$rvar=array( +'insertid' =>$inser_id +); +$encode_data = json_encode($rvar); +echo $encode_data; +} + + public function ipd_bed_assign_list($ipdno) + { + $sql="select m.bed_no,m.room_name,b.Fdate,b.TDate,b.Remark + from ipd_bed_assign b join hc_bed_master m on b.bed_id=m.id where b.ipd_id=".$ipdno; + $query = $this->db->query($sql); + $data['ipd_bed_assign']= $query->result(); + + $sql="select id,concat('Bed No:',bed_no,'/','[',room_name,']') as Bed_Desc from hc_bed_master where bed_used_p_id=0"; + $query = $this->db->query($sql); + $data['ipd_bed_list']= $query->result(); + + + $this->load->view('IPD2/ipd_bed_assign',$data); + + } + + + public function ipd_cash_print_pdf($ipd_id,$payid) + { + $sql="select *,date_format(payment_date,'%d-%m-%Y %h:%i %p') as payment_date_str , + if(credit_debit=0,'','Return') as Amount_str + from payment_history where payof_type=4 and payof_id=$ipd_id and id=$payid"; + $query = $this->db->query($sql); + $data['ipd_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['patient_master']= $query->result(); + + $data['ipd_id']=$ipd_id; + $data['payid']=$payid; + + //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 = false; + + $file_name='Charge_Invoice-'.date('Ymdhis').".pdf"; + + $filepath=$file_name; + + $content=$this->load->view('IPD2/ipd_payment_receipt_print',$data,TRUE); + + //echo $content; + + //$this->m_pdf->pdf->debug = true; + + //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 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 str_age from patient_master where id='".$data['ipd_info'][0]->p_id."' "; + $query = $this->db->query($sql); + $data['person_info']= $query->result(); + + $sql="select s.id,s.pay_type,m.bank_name + From hospital_bank m join hospital_bank_payment_source s on m.id=s.bank_id"; + $query = $this->db->query($sql); + $data['bank_data']= $query->result(); + + $this->load->view('IPD2/ipd_model_payment_box',$data); + } + + + + public function ipd_bed_list() + { + $sql="select id,concat('Bed No:',bed_no,'/','[',room_name,']') as Bed_Desc from hc_bed_master where bed_used_p_id=0"; + + $query = $this->db->query($sql); + $ipd_bed_list= $query->result(); + + echo ''; + echo ''; + echo ''; + } + + public function load_model_ded_box() + { + $this->load->view('IPD2/ipd_panel_deduction_payment'); + } + + + + public function discharge_update() + { + 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; + + $discharge_by=$user_name.'['.$user_id.']'; + + $data['master'] = array( + 'discharge_by' => $discharge_by, + 'discharge_remark' => $this->input->post('discharge_remark'), + 'discharge_balance_user' => $this->input->post('input_bal_user'), + 'discharge_balance_remark' => $this->input->post('input_bal_remark'), + 'ipd_status' => '1', + 'discharge_date' => str_to_MysqlDate($this->input->post('dis_date')), + 'discharge_time' => $this->input->post('dis_time'), + 'discarge_patient_status' => $this->input->post('p_status') + ); + + $ipd_id=$this->input->post('Ipd_ID'); + $this->Ipd_M->update($data['master'],$ipd_id); + + $inser_id=1; + + $rvar=array( + 'insertid' =>$inser_id, + 'showcontent' => "Discharge Status Updated." + ); + + $encode_data = json_encode($rvar); + echo $encode_data; + } + + public function update_ipdadmit_time() + { + if (!$this->input->is_ajax_request()) { exit('no valid req.'); } + + + $ipd_id=$this->input->post('Ipd_ID'); + + $data['master'] = array( + 'register_date' => str_to_MysqlDate($this->input->post('strdate')), + 'reg_time' => $this->input->post('strtime') + ); + + $ipd_id=$this->input->post('Ipd_ID'); + $this->Ipd_M->update($data['master'],$ipd_id); + + $inser_id=1; + + $rvar=array( + 'insertid' =>$inser_id, + 'showcontent' => "Admit Date Updated" + ); + + $encode_data = json_encode($rvar); + echo $encode_data; + } + + public function update_relative_update() + { + if (!$this->input->is_ajax_request()) { exit('no valid req.'); } + + + $Ipd_ID=$this->input->post('Ipd_ID'); + $P_mobile1=$this->input->post('P_mobile1'); + $P_mobile2=$this->input->post('P_mobile2'); + $contact_person_Name=$this->input->post('contact_person_Name'); + $case_type=$this->input->post('case_type'); + + $data['master'] = array( + 'contact_person_Name' => $contact_person_Name, + 'P_mobile1' => $P_mobile1, + 'P_mobile2' => $P_mobile2, + 'case_type' => $case_type + ); + + $this->Ipd_M->update($data['master'],$Ipd_ID); + + $inser_id=1; + + $rvar=array( + 'insertid' =>$inser_id, + 'showcontent' => "Admit Date Updated" + ); + + $encode_data = json_encode($rvar); + echo $encode_data; + } + + public function discharge_ipd($ipdno) + { + $sql="select * from ipd_master where id='".$ipdno."' "; + $query = $this->db->query($sql); + $data['ipd_info']= $query->result(); + + $sql="select * from ipd_discharg_status "; + $query = $this->db->query($sql); + $data['ipd_discharge_status']= $query->result(); + + $discount=$data['ipd_info'][0]->Discount; + + $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(); + + + if($data['ipd_info'][0]->ipd_status == 0 ) + { + $this->load->view('IPD2/ipd_discharge',$data); + }else{ + $this->load->view('IPD2/ipd_discharged_status',$data); + } + + + } + + public function getIpdTable() + { + + $requestData= $_REQUEST; + + $columns = array( + // datatable column index => database column name + 0 =>'ipd_code', + 1 => 'p_code', + 2 => 'p_fname', + 3=> 'admit_type', + 4=> 'insurance_no_1', + 5=> 'doc_name', + 6=> 'Disstatus', + 7=> 'str_register_date', + 8=> 'str_discharge_date', + 9=> 'status_desc' + ); + + // getting total number records without any search + $sql_f_all = "select * "; + + $sql_count="Select count(*) as no_rec "; + + $sql_from=" from v_ipd_list "; + + $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']) ){ //ipd_code + $sql_where.=" AND ipd_code LIKE '%".$requestData['columns'][0]['search']['value']."' "; + $sql_where_flag=1; + } + + if( !empty($requestData['columns'][1]['search']['value']) ){ //p_code + $sql_where.=" AND p_code LIKE '".$requestData['columns'][1]['search']['value']."%' "; + $sql_where_flag=1; + } + + if( !empty($requestData['columns'][2]['search']['value']) ){ //p_fname + $sql_where.=" AND p_fname LIKE '%".$requestData['columns'][2]['search']['value']."%' "; + $sql_where_flag=1; + } + + if( !empty($requestData['columns'][3]['search']['value']) ){ //P_mobile1 + $sql_where.=" AND (admit_type LIKE '%".$requestData['columns'][3]['search']['value']."%' + or ins_company_name LIKE '%".$requestData['columns'][3]['search']['value']."%')"; + $sql_where_flag=1; + } + + if( !empty($requestData['columns'][4]['search']['value']) ){ //P_mobile1 + $sql_where.=" AND insurance_no_1 LIKE '%".$requestData['columns'][4]['search']['value']."%' "; + $sql_where_flag=1; + } + + if( !empty($requestData['columns'][5]['search']['value']) ){ //P_mobile1 + $sql_where.=" AND doc_name LIKE '%".$requestData['columns'][5]['search']['value']."%' "; + $sql_where_flag=1; + } + + if( !empty($requestData['columns'][7]['search']['value']) ) + { //IPD Admit Date Range + $rangeArray = explode("/",$requestData['columns'][7]['search']['value']); + $minRange = $rangeArray[0]; + $maxRange = $rangeArray[1]; + $admitType = $rangeArray[2]; + if($admitType==0){ + $sql_where.=" AND ( Date(register_date) between '".$minRange."' AND '".$maxRange."' ) "; + }elseif($admitType==1){ + $sql_where.=" AND ( Date(discharge_date) between '".$minRange."' AND '".$maxRange."' ) "; + }else{ + $sql_where.=" AND (( Date(register_date) between '".$minRange."' AND '".$maxRange."' ) "; + $sql_where.=" OR ( Date(discharge_date) between '".$minRange."' AND '".$maxRange."' )) "; + } + + $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 discount_update($dis_no) + { + 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; + + $Discount_By=$user_name.'['.$user_id.']'.date('d-m-Y'); + + if($dis_no==1) + { + $data['master'] = array( + 'Discount_By' => $Discount_By, + 'Discount_Remark' => $this->input->post('Discount_Remark'), + 'Discount' => $this->input->post('Discount') + ); + }elseif($dis_no==2){ + $data['master'] = array( + 'Discount_By2' => $Discount_By, + 'Discount_Remark2' => $this->input->post('Discount_Remark'), + 'Discount2' => $this->input->post('Discount') + ); + }elseif($dis_no==3){ + $data['master'] = array( + 'Discount_By3' => $Discount_By, + 'Discount_Remark3' => $this->input->post('Discount_Remark'), + 'Discount3' => $this->input->post('Discount') + ); + } + + $ipd_id=$this->input->post('Ipd_ID'); + $this->Ipd_M->update($data['master'],$ipd_id); + + $inser_id=1; + + $rvar=array( + 'insertid' =>$inser_id, + 'showcontent' => "Discount Status Updated." + ); + + $encode_data = json_encode($rvar); + echo $encode_data; + } + + public function charge_update($dis_no) + { + 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; + + $charge_by=$user_name.'['.$user_id.']'.date('d-m-Y'); + + if($dis_no==1) + { + $data['master'] = array( + 'charge_by1' => $charge_by, + 'charge1' => $this->input->post('input_charge_remark1'), + 'chargeamount1' => $this->input->post('input_charge_Amount1') + ); + }elseif($dis_no==2){ + $data['master'] = array( + 'charge_by2' => $charge_by, + 'charge2' => $this->input->post('input_charge_remark2'), + 'chargeamount2' => $this->input->post('input_charge_Amount2') + ); + } + + $ipd_id=$this->input->post('Ipd_ID'); + $this->Ipd_M->update($data['master'],$ipd_id); + + $inser_id=1; + + $rvar=array( + 'insertid' =>$inser_id, + 'showcontent' => "Charge Status Updated." + ); + + $encode_data = json_encode($rvar); + echo $encode_data; + } + + public function readmit($dis_no) + { + 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; + + $charge_by=$user_name.'['.$user_id.']'.date('d-m-Y'); + + if($dis_no==2) + { + $data['master'] = array( + 'ipd_status' => '0' + ); + } + + $ipd_id=$this->input->post('Ipd_ID'); + $this->Ipd_M->update($data['master'],$ipd_id); + + $inser_id=1; + + $rvar=array( + 'insertid' =>$inser_id, + 'showcontent' => "Status Updated." + ); + + $encode_data = json_encode($rvar); + echo $encode_data; + } + + public function add_bed_room() + { + $room_list=$this->input->post('room_list'); + $Ipd_ID=$this->input->post('Ipd_ID'); + + + $data = array( + 'ipd_id' => $this->input->post('Ipd_ID'), + 'Fdate' => $this->input->post('start_datetime'), + 'TDate' => $this->input->post('end_datetime'), + 'bed_id' => $this->input->post('room_list') + ); + + $inser_id=$this->Ipd_M->bedassign($data); + + $sql="select m.bed_no,m.room_name,b.Fdate,b.TDate,b.Remark + from ipd_bed_assign b join hc_bed_master m on b.bed_id=m.id where b.ipd_id=".$Ipd_ID; + + $query = $this->db->query($sql); + $room_assign_info= $query->result(); + + $r_data='
+ + + + + + + + + + '; + + for ($i = 0; $i < count($room_assign_info); ++$i) { + $r_data=$r_data.' + + + + + '; + } + + $r_data=$r_data.'
Bed No.DescriptionDateVacant Date
'.$room_assign_info[$i]->bed_no.''.$room_assign_info[$i]->room_name.''.$room_assign_info[$i]->Fdate.''.$room_assign_info[$i]->TDate.'
'; + + $rvar=array( + 'insertid' =>$inser_id + ); + $encode_data = json_encode($rvar); + //echo $encode_data; + echo $r_data; + + } + + public function list_med_inv($ipd_id) + { + $sql="select * from invoice_med_master where ipd_credit=1 and ipd_id = ".$ipd_id; + $query = $this->db->query($sql); + $data['inv_master_credit']= $query->result(); + + $data['ipd_id']=$ipd_id; + + $this->load->view('IPD2/IPD_Medical_Invoice_Panel',$data); + } + + public function list_med_inv_details($ipd_id,$inv_med_id) + { + $sql="select * from invoice_med_master where ipd_credit=1 and id='".$inv_med_id."' and ipd_id = ".$ipd_id; + $query = $this->db->query($sql); + $data['inv_master_credit']= $query->result(); + + $sql="select * from inv_med_item where inv_med_id='".$inv_med_id."'"; + $query = $this->db->query($sql); + $data['inv_master_credit_details']= $query->result(); + + $this->load->view('IPD2/ipd_medical_invoice_short',$data); + } + + + public function Update_Invoice_ipd_credit_type() + { + $ipd_credit_type= $this->input->post('ipd_credit_type'); + $inv_id = $this->input->post('inv_id'); + + $dataupdate = array( + 'ipd_include' => $ipd_credit_type + ); + + $this->load->model('Invoice_M'); + $this->Invoice_M->update($dataupdate,$inv_id); + } + + + //Org. Update + + public function IPD_Invoice_Edit($IPD_ID) + { + $sql="select * from v_ipd_list + where id=".$IPD_ID; + $query = $this->db->query($sql); + $data['ipd_master']= $query->result(); + + $ins_comp_id=$data['ipd_master'][0]->insurance_id; + + if($ins_comp_id=='' || $ins_comp_id == null) + { + $ins_comp_id=0; + } + + $sql="select i.*,t.group_desc + from ipd_invoice_item i join ipd_item_type t on i.item_type=t.itype_id + where i.ipd_id=".$IPD_ID; + $query = $this->db->query($sql); + $data['invoiceDetails']= $query->result(); + + $sql="select sum(item_amount) as Gtotal from ipd_invoice_item where ipd_id=".$IPD_ID; + $query = $this->db->query($sql); + $data['invoiceGtotal']= $query->result(); + + $sql="select d.id ,d.p_fname ,concat(d.p_fname,' [',group_concat(m.SpecName),']') as DocSpecName + from doctor_master d join doc_spec s join med_spec m on d.id =s.doc_id and s.med_spec_id =m.id + where d.active=1 group by d.id order by d.p_fname"; + $query = $this->db->query($sql); + $data['doclist']= $query->result(); + + $sql="select * from med_spec order by SpecName"; + $query = $this->db->query($sql); + $data['med_spec']= $query->result(); + + $sql="select m.id,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 (ipd_items m join ipd_item_type t on m.itype=t.itype_id) + left join ipd_items_insurance i on m.id=i.hc_items_id AND hc_insurance_id=$ins_comp_id and isdelete=0 + where m.itype=1 order by m.idesc "; + $query = $this->db->query($sql); + $data['item_list_1']= $query->result(); + + $sql="select m.id,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 (ipd_items m join ipd_item_type t on m.itype=t.itype_id) + left join ipd_items_insurance i on m.id=i.hc_items_id AND hc_insurance_id=$ins_comp_id and isdelete=0 + where m.itype=2 order by m.idesc "; + $query = $this->db->query($sql); + $data['item_list_2']= $query->result(); + + $sql="select m.id,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 (ipd_items m join ipd_item_type t on m.itype=t.itype_id) + left join ipd_items_insurance i on m.id=i.hc_items_id AND hc_insurance_id=$ins_comp_id and isdelete=0 + where m.itype=5 order by m.idesc "; + $query = $this->db->query($sql); + $data['item_list_5']= $query->result(); + + $sql="select m.id,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 (ipd_items m join ipd_item_type t on m.itype=t.itype_id) + left join ipd_items_insurance i on m.id=i.hc_items_id AND hc_insurance_id=$ins_comp_id and isdelete=0 + where m.itype=3 order by m.idesc "; + $query = $this->db->query($sql); + $data['item_list_3']= $query->result(); + + $sql="select m.id,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 (ipd_items m join ipd_item_type t on m.itype=t.itype_id) + left join ipd_items_insurance i on m.id=i.hc_items_id AND hc_insurance_id=$ins_comp_id and isdelete=0 + where m.itype=6 order by m.idesc "; + $query = $this->db->query($sql); + $data['item_list_6']= $query->result(); + + $sql="select m.id,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 (ipd_items m join ipd_item_type t on m.itype=t.itype_id) + left join ipd_items_insurance i on m.id=i.hc_items_id AND hc_insurance_id=$ins_comp_id and isdelete=0 + where m.itype=7 order by m.idesc "; + $query = $this->db->query($sql); + $data['item_list_7']= $query->result(); + + $sql="select m.id,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 (ipd_items m join ipd_item_type t on m.itype=t.itype_id) + left join ipd_items_insurance i on m.id=i.hc_items_id AND hc_insurance_id=$ins_comp_id and isdelete=0 + where m.itype=8 order by m.idesc "; + $query = $this->db->query($sql); + $data['item_list_8']= $query->result(); + + $sql="select m.id,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 (ipd_items m join ipd_item_type t on m.itype=t.itype_id) + left join ipd_items_insurance i on m.id=i.hc_items_id AND hc_insurance_id=$ins_comp_id and isdelete=0 + where m.itype=10 order by m.idesc "; + $query = $this->db->query($sql); + $data['item_list_10']= $query->result(); + + $sql="select * from ipd_item_type "; + $query = $this->db->query($sql); + $data['item_list_cat']= $query->result(); + + $data['ins_comp_id']=$ins_comp_id; + + $this->load->view('IPD2/ipd_invoice_items',$data); + } + + public function ipd_package($ipd_id) + { + + $sql="select * from v_ipd_list + where id=$ipd_id"; + $query = $this->db->query($sql); + $data['ipd_master']= $query->result(); + + $ins_comp_id=$data['ipd_master'][0]->insurance_id; + + if($ins_comp_id=='' || $ins_comp_id == null) + { + $ins_comp_id=0; + } + + + $sql="SELECT m.id,m.ipd_pakage_name,m.Pakage_Min_Amount,i.hc_insurance_id, + i.code,if(i.hc_insurance_id is null,m.Pakage_Min_Amount,i.i_amount) as amount1, + if(i.hc_insurance_id is null,Concat(' Rs. ',m.Pakage_Min_Amount),Concat('[ Rs. ',i.i_amount,' /Org.Code ',i.code,']')) as org_code + from package m left join package_insurance i + on m.id=i.hc_items_id and i.hc_insurance_id=$ins_comp_id order by m.ipd_pakage_name" ; + $query = $this->db->query($sql); + $data['package_list']= $query->result(); + + $sql="select d.id ,d.p_fname ,concat(d.p_fname,' [',group_concat(m.SpecName),']') as DocSpecName + from doctor_master d join doc_spec s join med_spec m on d.id =s.doc_id and s.med_spec_id =m.id + where d.active=1 group by d.id order by d.p_fname"; + $query = $this->db->query($sql); + $data['doclist']= $query->result(); + + $this->load->view('IPD2/ipd_package',$data); + } + + public function show_Package($ipd_id) + { + $sql="select * from ipd_package where ipd_id=".$ipd_id; + $query = $this->db->query($sql); + $data['ipd_package']= $query->result(); + + echo ' + + + + + + '; + $srno=0; + $head=1; + foreach($data['ipd_package'] as $row) + { + $srno=$srno+1; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + } + + echo '
#Package NameAmount
'.$srno.''.$row->package_name.'
'.$row->package_desc.'
'; + echo ''; + echo '
'; + + } + + public function ipd_package_showitem($type) + { + + + $ipd_id=$this->input->post('ipd_id'); + $pack_id=$this->input->post('package_id'); + $package_name=$this->input->post('package_name'); + $comment=$this->input->post('comment'); + $package_desc=$this->input->post('comment'); + + $sql="select * from v_ipd_list + where id=$ipd_id"; + $query = $this->db->query($sql); + $data['ipd_master']= $query->result(); + + $ins_comp_id=$data['ipd_master'][0]->insurance_id; + + if($ins_comp_id=='' || $ins_comp_id == null) + { + $ins_comp_id=0; + } + + $user = $this->ion_auth->user()->row(); + $user_id = $user->id; + $user_name = $user->first_name.''. $user->last_name.'['.$user_id.']'.' D:'.date('d-m-Y h:i:s'); + + if($type==1) + { + $sql="SELECT m.id,m.ipd_pakage_name,m.Pakage_Min_Amount,i.hc_insurance_id, + i.code,if(i.hc_insurance_id is null,m.Pakage_Min_Amount,i.i_amount) as amount1, + if(i.hc_insurance_id is null,Concat(' Rs. ',m.Pakage_Min_Amount),Concat('[ Rs. ',i.i_amount,' /Org.Code ',i.code,']')) as org_code, + i.code + from package m left join package_insurance i + on m.id=i.hc_items_id and i.hc_insurance_id=$ins_comp_id + WHERE m.id=$pack_id"; + + $query = $this->db->query($sql); + $package= $query->result(); + + $item_custom_amount=$this->input->post('input_amount'); + $date_item=$this->input->post('date_item'); + $org_code=''; + + if($pack_id>1) + { + $package_desc=$package[0]->Pakage_description; + $package_name=$package[0]->ipd_pakage_name; + $item_amount=$package[0]->amount1; + $org_code=$package[0]->code; + } + + if($date_item=='') + { + $date_item=date('Y-m-d'); + } + + if($item_custom_amount>0) + { + $item_amount=$item_custom_amount; + } + + $data['insert_package'] = array( + 'ipd_id' => $ipd_id, + 'package_id' => $pack_id, + 'package_name' => $package_name, + 'package_desc' => $package_desc, + 'package_Amount' => $item_amount, + 'comment' => $comment, + 'update_by' => $user_name, + 'ins_id'=> $ins_comp_id, + 'org_code'=> $org_code + ); + $inser_id=$this->Ipd_M->insert_package( $data['insert_package']); + + }elseif($type==2) + { + $amount_value=$this->input->post('input_amount'); + $data['update_package'] = array( + 'package_Amount' => $amount_value + ); + + $inser_id=$this->Ipd_M->update_package( $data['update_package'],$this->input->post('itemid')); + + }else{ + echo $this->Ipd_M->deletepackage($this->input->post('itemid')); + //$this->db->delete("invoice_item", "id=".$this->input->post('itemid')); + } + + } + + public function doc_ipd_fee($doc_id) + { + $sql="select * from doc_ipd_fee where isdelete=0 and doc_fee_type=2 and doc_id= ".$doc_id." order by doc_fee_desc "; + $query = $this->db->query($sql); + $doc_fee= $query->result(); + + foreach($doc_fee as $row) + { + echo ''; + } + + } + + public function ipd_items_bytype() + { + $tid=$this->input->post('itype_idv'); + + $sql="select id,Concat(idesc,' : [',amount,']') as sdesc from ipd_items where itype=".$tid." order by idesc "; + + $query = $this->db->query($sql); + $data['labitem']= $query->result(); + + echo '
+ +
'; + } + + public function ipd_showitem($type) + { + + + $ipd_id=$this->input->post('ipd_id'); + $item_id=$this->input->post('itype_name_id'); + + $ins_id=$this->input->post('ins_id'); + + if($ins_id=='') + { + $ins_id=0; + } + + if($type==1) + { + + $sql="select m.id,m.idesc, + if(i.id is null,'',i.code) as org_code, if(i.hc_insurance_id is null,m.amount,i.amount1) AS amount1 + from (ipd_items m join ipd_item_type t on m.itype=t.itype_id) + left join ipd_items_insurance i on m.id=i.hc_items_id AND hc_insurance_id=$ins_id and isdelete=0 + where m.id=$item_id "; + $query = $this->db->query($sql); + $itemlist= $query->result(); + + if(count($itemlist)>0) + { + $item_rate=$itemlist[0]->amount1; + $item_name=$itemlist[0]->idesc; + $org_code=$itemlist[0]->org_code; + }else{ + $item_rate=$this->input->post('input_rate'); + $item_name=$this->input->post('itype_name'); + $org_code=''; + } + + $item_custom_rate=$this->input->post('input_rate'); + $date_item=$this->input->post('date_item'); + + if($date_item=='') + { + $date_item=date('Y-m-d'); + } + + if($item_custom_rate>0) + { + $item_rate=$item_custom_rate; + } + + $amount_value=$this->input->post('input_qty')*$item_rate; + + $doc_id=$this->input->post('doc_id'); + + 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; + } + + $item_id=$this->input->post('itype_name_id'); + + $data['insert_invoice_item'] = array( + 'ipd_id' => $ipd_id, + 'item_type' => $this->input->post('itype_idv'), + 'item_id' => $this->input->post('itype_name_id'), + 'item_name' => $item_name, + 'item_rate' => $item_rate, + 'item_added_date' => date('Y-m-d h:i:s'), + 'item_qty' => $this->input->post('input_qty'), + 'item_amount' => $amount_value, + 'doc_id' => $this->input->post('doc_id'), + 'doc_name' => $refername, + 'date_item' => $date_item, + 'comment' => $this->input->post('comment'), + 'ins_id' => $ins_id, + 'org_code' => $org_code, + ); + + $sql="Select * from ipd_invoice_item + where ipd_id=$ipd_id and item_id=$item_id and item_rate=$item_rate and doc_id=$doc_id" ; + $query = $this->db->query($sql); + $rec_exist= $query->result(); + + if(count($rec_exist)>0) + { + $inser_id=0; + }else{ + $inser_id=$this->Ipd_M->insert_ipd_item( $data['insert_invoice_item']); + } + + + }elseif($type==2) + { + $amount_value=$this->input->post('update_qty') * $this->input->post('item_rate'); + + $data['update_invoice_item'] = array( + 'item_qty' => $this->input->post('update_qty'), + 'item_amount' => $amount_value + ); + + $inser_id=$this->Ipd_M->update_ipd_item( $data['update_invoice_item'],$this->input->post('itemid')); + + }else{ + + $inser_id= $this->Ipd_M->deleteIpdinvoiceitem($this->input->post('itemid')); + //$this->db->delete("invoice_item", "id=".$this->input->post('itemid')); + } + + echo $inser_id; + + } + + public function show_ipd_items($ipd_id) + { + $sql="select * from v_ipd_list where id=".$ipd_id; + $query = $this->db->query($sql); + $data['ipd_master']= $query->result(); + + $sql="select * from ipd_package where ipd_id=".$ipd_id; + $query = $this->db->query($sql); + $data['ipd_package']= $query->result(); + + //package_select + $select_package_content=""; + + $ins_comp_id=$data['ipd_master'][0]->insurance_id; + + $sql="select t.group_desc,i.*,sum(i.item_amount) as xAmount + from ipd_invoice_item i join ipd_item_type t on i.item_type=t.itype_id + where i.ipd_id=".$ipd_id." + group by i.item_type,i.id with rollup"; + $query = $this->db->query($sql); + $data['invoiceDetails']= $query->result(); + + $sql="select sum(item_amount) as Gtotal from ipd_invoice_item where ipd_id=".$ipd_id; + $query = $this->db->query($sql); + $data['invoiceGtotal']= $query->result(); + + echo ' + + + + + + + + '; + $srno=0; + $head=1; + foreach($data['invoiceDetails'] as $row) + { + if($head==1 && $row->item_type<>null) + { + echo ''; + echo ''; + echo ''; + echo ''; + $head=0; + } + + if($row->item_type==null || $row->item_type=='') + { + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + + }elseif($row->id==null || $row->id==''){ + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + $head=1; + }else{ + $srno=$srno+1; + + $doc_name_desc=""; + if($row->doc_id>0) + { + $doc_name_desc='
Dr.'.$row->doc_name.' '.$row->doc_spec; + } + + $check=''; + if ($row->package_id>0) + { + $check='Checked'; + } + + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + + echo ''; + $check_box=''; + if(count($data['ipd_package'])) + { + $check_box=' Inc. In Pkg.'; + } + + echo ''; + echo ''; + echo ''; + echo ''; + + } + } + echo '
#Charge NameRateQtyAmount
#'.$row->group_desc.'
#Total Amount'.$row->xAmount.'
#Sub Total'.$row->xAmount.'
'.$srno.''.$row->item_name.''.$row->item_rate.''.$row->item_amount.'
#'.$doc_name_desc.'
'.$row->comment.'
'.$check_box; + echo '
+ + + +
'; + echo '
'; + echo ''; + + } + + + public function remove_refer($r_id) + { + if ($this->ion_auth->in_group('IPDReferUpdate')) { + $this->Ipd_M->remove_refer_ipd($r_id); + } + } + + public function add_refer($ipd_id,$refer_by) + { + $user = $this->ion_auth->user()->row(); + $user_id = $user->id; + $Update_user = $user->first_name.' '. $user->last_name.' ['.$user_id.'] '.date('Y-m-d H:i:s'); + + if ($this->ion_auth->in_group('IPDAdmit')) { + + $sql="select * + from refer_master + where id=$refer_by"; + $query = $this->db->query($sql); + $refer_master= $query->result(); + + if(count($refer_master)>0){ + if (!$this->input->is_ajax_request()) { exit('no valid req.'); } + + + + $data = array( + 'ipd_id' => $ipd_id, + 'refer_by' => $refer_by, + 'refer_type' => $refer_master[0]->refer_type, + 'refer_name' => $refer_master[0]->f_name, + 'update_by' => $Update_user, + ); + $inser_id=$this->Ipd_M->insert_refer_ipd($data); + } + + + } + } + + public function Update_Refer($ipd_id,$refer_id) + { + if (!$this->input->is_ajax_request()) { exit('no valid req.'); } + + + + $update_refer=array( + 'refer_by'=>$refer_id + ); + + $this->Ipd_M->update($update_refer,$ipd_id); + + } + + public function update_org_doc() + { + if (!$this->input->is_ajax_request()) { exit('no valid req.'); } + + $org_id=$this->input->post('org_id'); + $feild=$this->input->post('feild'); + $fvalue=$this->input->post('fvalue'); + + $this->load->model('Ocasemaster_M'); + + $update_ipd=array( + $feild=>$fvalue + ); + + $this->Ocasemaster_M->update($update_ipd,$org_id); + + } + + } \ No newline at end of file diff --git a/old_code_ci3/controllers/Ipd_Report.php b/old_code_ci3/controllers/Ipd_Report.php new file mode 100644 index 0000000..508c07b --- /dev/null +++ b/old_code_ci3/controllers/Ipd_Report.php @@ -0,0 +1,116 @@ +load->view('IPD_Report/ipd_balance_report'); + } + + public function Ipd_bal_panel_report($daterange,$output=0) + { + $rangeArray = explode("S",$daterange); + $minRange = $rangeArray[0]; + $maxRange = $rangeArray[1]; + + $where =" p.balance_amount>0 " ; + + $where.=" and Direct_Cust=1 and p.ipd_status=1 and p.register_date between '".$minRange."' and '".$maxRange."' " ; + + if(isset($doc_name)) + { + if($doc_name_id>0) + { + $where.=" and FIND_IN_SET('".$doc_name_id."',doc_list) "; + } + } + + $sql="select p.ipd_code,p.p_fname,Date_Format(p.register_date,'%d-%m-%Y') as str_register_date,p_code,p.Contact_info, + Date_Format(p.discharge_date,'%d-%m-%Y') as str_discharge_date,p.admit_type,p.doc_name,p.Bed_Desc,p.Direct_Cust, + p.net_amount,p.balance_amount,(p.org_amount_recived+p.total_paid_amount) as sum_of_paid + from v_ipd_list p where ".$where." group by p.p_id,p.doc_list order by id"; + + $query = $this->db->query($sql); + $dischargelist= $query->result(); + + $total_Payment=0.00; + $total_balance=0.00; + + $content=''; + + $content.=' + + + + + + + + + + + + + '; + + $sr_no=0; + foreach($dischargelist as $row) + { + $sr_no=$sr_no+1; + $content.=' + + + + + + + + + + + + + '; + $total_Payment+= $row->sum_of_paid; + $total_balance+= $row->balance_amount; + } + + $content.=' + + + + + + + + + + + + + '; + $content.="
#IPD CodeP CodePerson NamePhone No.Admit DateDischarge DateDoc. NameNet AmountPaid Amt.Balance Amt.TYPE
'.$sr_no.''.$row->ipd_code.''.$row->p_code.''.$row->p_fname.''.$row->Contact_info.''.$row->str_register_date.''.$row->str_discharge_date.''.$row->doc_name.''.$row->net_amount.''.$row->sum_of_paid.''.$row->balance_amount.''.$row->admit_type.'
#Total'.$total_Payment.''.$total_balance.'
"; + + if($output==0) + { + $this->load->library('m_pdf'); + $file_name="IPD_Balance_List-".date('Ymdhis').".pdf"; + $filepath=$file_name; + $this->m_pdf->pdf->WriteHTML($content); + $this->m_pdf->pdf->Output($filepath,"I"); + + }else{ + + ExportExcel($content,'IPD_Balance_List_'.date('dmYHis')); + } + + + + } + + } \ No newline at end of file diff --git a/old_code_ci3/controllers/Ipd_discharge.php b/old_code_ci3/controllers/Ipd_discharge.php new file mode 100644 index 0000000..2c3d936 --- /dev/null +++ b/old_code_ci3/controllers/Ipd_discharge.php @@ -0,0 +1,3564 @@ +load->model('ipdDischarge_M'); + $this->load->model('Ipd_M'); + $this->load->model('Patient_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 hc_department order by vName "; + $query = $this->db->query($sql); + $data['hc_department'] = $query->result(); + + $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); + return true; + } + + + /*$dataupdate = array( + 'discharge_time'=>date('H:i'), + ); + + $this->Ipd_M->update($dataupdate,$ipdno); + */ + + + $p_id = $data['ipd_master'][0]->p_id; + $ipd_admit_date = $data['ipd_master'][0]->register_date; + + $sql = "select * from patient_master where id=$p_id "; + $query = $this->db->query($sql); + $data['Pdata'] = $query->result(); + + 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(); + + //ipd_discharge_1_d + $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_investigation_during_admit g left join ipd_discharge_1_d 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_investigation_during_admit'] = $query->result(); + + //ipd_discharge_1_e + $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_special_investigation g left join ipd_discharge_1_e 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_special_investigation'] = $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"; + + echo $sql; + + $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 Medications New Method + $sql = "SELECT * ,d.dose_show_sign AS dose_shed,dw.dose_sign_desc AS dose_when, + df.dose_sign_desc AS dose_frequency,d_on.dose_sign_desc AS dose_where + FROM (((ipd_discharge_prescrption_prescribed pt + LEFT JOIN opd_dose_shed d ON pt.dosage=d.dose_shed_id) + LEFT JOIN opd_dose_when dw ON pt.dosage_when=dw.dose_when_id) + LEFT JOIN opd_dose_frequency df ON pt.dosage_freq=df.dose_freq_id) + LEFT JOIN opd_dose_where d_on ON pt.dosage_where=d_on.dose_where_id + where pt.ipd_id='" . $ipdno . "' order by pt.id"; + $query = $this->db->query($sql); + $data['ipd_discharge_prescrption_prescribed'] = $query->result(); + $data1['ipd_discharge_prescrption_prescribed'] = $data['ipd_discharge_prescrption_prescribed']; + + $data['ipd_discharge_prescrption_prescribed_content'] = $this->load->view('IPD_Discharge/ipd_prescription', $data1, true); + + //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,food_desc + 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(); + + //IPD discharge Medicince prescribed + $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); + $data['opd_dose_duration'] = $query->result(); + + $sql = "select * from med_formulation"; + $query = $this->db->query($sql); + $data['med_formulation'] = $query->result(); + + $sql = "SELECT o.id,o.next_visit_desc,DATE_ADD(CURDATE(),INTERVAL o.no_of_days DAY) AS next_date, + Concat(next_visit_desc,' (', Date_Format(DATE_ADD(CURDATE(),INTERVAL o.no_of_days DAY),'%d-%m-%Y') ,')') as next_visit_day + FROM opd_nextvisit o order by no_of_days"; + $query = $this->db->query($sql); + $data['opd_nextvisit'] = $query->result(); + + //IPD discharge Medicince prescribed End + + + $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 local_medical where med_name like '%" . $q . "%' order by med_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['med_name'])); + $new_row['value'] = htmlentities(stripslashes($row['med_name'])); + $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_investigation_m_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_investigation_during_admit g + left join ipd_discharge_1_d 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_m_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_d($datainsert, $IPD_id, $row->id); + } + + echo 'Saved'; + } + + public function update_investigation_s_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_special_investigation g + left join ipd_discharge_1_e 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_s_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_e($datainsert, $IPD_id, $row->id); + } + + 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; + } + + //Save Personal History + + public function update_personal_history() + { + $p_id = $this->input->post('p_id'); + + $opd_prescription_smoking_chk = $this->input->post('opd_prescription_smoking_chk'); + $opd_prescription_alcohol_chk = $this->input->post('opd_prescription_alcohol_chk'); + $opd_prescription_tobacoo_chk = $this->input->post('opd_prescription_tobacoo_chk'); + $opd_prescription_drug_chk = $this->input->post('opd_prescription_drug_chk'); + $opd_prescription_hypertesion_chk = $this->input->post('opd_prescription_hypertesion_chk'); + $opd_prescription_niddm_chk = $this->input->post('opd_prescription_niddm_chk'); + $opd_prescription_hbsag_chk = $this->input->post('opd_prescription_hbsag_chk'); + $opd_prescription_hcv_chk = $this->input->post('opd_prescription_hcv_chk'); + $opd_prescription_hiv_I_II_chk = $this->input->post('opd_prescription_hiv_I_II_chk'); + + $dataPatientMaster = array( + 'is_smoking' => $opd_prescription_smoking_chk, + 'is_alcohol' => $opd_prescription_alcohol_chk, + 'is_drug_abuse' => $opd_prescription_drug_chk, + 'is_tobacoo' => $opd_prescription_tobacoo_chk, + 'is_hypertesion' => $opd_prescription_hypertesion_chk, + 'is_niddm' => $opd_prescription_niddm_chk, + 'is_hbsag' => $opd_prescription_hbsag_chk, + 'is_hcv' => $opd_prescription_hcv_chk, + 'is_hiv_I_II' => $opd_prescription_hiv_I_II_chk, + ); + + $this->Patient_M->update($dataPatientMaster, $p_id); + + echo 'Saved '; + } + + + //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 = "
"; + + if (count($dataRec) > 0) { + $content .= ""; + } + + foreach ($dataRec as $row) { + $content .= ' + + + + + '; + } + + $content .= '
Complaint NameRemarks
+ + + + Update + Remove +
'; + + 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'); + $complaint = $this->input->post('complaint'); + $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, + 'comp_report' => $complaint, + '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 = "
"; + + if (count($dataRec) > 0) { + $content .= ""; + } + + foreach ($dataRec as $row) { + $content .= ' + + + + + '; + } + + $content .= '
Complaint NameRemarks
+ + + + Update + Remove +
'; + + 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 = "
"; + + if (count($dataRec) > 0) { + $content .= ''; + } + + foreach ($dataRec as $row) { + $content .= ' + + + + + '; + } + + $content .= '
Diagnosis Remarks
+ + + + 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'); + $diagnosis = $this->input->post('diagnosis'); + $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, + 'comp_report' => $diagnosis, + '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 = "
"; + if (count($dataRec) > 0) { + $content .= ''; + } + + foreach ($dataRec as $row) { + $content .= ' + + + + + '; + } + + $content .= '
Diagnosis Remarks
+ + + + 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 = "
"; + + if (count($dataRec) > 0) { + $content .= ''; + } + + foreach ($dataRec as $row) { + $content .= ' + + + + + '; + } + + $content .= '
Course Remarks
+ + + + 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'); + $comp_report = $this->input->post('course'); + $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, + 'comp_report' => $comp_report, + '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 = "
"; + + if (count($dataRec) > 0) { + $content .= ''; + } + + foreach ($dataRec as $row) { + $content .= ' + + + + + '; + } + + $content .= '
Course Remarks
+ + + + 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'); + $review_after = $this->input->post('input_next_visit'); + $ipd_id = $this->input->post('ipd_id'); + + $datainsert = array( + 'ipd_id' => $ipd_id, + 'comp_remark' => $editor_Sys_Exam, + 'review_after' => $review_after, + ); + + $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'); + + $input_med_name = strtoupper($this->input->post('input_med_name')); + $input_med_type = $this->input->post('input_med_type'); + $input_dosage = $this->input->post('input_dosage'); + $input_dosage_when = $this->input->post('input_dosage_when'); + $input_dosage_freq = $this->input->post('input_dosage_freq'); + $input_dose_where = $this->input->post('input_dose_where'); + $input_no_of_days = $this->input->post('input_no_of_days'); + $input_qty = $this->input->post('input_qty'); + $input_remark = strtoupper($this->input->post('input_remark')); + $hid_med_id = $this->input->post('hid_med_id'); + $ipd_id = $this->input->post('ipd_id'); + $hid_ipd_med_item_id = $this->input->post('hid_ipd_med_item_id'); + $input_med_salt = $this->input->post('input_med_salt'); + + $datainsert = array( + 'ipd_id' => $ipd_id, + 'med_id' => $hid_med_id, + 'med_name' => $input_med_name, + 'med_type' => $input_med_type, + 'med_salt' => $input_med_salt, + 'dosage' => $input_dosage, + 'dosage_when' => $input_dosage_when, + 'dosage_freq' => $input_dosage_freq, + 'dosage_where' => $input_dose_where, + 'qty' => $input_qty, + 'no_of_days' => $input_no_of_days, + 'remark' => $input_remark, + 'update_by' => $user_name + ); + + if ($hid_ipd_med_item_id > 0) { + $this->ipdDischarge_M->update_p_drug($datainsert, $hid_ipd_med_item_id); + } else { + $this->ipdDischarge_M->insert_p_drug($datainsert); + } + + + + //Discharge Medications New Method + $sql = "SELECT * ,d.dose_show_sign AS dose_shed,dw.dose_sign_desc AS dose_when, + df.dose_sign_desc AS dose_frequency,d_on.dose_sign_desc AS dose_where + FROM (((ipd_discharge_prescrption_prescribed pt + LEFT JOIN opd_dose_shed d ON pt.dosage=d.dose_shed_id) + LEFT JOIN opd_dose_when dw ON pt.dosage_when=dw.dose_when_id) + LEFT JOIN opd_dose_frequency df ON pt.dosage_freq=df.dose_freq_id) + LEFT JOIN opd_dose_where d_on ON pt.dosage_where=d_on.dose_where_id + where pt.ipd_id='" . $ipd_id . "' order by pt.id "; + $query = $this->db->query($sql); + $data['ipd_discharge_prescrption_prescribed'] = $query->result(); + + $content = $this->load->view('IPD_Discharge/ipd_prescription', $data, true); + + 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_prescrption_prescribed 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); + } + + //Discharge Medications New Method + $sql = "SELECT * ,d.dose_show_sign AS dose_shed,dw.dose_sign_desc AS dose_when, + df.dose_sign_desc AS dose_frequency,d_on.dose_sign_desc AS dose_where + FROM (((ipd_discharge_prescrption_prescribed pt + LEFT JOIN opd_dose_shed d ON pt.dosage=d.dose_shed_id) + LEFT JOIN opd_dose_when dw ON pt.dosage_when=dw.dose_when_id) + LEFT JOIN opd_dose_frequency df ON pt.dosage_freq=df.dose_freq_id) + LEFT JOIN opd_dose_where d_on ON pt.dosage_where=d_on.dose_where_id + where pt.ipd_id='" . $ipd_id . "' Order by pt.id"; + $query = $this->db->query($sql); + $data['ipd_discharge_prescrption_prescribed'] = $query->result(); + + $content = $this->load->view('IPD_Discharge/ipd_prescription', $data, true); + + echo $content; + } + + public function medical_Select() + { + 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'); + + $ipd_id = $this->input->post('ipd_id'); + $rec_id = $this->input->post('med_prec_id'); + + $sql = "select * from ipd_discharge_prescrption_prescribed + where id=" . $rec_id . " and ipd_id=" . $ipd_id; + $query = $this->db->query($sql); + $dataRec = $query->result(); + + $rvar = array( + "id" => $dataRec[0]->id, + "ipd_id" => $ipd_id, + "med_name" => $dataRec[0]->med_name, + "med_type" => $dataRec[0]->med_type, + "dosage" => $dataRec[0]->dosage, + "dosage_when" => $dataRec[0]->dosage_when, + "dosage_freq" => $dataRec[0]->dosage_freq, + "no_of_days" => $dataRec[0]->no_of_days, + "qty" => $dataRec[0]->qty, + "remark" => $dataRec[0]->remark, + ); + + $encode_data = json_encode($rvar); + echo $encode_data; + } + + //Chamunda Hospital + 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(); + + $sql = "select * from ipd_master where id='" . $ipdno . "' "; + $query = $this->db->query($sql); + $ipd_master_data = $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(); + + $sql = "select * from patient_master where id='" . $p_id . "' "; + $query = $this->db->query($sql); + $patient_master_data = $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 = date('h:i A', strtotime($ipd_master[0]->discharge_time)); + $Reg_time = date('h:i A', strtotime($ipd_master[0]->reg_time)); + } else { + $Discharge_time = ''; + $Reg_time = ''; + } + + $data['Discharge_time'] = $Discharge_time; + $data['Reg_time'] = $Reg_time; + + + //IPD DEpartment + + $dept_id = $ipd_master_data[0]->dept_id; + + if ($dept_id == '') { + $dept_id = 1; + } + + $sql = "select * from hc_department where iId=$dept_id"; + $query = $this->db->query($sql); + $ipd_department = $query->result(); + + $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(); + + $depart_name = $ipd_department[0]->vName; + + $doc_list_main_sign = ' + + + '; + + $row_num = 0; + + // Doctor Name + + foreach ($doc_master as $row) { + $row_num = $row_num + 1; + + $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_main_sign .= "

Treating Consultant

Dr. ' . $row->p_fname . '
[' . $row->SpecName . ']
+ ' . nl2br($row->doc_sign) . ' +
"; + + $data['doc_list_main_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(); + + //investigation Manual + $sql = "select g.id,g.col_name,g.col_description,d.col_id,d.short_head,d.rdata,g.col_unit + from ipd_discharge_investigation_during_admit g left join ipd_discharge_1_d 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_1 = $query->result(); + + //investigation 2 Xray + $sql = "select g.id,g.col_name,g.col_description,d.col_id,d.short_head,d.rdata,g.col_unit + from ipd_discharge_special_investigation g left join ipd_discharge_1_e 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_2 = $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,m.food_desc,m.food_desc_lang + FROM ipd_discharge_master_food m where m.id IN (" . $food_list . ")"; + $query = $this->db->query($sql); + $dis_food_interaction = $query->result(); + + //Diet Advice + + $data['diet_advice'] = ""; + if (count($dis_food_interaction) > 0 || count($ipd_discharge_drug_food_interaction) > 0) { + $content = '

Dietary : '; + $content .= ''; + + foreach ($dis_food_interaction as $row) { + $content .= '' . $row->food_short . ': ' . $row->food_desc_lang . '
'; + } + $content .= '

'; + + if ($ipd_discharge_drug_food_interaction[0]->food_text != '') { + $content .= $ipd_discharge_drug_food_interaction[0]->food_text; + } + $data['diet_advice'] = $content; + } + + + + //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(); + + //HTML Style + + + + if (count($ipd_discharge_status) < 1) { + $h1_head = ''; + } else { + $h1_head = $ipd_discharge_status[0]->status_details; + } + + $data['h1_head'] = $h1_head; + $data['depart_name'] = $depart_name; + + if (D_discharge_doctor_name == 1) { + $data['Doc_Name_List'] = $doc_list_main_sign; + } + + if ($ipd_master[0]->case_id == '0') { + $discharge_date_time = date('h:m A', strtotime($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; + } + + $data['ipd_master'] = $ipd_master; + + if (count($ipd_discharge_surgery) > 0) { + $data['Surgery'] = ''; + $content = '

Surgery : '; + foreach ($ipd_discharge_surgery as $row) { + $content .= '
' . $row->surgery_name . '    / Date of Surgery : ' . MysqlDate_to_str($row->surgery_date); + } + $content .= "

"; + $data['Surgery'] = $content; + } + + if (count($ipd_discharge_procedure) > 0) { + $data['Procedure'] = ''; + $content = '

Procedure : '; + + foreach ($ipd_discharge_procedure as $row) { + $content .= '
' . $row->procedure_name . '    / Date of Procedure : ' . MysqlDate_to_str($row->procedure_date); + } + + $content .= "

"; + + $data['Procedure'] = $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 .= 'Child Birth : '; + $content .= 'Delivery Date and Time : ' . MysqlDate_to_str($ipd_master[0]->delivery_date) . ' ' . $ipd_master[0]->delivery_time; + $content .= '
' . $baby_desc; + + $data['isdelivery'] = $content; + } + + //Presenting Complaints with Duration and Reason for Admission + if (count($ipd_discharge_complaint) > 0 || count($ipd_discharge_complaint_remark) > 0) { + + $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); + } + } + + $content .= "

"; + + + $data['discharge_complaint'] = $content; + } + + //Provisional Diagnosis at the time of Admission + if (count($ipd_discharge_general_exam_col) > 0) { + $content = '

General Examination on Admission :
'; + + foreach ($ipd_discharge_general_exam_col as $row) { + $content .= $row->col_name . ' :' . $row->rdata . $row->col_unit . '   '; + } + $content .= '

'; + + $data['discharge_general_exam'] = $content; + } + + foreach ($ipd_discharge_sys_exam as $row) { + $content = ''; + if ($row->rdata == null || $row->rdata == '') { + } else { + //$content.='

'.$row->sys_exam_name.'

'; + $content = $row->rdata; + } + + $data['discharge_sys_exam'] = $content; + } + + + //Personal History + + $personal_history = ''; + + if ($patient_master_data[0]->is_smoking == 1) { + $personal_history .= 'Smoking '; + } + + if ($patient_master_data[0]->is_alcohol == 1) { + $personal_history .= 'Alcoholic '; + } + + if ($patient_master_data[0]->is_drug_abuse == 1) { + $personal_history .= 'Drug Abuse '; + } + + if ($patient_master_data[0]->is_tobacoo == 1) { + $personal_history .= 'Tobacoo '; + } + + if ($patient_master_data[0]->is_hypertesion == 1) { + $personal_history .= 'Hypertension'; + } + + if ($patient_master_data[0]->is_niddm == 1) { + $personal_history .= 'Type 2 DM'; + } + + if ($patient_master_data[0]->is_hbsag == 1) { + $personal_history .= 'HBsAg '; + } + + if ($patient_master_data[0]->is_hcv == 1) { + $personal_history .= 'HCV '; + } + + if ($patient_master_data[0]->is_hiv_I_II == 1) { + $personal_history .= 'HIV I-II '; + } + + if ($patient_master_data[0]->Others == 1) { + $personal_history .= 'Others '; + } + + if (strlen($personal_history) > 0) { + $content = "

Personal History : " . $personal_history . "

"; + + $data['personal_history'] = $content; + } + + //CLINICAL INVESTIGATION REPORTS + $data['lab_test_content'] = "

Clinical Investigation Reports : "; + $content = ''; + if (isset($lab_request)) { + + $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 .= '
Test NameFixed Normals' . MysqlDate_to_str(str_replace("'", "", $value)) . '
' . $row['Test'] . '' . $row['FixedNormals'] . '' . $row['lab_test_value_' . $key] . '
'; + + if (isset($data['lab_test_content'])) { + $data['lab_test_content'] .= $content; + } else { + $data['lab_test_content'] = $content; + } + } + + //investigation Manual + if (count($ipd_discharge_exam_on_discharge_col_1) > 0) { + $content = ''; + foreach ($ipd_discharge_exam_on_discharge_col_1 as $row) { + $content .= '' . $row->col_name . ': ' . $row->rdata . '   / '; + } + $content .= "
"; + + if (isset($data['lab_test_content'])) { + $data['lab_test_content'] .= $content; + } else { + $data['lab_test_content'] = $content; + } + } + + + //Manual X-Ray + if (count($ipd_discharge_exam_on_discharge_col_2) > 0) { + $content = ''; + foreach ($ipd_discharge_exam_on_discharge_col_2 as $row) { + $content .= '' . $row->col_name . ':' . $row->rdata . "
"; + } + + if (isset($data['lab_test_content'])) { + $data['lab_test_content'] .= $content; + } else { + $data['lab_test_content'] = $content; + } + } + + if (count($ipd_discharge_2_rdata) > 0) { + $content = ''; + if ($ipd_discharge_2_rdata[0]->rdata != '') { + $content .= '

' . $ipd_discharge_2_rdata[0]->rdata . '
'; + } + if (isset($data['lab_test_content'])) { + $data['lab_test_content'] .= $content; + } else { + $data['lab_test_content'] = $content; + } + } + + $data['lab_test_content'] .= '

'; + + //Final Diagnosis at the time of Discharge + $content = '

Final Diagnosis'; + if (count($ipd_discharge_diagnosis) > 0) { + foreach ($ipd_discharge_diagnosis as $row) { + $content .= '
' . $row->comp_report . ' '; + if (strlen($row->comp_remark) > 0) { + $content .= '(' . $row->comp_remark . ')'; + } + } + } + + if (count($ipd_discharge_diagnosis_remark) > 0) { + if ($ipd_discharge_diagnosis_remark[0]->comp_remark != '') { + $content .= '
' . nl2br(trim($ipd_discharge_diagnosis_remark[0]->comp_remark)); + } + } + + $content .= "

"; + + $data['FinalDiagnosis'] = $content; + + //Summary of key investigtions during Hospitalization + if (count($ipd_discharge_investigtions_inhos) > 0) { + $content = ''; + if ($ipd_discharge_investigtions_inhos[0]->comp_remark != '') { + $content .= "Summary of key investigtions during Hospitalization"; + $content .= '
' . $ipd_discharge_investigtions_inhos[0]->comp_remark . '
'; + } + + $data['discharge_investigtions_inhos'] = $content; + } + + //Course in the hospital + if (count($ipd_discharge_course) > 0) { + $content = '

Course in the hospital'; + foreach ($ipd_discharge_course as $row) { + $content .= '
' . $row->comp_report . ' '; + $content .= '' . $row->comp_remark . ''; + } + $content .= "

"; + + $data['Course_in_the_hospital'] = $content; + } + + if (count($ipd_discharge_course_remark) > 0) { + $content = ''; + if ($ipd_discharge_course_remark[0]->comp_remark != '') { + $content .= '
' . $ipd_discharge_course_remark[0]->comp_remark . '
'; + } + if (isset($data['Course_in_the_hospital'])) { + $data['Course_in_the_hospital'] .= $content; + } else { + $data['Course_in_the_hospital'] = '

Course in the hospital' . $content . "

"; + } + } + + + //Exam in Discharge + if (count($ipd_discharge_exam_on_discharge_col) > 0) { + $content = '

Examination on Discharge : '; + $content .= ''; + + foreach ($ipd_discharge_exam_on_discharge_col as $row) { + $content .= $row->col_name . ': ' . $row->rdata . ' ' . $row->col_unit . '   / '; + } + $content .= '

'; + + $data['discharge_exam_on_discharge'] = $content; + } + + //Discharge Medicince + + $sql = "SELECT pt.* ,d.dose_show_sign AS dose_shed,d.dose_show_desc AS dose_shed_hindi, + dw.dose_sign_desc AS dose_when,dw.dose_sign_hindi AS dose_when_hindi, + df.dose_sign_desc AS dose_frequency,df.dose_sign_hindi AS dose_frequency_hindi, + d_on.dose_sign_desc AS dose_where,d_on.dose_sign_hindi AS dose_where_hindi, + m.genericname + FROM ((((ipd_discharge_prescrption_prescribed pt + LEFT JOIN opd_dose_shed d ON pt.dosage=d.dose_shed_id) + LEFT JOIN opd_dose_when dw ON pt.dosage_when=dw.dose_when_id) + LEFT JOIN opd_dose_frequency df ON pt.dosage_freq=df.dose_freq_id) + LEFT JOIN opd_dose_where d_on ON pt.dosage_where=d_on.dose_where_id) + LEFT JOIN opd_med_master m ON pt.med_id =m.id + where pt.ipd_id=" . $ipdno . " Order by pt.id"; + $query = $this->db->query($sql); + $ipd_p_prescribed = $query->result(); + + $medical = '

'; + $sr_no = 1; + if (count($ipd_p_prescribed) > 0) { + $medical = "

Discharge Medications"; + $medical .= '

+ + + + + + + + '; + + foreach ($ipd_p_prescribed as $row) { + + $medical .= ' + + + + + + '; + $medical .= ' + + + '; + + $sr_no = $sr_no + 1; + } + $medical .= "
Medicine NameDosageQtyDay
' . $sr_no . ' - ' . $row->med_type . ' ' . $row->med_name . '' . $row->dose_shed . ' / ' . $row->dose_shed_hindi . ' ' . $row->dose_when_hindi . ' ' . $row->dose_frequency_hindi . '' . $row->qty . '' . $row->no_of_days . '
'; + if (strlen($row->genericname) > 0 || strlen($row->remark) > 0 || strlen($row->dose_shed_hindi) > 0) { + if (strlen($row->genericname) > 1) { + $medical .= 'Composition : ' . $row->genericname . ''; + } + + if (strlen($row->remark) > 0) { + $medical .= ' Notes : ' . $row->remark . ''; + } + } + + $medical .= '

"; + + $data['Discharge_Medications'] = $medical; + } + + + $foot_banner_list = "0"; + $content = ""; + //Discharge Instructions 1 + if (count($ipd_discharge_instructions) > 0) { + + $content .= '

Discharge Advice/Instructions/Summary
'; + + if ($ipd_discharge_instructions[0]->comp_remark <> '') { + $content .= $ipd_discharge_instructions[0]->comp_remark; + } + + if (strlen($ipd_discharge_instructions[0]->review_after) > 0) { + $content .= '
Review after ' . $ipd_discharge_instructions[0]->review_after . ' days / as and when required
'; + } + + if (strlen($ipd_discharge_instructions[0]->footer_banner) > 0) { + $foot_banner_list = $ipd_discharge_instructions[0]->footer_banner; + } + + if ($ipd_discharge_instructions[0]->footer_text != '') { + $content .= $ipd_discharge_instructions[0]->footer_text; + } + + if ($foot_banner_list <> "0") { + $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 .= '

'; + } + } + } + + $data['Discharge_Instructions'] = $content; + + $content_html = $this->load->view('IPD_Discharge/' . D_discharge_content_format, $data, true); + + // Update in Database + $dataupdate = array( + 'ipd_id' => $ipdno, + 'content' => $content_html + ); + $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(); + + + $data['content'] = $content_html; + + $this->load->view('IPD_Discharge/ipd_discharge_preview', $data); + } + + + + + //Report Format + + public function create_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(); + + $sql = "select * from ipd_master where id='" . $ipdno . "' "; + $query = $this->db->query($sql); + $ipd_master_data = $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(); + + + $sql = "select * from patient_master where id='" . $p_id . "' "; + $query = $this->db->query($sql); + $patient_master_data = $query->result(); + + //IPD DEpartment + + $dept_id = $ipd_master_data[0]->dept_id; + + $sql = "select * from hc_department where iId=$dept_id"; + $query = $this->db->query($sql); + $ipd_department = $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 = date('h:m A', strtotime($ipd_master[0]->discharge_time)); + $Reg_time = date('h:m A', strtotime($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(); + + + $depart_name = ' + + + +
+

Department/Specialty : ' . $ipd_department[0]->vName . '

+
'; + + + $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 .= $depart_name; + + $content .= $content_space_line; + + $content .= $doc_list_main_sign; + + $content .= $content_space_line; + + if ($ipd_master[0]->case_id == '0') { + $discharge_date_time = date('h:m A', strtotime($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 . '
'; + } + } + + //Personal History + + $personal_history = ''; + + if ($patient_master_data[0]->is_smoking == 1) { + $personal_history .= 'Smoking '; + } + + if ($patient_master_data[0]->is_alcohol == 1) { + $personal_history .= 'Alcoholic '; + } + + if ($patient_master_data[0]->is_drug_abuse == 1) { + $personal_history .= 'Drug Abuse '; + } + + if ($patient_master_data[0]->is_tobacoo == 1) { + $personal_history .= 'Tobacoo '; + } + + if ($patient_master_data[0]->is_hypertesion == 1) { + $personal_history .= 'Hypertension '; + } + + if ($patient_master_data[0]->is_niddm == 1) { + $personal_history .= 'NIDDM '; + } + + if ($patient_master_data[0]->is_hbsag == 1) { + $personal_history .= 'HBsAg '; + } + + if ($patient_master_data[0]->is_hcv == 1) { + $personal_history .= 'HCV '; + } + + if ($patient_master_data[0]->is_hiv_I_II == 1) { + $personal_history .= 'HIV I-II '; + } + + if ($patient_master_data[0]->Others == 1) { + $personal_history .= 'Others '; + } + + if (strlen($personal_history) > 0) { + $content .= "Personal History : " . $personal_history; + } + + //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 .= "
"; + + + + //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 .= "

Dietary

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

Discharge Advice/Instructions/Summary

"; + $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(); + + + $department = ''; + + $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/' . D_discharge_template, $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"); + } +} diff --git a/old_code_ci3/controllers/Item.php b/old_code_ci3/controllers/Item.php new file mode 100644 index 0000000..d1823c6 --- /dev/null +++ b/old_code_ci3/controllers/Item.php @@ -0,0 +1,354 @@ +db->query($sql); + $data['data']= $query->result(); + + $this->load->view('item/item_type_search_v',$data); + } + + public function search_adv($itype_id=1) + { + + $sql = "SELECT * FROM v_hc_items where itype=".$itype_id; + $query = $this->db->query($sql); + $data= $query->result(); + echo ' Print

'; + + echo ' + + + + + + + + + + '; + if(count($data)>0){ + for ($i = 0; $i < count($data); ++$i) { + echo ' + + + + + + '; + } + } + + echo ' + + + + + + + + + +
OPD or IPDGroupCharge NameAmount
'.$data[$i]->isIPD_OPD.''.$data[$i]->group_desc.''.$data[$i]->idesc.''.$data[$i]->amount.' + +
OPD or IPDGroupCharge NameAmount
'; + echo ""; + + } + + public function search() + { + $sql = "SELECT * FROM hc_item_type order by group_desc"; + $query = $this->db->query($sql); + $data['labitemtype']= $query->result(); + + $sql = "SELECT * FROM v_hc_items where itype=1"; + $query = $this->db->query($sql); + $data['data']= $query->result(); + + $this->load->view('item/item_search_V',$data); + + } + + + public function search_ipd() + { + $sql = "SELECT * FROM ipd_item_type order by group_desc"; + $query = $this->db->query($sql); + $data['labitemtype']= $query->result(); + + $sql = "SELECT * FROM ipd_items where itype=1"; + $query = $this->db->query($sql); + $data['data']= $query->result(); + + $this->load->view('item_ipd/item_search_V',$data); + + } + + public function search_print($itype_id=1) + { + + $sql = "SELECT * FROM v_hc_items where itype=".$itype_id." order by group_desc"; + $query = $this->db->query($sql); + $data['data']= $query->result(); + + $this->load->view('item/item_item_list',$data); + + } + + function itemtype_record($id) + { + $sql = "SELECT *,(case is_ipd_opd when 0 then 'OPD-IPD' when 1 then 'OPD' when 2 then 'IPD' end) as isIPD_OPD + FROM hc_item_type where itype_id='".$id."' order by group_desc"; + $query = $this->db->query($sql); + $data['data_item']= $query->result(); + + $this->load->view('item/item_type_profile',$data); + } + + function item_record($id) + { + + $sql="select * from v_hc_items where id=".$id; + $query = $this->db->query($sql); + $data['data_item']= $query->result(); + + $sql="select * from hc_item_type"; + $query = $this->db->query($sql); + $data['data_item_type']= $query->result(); + + $sql="select * from v_insurance_item_list where c_item_id=".$id; + $query = $this->db->query($sql); + $data['data_insurance_item']= $query->result(); + + $sql="select * from hc_insurance where id>1"; + $query = $this->db->query($sql); + $data['data_insurance']= $query->result(); + + $this->load->view('item/item_profile_V',$data); + } + + public function UpdateRecord() + { + if (!$this->input->is_ajax_request()) { exit('no valid req.'); } + + $this->load->model('item_M'); + + $data = array( + 'itype' => $this->input->post('Item_Type'), + 'idesc' => $this->input->post('input_Item_name'), + 'amount' => $this->input->post('input_amount'), + 'update_date' => date('Y-m-d H:i:s') + ); + $old_id=$this->input->post('p_id'); + $update=$this->item_M->update($data,$old_id); + + if($update>0) + { + $rvar=array( + 'update' =>1, + 'showcontent'=> Show_Alert('success','Saved','Data Saved successfully') + ); + $encode_data = json_encode($rvar); + echo $encode_data; + } + + } + + public function AddRecord() + { + $sql="select * from hc_item_type"; + $query = $this->db->query($sql); + $data['data_item_type']= $query->result(); + + $this->load->view('item/item_create_V',$data); + } + + + public function AddItemTypeRecord() + { + $this->load->view('item/item_type_create'); + } + + public function CreateRecord() + { + if (!$this->input->is_ajax_request()) { exit('no valid req.'); } + + $this->load->model('item_M'); + $data = array( + 'itype' => $this->input->post('Item_Type'), + 'idesc' => $this->input->post('input_Item_name'), + 'amount' => $this->input->post('input_amount'), + 'update_date' => date('Y-m-d H:i:s') + ); + + $inser_id=$this->item_M->insert($data); + + if($inser_id>0) + { + + $rvar=array( + 'insertid' =>$inser_id + ); + $encode_data = json_encode($rvar); + echo $encode_data; + } + + } + + public function AddInsuranceItemRecord() + { + if (!$this->input->is_ajax_request()) { exit('no valid req.'); } + + $this->load->model('item_M'); + $data = array( + 'hc_items_id' => $this->input->post('p_id'), + 'hc_insurance_id' => $this->input->post('ins_company_name'), + 'amount1' => $this->input->post('input_amount'), + 'code' => $this->input->post('input_item_code') + ); + + $inser_id=$this->item_M->insert_in_item($data); + + if($inser_id>0) + { + $sql="select * from v_insurance_item_list where c_item_id=".$this->input->post('p_id'); + $query = $this->db->query($sql); + $data_insurance_item= $query->result(); + + echo ' + + + + + + + + + '; + for ($i = 0; $i < count($data_insurance_item); ++$i) { + echo ' + + + + + '; + } + echo '
Company NameAmountCodeAction
'.$data_insurance_item[$i]->ins_company_name.''.$data_insurance_item[$i]->i_amount.''.$data_insurance_item[$i]->code.'
'; + } + + } + + public function remove_record_item() + { + if (!$this->input->is_ajax_request()) { exit('no valid req.'); } + + $this->load->model('item_M'); + $data = array( + 'isdelete' => $this->input->post('in_remove_id') + ); + + $inser_id=$this->item_M->delete_in_item($data,$this->input->post('in_remove_id')); + + if($inser_id>0) + { + $sql="select * from v_insurance_item_list where c_item_id=".$this->input->post('p_id'); + $query = $this->db->query($sql); + $data_insurance_item= $query->result(); + + echo ' + + + + + + + + + '; + for ($i = 0; $i < count($data_insurance_item); ++$i) { + echo ' + + + + + '; + } + echo '
Company NameAmountCodeAction
'.$data_insurance_item[$i]->ins_company_name.''.$data_insurance_item[$i]->i_amount.''.$data_insurance_item[$i]->code.'
'; + } + + } + + + 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 + } + + + public function CreateItemTypeRecord() + { + if (!$this->input->is_ajax_request()) { exit('no valid req.'); } + + $this->load->model('item_M'); + $data = array( + 'is_ipd_opd' => $this->input->post('Item_Type_ipd'), + 'group_desc' => $this->input->post('input_Item_type') + ); + + $inser_id=$this->item_M->insert_type($data); + + if($inser_id>0) + { + + $rvar=array( + 'insertid' =>$inser_id + ); + $encode_data = json_encode($rvar); + echo $encode_data; + } + + } + + public function UpdateItemTypeRecord() + { + if (!$this->input->is_ajax_request()) { exit('no valid req.'); } + + $this->load->model('item_M'); + + $data = array( + 'is_ipd_opd' => $this->input->post('Item_Type_ipd'), + 'group_desc' => $this->input->post('input_Item_type') + ); + + $old_id=$this->input->post('itemtype_id'); + $update=$this->item_M->update_type($data,$old_id); + + if($update>0) + { + $rvar=array( + 'update' =>1, + 'showcontent'=> Show_Alert('success','Saved','Data Saved successfully') + ); + $encode_data = json_encode($rvar); + echo $encode_data; + } + + } + +} \ No newline at end of file diff --git a/old_code_ci3/controllers/Item_IPD.php b/old_code_ci3/controllers/Item_IPD.php new file mode 100644 index 0000000..63d053e --- /dev/null +++ b/old_code_ci3/controllers/Item_IPD.php @@ -0,0 +1,354 @@ +load->model('Item_ipd_M'); + } + + public function search_itemtype() + { + $sql = "SELECT * FROM ipd_item_type + order by group_desc"; + $query = $this->db->query($sql); + $data['data']= $query->result(); + + $this->load->view('item_ipd/item_type_search_v',$data); + } + + public function search_adv($itype_id=1) + { + + $sql = "SELECT i.*,t.group_desc FROM ipd_items i join ipd_item_type t on i.itype=itype_id where itype=$itype_id"; + $query = $this->db->query($sql); + $data= $query->result(); + echo ' Print

'; + + echo ' + + + + + + + + + '; + for ($i = 0; $i < count($data); ++$i) { + echo ' + + + + + '; + } + + echo ' + + + + + + + + +
GroupCharge NameAmount
'.$data[$i]->group_desc.''.$data[$i]->idesc.''.$data[$i]->amount.' + +
GroupCharge NameAmount
'; + echo ""; + + } + + public function search() + { + $sql = "SELECT * FROM ipd_item_type + order by group_desc"; + $query = $this->db->query($sql); + $data['labitemtype']= $query->result(); + + $sql = "SELECT i.*,t.group_desc + FROM ipd_items i join ipd_item_type t on i.itype=itype_id where itype=1"; + $query = $this->db->query($sql); + $data['data']= $query->result(); + + $this->load->view('item_ipd/item_search_V',$data); + + } + + public function search_print($itype_id=1) + { + $sql = "select m.id AS id,m.itype AS itype,m.idesc AS idesc,m.idesc_detail AS idesc_detail, + m.amount AS amount,t.itype_id AS itype_id, + t.group_desc AS group_desc, + 'IPD' AS isIPD_OPD + from (ipd_items m join ipd_item_type t on((m.itype = t.itype_id))) + where m.itype=".$itype_id." order by group_desc"; + $query = $this->db->query($sql); + $data['data']= $query->result(); + + $this->load->view('item_ipd/item_item_list',$data); + + } + + public function item_all_print() + { + $sql = "select m.id AS id,m.itype AS itype,m.idesc AS idesc,m.idesc_detail AS idesc_detail, + m.amount AS amount,t.itype_id AS itype_id, + t.group_desc AS group_desc, + 'IPD' AS isIPD_OPD + from (ipd_items m join ipd_item_type t on((m.itype = t.itype_id))) + order by group_desc"; + $query = $this->db->query($sql); + $data['data']= $query->result(); + + $this->load->view('item_ipd/item_item_list',$data); + + } + + function itemtype_record($id) + { + $sql = "SELECT * + FROM ipd_item_type where itype_id='".$id."' order by group_desc"; + $query = $this->db->query($sql); + $data['data_item']= $query->result(); + + $this->load->view('item_ipd/item_type_profile',$data); + } + + function item_record($id) + { + + $sql = "SELECT i.*,t.group_desc + FROM ipd_items i join ipd_item_type t on i.itype=itype_id where id=$id"; + $query = $this->db->query($sql); + $data['data_item']= $query->result(); + + $sql="select * from ipd_item_type"; + $query = $this->db->query($sql); + $data['data_item_type']= $query->result(); + + $sql="select * from v_insurance_ipd_item_list where c_item_id=".$id; + $query = $this->db->query($sql); + $data['data_insurance_item']= $query->result(); + + $sql="select * from hc_insurance where id>1"; + $query = $this->db->query($sql); + $data['data_insurance']= $query->result(); + + $this->load->view('item_ipd/item_profile_V',$data); + } + + public function UpdateRecord() + { + if (!$this->input->is_ajax_request()) { exit('no valid req.'); } + + + + $data = array( + 'itype' => $this->input->post('Item_Type'), + 'idesc' => $this->input->post('input_Item_name'), + 'amount' => $this->input->post('input_amount'), + 'update_date' => date('Y-m-d H:i:s') + ); + $old_id=$this->input->post('p_id'); + $update=$this->Item_ipd_M->update($data,$old_id); + + if($update>0) + { + $rvar=array( + 'update' =>1, + 'showcontent'=> Show_Alert('success','Saved','Data Saved successfully') + ); + $encode_data = json_encode($rvar); + echo $encode_data; + } + + } + + public function AddRecord() + { + $sql="select * from ipd_item_type"; + $query = $this->db->query($sql); + $data['data_item_type']= $query->result(); + + $this->load->view('item_ipd/item_create_V',$data); + } + + + public function AddItemTypeRecord() + { + $this->load->view('item_ipd/item_type_create'); + } + + public function CreateRecord() + { + if (!$this->input->is_ajax_request()) { exit('no valid req.'); } + + + $data = array( + 'itype' => $this->input->post('Item_Type'), + 'idesc' => $this->input->post('input_Item_name'), + 'amount' => $this->input->post('input_amount'), + 'update_date' => date('Y-m-d H:i:s') + ); + + $inser_id=$this->Item_ipd_M->insert($data); + + if($inser_id>0) + { + + $rvar=array( + 'insertid' =>$inser_id + ); + $encode_data = json_encode($rvar); + echo $encode_data; + } + + } + + public function AddInsuranceItemRecord() + { + if (!$this->input->is_ajax_request()) { exit('no valid req.'); } + + $this->load->model('item_ipd_M'); + $data = array( + 'hc_items_id' => $this->input->post('p_id'), + 'hc_insurance_id' => $this->input->post('ins_company_name'), + 'amount1' => $this->input->post('input_amount'), + 'code' => $this->input->post('input_item_code') + ); + + $inser_id=$this->item_ipd_M->insert_in_item($data); + + if($inser_id>0) + { + $sql="select * from v_insurance_ipd_item_list where c_item_id=".$this->input->post('p_id'); + $query = $this->db->query($sql); + $data_insurance_item= $query->result(); + + echo ' + + + + + + + + + '; + for ($i = 0; $i < count($data_insurance_item); ++$i) { + echo ' + + + + + '; + } + echo '
Company NameAmountCodeAction
'.$data_insurance_item[$i]->ins_company_name.''.$data_insurance_item[$i]->i_amount.''.$data_insurance_item[$i]->code.'
'; + } + + } + + public function remove_record_item() + { + if (!$this->input->is_ajax_request()) { exit('no valid req.'); } + + $this->load->model('item_ipd_M'); + $data = array( + 'isdelete' => $this->input->post('in_remove_id') + ); + + $inser_id=$this->item_ipd_M->delete_in_item($data,$this->input->post('in_remove_id')); + + $sql="select * from v_insurance_ipd_item_list where c_item_id=".$this->input->post('p_id'); + $query = $this->db->query($sql); + $data_insurance_item= $query->result(); + + echo ' + + + + + + + + + '; + for ($i = 0; $i < count($data_insurance_item); ++$i) { + echo ' + + + + + '; + } + echo '
Company NameAmountCodeAction
'.$data_insurance_item[$i]->ins_company_name.''.$data_insurance_item[$i]->i_amount.''.$data_insurance_item[$i]->code.'
'; + + } + + + + + 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 + } + + + public function CreateItemTypeRecord() + { + if (!$this->input->is_ajax_request()) { exit('no valid req.'); } + + $this->load->model('item_M'); + $data = array( + 'group_desc' => $this->input->post('input_Item_type') + ); + + $inser_id=$this->Item_ipd_M->insert_type($data); + + if($inser_id>0) + { + + $rvar=array( + 'insertid' =>$inser_id + ); + $encode_data = json_encode($rvar); + echo $encode_data; + } + + } + + public function UpdateItemTypeRecord() + { + if (!$this->input->is_ajax_request()) { exit('no valid req.'); } + + + $data = array( + 'group_desc' => $this->input->post('input_Item_type') + ); + + $old_id=$this->input->post('itemtype_id'); + $update=$this->Item_ipd_M->update_type($data,$old_id); + + if($update>0) + { + $rvar=array( + 'update' =>1, + 'showcontent'=> Show_Alert('success','Saved','Data Saved successfully') + ); + $encode_data = json_encode($rvar); + echo $encode_data; + } + + } + +} \ No newline at end of file diff --git a/old_code_ci3/controllers/Lab_Admin.php b/old_code_ci3/controllers/Lab_Admin.php new file mode 100644 index 0000000..6f1edb6 --- /dev/null +++ b/old_code_ci3/controllers/Lab_Admin.php @@ -0,0 +1,3493 @@ +db->query($sql); + $data['labReport_master']= $query->result(); + + $this->load->view('PathLab_Report/lab_report_list',$data); + } + + public function report_ultrasound_list($modality=2) + { + $sql="select * from radiology_ultrasound_template where modality=".$modality; + $query = $this->db->query($sql); + $data['labReport_master']= $query->result(); + + $data['modality']=$modality; + + $this->load->view('PathLab_Report/ultrasound_template_list',$data); + } + + public function report_test_list($repo_id) + { + $sql="select j.id,r.mstRepoKey,t.mstTestKey,t.Test,t.TestID,t.Result,j.EOrder + from lab_repo r join lab_repotests j join lab_tests t + on r.mstRepoKey=j.mstRepoKey and j.mstTestKey=t.mstTestKey where r.mstRepoKey=".$repo_id." order by j.EOrder" ; + $query = $this->db->query($sql); + $data['lab_Rep_Item_List']= $query->result(); + + $data['mstRepoKey']=$repo_id; + + $this->load->view('PathLab_Report/lab_report_test_list',$data); + } + + public function test_search_page($repo_id) + { + $data['repo_id']=$repo_id; + $this->load->view('PathLab_Report/lab_test_search',$data); + } + + public function test_parameter_load($mstTestKey,$mstRepoKey) + { + $sql="select * from lab_tests where mstTestKey=".$mstTestKey ; + $query = $this->db->query($sql); + $data['lab_test_parameter']= $query->result(); + + $sql="select *,if(option_bold=1,'Bold','') as option_bold_str from lab_tests_option where mstTestKey=".$mstTestKey. " order by sort_id " ; + $query = $this->db->query($sql); + $data['lab_test_option']= $query->result(); + + $data['mstRepoKey']=$mstRepoKey; + + $this->load->view('PathLab_Report/lab_report_item_edit',$data); + } + public function remove_test_option($option_id,$id_key) + { + $this->db->delete("lab_tests_option", "id=".$option_id); + + $sql="select *,if(option_bold=1,'Bold','') as option_bold_str from lab_tests_option where mstTestKey=".$id_key. " order by sort_id " ; + $query = $this->db->query($sql); + $lab_test_option= $query->result(); + + $option_content=' + + + + + + + + + '; + for ($i = 0; $i < count($lab_test_option); ++$i) { + $option_content=$option_content.' + + + + + '; + } + $option_content=$option_content.'
#CodeBoldAction
'.$lab_test_option[$i]->sort_id.''.$lab_test_option[$i]->option_value.''.$lab_test_option[$i]->option_bold_str.' +
+ + '; + + $option_current=$lab_test_option[$i]->id; + $sort_current=$lab_test_option[$i]->sort_id; + + if($i+1 < count($lab_test_option)) + { + $option_next=$lab_test_option[$i+1]->id; + $sort_next=$lab_test_option[$i+1]->sort_id; + + $option_content=$option_content. ''; + } + + if($i>0) + { + $option_prev=$lab_test_option[$i-1]->id; + $sort_prev=$lab_test_option[$i-1]->sort_id; + + $option_content=$option_content. ''; + + } + + $option_content=$option_content.'
+
'; + + $showcontent=Show_Alert('success','Saved','Data Saved successfully'); + + $rvar=array( + 'insert_id' => 1, + 'showcontent'=> $showcontent, + 'option_content' => $option_content + ); + + $encode_data = json_encode($rvar); + echo $encode_data; + + } + + public function test_parameter_edit() + { + if (!$this->input->is_ajax_request()) { exit('no valid req.'); } + + $this->load->model('PathLab_M'); + + $id_key=$this->input->post('mstTestKey'); + + $sql="select * from lab_tests where mstTestKey=".$id_key; + $query = $this->db->query($sql); + $lab_tests= $query->result(); + + $TestID=$lab_tests[0]->TestID; + $TestID_post=$this->input->post('input_test_code'); + + $test_chk=''; + + if($TestID!=$TestID_post || $TestID=='') + { + $test_chk='|is_unique[lab_tests.TestID]'; + } + + $FormRules = array( + array( + 'field' => 'input_Test_name', + 'label' => 'Test Name', + 'rules' => 'required|min_length[1]|max_length[30]' + ), + array( + 'field' => 'input_test_code', + 'label' => 'Test Code', + 'rules' => 'required|min_length[1]|max_length[30]'.$test_chk + ) + ); + + $this->form_validation->set_rules($FormRules); + + $update_value=1; + $showcontent=""; + if ($this->form_validation->run() == TRUE) + { + $idChecked=$this->input->post('input_isChecked'); + + $data = array( + 'Test'=> $this->input->post('input_Test_name'), + 'TestID'=> $this->input->post('input_test_code'), + 'Result'=> $this->input->post('input_Default'), + 'Formula'=> $this->input->post('input_Formula'), + 'VRule'=> $this->input->post('input_Validation'), + 'VMsg'=> $this->input->post('input_Message'), + 'Unit'=> $this->input->post('input_Unit'), + 'FixedNormals'=> $this->input->post('input_Fixed'), + 'isGenderSpecific'=> $idChecked, + 'FixedNormalsWomen'=> $this->input->post('input_FixedNormalsWomen') + ); + + $this->PathLab_M->update_item_parameter($data,$id_key); + + $showcontent=Show_Alert('success','Saved','Data Saved successfully'); + }else{ + $update_value=0; + $showcontent =Show_Alert('danger','Error',validation_errors()); + } + + + + $rvar=array( + 'update_value' => $update_value, + 'showcontent'=> $showcontent + ); + + $encode_data = json_encode($rvar); + echo $encode_data; + + + } + + public function test_parameter_add() + { + if (!$this->input->is_ajax_request()) { exit('no valid req.'); } + + $this->load->model('PathLab_M'); + + $id_key=$this->input->post('mstTestKey'); + $mstRepoKey=$this->input->post('mstRepoKey'); + + $sql="select * from lab_tests where mstTestKey=".$id_key; + $query = $this->db->query($sql); + $lab_tests= $query->result(); + + $TestID=""; + + if(count($lab_tests)>0) + { + $TestID=$lab_tests[0]->TestID; + } + + $TestID_post=$this->input->post('input_test_code'); + + $test_chk=''; + + if($TestID!=$TestID_post || $TestID=='') + { + $test_chk='|is_unique[lab_tests.TestID]'; + } + + $FormRules = array( + array( + 'field' => 'input_Test_name', + 'label' => 'Test Name', + 'rules' => 'required|min_length[1]|max_length[30]' + ), + array( + 'field' => 'input_test_code', + 'label' => 'Test Code', + 'rules' => 'required|min_length[1]|max_length[30]'.$test_chk + ) + ); + + $this->form_validation->set_rules($FormRules); + + $insert_id=0; + $showcontent=""; + if ($this->form_validation->run() == TRUE) + { + $udata = array( + 'Test'=> $this->input->post('input_Test_name'), + 'TestID'=> $this->input->post('input_test_code'), + 'Result'=> $this->input->post('input_Default'), + 'Formula'=> $this->input->post('input_Formula'), + 'VRule'=> $this->input->post('input_Validation'), + 'VMsg'=> $this->input->post('input_Message'), + 'Unit'=> $this->input->post('input_Unit'), + 'FixedNormals'=> $this->input->post('input_Fixed') + ); + + $insert_id=$this->PathLab_M->insert_item_parameter($udata,$id_key); + + $sql="select Max(EOrder) as MEOrder from lab_repotests where mstRepoKey=".$mstRepoKey; + $query = $this->db->query($sql); + $data['lab_repotests']= $query->result(); + + $MEOrder=0; + if(count($data['lab_repotests'])>0) + { + $MEOrder=$data['lab_repotests'][0]->MEOrder; + } + + if($MEOrder === NULL) + { + $MEOrder=1; + }else{ + $MEOrder=$MEOrder+1; + } + + $udata = array( + 'mstRepoKey'=> $mstRepoKey, + 'mstTestKey'=> $insert_id, + 'EOrder'=> $MEOrder + ); + + $sortorder_insert_id=$this->PathLab_M->insert_item_sortorder($udata); + + $showcontent=Show_Alert('success','Saved','Data Saved successfully'); + }else{ + $insert_id=0; + $showcontent =Show_Alert('danger','Error',validation_errors()); + } + + + $rvar=array( + 'insert_id' => $insert_id, + 'showcontent'=> $showcontent + ); + + $encode_data = json_encode($rvar); + echo $encode_data; + + + } + + public function test_parameter_option_add() + { + if (!$this->input->is_ajax_request()) { exit('no valid req.'); } + + $this->load->model('PathLab_M'); + + $FormRules = array( + array( + 'field' => 'input_op_value', + 'label' => 'Code', + 'rules' => 'required|min_length[1]|max_length[30]' + ) + ); + + $this->form_validation->set_rules($FormRules); + + $sort_id=1; + $id_key=$this->input->post('mstTestKey'); + + $sql="select Max(sort_id) as msort_id from lab_tests_option where mstTestKey=".$id_key; + $query = $this->db->query($sql); + $lab_tests_option= $query->result(); + + if(count($lab_tests_option)>0) + { + $sort_id=$lab_tests_option[0]->msort_id; + $sort_id=$sort_id+1; + } + + $insert_id=0; + $showcontent=""; + $option_content=""; + if ($this->form_validation->run() == TRUE) + { + $data = array( + 'mstTestKey'=> $id_key, + 'sort_id'=> $sort_id, + 'option_value'=> $this->input->post('input_op_value'), + 'option_text'=> $this->input->post('input_op_value'), + 'option_bold'=> $this->input->post('chk_bold') + ); + + $insert_id=$this->PathLab_M->insert_item_parameter_option($data); + + $sql="select *,if(option_bold=1,'Bold','') as option_bold_str from lab_tests_option where mstTestKey=".$id_key. " order by sort_id " ; + $query = $this->db->query($sql); + $lab_test_option= $query->result(); + + $option_content=' + + + + + + + + + '; + for ($i = 0; $i < count($lab_test_option); ++$i) { + + $option_content=$option_content.' + + + + + '; + } + $option_content=$option_content.'
#CodeBoldAction
'.$lab_test_option[$i]->sort_id.''.$lab_test_option[$i]->option_value.''.$lab_test_option[$i]->option_bold_str.'
+ '; + + $option_current=$lab_test_option[$i]->id; + $sort_current=$lab_test_option[$i]->sort_id; + + if($i+1 < count($lab_test_option)) + { + $option_next=$lab_test_option[$i+1]->id; + $sort_next=$lab_test_option[$i+1]->sort_id; + + $option_content=$option_content. ''; + } + + if($i>0) + { + $option_prev=$lab_test_option[$i]->id; + $sort_prev=$lab_test_option[$i]->sort_id; + + $option_content=$option_content. ''; + + } + + $option_content=$option_content.'
+
'; + + $showcontent=Show_Alert('success','Saved','Data Saved successfully'); + }else{ + $$insert_id=0; + $showcontent =Show_Alert('danger','Error',validation_errors()); + } + + $rvar=array( + 'insert_id' => $insert_id, + 'showcontent'=> $showcontent, + 'option_content' => $option_content + ); + + $encode_data = json_encode($rvar); + echo $encode_data; + } + + public function change_sort($id_key,$option_id,$current,$change_option_id,$change) + { + $this->load->model('PathLab_M'); + + $udata = array( + 'sort_id'=> 0 + ); + + $this->PathLab_M->update_item_parameter_option($udata,$option_id); + + $udata = array( + 'sort_id'=> $current + ); + $this->PathLab_M->update_item_parameter_option($udata,$change_option_id); + + + $udata = array( + 'sort_id'=> $change + ); + $this->PathLab_M->update_item_parameter_option($udata,$option_id); + + + + $sql="select *,if(option_bold=1,'Bold','') as option_bold_str from lab_tests_option where mstTestKey=".$id_key. " order by sort_id " ; + $query = $this->db->query($sql); + $lab_test_option= $query->result(); + + $option_content=' + + + + + + + + + '; + for ($i = 0; $i < count($lab_test_option); ++$i) { + $option_content=$option_content.' + + + + + '; + } + $option_content=$option_content.'
#CodeBoldAction
'.$lab_test_option[$i]->sort_id.''.$lab_test_option[$i]->option_value.''.$lab_test_option[$i]->option_bold_str.' +
+ '; + + $option_current=$lab_test_option[$i]->id; + $sort_current=$lab_test_option[$i]->sort_id; + + if($i+1 < count($lab_test_option)) + { + $option_next=$lab_test_option[$i+1]->id; + $sort_next=$lab_test_option[$i+1]->sort_id; + + $option_content=$option_content. ''; + } + + if($i>0) + { + $option_prev=$lab_test_option[$i-1]->id; + $sort_prev=$lab_test_option[$i-1]->sort_id; + + $option_content=$option_content. ''; + + } + + $option_content=$option_content.'
+
'; + + $showcontent=Show_Alert('success','Saved','Data Saved successfully'); + + $rvar=array( + 'insert_id' => 1, + 'showcontent'=> $showcontent, + 'option_content' => $option_content + ); + + $encode_data = json_encode($rvar); + echo $encode_data; + + } + + public function change_sort_item($repo_id,$option_id,$current,$change_option_id,$change) + { + $this->load->model('PathLab_M'); + + $udata = array( + 'EOrder'=> 0 + ); + $this->PathLab_M->update_item_sortorder($udata,$option_id); + + $udata = array( + 'EOrder'=> $current + ); + $this->PathLab_M->update_item_sortorder($udata,$change_option_id); + + $udata = array( + 'EOrder'=> $change + ); + $this->PathLab_M->update_item_sortorder($udata,$option_id); + + $sql="select j.id,r.mstRepoKey,t.mstTestKey,t.Test,t.TestID,t.Result,j.EOrder + from lab_repo r join lab_repotests j join lab_tests t + on r.mstRepoKey=j.mstRepoKey and j.mstTestKey=t.mstTestKey where r.mstRepoKey=".$repo_id." order by j.EOrder" ; + $query = $this->db->query($sql); + $data['lab_Rep_Item_List']= $query->result(); + + $data['mstRepoKey']=$repo_id; + + $this->load->view('PathLab_Report/lab_report_test_list',$data); + + } + + + public function reportedit_load($repo_id=0) + { + $sql="select * from lab_repo where mstRepoKey=".$repo_id; + $query = $this->db->query($sql); + $data['labReport_master']= $query->result(); + + $item_id=0; + + if($repo_id>0) + { + $item_id=$data['labReport_master'][0]->charge_id; + } + + //$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 "; + + $query = $this->db->query($sql); + $data['hc_items']= $query->result(); + + $sql="select * from lab_rgroups "; + $query = $this->db->query($sql); + $data['lab_rgroups']= $query->result(); + + $sql="select j.id,r.mstRepoKey,t.mstTestKey,t.Test,t.TestID,t.Result,j.EOrder + from lab_repo r join lab_repotests j join lab_tests t + on r.mstRepoKey=j.mstRepoKey and j.mstTestKey=t.mstTestKey where r.mstRepoKey=".$repo_id." order by j.EOrder" ; + $query = $this->db->query($sql); + $data['lab_Rep_Item_List']= $query->result(); + + $sql="select * from color "; + $query = $this->db->query($sql); + $data['color_name']= $query->result(); + + $data['repo_id']=$repo_id; + + $this->load->view('PathLab_Report/lab_report_edit',$data); + } + + public function reportedit_ultrasound_load($modality=2,$repo_id=0) + { + $sql="select * from radiology_ultrasound_template where modality=$modality and id=".$repo_id; + $query = $this->db->query($sql); + $data['labReport_master']= $query->result(); + + $item_id=0; + + if($repo_id>0) + { + $item_id=$data['labReport_master'][0]->charge_id; + } + + + + $sql="select * from hc_items where itype=$modality 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); + } + + public function report_update() + { + + $this->load->model('PathLab_M'); + + $id_key=$this->input->post('repo_id'); + + $sql="select * from lab_repo where mstRepoKey=".$id_key; + $query = $this->db->query($sql); + $lab_repo= $query->result(); + + $repo_title=$lab_repo[0]->Title; + $repo_title_post=$this->input->post('input_Reportname'); + + $repo_chk=''; + + if($repo_title!=$repo_title_post) + { + $repo_chk='|is_unique[lab_repo.Title]'; + } + + $charge_id=$lab_repo[0]->charge_id; + $charge_id_post=$this->input->post('charge_id'); + $charge_chk=''; + + if($charge_id_post>0) + { + if($charge_id_post!=$charge_id) + { + $charge_chk='|is_unique[lab_repo.charge_id]'; + } + } + $update_record=0; + + $FormRules = array( + array( + 'field' => 'input_Reportname', + 'label' => 'Name', + 'rules' => 'required|min_length[1]|max_length[100]'.$repo_chk + ), + array( + 'field' => 'charge_id', + 'label' => 'Charge Name', + 'rules' => 'required|min_length[1]|max_length[30]'.$charge_chk + ) + ); + + $this->form_validation->set_rules($FormRules); + + if ($this->form_validation->run() == TRUE) + { + $data = array( + 'Title'=> $this->input->post('input_Reportname'), + 'GrpKey'=> $this->input->post('group_id'), + 'charge_id'=> $this->input->post('charge_id'), + 'HTMLData'=> $this->input->post('HTMLData'), + ); + + $this->PathLab_M->update_report($data,$id_key); + + $update_record=1; + + $showcontent=Show_Alert('success','Saved','Data Saved successfully'); + + }else{ + $showcontent =Show_Alert('danger','Error',validation_errors()); + } + + + $rvar=array( + 'update_record' => $update_record, + 'showcontent' => $showcontent + ); + + $encode_data = json_encode($rvar); + echo $encode_data; + } + + public function report_ultrasound_insert($modality) + { + if (!$this->input->is_ajax_request()) { exit('no valid req.'); } + + $this->load->model('PathLab_M'); + + $FormRules = array( + array( + 'field' => 'input_Reportname', + 'label' => 'Name', + 'rules' => 'required|min_length[1]|max_length[100]|is_unique[lab_repo.Title]' + ) + ); + + $this->form_validation->set_rules($FormRules); + + $insertid=0; + $showcontent=""; + if ($this->form_validation->run() == TRUE) + { + $id_key=$this->input->post('repo_id'); + $data = array( + 'template_name'=> $this->input->post('input_Reportname'), + '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 + ); + $insertid=$this->PathLab_M->insert_ultrasound_report($data); + $showcontent="Data Saved successfully"; + + }else{ + $showcontent =validation_errors(); + } + + $rvar=array( + 'insertid' => $insertid, + 'showcontent'=> $showcontent + ); + + $encode_data = json_encode($rvar); + echo $encode_data; + + } + + public function report_ultrasound_update($modality=2) + { + + $this->load->model('PathLab_M'); + + $id_key=$this->input->post('repo_id'); + + $sql="select * from radiology_ultrasound_template where id=".$id_key; + $query = $this->db->query($sql); + $lab_repo= $query->result(); + + $repo_title=$lab_repo[0]->title; + $repo_title_post=$this->input->post('input_Reportname'); + + $repo_chk=''; + + $charge_id_post=$this->input->post('charge_id'); + + + $update_record=0; + + $FormRules = array( + array( + 'field' => 'input_Reportname', + 'label' => 'Name', + 'rules' => 'required|min_length[1]|max_length[100]' + ), + array( + 'field' => 'charge_id', + 'label' => 'Charge Name', + 'rules' => 'required|min_length[1]|max_length[30]' + ) + ); + + $this->form_validation->set_rules($FormRules); + + if ($this->form_validation->run() == TRUE) + { + $data = array( + 'template_name'=> $this->input->post('input_Reportname'), + 'title'=> $this->input->post('group_id'), + 'charge_id'=> $charge_id_post, + 'Findings'=> $this->input->post('HTMLData'), + 'Impression'=> $this->input->post('Impression'), + 'modality'=> $modality + ); + + $this->PathLab_M->update_ultrasound_report($data,$id_key); + + $update_record=1; + + $showcontent=Show_Alert('success','Saved','Data Saved successfully'); + + }else{ + $showcontent =Show_Alert('danger','Error',validation_errors()); + } + + + $rvar=array( + 'update_record' => $update_record, + 'showcontent' => $showcontent + ); + + $encode_data = json_encode($rvar); + echo $encode_data; + } + + public function report_insert() + { + if (!$this->input->is_ajax_request()) { exit('no valid req.'); } + + $this->load->model('PathLab_M'); + + $FormRules = array( + array( + 'field' => 'input_Reportname', + 'label' => 'Name', + 'rules' => 'required|min_length[1]|max_length[100]|is_unique[lab_repo.Title]' + ) + ); + + $this->form_validation->set_rules($FormRules); + + $insertid=0; + $showcontent=""; + if ($this->form_validation->run() == TRUE) + { + $id_key=$this->input->post('repo_id'); + $data = array( + 'Title'=> $this->input->post('input_Reportname'), + 'GrpKey'=> $this->input->post('group_id'), + 'charge_id'=> $this->input->post('charge_id'), + ' HTMLData'=> $this->input->post('HTMLData') + ); + $insertid=$this->PathLab_M->insert_report($data); + $showcontent=Show_Alert('success','Saved','Data Saved successfully'); + + + }else{ + $showcontent =Show_Alert('danger','Error',validation_errors()); + } + + $rvar=array( + 'insertid' => $insertid, + 'showcontent'=> $showcontent + ); + + $encode_data = json_encode($rvar); + echo $encode_data; + + } + + + public function lab_master() + { + $this->load->view('PathLab_Report/lab_main'); + } + + public function lab_path($lab_type) + { + $data['lab_type']=$lab_type; + $this->load->view('PathLab_Report/pathlab_request_list',$data); + } + + + public function Entry_Update() + { + $this->load->model('PathLab_M'); + + $test_id=$this->input->post('test_id'); + $test_value=$this->input->post('test_value'); + + $udata = array( + 'lab_test_value'=> $test_value + ); + $this->PathLab_M->update_test_entry($udata,$test_id); + + + $sql="select lab_test_value from lab_request_item where id=".$test_id; + $query = $this->db->query($sql); + $data_value= $query->result(); + + echo $data_value[0]->lab_test_value; + + } + + public function Remark_Update($req_id) + { + $this->load->model('PathLab_M'); + + $udata = array( + 'Remark'=> $this->input->post('HTMLData') + ); + + $this->PathLab_M->update_test_request($udata,$req_id); + + echo "Saved"; + + } + + public function Final_Update($req_id) + { + $this->load->model('PathLab_M'); + + $udata = array( + 'Report_Data'=> $this->input->post('HTMLData') + ); + + $this->PathLab_M->update_test_request($udata,$req_id); + + echo "Saved"; + + } + + public function Report_Final_print($inv_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.'['.$user_id.']['.date('d-m-Y h:m:s').']'; + + $udata = array( + 'Report_Data'=> $this->input->post('HTMLData'), + 'report_update'=> $user_name + ); + + $sortorder_insert_id=$this->PathLab_M->update_invoice_report($udata,$inv_req_id); + echo 'Report Update'; + + } + + public function Report_single_print($lab_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.'['.$user_id.']['.date('d-m-Y h:m:s').']'; + + $udata = array( + 'Report_Data'=> $this->input->post('HTMLData'), + 'report_update'=> $user_name + ); + + $sortorder_insert_id=$this->PathLab_M->update_test_request($udata,$lab_req_id); + echo 'Report Update'; + + + } + + public function confirm_report($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); + + echo "Verified and Ready for Print"; + + } + + + + public function create_report($req_id) { + + $this->load->model('PathLab_M'); + + $sql="select * from lab_request where id=".$req_id; + $query = $this->db->query($sql); + $data_lab_request= $query->result(); + + $p_id=$data_lab_request[0]->patient_id; + + $sql="select * from patient_master_exten where id=$p_id"; + $query = $this->db->query($sql); + $data_patient_data= $query->result(); + + $gender=$data_patient_data[0]->gender; + + + $sql="select d.mstTestKey,d.Test,d.TestID,d.Result,d.Formula,d.VRule,d.VMsg,d.Unit, d.FixedNormals, + i.lab_test_value,i.lab_test_remark,i.id ,s.EOrder,d.isGenderSpecific,d.FixedNormalsWomen, + group_concat(concat(o.id,':',o.option_text,':',o.option_value) ORDER BY o.sort_id) as option_value + from (lab_request_item i join lab_tests d join lab_repotests s + on i.lab_test_id=d.mstTestKey and d.mstTestKey=s.mstTestKey and i.lab_repo_id=s.mstRepoKey) + left join lab_tests_option o on d.mstTestKey=o.mstTestKey + where i.lab_request_id=".$req_id." group by d.mstTestKey order by s.EOrder"; + $query = $this->db->query($sql); + $data_lab_test_list= $query->result(); + + $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; + + + $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; + $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 ; + $query = $this->db->query($sql); + $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_Head_H3.'
+ '; + + + $Report_Footer=$data_lab_request[0]->Remark; + + //update report_string with test parameter + + $lab_test_array=array(); + for($j = 0; $j < count($data_lab_test_list); ++$j) { + $lab_test_array[$data_lab_test_list[$j]->TestID]=$data_lab_test_list[$j]->lab_test_value; + } + + + for ($i = 0; $i < count($data_lab_test_list); ++$i) { + + $FixedNormals=$data_lab_test_list[$i]->FixedNormals; + $isGenderSpecific=$data_lab_test_list[$i]->isGenderSpecific; + $FixedNormalsWomen=$data_lab_test_list[$i]->FixedNormalsWomen; + + $Test_Formula=$data_lab_test_list[$i]->Formula; + + //$LabTestValue=$data_lab_test_list[$i]->lab_test_value; + + if(strlen($Test_Formula)>0){ + foreach($lab_test_array as $key=>$value){ + if(is_numeric($value)) + { + $Test_Formula=str_replace('{'.$key.'}',$value,$Test_Formula); + }else{ + $Test_Formula=str_replace('{'.$key.'}','0',$Test_Formula); + } + + } + + //echo $Test_Formula; + + $LabTestValue=Round(cal_exp(trim($Test_Formula)),2); + + + }else{ + $LabTestValue=$data_lab_test_list[$i]->lab_test_value; + } + + + if($isGenderSpecific==1) + { + if($gender==1) + { + if(strlen($FixedNormals)>0 && is_numeric($LabTestValue)) + { + $FixedNormals_array=explode('-',$FixedNormals); + + if(is_array($FixedNormals_array)) + { + $FixedNormals_min=$FixedNormals_array[0]; + $FixedNormals_max=$FixedNormals_array[1]; + if(is_numeric($FixedNormals_min)&&is_numeric($FixedNormals_min)) + { + if($LabTestValue>=$FixedNormals_min && $LabTestValue<=$FixedNormals_max ) + { + + }else{ + $LabTestValue=''.$LabTestValue.''; + } + } + } + + } + }else{ + if(strlen($FixedNormalsWomen)>0 && is_numeric($LabTestValue)) + { + $FixedNormals_array=explode('-',$FixedNormalsWomen); + + if(is_array($FixedNormals_array)) + { + $FixedNormals_min=$FixedNormals_array[0]; + $FixedNormals_max=$FixedNormals_array[1]; + if(is_numeric($FixedNormals_min)&&is_numeric($FixedNormals_max)) + { + if($LabTestValue>=$FixedNormals_min && $LabTestValue<=$FixedNormals_max ) + { + + }else{ + $LabTestValue=''.$LabTestValue.''; + } + } + } + + } + } + + }else{ + if(strlen($FixedNormals)>0 && is_numeric($LabTestValue)) + { + $FixedNormals_array=explode('-',$FixedNormals); + + if(is_array($FixedNormals_array)) + { + $FixedNormals_min=$FixedNormals_array[0]; + $FixedNormals_max=$FixedNormals_array[1]; + if(is_numeric($FixedNormals_min)&&is_numeric($FixedNormals_min)) + { + if($LabTestValue>=$FixedNormals_min && $LabTestValue<=$FixedNormals_max ) + { + + }else{ + $LabTestValue=''.$LabTestValue.''; + } + } + } + + } + } + + $Report_string=str_replace('{'.$data_lab_test_list[$i]->TestID.'}',$LabTestValue,$Report_string); + } + + $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); + + //echo 'Report Created'.$lab_invoice_request[0]->id; + + redirect('Lab_Admin/show_report_final/'.$req_id); + } + + + + public function show_report_final($req_id) + { + $sql="select * from lab_request where id=".$req_id; + $query = $this->db->query($sql); + $data['report_format']= $query->result(); + + $this->load->view('PathLab_Report/lab_final_report_show',$data); + } + + public function report_compile1($inv_id,$lab_type) + { + $sql="select l.*,g.RepoGrp, + date_format(l.collected_time,'%d-%m-%Y %h:%i %p') as str_collected_time, + date_format(l.reported_time,'%d-%m-%Y %h:%i %p') as str_reported_time + FROM (lab_request l join lab_repo r on l.lab_repo_id=r.mstRepoKey) + left join lab_rgroups g on r.GrpKey=g.mstRGrpKey + where l.print_combine=1 and status=2 and l.charge_id=".$inv_id." and l.lab_type=".$lab_type." order by g.sort_order"; + + $query = $this->db->query($sql); + $data_lab_request= $query->result(); + + $sql="Select max(report_edit_req_no) as no + from lab_request where charge_id=".$inv_id." and lab_type=".$lab_type." "; + $query = $this->db->query($sql); + $data_lab_request_edit= $query->result(); + + if($data_lab_request_edit[0]->no>0) + { + $data_lab_request_edit_str='/'.$data_lab_request_edit[0]->no; + $note_edit_str='Caution : Please ignore the earlier report.'; + }else{ + $data_lab_request_edit_str=''; + $note_edit_str=''; + } + + + $sql="select * , + date_format(l.collected_time,'%d-%m-%Y %h:%i %p') as str_collected_time, + date_format(l.reported_time,'%d-%m-%Y %h:%i %p') as str_reported_time + from lab_invoice_request l + where invoice_id='".$inv_id."' and lab_type='".$lab_type."'"; + $query = $this->db->query($sql); + $lab_invoice_request= $query->result(); + + if(count($data_lab_request)==0) + { + exit( 'No Record Ready for print Report'); + } + + + $sql="select * from invoice_master where id=".$inv_id; + $query = $this->db->query($sql); + $invoice_master= $query->result(); + + $sql="select * + from patient_master_exten p where id=".$invoice_master[0]->attach_id; + $query = $this->db->query($sql); + $data_patient_master= $query->result(); + + if($invoice_master[0]->refer_by_id>0) + { + $sql="select * from doctor_master where id=".$invoice_master[0]->refer_by_id; + $query = $this->db->query($sql); + $doc_master= $query->result(); + $rdoc_name='Dr.'.$doc_master[0]->p_fname; + }else{ + $rdoc_name=$invoice_master[0]->refer_by_other; + } + + $sql="select * from ipd_master where ipd_status=0 and p_id=".$invoice_master[0]->attach_id; + $query = $this->db->query($sql); + $ipd_master= $query->result(); + + + + $insurance_case_id=$invoice_master[0]->insurance_case_id; + + $org_ID=''; + + if($insurance_case_id>1) + { + $sql="select o.* ,i.short_name + from organization_case_master o join hc_insurance i on o.insurance_id=i.id + where o.id=".$insurance_case_id; + $query = $this->db->query($sql); + $org_master= $query->result(); + + if(count($org_master)>0){ + $org_ID='Org. ID: '.$org_master[0]->case_id_code.'
'; + $org_ID.='Org.Name :'.$org_master[0]->short_name.'
'; + } + } + + $ipd_id=''; + + if(count($ipd_master)>0) + { + $ipd_id='IPD No. : '. $ipd_master[0]->ipd_code.'
'; + } + + //$print_datetime=$data_lab_request[0]->Request_Date; + + $print_datetime=date('d-m-Y h:i:s A'); + + + if($lab_invoice_request[0]->collected_time<>'') + { + $Collection_data='
+ Collected : '.$lab_invoice_request[0]->str_collected_time.'
+ Reported : '.$lab_invoice_request[0]->str_reported_time; + } + + $Header=' + + + + + + '; + + $Header.=' +
+ Inovice ID : '.$invoice_master[0]->invoice_code.' '.$data_lab_request_edit_str.'
+ Patient Name : '.$data_patient_master[0]->title.' '.$data_patient_master[0]->p_fname.'
+ '.$data_patient_master[0]->p_relative.' '.$data_patient_master[0]->p_rname.'
+ Age/Sex : '.$data_patient_master[0]->str_age.'/'.$data_patient_master[0]->xgender.'
+ UHID : '.$data_patient_master[0]->p_code.'
+
'.$ipd_id.$org_ID.' + Print Date : '.$print_datetime.'
+ '.$Collection_data.' + Reffered By : '.$rdoc_name.'
+
'.$note_edit_str.' +
'; + + $RawData=""; + $group_name=''; + $first_header=1; + + for($i=0;$iRepoGrp==$group_name) + { + $groupHead=''; + }else{ + if($first_header==0) + { + //$groupHead='
'; + $groupHead=''; + }else{ + $groupHead=''; + } + + $groupHead.=' +

'.$data_lab_request[$i]->RepoGrp.'

'; + + $first_header=0; + } + + $RawData=$RawData.$groupHead; + $RawData=$RawData.$data_lab_request[$i]->Report_Data; + + $group_name=$data_lab_request[$i]->RepoGrp; + + } + + $complete_report=$RawData; + + $inv_req_id=0; + if(count($lab_invoice_request)>0) + { + $inv_req_id=$lab_invoice_request[0]->id; + } + + $this->load->model('PathLab_M'); + + $user = $this->ion_auth->user()->row(); + $user_id = $user->id; + $user_name = $user->first_name.' '. $user->last_name.'['.$user_id.']['.date('d-m-Y h:m:s').']'; + + $udata = array( + 'report_data'=> $complete_report, + 'report_compile'=> $user_name, + 'report_header'=> $Header, + ); + + $sortorder_insert_id=$this->PathLab_M->update_invoice_report($udata,$inv_req_id); + echo 'Data Compile'; + + $filename = $inv_id.'-'.$lab_type.'-'.time() . '.pdf'; + + $folder_name='uploads/'.date('Ymd'); + + if (!file_exists($folder_name)) { + mkdir($folder_name, 0777, true); + chmod($folder_name, 0777); + } + + $lab_file_name=$folder_name.'/'.$filename; + + } + + public function report_compile($inv_id,$lab_type) + { + $sql="select l.*,g.RepoGrp, + date_format(l.collected_time,'%d-%m-%Y %h:%i %p') as str_collected_time, + date_format(l.reported_time,'%d-%m-%Y %h:%i %p') as str_reported_time + FROM (lab_request l join lab_repo r on l.lab_repo_id=r.mstRepoKey) + left join lab_rgroups g on r.GrpKey=g.mstRGrpKey + where l.print_combine=1 and status=2 and l.charge_id=".$inv_id." and l.lab_type=".$lab_type." order by g.sort_order"; + + $query = $this->db->query($sql); + $data_lab_request= $query->result(); + + $sql="Select max(report_edit_req_no) as no + from lab_request where charge_id=".$inv_id." and lab_type=".$lab_type." "; + $query = $this->db->query($sql); + $data_lab_request_edit= $query->result(); + + if($data_lab_request_edit[0]->no>0) + { + $sql="SELECT GROUP_CONCAT(CONCAT_WS('/',l.log_type,l.log_Faults,l.comments,'Report:',r.report_name)) AS report_log + from lab_log l JOIN lab_request r ON l.lab_repo_id=r.id + WHERE r.charge_id=$inv_id AND r.lab_type=$lab_type"; + + $query = $this->db->query($sql); + $data_lab_edit_error= $query->result(); + + $report_log=''; + + if(count($data_lab_edit_error)>0){ + $report_log=$data_lab_edit_error[0]->report_log; + } + + $data_lab_request_edit_str='/'.$data_lab_request_edit[0]->no; + $note_edit_str='Caution : The previous report has been corrected. Please ignore the previous report.
Error Type : '.$report_log; + //$note_edit_str=''; + }else{ + $data_lab_request_edit_str=''; + $note_edit_str=''; + } + + + $sql="select * , + date_format(l.collected_time,'%d-%m-%Y %h:%i %p') as str_collected_time, + date_format(l.reported_time,'%d-%m-%Y %h:%i %p') as str_reported_time + from lab_invoice_request l + where invoice_id='".$inv_id."' and lab_type='".$lab_type."'"; + $query = $this->db->query($sql); + $lab_invoice_request= $query->result(); + + if(count($data_lab_request)==0) + { + exit( 'No Record Ready for print Report'); + } + + + $sql="select * from invoice_master where id=".$inv_id; + $query = $this->db->query($sql); + $invoice_master= $query->result(); + + $sql="select * + from patient_master_exten p where id=".$invoice_master[0]->attach_id; + $query = $this->db->query($sql); + $data_patient_master= $query->result(); + + + if($invoice_master[0]->refer_by_id>0) + { + $sql="select * from doctor_master where id=".$invoice_master[0]->refer_by_id; + $query = $this->db->query($sql); + $doc_master= $query->result(); + $rdoc_name='Dr.'.$doc_master[0]->p_fname; + }else{ + $rdoc_name=$invoice_master[0]->refer_by_other; + } + + $sql="select * from ipd_master where ipd_status=0 and p_id=".$invoice_master[0]->attach_id; + $query = $this->db->query($sql); + $ipd_master= $query->result(); + + + + $insurance_case_id=$invoice_master[0]->insurance_case_id; + + $org_ID=''; + + if($insurance_case_id>1) + { + $sql="select o.* ,i.short_name + from organization_case_master o join hc_insurance i on o.insurance_id=i.id + where o.id=".$insurance_case_id; + $query = $this->db->query($sql); + $org_master= $query->result(); + + if(count($org_master)>0){ + $org_ID='Org. ID: '.$org_master[0]->case_id_code.'
'; + $org_ID.='Org.Name :'.$org_master[0]->short_name.'
'; + } + } + + $ipd_id=''; + + if(count($ipd_master)>0) + { + $ipd_id='IPD No. : '. $ipd_master[0]->ipd_code.''; + } + + //$print_datetime=$data_lab_request[0]->Request_Date; + + $print_datetime=date('d-m-Y h:i:s A'); + + + if($lab_invoice_request[0]->collected_time<>'') + { + $Collection_data='
+ Collected : '.$lab_invoice_request[0]->str_collected_time.'
+ Reported : '.$lab_invoice_request[0]->str_reported_time; + } + + $Header=' + + + + + + + '; + + $Header.=' +
+ Inovice ID : '.$invoice_master[0]->invoice_code.' '.$data_lab_request_edit_str.'
+ Patient Name : '.$data_patient_master[0]->title.' '.$data_patient_master[0]->p_fname.'
+ '.$data_patient_master[0]->p_relative.' '.$data_patient_master[0]->p_rname.'
+ Age/Sex : '.$data_patient_master[0]->str_age.'/'.$data_patient_master[0]->xgender.'
+ UHID : '.$data_patient_master[0]->p_code.'
+
'.$ipd_id.' + '.$Collection_data.' +
Reffered By : '.$rdoc_name.'
+ Page No. : {PAGENO} / {nbpg} +
+ +
'.$note_edit_str.' +
'; + + $RawData=""; + $group_name=''; + $first_header=1; + + for($i=0;$iRepoGrp==$group_name) + { + $groupHead=''; + }else{ + if($first_header==0) + { + //$groupHead='
'; + $groupHead=''; + }else{ + $groupHead=''; + } + + $groupHead.=' +

'.$data_lab_request[$i]->RepoGrp.'

'; + + $first_header=0; + } + + $RawData=$RawData.$groupHead; + $RawData=$RawData.$data_lab_request[$i]->Report_Data; + + $group_name=$data_lab_request[$i]->RepoGrp; + + } + + $complete_report=$RawData; + + $inv_req_id=0; + if(count($lab_invoice_request)>0) + { + $inv_req_id=$lab_invoice_request[0]->id; + } + + $this->load->model('PathLab_M'); + + $user = $this->ion_auth->user()->row(); + $user_id = $user->id; + $user_name = $user->first_name.' '. $user->last_name.'['.$user_id.']['.date('d-m-Y h:m:s').']'; + + $udata = array( + 'report_data'=> $complete_report, + 'report_compile'=> $user_name, + 'report_header'=> $Header, + ); + + $sortorder_insert_id=$this->PathLab_M->update_invoice_report($udata,$inv_req_id); + echo 'Data Compile'; + + $filename = $inv_id.'-'.$lab_type.'-'.time() . '.pdf'; + + $folder_name='uploads/'.date('Ymd'); + + if (!file_exists($folder_name)) { + mkdir($folder_name, 0777, true); + chmod($folder_name, 0777); + } + + $lab_file_name=$folder_name.'/'.$filename; + + } + + public function report_compile_single($inv_id,$lab_type,$req_id,$print=1) + { + $sql="select l.*,g.RepoGrp, + date_format(l.collected_time,'%d-%m-%Y %h:%i %p') as str_collected_time, + date_format(l.reported_time,'%d-%m-%Y %h:%i %p') as str_reported_time + from lab_request l left join (lab_repo r join lab_rgroups g on r.GrpKey=g.mstRGrpKey) + on l.lab_repo_id=r.mstRepoKey + where l.id=".$req_id." and l.charge_id=".$inv_id." and l.lab_type=".$lab_type." order by g.sort_order"; + $query = $this->db->query($sql); + $data['lab_request']=$query->result(); + + $data_lab_request=$data['lab_request']; + + $sql="select * , + date_format(l.collected_time,'%d-%m-%Y %h:%i %p') as str_collected_time, + date_format(l.reported_time,'%d-%m-%Y %h:%i %p') as str_reported_time + from lab_invoice_request l + where invoice_id='".$inv_id."' and lab_type='".$lab_type."'"; + $query = $this->db->query($sql); + $lab_invoice_request= $query->result(); + + $sql="SELECT max(r.report_edit_req_no) as no + from lab_request r JOIN lab_log l ON r.id=l.lab_repo_id + Where r.id=$req_id"; + $query = $this->db->query($sql); + $data_lab_request_edit= $query->result(); + + if($data_lab_request_edit[0]->no>0) + { + $sql="SELECT GROUP_CONCAT(CONCAT_WS('/',l.log_type,l.log_Faults,l.comments,'Report:',r.report_name)) AS report_log + from lab_log l JOIN lab_request r ON l.lab_repo_id=r.id + WHERE r.charge_id=$inv_id AND r.lab_type=$lab_type and l.lab_repo_id=$req_id"; + + $query = $this->db->query($sql); + $data_lab_edit_error= $query->result(); + + $report_log=''; + + if(count($data_lab_edit_error)>0){ + $report_log=$data_lab_edit_error[0]->report_log; + } + + $data_lab_request_edit_str='/'.$data_lab_request_edit[0]->no; + $note_edit_str='Caution : The previous report has been corrected. Please ignore the previous report.
Error Type : '.$report_log; + //$note_edit_str=''; + }else{ + $data_lab_request_edit_str=''; + $note_edit_str=''; + } + + $sql="select * from invoice_master where id=".$inv_id; + $query = $this->db->query($sql); + $invoice_master= $query->result(); + + $sql="select * + from patient_master_exten p where id=".$invoice_master[0]->attach_id; + $query = $this->db->query($sql); + $data_patient_master= $query->result(); + + if($invoice_master[0]->refer_by_id>0) + { + $sql="select * from doctor_master where id=".$invoice_master[0]->refer_by_id; + $query = $this->db->query($sql); + $doc_master= $query->result(); + $rdoc_name='Dr.'.$doc_master[0]->p_fname; + }else{ + $rdoc_name=$invoice_master[0]->refer_by_other; + } + + $sql="select * from ipd_master where ipd_status=0 and p_id=".$invoice_master[0]->attach_id; + $query = $this->db->query($sql); + $ipd_master= $query->result(); + + $ipd_id=''; + + if(count($ipd_master)>0) + { + $ipd_id='IPD No. : '. $ipd_master[0]->ipd_code.'
'; + } + + $insurance_case_id=$invoice_master[0]->insurance_case_id; + + $org_ID=''; + + if($insurance_case_id>1) + { + $sql="select o.* ,i.short_name + from organization_case_master o join hc_insurance i on o.insurance_id=i.id + where o.id=".$insurance_case_id; + $query = $this->db->query($sql); + $org_master= $query->result(); + + if(count($org_master)>0){ + $org_ID='Org. ID: '.$org_master[0]->case_id_code.'
'; + $org_ID.='Org.Name :'.$org_master[0]->short_name.'
'; + } + } + + $print_datetime=$data_lab_request[0]->Request_Date; + + $print_datetime=date('d-m-Y h:i:sa'); + + if($lab_invoice_request[0]->collected_time<>'') + { + $Collection_data=' + Collected : '.$lab_invoice_request[0]->str_collected_time.'
+ Reported : '.$lab_invoice_request[0]->str_reported_time; + } + + + $Header=' + + + + + + '; + + $Header.=' +
+ Inovice ID : '.$invoice_master[0]->invoice_code.'
+ Patient Name : '.$data_patient_master[0]->title.' '.$data_patient_master[0]->p_fname.'
+ '.$data_patient_master[0]->p_relative.' '.$data_patient_master[0]->p_rname.'
+ Age/Sex : '.$data_patient_master[0]->str_age.'/'.$data_patient_master[0]->xgender.'
+ UHID : '.$data_patient_master[0]->p_code.'
+ Reffered By : '.$rdoc_name.'
+
'.$ipd_id.$org_ID.' + + '.$Collection_data.' +
'.$note_edit_str.' +
'; + $RawData=""; + $group_name=''; + $first_header=1; + + for($i=0;$iRepoGrp==$group_name) + { + $groupHead=''; + }else{ + if($first_header==0) + { + //$groupHead='
'; + $groupHead=''; + }else{ + $groupHead=''; + } + + $groupHead.=' +

'.$data_lab_request[$i]->RepoGrp.'

'; + + $first_header=0; + } + + $RawData=$RawData.$groupHead; + $RawData=$RawData.$data_lab_request[$i]->Report_Data; + $group_name=$data_lab_request[$i]->RepoGrp; + } + + $complete_report=$RawData; + + + $inv_req_id=0; + + $sql="select * from diagnosis_head_name where d_type=".$lab_type; + $query = $this->db->query($sql); + $data['lab_head_name']= $query->result(); + + //Report Show in PDF + + $inv_req_id=$lab_invoice_request[0]->id; + //$complete_report=$data['lab_invoice_request'][0]->report_data; + + $sql="select * from hc_item_type where itype_id=".$lab_invoice_request[0]->lab_type; + $query = $this->db->query($sql); + $report_head_row= $query->result(); + + $report_head=$report_head_row[0]->group_desc.' / Invoice ID :'.$invoice_master[0]->invoice_code.' / Person Name :'.$data_patient_master[0]->p_fname; + + $user = $this->ion_auth->user()->row(); + $user_id = $user->id; + $user_name = $user->first_name.''. $user->last_name; + + if($print>0) + { + if(count($data['lab_head_name'])>0) + { + $data['docname']=$data['lab_head_name'][0]->doc_name; + $data['docedu']=$data['lab_head_name'][0]->doc_edu; + $data['tech_name']=$data['lab_head_name'][0]->tech_name; + }else{ + $data['docname']=''; + $data['docedu']=''; + $data['tech_name']=''; + } + + $folder_name='uploads/'.date('Ymd'); + + if (!file_exists($folder_name)) { + mkdir($folder_name, 0777, true); + chmod($folder_name, 0777); + } + + $file_name='Report'.$inv_id."-".$lab_type."-".date('dmYhis').".pdf"; + + $filepath=$folder_name.'/'.$file_name; + + $data['complete_report']=$complete_report; + $data['report_head']=$report_head; + + $data['report_header']=$Header; + + + $data['print_on_type']="0"; + $data['bar_content']=$inv_id.'-'.$lab_type; + //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 = false; + + + $filepath=$file_name; + + //$this->load->view('Medical/medical_bill_print_format',$data); + $content=$this->load->view('Lab_Panel/patient_lab_report',$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"); + + + }else{ + $this->load->view('Lab_Panel/lab_single_report',$data); + } + } + + public function report_compile_xray_single($inv_id,$lab_type,$req_id,$print=1,$print_on_type=0) + { + $sql="select l.*,g.RepoGrp, + date_format(l.collected_time,'%d-%m-%Y %h:%i %p') as str_collected_time, + date_format(l.reported_time,'%d-%m-%Y %h:%i %p') as str_reported_time + from lab_request l left join (lab_repo r join lab_rgroups g on r.GrpKey=g.mstRGrpKey) + on l.lab_repo_id=r.mstRepoKey + where l.id=".$req_id." and l.charge_id=".$inv_id." and l.lab_type=".$lab_type." order by g.sort_order"; + $query = $this->db->query($sql); + $data['lab_request']=$query->result(); + + $data_lab_request=$data['lab_request']; + + $sql="select * , + date_format(l.collected_time,'%d-%m-%Y %h:%i %p') as str_collected_time, + date_format(l.reported_time,'%d-%m-%Y %h:%i %p') as str_reported_time + from lab_invoice_request l + where invoice_id='".$inv_id."' and lab_type='".$lab_type."'"; + $query = $this->db->query($sql); + $lab_invoice_request= $query->result(); + + $sql="select * from invoice_master where id=".$inv_id; + $query = $this->db->query($sql); + $invoice_master= $query->result(); + + $sql="select * + from patient_master_exten p where id=".$invoice_master[0]->attach_id; + $query = $this->db->query($sql); + $data_patient_master= $query->result(); + + if($invoice_master[0]->refer_by_id>0) + { + $sql="select * from doctor_master where id=".$invoice_master[0]->refer_by_id; + $query = $this->db->query($sql); + $doc_master= $query->result(); + $rdoc_name='Dr.'.$doc_master[0]->p_fname; + }else{ + $rdoc_name=$invoice_master[0]->refer_by_other; + } + + $sql="select * from ipd_master where ipd_status=0 and p_id=".$invoice_master[0]->attach_id; + $query = $this->db->query($sql); + $ipd_master= $query->result(); + + $ipd_id=''; + + if(count($ipd_master)>0) + { + $ipd_id='IPD No. : '. $ipd_master[0]->ipd_code.'
'; + } + + $insurance_case_id=$invoice_master[0]->insurance_case_id; + + $org_ID=''; + + if($insurance_case_id>1) + { + $sql="select o.* ,i.short_name + from organization_case_master o join hc_insurance i on o.insurance_id=i.id + where o.id=".$insurance_case_id; + $query = $this->db->query($sql); + $org_master= $query->result(); + + if(count($org_master)>0){ + $org_ID='Org. ID: '.$org_master[0]->case_id_code.'
'; + $org_ID.='Org.Name :'.$org_master[0]->short_name.'
'; + } + } + + $print_datetime=$data_lab_request[0]->Request_Date; + $print_datetime=date('d-m-Y h:i:sa'); + + if($lab_invoice_request[0]->collected_time<>'') + { + $Collection_data=' + Report Time : '.$lab_invoice_request[0]->str_reported_time; + } + + $Header=' + + + + + + '; + + $Header.=' +
+ Patient Name : '.$data_patient_master[0]->title.' '.$data_patient_master[0]->p_fname.'
+ '.$data_patient_master[0]->p_relative.' '.$data_patient_master[0]->p_rname.'
+ Age/Sex : '.$data_patient_master[0]->str_age.'/'.$data_patient_master[0]->xgender.'
+ Reffered By : '.$rdoc_name.'
+
+ Inovice ID : '.$invoice_master[0]->invoice_code.'
+ UHID : '.$data_patient_master[0]->p_code.'
+ '.$ipd_id.$org_ID.' + '.$Collection_data.' +
+
'; + $RawData=""; + + if(count($data_lab_request)>0) + { + $groupHead='

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

'; + + $RawData=$RawData.$groupHead; + $RawData=trim($RawData.$data_lab_request[0]->Report_Data); + $report_data_Impression="

Impression : ".nl2br($data_lab_request[0]->report_data_Impression).'

'; + $RawData=$RawData.$report_data_Impression; + } + + $complete_report=$RawData; + + $sql="select * from diagnosis_head_name where d_type=".$lab_type; + $query = $this->db->query($sql); + $data['lab_head_name']= $query->result(); + + //Report Show in PDF + + $inv_req_id=$lab_invoice_request[0]->id; + //$complete_report=$data['lab_invoice_request'][0]->report_data; + + $sql="select * from hc_item_type where itype_id=".$lab_invoice_request[0]->lab_type; + $query = $this->db->query($sql); + $report_head_row= $query->result(); + + $report_head=$report_head_row[0]->group_desc.' / Invoice ID :'.$invoice_master[0]->invoice_code.' / Person Name :'.$data_patient_master[0]->p_fname; + + $user = $this->ion_auth->user()->row(); + $user_id = $user->id; + $user_name = $user->first_name.''. $user->last_name; + + if($print>0) + { + if(count($data['lab_head_name'])>0) + { + $data['docname']=$data['lab_head_name'][0]->doc_name; + $data['docedu']=$data['lab_head_name'][0]->doc_edu; + $data['tech_name']=$data['lab_head_name'][0]->tech_name; + $data['print_format_head_page']=$data['lab_head_name'][0]->print_format_head_page; + $data['print_page_direct']=$data['lab_head_name'][0]->print_format_head_page; + }else{ + $data['docname']=''; + $data['docedu']=''; + $data['tech_name']=''; + $data['print_format_head_page']='patient_lab_xray_report'; + $data['print_page_direct']='patient_lab_xray_report'; + } + + $folder_name='uploads/'.date('Ymd'); + + if (!file_exists($folder_name)) { + mkdir($folder_name, 0777, true); + chmod($folder_name, 0777); + } + + $file_name='Report'.$inv_id."-".$lab_type."-".date('dmYhis').".pdf"; + + $filepath=$folder_name.'/'.$file_name; + + $data['complete_report']=$complete_report; + $data['report_head']=$report_head; + $data['report_header']=$Header; + + + $data['print_on_type']=$print_on_type; + $data['bar_content']=$inv_id.'-'.$lab_type; + //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 = false; + + $this->m_pdf->pdf->setAutoBottomMargin='pad'; + + $filepath=$file_name; + + if($print_on_type=0){ + $content=$this->load->view('Lab_Panel/'.$data['print_format_head_page'],$data,TRUE); + }else{ + $content=$this->load->view('Lab_Panel/'.$data['print_page_direct'],$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"); + }else{ + $this->load->view('Lab_Panel/lab_single_report',$data); + } + } + + public function report_compile_edit($inv_id,$lab_type,$req_id,$print=1) + { + $sql="select l.*,g.RepoGrp + from lab_request l left join (lab_repo r join lab_rgroups g on r.GrpKey=g.mstRGrpKey) + on l.lab_repo_id=r.mstRepoKey + where l.id=".$req_id." and l.charge_id=".$inv_id." and l.lab_type=".$lab_type." order by g.sort_order"; + //echo $sql; + $query = $this->db->query($sql); + $data_lab_request= $query->result(); + + $sql="select * from invoice_master where id=".$inv_id; + $query = $this->db->query($sql); + $invoice_master= $query->result(); + + $sql="select * + from patient_master_exten p where id=".$invoice_master[0]->attach_id; + $query = $this->db->query($sql); + $data_patient_master= $query->result(); + + + + + if($invoice_master[0]->refer_by_id>0) + { + $sql="select * from doctor_master where id=".$invoice_master[0]->refer_by_id; + $query = $this->db->query($sql); + $doc_master= $query->result(); + $rdoc_name='Dr.'.$doc_master[0]->p_fname; + }else{ + $rdoc_name=$invoice_master[0]->refer_by_other; + } + + $sql="select * from ipd_master where ipd_status=0 and p_id=".$invoice_master[0]->attach_id; + $query = $this->db->query($sql); + $ipd_master= $query->result(); + + $ipd_id=''; + + if(count($ipd_master)>0) + { + $ipd_id='IPD No. : '. $ipd_master[0]->ipd_code.'
'; + } + $print_datetime=$data_lab_request[0]->Request_Date; + + $print_datetime=date('d-m-Y h:i:sa'); + + if($data_lab_request[0]->collected_time<>'') + { + $Collection_data=' + Collected : '.$data_lab_request[0]->collected_time.'
+ Reported : '.$data_lab_request[0]->reported_time; + + } + + $Header=' + + + + + + '; + + $Header.=' +
+ Inovice ID : '.$invoice_master[0]->invoice_code.'
+ Patient Name : '.$data_patient_master[0]->p_fname.'
+ Age/Sex : '.$data_patient_master[0]->str_age.'/'.$data_patient_master[0]->xgender.'
+ UHID : '.$data_patient_master[0]->p_code.'
+ Reffered By : '.$rdoc_name.'
+
'.$ipd_id.'
+ Print Date : '.$print_datetime.'
+ '.$Collection_data.' +
+
'; + $RawData=""; + $group_name=''; + $first_header=1; + + for($i=0;$iRepoGrp==$group_name) + { + $groupHead=''; + }else{ + if($first_header==0) + { + //$groupHead='
'; + $groupHead=''; + }else{ + $groupHead=''; + } + + $groupHead.=' +

'.$data_lab_request[$i]->RepoGrp.'

'; + + $first_header=0; + } + + $RawData=$RawData.$groupHead; + $RawData=$RawData.$data_lab_request[$i]->Report_Data; + + $group_name=$data_lab_request[$i]->RepoGrp; + + } + + $complete_report=$Header.'
'.$RawData; + + $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(); + + $inv_req_id=0; + + $sql="select * from diagnosis_head_name where d_type=".$lab_type; + $query = $this->db->query($sql); + $data['lab_head_name']= $query->result(); + + //Report Show in PDF + + $inv_req_id=$data['lab_invoice_request'][0]->id; + //$complete_report=$data['lab_invoice_request'][0]->report_data; + + $sql="select * from hc_item_type where itype_id=".$data['lab_invoice_request'][0]->lab_type; + $query = $this->db->query($sql); + $report_head_row= $query->result(); + + $report_head=$report_head_row[0]->group_desc.' / Invoice ID :'.$invoice_master[0]->invoice_code.' / Person Name :'.$data_patient_master[0]->p_fname; + + $user = $this->ion_auth->user()->row(); + $user_id = $user->id; + $user_name = $user->first_name.''. $user->last_name; + + if($print>0) + { + if(count($data['lab_head_name'])>0) + { + $docname=$data['lab_head_name'][0]->doc_name; + $docedu=$data['lab_head_name'][0]->doc_edu; + $tech_name=$data['lab_head_name'][0]->tech_name; + }else{ + $docname=''; + $docedu=''; + $tech_name=''; + } + + $folder_name='uploads/'.date('Ymd'); + + if (!file_exists($folder_name)) { + mkdir($folder_name, 0777, true); + chmod($folder_name, 0777); + } + + $file_name='Report'.$inv_id."-".$lab_type."-".date('dmYhis').".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'=>$invoice_master[0]->attach_id, + 'ipd_id'=>$invoice_master[0]->ipd_id, + 'case_id'=>$invoice_master[0]->insurance_case_id, + 'file_desc'=>$report_head, + 'charge_id'=>$invoice_master[0]->id, + 'charge_type' => $lab_type + ); + + $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_lab_report_pdf($complete_report,$filepath,'',$report_head,$docname,$docedu,$tech_name); + + }else{ + $this->load->view('PathLab_Report/lab_final_print',$data); + } + } + + public function report_remove($inv_id,$lab_type,$item_id) + { + $this->load->model('PathLab_M'); + $this->PathLab_M->delete_request_entry($item_id); + + echo 'Item Removed'; + + } + + public function Update_CombineReport() + { + $this->load->model('PathLab_M'); + + $item_id=$this->input->post('item_id'); + $checked=$this->input->post('checked'); + + $udata = array( + 'print_combine'=> $checked + ); + + $this->PathLab_M->update_test_request($udata,$item_id); + + echo "Saved"; + + } + + public function Update_Report_time() + { + $this->load->model('PathLab_M'); + + $datetimepicker1=$this->input->post('datetimepicker1'); + $datetimepicker2=$this->input->post('datetimepicker2'); + $inv_id=$this->input->post('inv_id'); + $lab_type=$this->input->post('lab_type'); + + $sql="select * from lab_invoice_request where invoice_id='".$inv_id."' and lab_type='".$lab_type."'"; + $query = $this->db->query($sql); + $lab_invoice_request= $query->result(); + + if(count($lab_invoice_request)>0) + { + $rec_id=$lab_invoice_request[0]->id; + + $udata = array( + 'collected_time'=> $datetimepicker1, + 'reported_time'=> $datetimepicker2 + ); + + $this->PathLab_M->update_invoice_report($udata,$rec_id); + } + + echo "Saved"; + } + + public function show_print_final_edit($inv_id,$lab_type,$print=0) + { + $user = $this->ion_auth->user()->row(); + $user_id = $user->id; + $user_name = $user->first_name.''. $user->last_name; + + $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(); + + $sql="select * from invoice_master where id='".$inv_id."'"; + $query = $this->db->query($sql); + $data_invoice_master= $query->result(); + + $sql="select * from patient_master_exten where id='".$data_invoice_master[0]->attach_id."'"; + $query = $this->db->query($sql); + $data_person_master= $query->result(); + + $sql="select * from diagnosis_head_name where d_type=".$lab_type; + $query = $this->db->query($sql); + $data['lab_head_name']= $query->result(); + + $inv_req_id=0; + if(count($data['lab_invoice_request'])>0) + { + $inv_req_id=$data['lab_invoice_request'][0]->id; + $complete_report=$data['lab_invoice_request'][0]->report_data; + + $sql="select * from hc_item_type where itype_id=".$data['lab_invoice_request'][0]->lab_type; + $query = $this->db->query($sql); + $report_head_row= $query->result(); + + $report_head=$report_head_row[0]->group_desc.' / Invoice ID :'.$data_invoice_master[0]->invoice_code.' / Person Name :'.$data_person_master[0]->p_fname; + + $sql="select * from invoice_master where id=".$data['lab_invoice_request'][0]->invoice_id; + $query = $this->db->query($sql); + $report_invoice_info= $query->result(); + + if($print>0) + { + if(count($data['lab_head_name'])>0) + { + $docname=$data['lab_head_name'][0]->doc_name; + $docedu=$data['lab_head_name'][0]->doc_edu; + $tech_name=$data['lab_head_name'][0]->tech_name; + }else{ + $docname=''; + $docedu=''; + $tech_name=''; + } + + $folder_name='uploads/'.date('Ymd'); + + if (!file_exists($folder_name)) { + mkdir($folder_name, 0777, true); + chmod($folder_name, 0777); + } + + $file_name='Report'.$inv_id."-".$lab_type."-".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'=>$data_invoice_master[0]->attach_id, + 'ipd_id'=>$data_invoice_master[0]->ipd_id, + 'case_id'=>$data_invoice_master[0]->insurance_case_id, + 'file_desc'=>$report_head, + 'charge_id'=>$data_invoice_master[0]->id + ); + + $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); + } + + $this->load->model('PathLab_M'); + + $rec_id=$data['lab_invoice_request'][0]->id; + + $udata = array( + 'report_print_status'=> '1', + 'report_print_time'=> date('Y-m-d h:i:s'), + ); + + $this->PathLab_M->update_invoice_report($udata,$rec_id); + + //create_lab_report_pdf($complete_report,$filepath,'',$report_head,$docname,$docedu,$tech_name); + create_Document_logo_pdf($complete_report,$filepath,'',$report_head,$docname,$docedu,$tech_name); + + //load mPDF library + + }else{ + $this->load->view('PathLab_Report/lab_final_print',$data); + } + }else{ + echo 'Error : Record not Exist in lab_invoice_request'; + } + + } + + public function final_edit_single_report($inv_id,$lab_type,$print=0) + { + $user = $this->ion_auth->user()->row(); + $user_id = $user->id; + $user_name = $user->first_name.''. $user->last_name; + + $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(); + + $sql="select * from invoice_master where id='".$inv_id."'"; + $query = $this->db->query($sql); + $data_invoice_master= $query->result(); + + $sql="select * from patient_master_exten where id='".$data_invoice_master[0]->attach_id."'"; + $query = $this->db->query($sql); + $data_person_master= $query->result(); + + $sql="select * from diagnosis_head_name where d_type=".$lab_type; + $query = $this->db->query($sql); + $data['lab_head_name']= $query->result(); + + $inv_req_id=0; + if(count($data['lab_invoice_request'])>0) + { + $inv_req_id=$data['lab_invoice_request'][0]->id; + $complete_report=$data['lab_invoice_request'][0]->report_data; + + $sql="select * from hc_item_type where itype_id=".$data['lab_invoice_request'][0]->lab_type; + $query = $this->db->query($sql); + $report_head_row= $query->result(); + + $report_head=$report_head_row[0]->group_desc.' / Invoice ID :'.$data_invoice_master[0]->invoice_code.' / Person Name :'.$data_person_master[0]->p_fname; + + $sql="select * from invoice_master where id=".$data['lab_invoice_request'][0]->invoice_id; + $query = $this->db->query($sql); + $report_invoice_info= $query->result(); + + if($print>0) + { + if(count($data['lab_head_name'])>0) + { + $docname=$data['lab_head_name'][0]->doc_name; + $docedu=$data['lab_head_name'][0]->doc_edu; + $tech_name=$data['lab_head_name'][0]->tech_name; + }else{ + $docname=''; + $docedu=''; + $tech_name=''; + } + + $folder_name='uploads/'.date('Ymd'); + + if (!file_exists($folder_name)) { + mkdir($folder_name, 0777, true); + chmod($folder_name, 0777); + } + + $file_name='Report'.$inv_id."-".$lab_type."-".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'=>$data_invoice_master[0]->attach_id, + 'ipd_id'=>$data_invoice_master[0]->ipd_id, + 'case_id'=>$data_invoice_master[0]->insurance_case_id, + 'file_desc'=>$report_head, + 'charge_id'=>$data_invoice_master[0]->id + ); + + $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_lab_report_pdf($complete_report,$filepath,'',$report_head,$docname,$docedu,$tech_name); + create_Document_logo_pdf($complete_report,$filepath,'',$report_head,$docname,$docedu,$tech_name); + + //load mPDF library + + }else{ + $this->load->view('PathLab_Report/lab_final_print',$data); + } + }else{ + echo 'Error : Record not Exist in lab_invoice_request'; + } + + } + + + + public function print_pdf_create($inv_id,$lab_type,$print=0,$print_on_type=0) + { + + $this->load->model('PathLab_M'); + + $user = $this->ion_auth->user()->row(); + $user_id = $user->id; + $user_name = $user->first_name.''. $user->last_name; + + $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(); + + $sql="Select max(report_edit_req_no) as no + from lab_request where charge_id=".$inv_id." and lab_type=".$lab_type." "; + $query = $this->db->query($sql); + $data_lab_request_edit= $query->result(); + + if($data_lab_request_edit[0]->no>0) + { + $data_lab_request_edit_str='/'.$data_lab_request_edit[0]->no; + $note_edit_str='Caution : Please ignore the earlier report.'; + }else{ + $data_lab_request_edit_str=''; + $note_edit_str=''; + } + + $sql="select * from invoice_master where id='".$inv_id."'"; + $query = $this->db->query($sql); + $data_invoice_master= $query->result(); + + $sql="select * from patient_master_exten where id='".$data_invoice_master[0]->attach_id."'"; + $query = $this->db->query($sql); + $data_person_master= $query->result(); + + $sql="select * from diagnosis_head_name where d_type=".$lab_type; + $query = $this->db->query($sql); + $data['lab_head_name']= $query->result(); + + $inv_req_id=0; + if(count($data['lab_invoice_request'])>0) + { + $inv_req_id=$data['lab_invoice_request'][0]->id; + $data['complete_report']=$data['lab_invoice_request'][0]->report_data; + $data['report_header']=$data['lab_invoice_request'][0]->report_header; + + $sql="select * from hc_item_type where itype_id=".$data['lab_invoice_request'][0]->lab_type; + $query = $this->db->query($sql); + $report_head_row= $query->result(); + + $report_head=$report_head_row[0]->group_desc.' / Invoice ID :'.$data_invoice_master[0]->invoice_code.$data_lab_request_edit_str.' / Person Name :'.$data_person_master[0]->p_fname; + + $sql="select * from invoice_master where id=".$data['lab_invoice_request'][0]->invoice_id; + $query = $this->db->query($sql); + $report_invoice_info= $query->result(); + + if($print>0) + { + $page_format='patient_lab_report'; + $page_format_head='patient_lab_report'; + + if(count($data['lab_head_name'])>0) + { + $docname=$data['lab_head_name'][0]->doc_name; + $docedu=$data['lab_head_name'][0]->doc_edu; + $tech_name=$data['lab_head_name'][0]->tech_name; + $page_format=$data['lab_head_name'][0]->print_format_head_page; + $page_format_head=$data['lab_head_name'][0]->print_page_direct; + }else{ + $docname=''; + $docedu=''; + $tech_name=''; + } + + $data['docname']=$docname; + $data['docedu']=$docedu; + $data['tech_name']=$tech_name; + + $folder_name='uploads/'.date('Ymd'); + + if (!file_exists($folder_name)) { + mkdir($folder_name, 0777, true); + chmod($folder_name, 0777); + } + + $file_name='Report-'.$inv_id."-".$lab_type."-".date('Ymd-his').".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'=>$data_invoice_master[0]->attach_id, + 'ipd_id'=>$data_invoice_master[0]->ipd_id, + 'case_id'=>$data_invoice_master[0]->insurance_case_id, + 'file_desc'=>$report_head, + 'charge_id'=>$data_invoice_master[0]->id + ); + + $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(); + + $file_ID=0; + + if(count($check_file_exist)<1){ + $file_ID=$this->File_M->insert($udata); + + }else + { + $this->File_M->update($udata,$check_file_exist[0]->id); + $file_ID=$check_file_exist[0]->id; + } + + $Lab_reg_data = array( + 'file_id'=>$file_ID, + ); + + $this->PathLab_M->update_invoice_report($Lab_reg_data,$data['lab_invoice_request'][0]->id); + + $data['report_head']=$report_head; + + //load mPDF library + $this->load->library('m_pdf'); + + + $data['bar_content']=$inv_id.'-'.$lab_type; + $data["print_on_type"]=$print_on_type; + $data["data_lab_request_edit_str"]=$data_lab_request_edit_str; + $data['note_edit_str']=$note_edit_str; + + if($print_on_type==1) + { + $content=$this->load->view('Lab_Panel/'.$page_format_head,$data,TRUE); + }else{ + $content=$this->load->view('Lab_Panel/'.$page_format,$data,TRUE); + } + + + //$this->m_pdf->pdf->curlAllowUnsafeSslRequests = true; + + $this->m_pdf->pdf->shrink_tables_to_fit = 1; + + //generate the PDF from the given html + $this->m_pdf->pdf->WriteHTML($content); + + $this->m_pdf->pdf->Output($filepath,"I"); + + //echo $content; + }else{ + $this->load->view('PathLab_Report/lab_final_print',$data); + } + }else{ + echo 'Error : Record not Exist in lab_invoice_request'; + } + + } + + + public function add_test_repo($repo_id,$test_id) + { + $sql="select * from lab_repotests where mstRepoKey=".$repo_id." and mstTestKey=".$test_id; + $query = $this->db->query($sql); + $data['lab_repotests_chk']= $query->result(); + + if(count($data['lab_repotests_chk'])<1) + { + $this->load->model('PathLab_M'); + + $sql="select Max(EOrder) as MEOrder from lab_repotests where mstRepoKey=".$repo_id; + $query = $this->db->query($sql); + $data['lab_repotests']= $query->result(); + + $MEOrder=0; + if(count($data['lab_repotests'])>0) + { + $MEOrder=$data['lab_repotests'][0]->MEOrder; + } + + if($MEOrder === NULL) + { + $MEOrder=1; + }else{ + $MEOrder=$MEOrder+1; + } + + $udata = array( + 'mstRepoKey'=> $repo_id, + 'mstTestKey'=> $test_id, + 'EOrder'=> $MEOrder + ); + + $sortorder_insert_id=$this->PathLab_M->insert_item_sortorder($udata); + + $showcontent=Show_Alert('success','Saved','Add successfully'); + + }else{ + $sortorder_insert_id=0; + $showcontent=Show_Alert('error','Already....','Already Added'); + } + + $rvar=array( + 'insertid' => $sortorder_insert_id, + 'showcontent'=> $showcontent + ); + + $encode_data = json_encode($rvar); + echo $encode_data; + + } + + public function remove_test_item($repo_id,$test_id) + { + $this->db->delete("lab_repotests", "mstRepoKey=".$repo_id." and mstTestKey=".$test_id); + + } + + public function test_item_search() + { + $Test_Name=$this->input->post('input_Test_name'); + $repo_id=$this->input->post('repo_id'); + + $sql="select * from lab_tests where Test like '%".$Test_Name."%'"; + $query = $this->db->query($sql); + $search_result= $query->result(); + + echo ''; + for($i=0;$i'; + } + + echo '
'.$search_result[$i]->Test.'[ '.$search_result[$i]->TestID.' ]
'; + + } + + public function lab_file_scan($repo_id,$test_id) + { + $data['repo_id']=$repo_id; + $data['test_id']=$test_id; + + $this->load->view('PathLab_Report/lab_file_scan',$data); + } + + public function lab_file_scan_complete($repo_id,$lab_type) + { + $data['repo_id']=$repo_id; + $data['lab_type']=$lab_type; + + $this->load->view('PathLab_Report/lab_file_scan_whole',$data); + } + + public function lab_file_upload($repo_id,$test_id) + { + $data['repo_id']=$repo_id; + $data['test_id']=$test_id; + + $this->load->view('PathLab_Report/lab_file_upload',$data); + } + + public function lab_file_upload_complete($inv_id,$lab_type) + { + $data['inv_id']=$inv_id; + $data['lab_type']=$lab_type; + + $this->load->view('PathLab_Report/lab_file_upload_complete',$data); + } + + public function save_image($repo_id,$test_id) + { + $filename = $repo_id.'-'.$test_id.'-'.time() . '.jpg'; + + $folder_name='uploads/'.date('Ymd'); + + if (!file_exists($folder_name)) { + mkdir($folder_name, 0777, true); + chmod($folder_name, 0777); + } + + $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|dcm'; + + //$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('File_M'); + + $file_insert_id=$this->File_M->insert($data['upload_data']); + + $sql="select * from lab_request where id=".$repo_id; + $query = $this->db->query($sql); + $lab_request_result= $query->result(); + + $pid=0; + $ipd_id=0; + $org_id=0; + + if(count($lab_request_result)>0) + { + $pid=$lab_request_result[0]->patient_id; + $ipd_id=$lab_request_result[0]->ipd_id; + $org_id=$lab_request_result[0]->org_id; + $charge_type=$lab_request_result[0]->lab_type; + $inv_id=$lab_request_result[0]->charge_id; + } + + $udata = array( + 'repo_id'=> $repo_id, + 'repo_test_id'=> $test_id, + 'upload_by'=> $user_name, + 'pid'=>$pid, + 'ipd_id'=>$ipd_id, + 'case_id'=>$org_id, + 'charge_type'=> $charge_type, + 'charge_id'=>$inv_id, + ); + + if($file_insert_id>0) + { + $this->File_M->update($udata,$file_insert_id); + } + + echo $filename; + } + } + + public function save_image_complete($inv_id,$lab_type) + { + $filename = $inv_id.'-'.$lab_type.'-'.time() . '.jpg'; + + $folder_name='uploads/'.date('Ymd'); + + if (!file_exists($folder_name)) { + mkdir($folder_name, 0777, true); + chmod($folder_name, 0777); + } + + $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('File_M'); + + $file_insert_id=$this->File_M->insert($data['upload_data']); + + $sql="select * from lab_request where charge_id=$inv_id and lab_type=$lab_type" ; + $query = $this->db->query($sql); + $lab_request_result= $query->result(); + + + $pid=0; + $ipd_id=0; + $org_id=0; + + + if(count($lab_request_result)>0) + { + $pid=$lab_request_result[0]->patient_id; + $ipd_id=$lab_request_result[0]->ipd_id; + $org_id=$lab_request_result[0]->org_id; + $charge_type=$lab_request_result[0]->lab_type; + $repo_id=$lab_request_result[0]->id; + } + + $udata = array( + 'repo_id'=> $repo_id, + 'upload_by'=> $user_name, + 'pid'=>$pid, + 'ipd_id'=>$ipd_id, + 'case_id'=>$org_id, + 'charge_type'=> $lab_type, + 'charge_id'=>$inv_id, + ); + + if($file_insert_id>0) + { + $this->File_M->update($udata,$file_insert_id); + } + + echo $filename; + } + } + + public function process_ajax() + { + $output_dir = "uploads/"; + + if(isset($_FILES["myfile"])) + { + $ret = array(); + + $error = $_FILES["myfile"]["error"]; + + // upload single file + if(!is_array($_FILES["myfile"]["name"])) //single file + { + $fileName = $_FILES["myfile"]["name"]; + move_uploaded_file($_FILES["myfile"]["tmp_name"],$output_dir.$fileName); + $ret[]= $fileName; + } + else + { + // Handle Multiple files + $fileCount = count($_FILES["myfile"]["name"]); + for($i=0; $i<$fileCount; $i++) + { + $fileName = $_FILES["myfile"]["name"][$i]; + move_uploaded_file($_FILES["myfile"]["tmp_name"][$i],$output_dir.$fileName); + $ret[]= $fileName; + } + } + // output file names as comma seperated strings to display status + echo json_encode($ret); + } + } + + public function lab_file_list($repo_id,$lab_type) + { + $sql="select * from file_upload_data + where repo_id=".$repo_id." and repo_test_id=".$lab_type; + $query = $this->db->query($sql); + $data['lab_file_list']= $query->result(); + + $this->load->view('PathLab_Report/lab_report_file_show',$data); + + } + + public function lab_file_list_all($inv_id,$lab_type) + { + $sql="select * from file_upload_data + where charge_id=$inv_id and charge_type=$lab_type"; + $query = $this->db->query($sql); + $data['lab_file_list']= $query->result(); + + + + $this->load->view('PathLab_Report/lab_report_file_show',$data); + + } + + public function render_file($file_id) + { + $sql="select * from file_upload_data where id=".$file_id; + $query = $this->db->query($sql); + $data['lab_file_details']= $query->result(); + + $this->load->view('PathLab_Report/lab_file_show',$data); + } + + public function lab_files_upload($repo_id,$test_id) + { + + $folder_name='uploads/'.date('Ymd'); + + if (!file_exists($folder_name)) { + mkdir($folder_name, 0777, true); + chmod($folder_name, 0777); + } + + $user = $this->ion_auth->user()->row(); + $user_id = $user->id; + $user_name = $user->first_name.''. $user->last_name; + + $output_dir = $folder_name; + + if(isset($_FILES["myfile"])) + { + $ret = array(); + + $error = $_FILES["myfile"]["error"]; + + // upload single file + if(!is_array($_FILES["myfile"]["name"])) //single file + { + $filename = $repo_id.'-'.$test_id.'-'.time() .$_FILES["myfile"]["name"]; + $config['upload_path'] = $folder_name; + $config['file_name'] = $filename; + $config['allowed_types'] = 'gif|jpg|png|jpeg|pdf|doc'; + + $this->load->library('upload', $config); + echo $filename; + //move_uploaded_file($_FILES["myfile"]["tmp_name"],$output_dir.$fileName); + + if (!$this->upload->do_upload('myfile')) { + $error = array('error' => $this->upload->display_errors()); + echo $error['error']; + }else{ + $data = array('upload_data' => $this->upload->data()); + $this->load->model('File_M'); + $file_insert_id=$this->File_M->insert($data['upload_data']); + + $sql="select * from lab_request where id=".$repo_id; + $query = $this->db->query($sql); + $lab_request_result= $query->result(); + + $pid=0; + $ipd_id=0; + $org_id=0; + + if(count($lab_request_result)>0) + { + $pid=$lab_request_result[0]->patient_id; + $ipd_id=$lab_request_result[0]->ipd_id; + $org_id=$lab_request_result[0]->org_id; + $charge_type=$lab_request_result[0]->lab_type; + $inv_id=$lab_request_result[0]->charge_id; + } + + $udata = array( + 'repo_id'=> $repo_id, + 'repo_test_id'=> $test_id, + 'charge_type'=> $charge_type, + 'charge_id'=>$inv_id, + 'upload_by'=> $user_name, + 'pid'=>$pid, + 'ipd_id'=>$ipd_id, + 'case_id'=>$org_id + ); + + if($file_insert_id>0) + { + $this->File_M->update($udata,$file_insert_id); + } + + } + + $ret[]= $_FILES["myfile"]["name"]; + } + else + { + // Handle Multiple files + $fileCount = count($_FILES["myfile"]["name"]); + for($i=0; $i<$fileCount; $i++) + { + $filename = $repo_id.'-'.$test_id.'-'.time() .$_FILES["myfile"]["name"][$i]; + + //$fileName = $_FILES["myfile"]["name"][$i]; + //move_uploaded_file($_FILES["myfile"]["tmp_name"][$i],$output_dir.$fileName); + + if (!$this->upload->do_upload($_FILES["myfile"]["tmp_name"][$i])) { + $error = array('error' => $this->upload->display_errors()); + echo $error['error']; + }else{ + $data = array('upload_data' => $this->upload->data()); + $this->load->model('File_M'); + $file_insert_id=$this->File_M->insert($data['upload_data']); + + $sql="select * from lab_request where id=".$repo_id; + $query = $this->db->query($sql); + $lab_request_result= $query->result(); + + $pid=0; + $ipd_id=0; + $org_id=0; + + if(count($lab_request_result)>0) + { + $pid=$lab_request_result[0]->patient_id; + $ipd_id=$lab_request_result[0]->ipd_id; + $org_id=$lab_request_result[0]->org_id; + $charge_type=$lab_request_result[0]->lab_type; + $inv_id=$lab_request_result[0]->charge_id; + } + + $udata = array( + 'repo_id'=> $repo_id, + 'repo_test_id'=> $test_id, + 'charge_type'=> $charge_type, + 'charge_id'=>$inv_id, + 'upload_by'=> $user_name, + 'pid'=>$pid, + 'ipd_id'=>$ipd_id, + 'case_id'=>$org_id + ); + + if($file_insert_id>0) + { + $this->File_M->update($udata,$file_insert_id); + } + } + + $ret[]= $_FILES["myfile"]["name"][$i]; + } + } + // output file names as comma seperated strings to display status + echo json_encode($ret); + } + } + + public function lab_files_upload_complete($inv_id,$lab_type) + { + + $folder_name='uploads/'.date('Ymd'); + + if (!file_exists($folder_name)) { + mkdir($folder_name, 0777, true); + chmod($folder_name, 0777); + } + + $user = $this->ion_auth->user()->row(); + $user_id = $user->id; + $user_name = $user->first_name.''. $user->last_name; + + $output_dir = $folder_name; + + if(isset($_FILES["myfile"])) + { + $ret = array(); + + $error = $_FILES["myfile"]["error"]; + + // upload single file + if(!is_array($_FILES["myfile"]["name"])) //single file + { + $filename = $inv_id.'-'.$lab_type.'-'.time() .$_FILES["myfile"]["name"]; + $config['upload_path'] = $folder_name; + $config['file_name'] = $filename; + $config['allowed_types'] = 'gif|jpg|png|jpeg|pdf|doc'; + + $this->load->library('upload', $config); + echo $filename; + //move_uploaded_file($_FILES["myfile"]["tmp_name"],$output_dir.$fileName); + + if (!$this->upload->do_upload('myfile')) { + $error = array('error' => $this->upload->display_errors()); + echo $error['error']; + }else{ + $data = array('upload_data' => $this->upload->data()); + $this->load->model('File_M'); + $file_insert_id=$this->File_M->insert($data['upload_data']); + + $sql="select * from lab_request where charge_id=$inv_id and lab_type=$lab_type" ; + $query = $this->db->query($sql); + $lab_request_result= $query->result(); + + $pid=0; + $ipd_id=0; + $org_id=0; + + if(count($lab_request_result)>0) + { + $pid=$lab_request_result[0]->patient_id; + $ipd_id=$lab_request_result[0]->ipd_id; + $org_id=$lab_request_result[0]->org_id; + $repo_id=$lab_request_result[0]->id; + + + } + + $udata = array( + 'repo_id'=> $repo_id, + 'charge_type'=> $lab_type, + 'charge_id'=>$inv_id, + 'upload_by'=> $user_name, + 'pid'=>$pid, + 'ipd_id'=>$ipd_id, + 'case_id'=>$org_id + ); + + if($file_insert_id>0) + { + $this->File_M->update($udata,$file_insert_id); + } + + } + + $ret[]= $_FILES["myfile"]["name"]; + } + else + { + // Handle Multiple files + $fileCount = count($_FILES["myfile"]["name"]); + for($i=0; $i<$fileCount; $i++) + { + $filename = $inv_id.'-'.$lab_type.'-'.time() .$_FILES["myfile"]["name"][$i]; + + //$fileName = $_FILES["myfile"]["name"][$i]; + //move_uploaded_file($_FILES["myfile"]["tmp_name"][$i],$output_dir.$fileName); + + if (!$this->upload->do_upload($_FILES["myfile"]["tmp_name"][$i])) { + $error = array('error' => $this->upload->display_errors()); + echo $error['error']; + }else{ + $data = array('upload_data' => $this->upload->data()); + $this->load->model('File_M'); + $file_insert_id=$this->File_M->insert($data['upload_data']); + + $sql="select * from lab_request where id=".$inv_id; + $query = $this->db->query($sql); + $lab_request_result= $query->result(); + + $pid=0; + $ipd_id=0; + $org_id=0; + + if(count($lab_request_result)>0) + { + $pid=$lab_request_result[0]->patient_id; + $ipd_id=$lab_request_result[0]->ipd_id; + $org_id=$lab_request_result[0]->org_id; + } + + $udata = array( + 'repo_id'=> $repo_id, + 'charge_type'=> $lab_type, + 'upload_by'=> $user_name, + 'pid'=>$pid, + 'ipd_id'=>$ipd_id, + 'case_id'=>$org_id + ); + + if($file_insert_id>0) + { + $this->File_M->update($udata,$file_insert_id); + } + } + + $ret[]= $_FILES["myfile"]["name"][$i]; + } + } + // output file names as comma seperated strings to display status + echo json_encode($ret); + } + } + + + public function send_sms_lab_report($inv_id,$lab_type) + { + $sql="select * from lab_invoice_request where invoice_id='".$inv_id."' and lab_type='".$lab_type."'"; + $query = $this->db->query($sql); + $lab_invoice_request= $query->result(); + + $file_id=0; + + if(count($lab_invoice_request)>0) + { + $file_id=$lab_invoice_request[0]->file_id; + + $file_id_en=encode_dst($file_id); + + $message="Your Report is ready. click on ".base_url()."PhoneSMS/show_lab_report/".$file_id_en.' From Apollo Diag.&Path. Lab'; + $message = urlencode($message);// urlencode your message + + //echo $message; + + $tomobile=$this->input->post('sms_number'); + + //Send SMS + $url="https://www.way2sms.com/api/v1/sendCampaign"; + + $curl = curl_init(); + curl_setopt($curl, CURLOPT_POST, 1);// set post data to true + curl_setopt($curl, CURLOPT_POSTFIELDS, "apikey=B7DYP7GU8K92YJ8ZQGE6DWCUM1DXGOBS&secret=JG534P9WPHQ0Z9H7&usetype=prod&phone=$tomobile&senderid=DSTECH&message=$message");// post data + // query parameter values must be given without squarebrackets. + // Optional Authentication: + curl_setopt($curl, CURLOPT_HTTPAUTH, CURLAUTH_BASIC); + curl_setopt($curl, CURLOPT_URL, $url); + curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1); + $result = curl_exec($curl); + curl_close($curl); + + echo 'Message Send.'; + }else{ + echo 'Report Not Ready'; + } + + } + + + public function lab_tab_2_process($req_id) + { + $sql="select * from lab_request where id=".$req_id; + $query = $this->db->query($sql); + $labreport_entry= $query->result(); + + $user = $this->ion_auth->user()->row(); + $user_id = $user->id; + $user_name = $user->first_name.''. $user->last_name; + + $insert_id=0; + + $this->load->model('PathLab_M'); + + if(count($labreport_entry)>0) + { + + $sql="select r.mstRepoKey,t.mstTestKey,j.EOrder,t.Result + from lab_repo r join lab_repotests j join lab_tests t + on r.mstRepoKey=j.mstRepoKey and j.mstTestKey=t.mstTestKey + where r.mstRepoKey=".$labreport_entry[0]->lab_repo_id." order by j.EOrder"; + + $query = $this->db->query($sql); + $chkdata= $query->result(); + + for ($i = 0; $i < count($chkdata); ++$i) + { + + $sql="select * from lab_request_item + where lab_request_id='".$req_id."' and lab_repo_id='".$chkdata[$i]->mstRepoKey."' + and lab_test_id='".$chkdata[$i]->mstTestKey."'"; + + + $query = $this->db->query($sql); + $chktestlist= $query->result(); + + if(count($chktestlist)<1) + { + $udata = array( + 'lab_request_id'=> $req_id, + 'lab_repo_id'=> $chkdata[$i]->mstRepoKey, + 'lab_test_id'=> $chkdata[$i]->mstTestKey, + ); + + $insert_id=$this->PathLab_M->insert_test_entry($udata); + } + } + } + + $sql= "select d.mstTestKey,d.Test,d.TestID,d.Result,d.Formula,d.VRule,d.VMsg,d.Unit, d.FixedNormals, + i.lab_test_value,i.lab_test_remark,i.id ,s.EOrder, + group_concat(concat(o.id,':',o.option_text,':',o.option_value) ORDER BY o.sort_id) as option_value, + d.Formula + from (lab_request_item i join lab_tests d join lab_repotests s + on i.lab_test_id=d.mstTestKey and d.mstTestKey=s.mstTestKey and i.lab_repo_id=s.mstRepoKey) + left join lab_tests_option o on d.mstTestKey=o.mstTestKey + where i.lab_request_id=".$req_id." group by d.mstTestKey order by s.EOrder"; + + $query = $this->db->query($sql); + $data['lab_request_item_entry']= $query->result(); + + $sql="select * from lab_request where id=".$req_id; + $query = $this->db->query($sql); + $data['lab_request_master']= $query->result(); + + $this->load->view('PathLab_Report/lab_test_entry',$data); + + } + + + public function report_edit_request_show($repo_id) + { + $sql="select * from lab_request where id=".$repo_id; + $query = $this->db->query($sql); + $data['lab_request']= $query->result(); + + $sql="SELECT s.id,m.analytical_id, + Concat(s.analytical_faults,'[',m.analytical_name,']' ) AS log_type + from lab_log_analytical_type m JOIN lab_log_type_master s + ON m.analytical_id=s.analytical_faults_type"; + $query = $this->db->query($sql); + $data['lab_log_type_master']= $query->result_array(); + + $data['Faults_id']=1; + + $data['repo_id']=$repo_id; + + $this->load->view('PathLab_Report/lab_report_edit_request',$data); + + } + + + public function report_edit_request() + { + $this->load->model('PathLab_M'); + + $user = $this->ion_auth->user()->row(); + $user_id = $user->id; + $user_name = $user->first_name.' '. $user->last_name.'['.$user_id.']['.date('d-m-Y h:i:s').']'; + + $sql="select * from lab_log_type_master where id=".$this->input->post('cbo_sub_Analytical'); + $query = $this->db->query($sql); + $lab_log_type_master= $query->result(); + + $Analytical_text=""; + $sub_Analytical_text=""; + $log_type_id="0"; + + if(count($lab_log_type_master)>0) + { + $log_type_id=$lab_log_type_master[0]->analytical_faults_type; + $sub_Analytical_text=$lab_log_type_master[0]->analytical_faults; + + + $sql="select * from lab_log_analytical_type where analytical_id=".$lab_log_type_master[0]->analytical_faults_type; + $query = $this->db->query($sql); + $lab_log_analytical_type= $query->result(); + + $Analytical_text=$lab_log_analytical_type[0]->analytical_name; + } + + $udata = array( + 'log_by_id'=> $user_id, + 'log_by'=> $user_name, + 'log_type_id'=> $log_type_id, + 'log_type'=> $Analytical_text, + 'log_Faults_id'=> $this->input->post('cbo_sub_Analytical'), + 'log_Faults'=> $sub_Analytical_text, + 'comments'=> $this->input->post('other_reason'), + 'lab_repo_id'=>$this->input->post('repo_id'), + ); + + $insert_id=$this->PathLab_M->insert_lab_log($udata); + if($insert_id>0) + { + $showcontent="Request to OPEN Report Done"; + $id_key=$this->input->post('repo_id'); + + $sql="select * from lab_request where id=".$id_key; + $query = $this->db->query($sql); + $lab_request= $query->result(); + + $report_edit_req_no=$lab_request[0]->report_edit_req_no; + + $report_edit_req_no =$report_edit_req_no+1; + + $data = array( + 'status'=> '1', + 'report_edit_req_no'=>$report_edit_req_no, + ); + + $this->PathLab_M->update_test_request($data,$id_key); + + }else{ + $showcontent="Some Error, Please Contact to Admin"; + } + + $rvar=array( + 'insertid' => $insert_id, + 'showcontent'=> $showcontent + ); + + $encode_data = json_encode($rvar); + echo $encode_data; + + } + + public function update_lab_no() + { + $this->load->model('PathLab_M'); + + $lab_req_id=$this->input->post('lab_req_id'); + $inputLabNo=$this->input->post('inputLabNo'); + + $user = $this->ion_auth->user()->row(); + $user_id = $user->id; + $user_name = $user->first_name.' '. $user->last_name.'['.$user_id.']['.date('d-m-Y h:i:s').']'; + + $sql="select * from lab_invoice_request where id=$lab_req_id "; + $query = $this->db->query($sql); + $lab_invoice_request= $query->result(); + + if(count($lab_invoice_request)>0) + { + $udata = array( + 'lab_test_no'=> $inputLabNo, + ); + + $this->PathLab_M->update_invoice_report($udata,$lab_req_id); + } + + echo "Saved"; + } + +} \ No newline at end of file diff --git a/old_code_ci3/controllers/Lab_Report.php b/old_code_ci3/controllers/Lab_Report.php new file mode 100644 index 0000000..736cbf9 --- /dev/null +++ b/old_code_ci3/controllers/Lab_Report.php @@ -0,0 +1,564 @@ +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); + } + + public function search_lab_4($lab_type) + { + $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, + 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, + 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 . " + + 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, + 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 . "' ) + + group by m.id order by m.id desc limit 50"; + } + + $query = $this->db->query($sql); + $data['labreport_preprocess'] = $query->result(); + + if ($lab_type == 5 or $lab_type == 6) // Pathology or Biopsy + { + $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 = preg_replace('/[^A-Za-z0-9_ \-]/', '', $sdata); + + 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, + 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) + 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, + 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, + 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) + 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 r.lab_test_no=$sdata + + group by m.id order by m.id desc limit 50"; + } + + $query = $this->db->query($sql); + $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 = preg_replace('/[^A-Za-z0-9_ \-]/', '', $sdata); + + 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, + 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) + 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, + 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, + 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) + 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 r.daily_sr_no=$sdata + + group by m.id order by m.id desc limit 50"; + } + + $query = $this->db->query($sql); + $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) + { + $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, + 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 + 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_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; + + $query = $this->db->query($sql); + $data['labreport_preprocess'] = $query->result(); + + $user = $this->ion_auth->user()->row(); + $user_id = $user->id; + $user_name = $user->first_name . '' . $user->last_name; + + $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; + $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; + } + } + } + + $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') + ); + + //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; + $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 + where lab_type=$lab_type and date(report_insert)=curdate()"; + $query = $this->db->query($sql); + $lab_invoice_count = $query->result(); + + $count_rec = $lab_invoice_count[0]->no_rec; + + $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); + } + } + + //Add Second Step + + + echo $insert_id; + } + + public function create_report_xray($req_id) + { + + $this->load->model('PathLab_M'); + + $sql = "select * from lab_request where id=" . $req_id; + $query = $this->db->query($sql); + $data_lab_request = $query->result(); + + $p_id = $data_lab_request[0]->patient_id; + + $sql = "select * from patient_master_exten where id=$p_id"; + $query = $this->db->query($sql); + $data_patient_data = $query->result(); + + + $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; + + $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; + $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; + $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 = ""; + } + + $Report_Header = ' + + + + + +
' . $Report_Head_H3 . '
+ '; + + $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') + ); + + $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(); + + $sql = "select * from radiology_ultrasound_template where charge_id=" . $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); + + //redirect('Lab_Admin/show_report_final/'.$req_id); + } + + public function show_report_final($req_id) + { + $sql = "select * from lab_request where id=" . $req_id; + $query = $this->db->query($sql); + $data['report_format'] = $query->result(); + + $sql = "select * from invoice_item where id=" . $data['report_format'][0]->charge_item_id; + $query = $this->db->query($sql); + $data['invoice_item'] = $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); + } + + public function get_template_xray($req_id) + { + $sql = "select * from radiology_ultrasound_template where id=$req_id"; + $query = $this->db->query($sql); + $radiology_ultrasound_template = $query->result(); + + $Findings = ""; + $Impression = ""; + + if (count($radiology_ultrasound_template) > 0) { + $Findings = $radiology_ultrasound_template[0]->Findings; + $Impression = $radiology_ultrasound_template[0]->Impression; + } + + $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') + ); + + $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); + + echo "Verified and Ready for Print"; + } + + + + public function select_lab_invoice_path($inv_id, $lab_type) + { + $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, + 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; + $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 . "'"; + $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); + } + + //Other then XRay + + public function select_lab_invoice($inv_id, $lab_type) + { + $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, + 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; + $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 . "'"; + $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); + } + + 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 . "'"; + $query = $this->db->query($sql); + $data['lab_invoice_request'] = $query->result(); + + $this->load->view('Lab_Panel/lab_date_show', $data); + } + + 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, + 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 + 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_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 . " + order by t.item_name"; + $query = $this->db->query($sql); + $data['testlist'] = $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(); + + $this->load->view('Lab_Panel/lab_invoice_main_test_list', $data); + } + + // Report Test List + 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, + 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 + 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_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 . " + order by t.item_name"; + $query = $this->db->query($sql); + $data['testlist'] = $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(); + + $this->load->view('Lab_Panel/lab_invoice_main_xray_test_list', $data); + } + + 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 . "'"; + $query = $this->db->query($sql); + $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) + { + $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, + 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; + $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 . "'"; + $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); + } +} diff --git a/old_code_ci3/controllers/Master_data.php b/old_code_ci3/controllers/Master_data.php new file mode 100644 index 0000000..8459763 --- /dev/null +++ b/old_code_ci3/controllers/Master_data.php @@ -0,0 +1,107 @@ +load->model('Master_M'); + } + + function tag_index() + { + $sql="select * from tag_master order by tag_name "; + $query = $this->db->query($sql); + $data['tag_master']= $query->result(); + + $this->load->view('MasterData/tag_master_index',$data); + } + + function tag_add() + { + $this->load->view('MasterData/tag_master_add'); + } + + function tag_save() + { + $input_tag_name = $this->input->post('input_tag_name'); + $input_tag_desc = $this->input->post('input_tag_desc'); + $hid_tag_id = $this->input->post('hid_tag_id'); + + $user = $this->ion_auth->user()->row(); + $user_id = $user->id; + $user_name = $user->first_name.''. $user->last_name; + + $insert_data=array( + 'tag_name'=>$input_tag_name, + 'tag_type_id'=>'0', + 'tag_desc'=>$input_tag_desc, + 'insert_dateimte'=>date('Y-m-d H:i:s'), + 'insert_by'=>$user_name, + ); + + if($hid_tag_id==0){ + $inser_id=$this->Master_M->insert_tag_master($insert_data); + }else{ + $inser_id=$this->Master_M->update_tag_master($insert_data,$hid_tag_id); + } + + echo $inser_id; + } + + // Employee Master + public function Employee_master_list() + { + $sql="select * from employee_master order by emp_name "; + $query = $this->db->query($sql); + $data['employee_master']= $query->result(); + + $this->load->view('MasterData/employee_master_list',$data); + } + + function Employee_add() + { + $this->load->view('MasterData/emp_master_add'); + } + + function Employee_edit($emp_id) + { + $sql="select * from employee_master where emp_id= $emp_id"; + $query = $this->db->query($sql); + $data['employee_master']= $query->result(); + + $this->load->view('MasterData/emp_master_edit',$data); + } + + function Employee_save() + { + $input_emp_code = $this->input->post('input_emp_code'); + $input_emp_name = $this->input->post('input_emp_name'); + $input_emp_dob = $this->input->post('input_emp_dob'); + $input_emp_joinning_date = $this->input->post('input_emp_joinning_date'); + $input_emp_phone_no = $this->input->post('input_emp_phone_no'); + $hid_emp_id = $this->input->post('hid_emp_id'); + + $user = $this->ion_auth->user()->row(); + $user_id = $user->id; + $user_name = $user->first_name.''. $user->last_name.' ['.$user_id.']'; + + $insert_data=array( + 'emp_code'=>$input_emp_code, + 'emp_name'=>$input_emp_name, + 'emp_dob'=>$input_emp_dob, + 'emp_joinning_date'=>$input_emp_joinning_date, + 'emp_phone_no'=>$input_emp_phone_no, + + 'add_by'=>$user_name.' : '.date('Y-m-d H:i:s'), + ); + + if($hid_emp_id==0){ + $inser_id=$this->Master_M->insert_employee_master($insert_data); + }else{ + $inser_id=$this->Master_M->update_employee_master($insert_data,$hid_emp_id); + } + + echo $inser_id; + } +} \ No newline at end of file diff --git a/old_code_ci3/controllers/Medical.php b/old_code_ci3/controllers/Medical.php new file mode 100644 index 0000000..dbd9066 --- /dev/null +++ b/old_code_ci3/controllers/Medical.php @@ -0,0 +1,5230 @@ +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 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 = '') + { + + $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); + } + + public function purchase_file_hide($file_id, $purchase_id = '') + { + $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); + } + + + 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[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->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,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); + } + + 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, + DATEDIFF(LAST_DAY(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 + 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 . "%' "; + + if (strlen($q) > 5) { + $sql = $sql . " or p.item_name SOUNDS LIKE '" . $q . "' or p.genericname like '%" . $q . "%'"; + } + + $sql = $sql . ") order by p.item_name,t.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, 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 + } + 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'][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; + + $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'); + + /* $sql="select * from invoice_med_master where id=".$inv_id; + $query = $this->db->query($sql); + $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; + $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(); + + $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); + } + } + } + + 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(); + + $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 { + 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); + //$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() + ); + $encode_data = json_encode($rvar); + echo $encode_data; + } + + 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, + 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"; + $sql = "select item_code + from inv_med_item where 1<>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); + + //$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(); + + $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.ipd_code,p.p_code,p.p_fname,p.mphone1,m.payment_received,m.payment_balance,m.net_amount + 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.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; + $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); + + + $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 -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(); + } + + 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 + 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, + 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, + 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)"; + } + + $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'); + + $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'); + + $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 ''; + } + } +} diff --git a/old_code_ci3/controllers/Medical_Invoice_PDF.php b/old_code_ci3/controllers/Medical_Invoice_PDF.php new file mode 100644 index 0000000..57d0b4e --- /dev/null +++ b/old_code_ci3/controllers/Medical_Invoice_PDF.php @@ -0,0 +1,104 @@ +load->library("Pdf"); + + } + + //Sale Report + + public function Report_1() + { + $this->load->view('Medical/Report/Med_Report_1'); + } + + public function Invoice_PDF($sale_date_range,$output=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(); + + + + } + + + + +} \ No newline at end of file diff --git a/old_code_ci3/controllers/Medical_Print.php b/old_code_ci3/controllers/Medical_Print.php new file mode 100644 index 0000000..67e3915 --- /dev/null +++ b/old_code_ci3/controllers/Medical_Print.php @@ -0,0 +1,1150 @@ +load->model('Medical_M'); + + $this->Medical_M->update_invoice_group($inv_id); + $this->Medical_M->update_invoice_final($inv_id); + + $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,(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, + (twdisc_amount) as twdisc_amount, + (i.disc_amount+i.disc_whole) as d_amt, + (i.CGST+i.SGST) as gst, + (i.CGST_per+i.SGST_per) as gst_per ,i.sale_return, + i.TaxableAmount + from inv_med_item i join invoice_med_master m + on i.inv_med_id=m.id + where m.id=$inv_id order by i.sale_return,id"; + $query = $this->db->query($sql); + $data['inv_items']= $query->result(); + + $sql="select *, + date_format(inv_date,'%d-%m-%Y') as str_inv_date, + (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_med_master']= $query->result(); + + $data['Doc_name']=""; + + if($data['invoice_med_master'][0]->doc_id>0) + { + $doc_id=$data['invoice_med_master'][0]->doc_id; + + $sql="select * from doctor_master + where id=$doc_id"; + $query = $this->db->query($sql); + $doctor_master= $query->result(); + + $data['Doc_name']=$doctor_master[0]->p_title.' '.$doctor_master[0]->p_fname; + }else{ + $data['Doc_name']=$data['invoice_med_master'][0]->doc_name; + } + + if($data['invoice_med_master'][0]->patient_id>0) + { + $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['patient_master']= $query->result(); + + + + + if($data['invoice_med_master'][0]->ipd_id>0) + { + $ipd_id=$data['invoice_med_master'][0]->ipd_id; + + $sql="select * from v_ipd_list + where id=$ipd_id"; + $query = $this->db->query($sql); + $data['ipd_master']= $query->result(); + + $org_id=$data['ipd_master'][0]->case_id; + + $sql="select * from organization_case_master + where id=$org_id"; + $query = $this->db->query($sql); + $data['org_master']= $query->result(); + + + }else if( $data['invoice_med_master'][0]->case_id>0) + { + + $org_id=$data['invoice_med_master'][0]->case_id; + + $sql="select * from organization_case_master + where id=$org_id"; + $query = $this->db->query($sql); + $data['org_master']= $query->result(); + } + + } + + $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(); + + //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 = false; + + $file_name='Report-MedicalBill_'.$inv_id.'_'.date('Ymdhis').".pdf"; + + $filepath=$file_name; + + //$this->load->view('Medical/medical_bill_print_format',$data); + + if($print_format==0) + { + $content=$this->load->view('Medical/Print/medical_bill_print_format_single',$data,TRUE); + }elseif($print_format==1){ + + $content=$this->load->view('Medical/Print/medical_bill_print_a6',$data,TRUE); + $this->m_pdf->pdf->SetJS('this.print();'); + }elseif($print_format==2){ + + $content=$this->load->view('Medical/Print/medical_bill_print_a5',$data,TRUE); + $this->m_pdf->pdf->SetJS('this.print();'); + }elseif($print_format==3){ + + $content=$this->load->view('Medical/Print/medical_bill_print_a5_discount',$data,TRUE); + $this->m_pdf->pdf->SetJS('this.print();'); + } + //echo $content; + + //generate the PDF from the given html + $this->m_pdf->pdf->WriteHTML($content); + + //download it. + $this->m_pdf->pdf->Output($filepath,"I"); + + + + } + + + public function invoice_print_all($ipd_id,$cash=0,$salt_name=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 , + p.genericname + from (inv_med_item i join invoice_med_master m on i.inv_med_id=m.id) + Left join med_product_master p on i.item_code=p.id + where m.group_invoice_id>0 and i.qty>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 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.p_relative,m.p_rname, + 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,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 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(); + + + $data['salt_name']=$salt_name; + + //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-'.$ipd_id."-".date('Ymdhis').".pdf"; + + $filepath=$file_name; + + //$this->load->view('Medical/medical_bill_print_format',$data); + $content=$this->load->view('Medical/Print/medical_bill_print_format',$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->m_pdf->pdf->Output('uploads/'.$filepath,"F"); + + } + + public function invoice_print_salt_all($ipd_id,$cash=0,$print_size=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, + p.genericname + from (inv_med_item i join invoice_med_master m + on i.inv_med_id=m.id) + join med_product_master p on i.item_code=p.id + where m.group_invoice_id>0 and i.qty>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 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,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 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(); + + //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-'.$ipd_id."-".date('Ymdhis').".pdf"; + + $filepath=$file_name; + + //$this->load->view('Medical/medical_bill_print_format',$data); + $content=$this->load->view('Medical/Print/medical_bill_print_format',$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->m_pdf->pdf->Output('uploads/'.$filepath,"F"); + + } + + public function invoice_print_with_return_all($ipd_id,$cash=0,$print_size=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) + { + $med_type=1; + }elseif($cash==1) + { + $med_type=2; + }elseif($cash==2) + { + $med_type=3; + } + + $this->Medical_M->update_invoice_group_gst($ipd_id,$med_type); + + /* $sql="SELECT *,SUM(i.amount) AS t_amount + FROM v_med_item_with_return i + where i.ipd_id=".$ipd_id.$cash_where." + group by i.inv_med_id,i.id WITH ROLLUP"; + $query = $this->db->query($sql); */ + + //$query = $this->db->query('call p_get_list_ipd_med_item('.$ipd_id.')'); + //$query->next_result(); + $sql="Select i.inv_med_id AS inv_med_id,i.id AS id,m.ipd_id AS ipd_id,i.item_Name AS item_Name, + i.formulation AS formulation,i.batch_no AS batch_no,date_format(i.expiry,'%m-%Y') AS expiry, + i.price AS price,i.qty AS Cur_qty,if(isnull(r.r_qty),i.qty,(i.qty + sum(r.r_qty))) AS qty, + (if(isnull(r.r_qty),i.qty,(i.qty + sum(r.r_qty)))*i.price) AS amount,i.HSNCODE AS HSNCODE, + m.inv_med_code AS inv_med_code,m.id AS m_id,date_format(m.inv_date,'%d-%m-%Y') AS str_inv_date, + r.id AS r_id,sum(r.r_qty) AS tot_return + from ((inv_med_item i join invoice_med_master m on((m.id = i.inv_med_id))) + left join inv_med_item_return r on((i.id = r.inv_item_id))) + WHERE m.ipd_credit=0 AND m.ipd_id=$ipd_id + group by i.inv_med_id,i.id WITH ROLLUP "; + $query = $this->db->query($sql); + $data['inv_items']= $query->result(); + + $sql="SELECT *,SUM(i.amount) AS t_amount + FROM v_med_item_return i + where i.ipd_id=".$ipd_id.$cash_where." + group by i.inv_med_id,i.id WITH ROLLUP"; + $query = $this->db->query($sql); + $data['inv_items_return']= $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 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,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 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(); + + //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-'.$ipd_id."-".date('Ymdhis').".pdf"; + + $filepath=$file_name; + + //$this->load->view('Medical/medical_bill_print_format',$data); + $content=$this->load->view('Medical/Print/medical_bill_print_format_with_return',$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->m_pdf->pdf->Output('uploads/'.$filepath,"F"); + + } + + + public function invoice_print_all_bill($ipd_id) + { + //$cash 0 for Cash Only,1 for Credit only,2 Package Credit only,3 for All + $this->load->model('Medical_M'); + + $cash_where=" "; + + + $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'); + + $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 i.qty>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(); + + //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-'.$ipd_id."-".date('Ymdhis').".pdf"; + + $filepath=$file_name; + + //$this->load->view('Medical/medical_bill_print_format',$data); + $content=$this->load->view('Medical/Print/medical_bill_print_format_newpage',$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"); + + } + + + public function medicine_list_print_all($ipd_id,$cash=-1) + { + //$cash 0 for Cash Only,1 for Credit only,2 Package Credit only,3 for All + $this->load->model('Medical_M'); + + $sql="select i.item_Name,i.formulation,p.genericname, SUM(i.qty) AS i_qty_total + FROM (inv_med_item i join invoice_med_master m on i.inv_med_id=m.id) + JOIN med_product_master p ON i.item_code=p.id + where m.group_invoice_id>0 and i.qty>0 + and m.ipd_id=$ipd_id AND i.formulation <>'SUR' + group BY i.item_code order BY i.item_Name"; + + //echo $sql; + + $query = $this->db->query($sql); + $data['inv_items']= $query->result(); + + $sql="select i.item_Name,i.formulation,p.genericname, SUM(i.qty) AS i_qty_total + FROM (inv_med_item i join invoice_med_master m on i.inv_med_id=m.id) + JOIN med_product_master p ON i.item_code=p.id + where m.group_invoice_id>0 and i.qty>0 + and m.ipd_id=$ipd_id AND i.formulation ='SUR' + group BY i.item_code order BY i.item_Name"; + + //echo $sql; + + $query = $this->db->query($sql); + $data['inv_items_sur']= $query->result(); + + $sql="select m.p_id,p.p_fname,m.ipd_code,p.p_code, m.doc_name, + m.org_id,m.doc_list 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(); + + $data['doc_list_sign']=""; + $data['doc_list_main_sign']=""; + + if(count($data['ipd_master'])>0) + { + $doc_list=$data['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=""; + + foreach($doc_master as $row) + { + $doc_list.="Dr. ".$row->p_fname." [".$row->SpecName."]

"; + } + + $data['doc_list']=$doc_list; + + } + + + $this->load->library('m_pdf'); + + //$this->m_pdf->pdf->SetProtection(array(), '1234567', '277395'); + + $file_name='MedicineList-MedicalBill-'.$ipd_id."-".date('Ymdhis').".pdf"; + + $filepath=$file_name; + + //$this->load->view('Medical/medical_bill_print_format',$data); + $content=$this->load->view('Medical/Print/Medicine_consolidated_List',$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"); + + } + + public function medicine_list_print($ipd_id,$cash=-1) + { + //$cash 0 for Cash Only,1 for Credit only,2 Package Credit only,3 for All + $this->load->model('Medical_M'); + + $sql="SELECT i.inv_med_id,i.id,i.item_Name,i.formulation,p.genericname, + sum(i.qty) as tot_qty, m.inv_med_code,m.id as m_id, + date_format(m.inv_date,'%d-%m-%Y') as str_inv_date + FROM (inv_med_item i join invoice_med_master m on i.inv_med_id=m.id) + JOIN med_product_master p ON i.item_code=p.id + where m.group_invoice_id>0 and i.qty>0 + and m.ipd_id=$ipd_id AND i.formulation <>'SUR' + GROUP BY i.item_code + order by m.inv_date,i.id"; + + //echo $sql; + + $query = $this->db->query($sql); + $data['inv_items']= $query->result(); + + $sql="select m.p_id,p.p_fname,m.ipd_code,p.p_code, m.doc_name, + m.org_id,m.doc_list 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(); + + $data['doc_list_sign']=""; + $data['doc_list_main_sign']=""; + + if(count($data['ipd_master'])>0) + { + $doc_list=$data['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.' +
'.nl2br($row->doc_sign).' +
+
+ Signature of Consultant +




+
Dr. '.$row->p_fname.'
['.$row->SpecName.']
+ '.nl2br($row->doc_sign).' +
"; + $doc_list_main_sign.=""; + + $data['doc_list_sign']=$doc_list_sign; + $data['doc_list_main_sign']=$doc_list_main_sign; + } + + + $this->load->library('m_pdf'); + + //$this->m_pdf->pdf->SetProtection(array(), '1234567', '277395'); + + $file_name='MedicineList-MedicalBill-'.$ipd_id."-".date('Ymdhis').".pdf"; + + $filepath=$file_name; + + //$this->load->view('Medical/medical_bill_print_format',$data); + $content=$this->load->view('Medical/Print/Medicine_List',$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"); + + } + + public function medicine_list_surgical_print($ipd_id,$cash=-1) + { + //$cash 0 for Cash Only,1 for Credit only,2 Package Credit only,3 for All + $this->load->model('Medical_M'); + + $cash_where=" "; + + $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,(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, + (twdisc_amount) as twdisc_amount, + (i.disc_amount+i.disc_whole) as d_amt, + (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 i.qty>0 + and m.ipd_id=$ipd_id and formulation ='SUR' order by m.inv_date,i.id"; + + //echo $sql; + + $query = $this->db->query($sql); + $data['inv_items']= $query->result(); + + $sql="select m.p_id,p.p_fname,m.ipd_code,p.p_code, m.doc_name, + m.org_id,m.doc_list 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(); + + $data['doc_list_sign']=""; + $data['doc_list_main_sign']=""; + + if(count($data['ipd_master'])>0) + { + $doc_list=$data['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.' +
'.nl2br($row->doc_sign).' +
+
+ Signature of Consultant +




+
Dr. '.$row->p_fname.'
['.$row->SpecName.']
+ '.nl2br($row->doc_sign).' +
"; + $doc_list_main_sign.=""; + + $data['doc_list_sign']=$doc_list_sign; + $data['doc_list_main_sign']=$doc_list_main_sign; + } + + + $this->load->library('m_pdf'); + + //$this->m_pdf->pdf->SetProtection(array(), '1234567', '277395'); + + $file_name='MedicineList-MedicalBill-'.$ipd_id."-".date('Ymdhis').".pdf"; + + $filepath=$file_name; + + //$this->load->view('Medical/medical_bill_print_format',$data); + $content=$this->load->view('Medical/Print/Medicine_List',$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"); + + } + + public function ipd_cash_print_pdf($ipd_id,$payid) + { + $sql="select *,date_format(payment_date,'%d-%m-%Y %h:%i %p') as payment_date_str , + if(credit_debit=0,'','Return') as Amount_str + from payment_history_medical where Customerof_type=2 and ipd_id=$ipd_id and id=$payid"; + $query = $this->db->query($sql); + $data['ipd_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, + IFNULL(GET_AGE_BY_DOB(dob),age) AS age from patient_master where id='".$pno."' "; + $query = $this->db->query($sql); + $data['patient_master']= $query->result(); + + $data['ipd_id']=$ipd_id; + $data['payid']=$payid; + + //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 = false; + + $file_name='Charge_Invoice-'.date('Ymdhis').".pdf"; + + $filepath=$file_name; + + $content=$this->load->view('Medical/Print//medical_cash_received_bill',$data,TRUE); + + //echo $content; + + //$this->m_pdf->pdf->debug = true; + + //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 Print_bill_on_uhid() + { + + } + + public function Print_bill_on_uhid_print($uhis_id,$cash=0,$print_size=0) + { + //$cash 0 for Cash Only,1 for OPD Cridit + $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 i.qty>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 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,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 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(); + + //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-'.$ipd_id."-".date('Ymdhis').".pdf"; + + $filepath=$file_name; + + //$this->load->view('Medical/medical_bill_print_format',$data); + $content=$this->load->view('Medical/Print/medical_bill_print_format',$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->m_pdf->pdf->Output('uploads/'.$filepath,"F"); + + } + + + public function print_purchase_return($inv_id) + { + $sql = "select p.id,p.p_r_invoice_no as 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.status as inv_status + from purchase_return_invoice p join med_supplier s on p.sid=s.sid + where p.id=" . $inv_id; + $query = $this->db->query($sql); + $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 + 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); + $data['purchase_return_invoice_item'] = $query->result(); + + $content = $this->load->view('Medical/Stock/purchase_return_invoice_item_print', $data, true); + + //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 = false; + + $file_name='Return_Invoice-'.$inv_id."-".date('Ymdhis').".pdf"; + + $filepath=$file_name; + + //echo $content; + + $this->m_pdf->pdf->debug = true; + + //generate the PDF from the given html + $this->m_pdf->pdf->WriteHTML($content); + + //download it. + $this->m_pdf->pdf->Output($filepath,"I"); + } + + public function print_purchase($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(); + + $content = $this->load->view('Medical/Stock/purchase_invoice_item_print', $data, true); + + //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 = false; + + $file_name='Return_Invoice-'.$inv_id."-".date('Ymdhis').".pdf"; + + $filepath=$file_name; + + //echo $content; + + $this->m_pdf->pdf->debug = true; + + //generate the PDF from the given html + $this->m_pdf->pdf->WriteHTML($content); + + //download it. + $this->m_pdf->pdf->Output("TEST.pdf","I"); + } + +} + diff --git a/old_code_ci3/controllers/Medical_Report.php b/old_code_ci3/controllers/Medical_Report.php new file mode 100644 index 0000000..1eb3b52 --- /dev/null +++ b/old_code_ci3/controllers/Medical_Report.php @@ -0,0 +1,3012 @@ +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 . "'"; + + if (!$this->ion_auth->in_group('MedOLDRec')) { + $sql_where .= " and m.inv_date >=date_add(sysdate(),interval -1 day)"; + } + + $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 . "'"; + + if (!$this->ion_auth->in_group('MedOLDRec')) { + $sql_where .= " and m.inv_date >=date_add(sysdate(),interval -1 day)"; + } + + $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); + } + } + + + // + //Daily Medicine Doctor Wise Sale Report + public function Report_daily_med_sale_doc() + { + $sql = "select * from doctor_master where active=1 order by p_fname"; + $query = $this->db->query($sql); + $data['doclist'] = $query->result(); + + $this->load->view('Medical/Report/Med_Report_daily_med_doc_sale', $data); + } + + public function Report_daily_med_sale_doc_data($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 m.doc_id in (" . $doc_id_list . ")"; + } + + $sql_where .= " and m.inv_date between '" . $minRange . "' and '" . $maxRange . "'"; + + if (!$this->ion_auth->in_group('MedOLDRec')) { + $sql_where .= " and m.inv_date >=date_add(sysdate(),interval -1 day)"; + } + + $sql = "SELECT m.doc_id,d.p_fname, 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) + 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) + LEFT JOIN doctor_master d ON m.doc_id=d.id + 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->p_fname . '' . $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); + } + } + + 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() + { + $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 . "'"; + + if (!$this->ion_auth->in_group('MedOLDRec')) { + $sql_where .= " and m.inv_date >=date_add(sysdate(),interval -1 day)"; + } + + $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 . "'"; + + if (!$this->ion_auth->in_group('MedOLDRec')) { + $sql_where .= " and m.date_of_invoice >=date_add(sysdate(),interval -1 day)"; + } + + $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 . "'"; + + if (!$this->ion_auth->in_group('MedOLDRec')) { + $sql_where .= " and m.inv_date >=date_add(sysdate(),interval -1 day)"; + } + + $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 . "' "; + + if (!$this->ion_auth->in_group('MedOLDRec')) { + $sql_where .= " and date(m.inv_date) >=date(date_add(sysdate(),interval -2 day))"; + } + + + + $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 . "' "; + + if (!$this->ion_auth->in_group('MedOLDRec')) { + $sql_where .= " and date(m.inv_date) >=date(date_add(sysdate(),interval -2 day))"; + } + + + $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, + (if(m.ipd_credit=1 and m.ipd_credit_type=1,g.net_amount,0)) as IPD_Credit_Amount, + (if(m.ipd_credit=1 and m.ipd_credit_type=0,g.net_amount,0)) as IPD_Package_Amount, + (if(m.ipd_credit=0,g.net_amount,0)) as IPD_CASH_Amount, (g.net_amount-pay_his.Total_Paid_Amount) as cash_balance, + pay_his.Total_Paid_Amount as Paid_Amount + FROM ((invoice_med_master m join v_ipd_list p on m.ipd_id=p.id ) join inv_med_group g ON m.med_group_id=g.med_group_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 .= ''; + } + + $content .= '
IPD CodePatient CodePatient NameAdmit dt.Discharge Dt.TPA NameCashPaid Amt.Cash BalanceCreditPackage
' . $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->Paid_Amount . '' . Round($row->cash_balance,0) . '' . $row->IPD_Credit_Amount . '' . $row->IPD_Package_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 . ")"; + } + + if (!$this->ion_auth->in_group('MedOLDRec')) { + $sql_where .= " and p.payment_date >=date_add(sysdate(),interval -1 day)"; + } + + $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_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)"; + } + + $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_3_purchase_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 . "'"; + + if (!$this->ion_auth->in_group('MedOLDRec')) { + $sql_where .= " and date(m.inv_date) >=date(date_add(sysdate(),interval -2 day))"; + } + + + $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(); + + + $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, + s.state, + 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 . " and s.state='" . M_State . "' group by p.id order by s.state,p.id"; + + $query = $this->db->query($sql); + $pur_inv_total_local = $query->result(); + + $sql = "select p.id,p.Invoice_no,p.date_of_invoice,p.sid,s.name_supplier,s.short_name,s.gst_no, + s.state, + 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 . " and s.state<>'" . M_State . "' group by p.id order by s.state,p.id"; + + $query = $this->db->query($sql); + $pur_inv_total_IGST = $query->result(); + + + $xcontent_head = ''; + + $xcontent_head .= ' + + + + + + + + + + + + + + + + + + + + + + + + + '; + + $sr_no = 0; + $tamt = 0; + $tramt = 0; + $tgst = 0; + + $xcontent = ''; + + foreach ($pur_inv_total_local as $row) { + $sr_no = $sr_no + 1; + $tamt = $tamt + $row->tamount; + $tramt = $tramt + round($row->tamount); + $tgst = $tgst + round($row->gst); + + $xcontent .= ' + + + + + + + + + + + + + + + + + + + + + + + + + '; + } + + $xcontent_total = ' + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
#Invoice IDSupplierGSTStateDateAmountR AmountGSTTotGST_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
' . $sr_no . '' . $row->Invoice_no . '' . $row->name_supplier . '' . $row->gst_no . '' . $row->state . '' . $row->date_of_invoice . '' . $row->tamount . '' . round($row->tamount) . '' . round($row->gst) . '' . 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) . '
#Total' . $tamt . '' . $tramt . '' . $tgst . '
'; + + $SGST_Purchase_List = $xcontent_head . $xcontent . $xcontent_total; + + //IGST Record + + $content = ''; + + + $xcontent_head = ' + + + + + + + + + + + + + + + + + + + + + + + + + + + '; + $sr_no = 0; + $tamt = 0; + $tramt = 0; + $tgst = 0; + + $xcontent = ''; + + foreach ($pur_inv_total_IGST as $row) { + $sr_no = $sr_no + 1; + $tamt = $tamt + $row->tamount; + $tramt = $tramt + round($row->tamount); + $tgst = $tgst + round($row->gst); + + $xcontent .= ' + + + + + + + + + + + + + + + + + + + + + + + + + '; + } + + $xcontent_total = ' + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
#Invoice IDSupplierGSTStateDateAmountR AmountGSTTotGST_per_0CGST_per_0IGST_per_0TotGST_per_5CGST_per_2_5IGST_per_2_5TotGST_per_12CGST_per_6IGST_per_6TotGST_per_18CGST_per_9IGST_per_9TotGST_per_28CGST_per_14IGST_per_14
' . $sr_no . '' . $row->Invoice_no . '' . $row->name_supplier . '' . $row->gst_no . '' . $row->state . '' . $row->date_of_invoice . '' . $row->tamount . '' . round($row->tamount) . '' . round($row->gst) . '' . 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) . '
#Total' . $tamt . '' . $tramt . '' . $tgst . '
'; + + $IGST_Purchase_List = $xcontent_head . $xcontent . $xcontent_total; + + $final_content = $SGST_Purchase_List; + + if (count($pur_inv_total_IGST) > 0) { + $final_content .= " + + + +
"; + $final_content .= $IGST_Purchase_List; + } + + //echo $content; + if ($output == 0) { + create_report_pdf_landscape($final_content, 'Med_Invoice'); + } else { + ExportExcel($final_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,s.state, + 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 . ' / State : ' . $row->state . '
#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'); + } + } + + public function purchase_invoice_data_gsr_rate_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 m.date_of_invoice between '" . $minRange . "' and '" . $maxRange . "'"; + + if ($supplier_id > 0) { + $sql_where .= " and s.sid= '" . $supplier_id . "' "; + } + + $sql = "SELECT m.id,m.supp_name,m.date_of_invoice,m.Invoice_no,s.name_supplier,s.sid, + s.short_name,s.gst_no,s.state, + 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.taxable_amount) as TaxableAmount, + SUM(t.net_amount) as Amount + FROM (purchase_invoice m join purchase_invoice_item t + ON m.id=t.purchase_id) + JOIN med_supplier s ON m.sid=s.sid + where " . $sql_where . " group BY s.sid,m.id,t.CGST_per 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 . ' / State : ' . $row->state . '
#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 . "'"; + + $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))"; + } + + + $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, + + sum(i.TaxableAmount) 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 .= ''; + } + + $content .= '
Invoice IDInv.Dateinv.NameInvoice TypeQtyTot.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->No_of_Qty . '' . $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'); + } + + + + public function Report_5_HSNdata($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 . "'"; + + //$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))"; + } + + + $sql = "select Left(i.HSNCODE," . M_HSNCODE_LEN . ") as HSNCODE, + count(i.id) as No_of_Items, + sum(i.qty) as No_of_Qty, + i.CGST_per , + sum(i.twdisc_amount) 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, + + sum(i.TaxableAmount) 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 Left(i.HSNCODE," . M_HSNCODE_LEN . ") ,i.CGST_per "; + + $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 .= '
HSN CodeItem QtyTax Per.Tot.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->HSNCODE . '' . $row->No_of_Qty . '' . $row->CGST_per . '' . $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_hsn'); + } + + + //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')); + } + } + + + //Short Medicine Data + + public function Short_medicine() + { + $sql = "select * from med_formulation order by formulation_length"; + $query = $this->db->query($sql); + $data['med_formulation'] = $query->result(); + + $this->load->view('Medical/Stock/Short_medicine', $data); + } + + public function Short_medicine_data($sale_date_range, $formulation, $output = 0) + { + $rangeArray = explode("S", $sale_date_range); + $minRange = $rangeArray[0]; + $maxRange = $rangeArray[1]; + + $formulation_list = str_replace("S", ",", $formulation); + + $content = ""; + + $where = " s.short_date between '" . $minRange . "' and '" . $maxRange . "'"; + + if ($formulation_list <> '0') { + $where .= " and m.formulation_id in (" . $formulation_list . ")"; + } + + $sql = "SELECT s.id,s.item_Name,s.curQty,m.formulation, + date_format(s.short_date,'%d-%m-%Y') as str_short_date, + s.supplier_name + FROM med_short_list s join med_product_master m on s.item_code=m.id + where " . $where . " order by short_date desc "; + + $query = $this->db->query($sql); + $stock_list = $query->result(); + + //$content.=$sql; + + $content .= ' + + + + + + + + '; + + foreach ($stock_list as $row) { + $content .= ''; + $content .= ' '; + $content .= ' '; + $content .= ' '; + $content .= ' '; + $content .= ' '; + $content .= ' '; + + $content .= ''; + } + + $content .= '
IDDateItem NameFormulationQtySupplier
' . $row->id . '' . $row->str_short_date . '' . $row->item_Name . '' . $row->formulation . '' . Round($row->curQty) . '' . $row->supplier_name . '
'; + + if ($output == 0) { + //load mPDF library + $this->load->library('m_pdf'); + + $file_name = 'Report_Medicine_Short_' . 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')); + } + } + + public function Report_gst_1() + { + $this->load->view('Medical/Report/Report_gst_1'); + } +} diff --git a/old_code_ci3/controllers/Medical_app.php b/old_code_ci3/controllers/Medical_app.php new file mode 100644 index 0000000..f264b73 --- /dev/null +++ b/old_code_ci3/controllers/Medical_app.php @@ -0,0 +1,453 @@ +load->database(); + //$this->load->helper(array('cookie','url','language')); + + // Load form helper library + //$this->load->helper('form'); + + // Load form validation library + //$this->load->library('form_validation'); + + // Load session library + //$this->load->library('session'); + + $this->load->helper('security'); + + } + + public function index() + { + $this->load->view('Medical_app/index'); + } + + public function load_dash() + { + $session_data = $this->session->userdata(); + print_r($session_data); + if($session_data['u_id']=='') + { + redirect('Medical_app/select_user_login'); + }else{ + $this->load->view('Medical_app/dash_main'); + } + } + + public function select_user_login() + { + $sql="select * + from users + where active=1 and medical_app=1"; + $query = $this->db->query($sql); + + $data['user_data']= $query->result(); + + $this->load->view('Medical_app/select_doctor',$data); + } + + public function login($user_id=0) + { + // Retrieve session data + $session_set_value = $this->session->userdata(); + + $data['user_id'] = $user_id; + + $sql="select * + from users + where active=1 and id=$user_id and medical_app=1 "; + $query = $this->db->query($sql); + $data['user_data_profile']= $query->result(); + + // Check for remember_me data in retrieved session data + if (isset($session_set_value['remember_me']) && $session_set_value['remember_me'] == "1") { + //$this->load->view('admin_page'); + $this->load->view('Mobile_app/dash_main',$data); + } else { + + // Check for validation + $this->form_validation->set_rules('password', 'Pin Number', 'trim|required|xss_clean'); + + if ($this->form_validation->run() == FALSE) { + //$this->load->view('login_form'); + $this->load->view('Medical_app/login',$data); + } else { + $username = $user_id; + $password = $this->input->post('password'); + + $sql = "SELECT * + FROM users + WHERE id=$username and login_pin='$password' and medical_app=1"; + + $query = $this->db->query($sql); + $data_login= $query->result(); + + if (count($data_login)>0) { + $this->session->set_userdata('remember_me', TRUE); + + $session_data = array( + 'p_fname'=> $data_login[0]->first_name, + 'p_mname'=> $data_login[0]->last_name, + 'u_id' => $data_login[0]->id, + 'username' => $username, + 'password' => $password + ); + + $this->session->set_userdata($session_data); + + $data['user'] = 1; + $this->load->view('Medical_app/dash_main',$data); + + } else { + $data['error_message'] = 'Invalid Pin'; + + $this->load->view('Medical_app/login', $data); + } + } + } + } + + public function logout() + { + // Destroy session data + $this->session->sess_destroy(); + $data['message_display'] = 'Successfully Logout'; + redirect('Mobile_app/select_user_login'); + } + + + //Customer Search + function patient_index_all() + { + $data['_view'] = ''; + + $this->load->view('Mobile_app/patient_page',$data); + } + + function patient_index($day=0,$doc_id=0) + { + if($doc_id==0) + { + $where=""; + }else{ + $where=" and o.doc_id = ".$doc_id; + } + + if($day>=0){ + $where_date=" and date(o.opd_book_date) = DATE_ADD(CURDATE(),INTERVAL -".$day." DAY)"; + } + + $sql = "SELECT p.*,Date_Format(o.last_opdvisit_date,'%d-%m-%Y %H:%i') AS last_date_visit, + o.*, + if(date(o.opd_book_date)=curdate(),1,0) as opd_today + FROM (patient_master_exten p + JOIN opd_master o ON p.id=o.p_id) + WHERE 1=1 $where_date $where + Group by p.id + order by o.opd_id desc"; + + $query = $this->db->query($sql); + $data['data']= $query->result(); + + $data['doc_id']=$doc_id; + $data['day']=$day; + + $data['sql']= $sql; + + $data['_view'] = 'Mobile_app/patient_search_v'; + + $this->load->view('Mobile_app/patient_page',$data); + } + + function patient_search() + { + $doc_id=$this->input->post('doc_id'); + $day=$this->input->post('day'); + $sdata=$this->input->post('data_search'); + + $where="1=1 "; + + if($doc_id==0) + { + $where.=""; + }else{ + $where.=" and o.doc_id = ".$doc_id; + } + + if($day>=0){ + $where_date=" and date(o.opd_book_date) = DATE_ADD(CURDATE(),INTERVAL -".$day." DAY)"; + }else{ + $where_date=""; + } + + $sdata = preg_replace('/[^A-Za-z0-9 _\-]/', '', trim($sdata)); + + if(is_numeric($sdata)) + { + $where.=" and (mphone1 = '".$sdata."' or udai='".$sdata."' or p_code like '%".$sdata."')" ; + }elseif (filter_var($sdata, FILTER_VALIDATE_EMAIL)) { + $where.=" email1 = '".$sdata."'" ; + }else{ + $where.=" and (p_fname like '%".$sdata."%' or + SUBSTRING_INDEX(p_fname,' ',1) sounds like '".$sdata."')"; + } + + $sql = "SELECT p.*,Date_Format(o.last_opdvisit_date,'%d-%m-%Y %H:%i') AS last_date_visit, + o.*, + if(date(o.opd_book_date)=curdate(),1,0) as opd_today + FROM (patient_master_exten p + JOIN opd_master o ON p.id=o.p_id) + WHERE ".$where." ".$where_date." + order by o.opd_id desc "; + + $query = $this->db->query($sql); + $data['data']= $query->result(); + + $data['sql']= $sql; + + $this->load->view('Mobile_app/patient_search_v',$data); + + + + } + + function patient_index_opd() + { + if (isset($_POST['search'])){ + + $doc_id=$this->input->post('doc_id'); + $day=$this->input->post('day'); + $sdata=$this->input->post('search'); + + if($doc_id==0) + { + $where="1=1 "; + }else{ + $where=" o.doc_id = ".$doc_id; + } + + if($day>=0){ + $where_date=" and date(o.opd_book_date) = DATE_ADD(CURDATE(),INTERVAL -".$day." DAY)"; + }else{ + $where_date=" and date(o.opd_book_date) > DATE_ADD(CURDATE(),INTERVAL -180 DAY)"; + } + + $sdata = preg_replace('/[^A-Za-z0-9 _\-]/', '', trim($sdata)); + + if(is_numeric($sdata)) + { + $where.=" and (mphone1 = '".$sdata."' or udai='".$sdata."' or p_code like '%".$sdata."')" ; + }elseif (filter_var($sdata, FILTER_VALIDATE_EMAIL)) { + $where.=" and email1 = '".$sdata."'" ; + }else{ + $where.=" and (p_fname like '%".$sdata."%' or + SUBSTRING_INDEX(p_fname,' ',1) sounds like '".$sdata."')"; + } + + $sql = "SELECT p.*,Date_Format(p.last_visit,'%d-%m-%Y %H:%i') AS last_date_visit, + o.doc_name, + if(date(o.opd_book_date)=curdate(),1,0) as opd_today + FROM (patient_master_exten p + JOIN opd_master o ON p.id=o.p_id) + WHERE ".$where." ".$where_date." Group by p.id + order by o.opd_id desc "; + + $query = $this->db->query($sql); + $data['data']= $query->result(); + + //$data['sql']= $sql; + + $content=$this->load->view('Medical_app/ipd_panel_sub',$data,TRUE); + + echo $content; + echo $sql; + + } + } + + + function person_record($pno) + { + $sql="select * from patient_master_exten where id=".$pno; + $query = $this->db->query($sql); + $data['data']= $query->result(); + + $sql="select *,date_format(apointment_date,'%d-%m-%Y') as str_apointment_date + from opd_master where p_id=".$pno; + $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, + 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 + from hc_insurance_card i join hc_insurance m on i.insurance_id=m.id + where m.active=1 and 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 p_id=".$pno; + $query = $this->db->query($sql); + $data['case_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"; + + 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; + + $sql="select * from file_upload_data where pid=".$pno." order by id desc"; + $query = $this->db->query($sql); + $data['opd_file_list']= $query->result(); + + $this->load->view('Mobile_app/patient_opd_profile',$data); + + } + + + public function show_profile_opd($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 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(); + + $this->load->view('Mobile_app/person_file_show',$data); + } + + public function take_opd_picture($opd_id,$pno) + { + $data['opd_id']=$opd_id; + $data['pno']=$pno; + + $sql="select * from patient_master_exten where id=".$pno; + $query = $this->db->query($sql); + $data['data']= $query->result(); + + $sql="select o.* from opd_master o where o.opd_id=$opd_id"; + $query = $this->db->query($sql); + $data['opd_master']= $query->result(); + + + $this->load->view('Mobile_app/opd_scan',$data); + } + + //IPD Panel + + public function ipd_panel() + { + $sql="SELECT i.*,p.p_fname,p.str_age,p.xgender, + date_format(i.register_date,'%d-%m-%Y') AS admit_dt, + DATE_FORMAT(i.discharge_date,'%d-%m-%Y') AS discharge_dt, + m.gross_amount,m.discount_group,m.discount_group_2,m.net_amount,m.payment_received, + if(m.med_type>1,'TPA','CASH') AS pay_type,m.payment_balance + FROM (inv_med_group m JOIN ipd_master i ON m.ipd_id=i.id) + JOIN patient_master_exten p ON i.p_id=p.id + WHERE i.ipd_status=0 AND m.net_amount>0" ; + + $query = $this->db->query($sql); + $data['ipd_data']= $query->result(); + + $this->load->view('Medical_app/ipd_panel',$data); + } + + public function ipd_panel_search() + { + $this->load->view('Medical_app/ipd_panel_search'); + } + + public function ipd_panel_search_data($search_text='',$pay_type=1) + { + $sdata=$this->input->post('data_search'); + + $where="1=1 "; + + if(is_numeric($sdata)) + { + $where.=" and (p.mphone1 = '".$sdata."' or p.udai='".$sdata."' or p.p_code like '%".$sdata."' or i.ipd_code like '%".$sdata."')" ; + }elseif (filter_var($sdata, FILTER_VALIDATE_EMAIL)) { + $where.=" and p.email1 = '".$sdata."'" ; + }else{ + $where.=" and (p.p_fname like '".$sdata."%' or + SUBSTRING_INDEX(p_fname,' ',1) sounds like '".$sdata."')"; + } + + $sql="SELECT i.*,p.p_fname,p.str_age,p.xgender, + date_format(i.register_date,'%d-%m-%Y') AS admit_dt, + DATE_FORMAT(i.discharge_date,'%d-%m-%Y') AS discharge_dt, + m.gross_amount,m.discount_group,m.discount_group_2,m.net_amount,m.payment_received, + if(m.med_type>1,'TPA','CASH') AS pay_type,m.payment_balance + FROM (inv_med_group m JOIN ipd_master i ON m.ipd_id=i.id) + JOIN patient_master_exten p ON i.p_id=p.id + WHERE $where AND m.net_amount>0" ; + + $query = $this->db->query($sql); + $data['ipd_data']= $query->result(); + + $content=$this->load->view('Medical_app/ipd_panel_sub',$data,TRUE); + + //echo $sql; + echo $content; + } + + public function open_ipd_bill($ipd_id) + { + $this->db->query("CALL p_revoke_bill(".$ipd_id.")"); + echo 'Done : Bill Opened'; + } + + public function get_ipd_bill_purchase($ipd_id) + { + $sql="select m.ipd_code,m.inv_name,sum(i.twdisc_amount) as Bill_Amount, + sum(Round(COALESCE(p.net_amount/p.total_unit,i.price2),2)*i.qty) as purchase_amount, + SUM(i.disc_whole) as Dis_Amount + from ((invoice_med_master m join inv_med_item i on m.id=i.inv_med_id) + left join purchase_invoice_item p on p.id=i.store_stock_id) + join ipd_master ipd on m.ipd_id=ipd.id + WHERE ipd.id=$ipd_id group by m.ipd_id "; + + $query = $this->db->query($sql); + $ipd_data= $query->result(); + + if(count($ipd_data)>0){ + $content="IPD : ".$ipd_data[0]->ipd_code."
". + "Name : ".$ipd_data[0]->inv_name."
". + "Bill Amount : ".$ipd_data[0]->Bill_Amount."
". + "Discount : ".$ipd_data[0]->Dis_Amount."
". + "Purchase : ".$ipd_data[0]->purchase_amount.""; + + }else{ + $content="Not Found"; + } + + echo $content; + + } + +} + diff --git a/old_code_ci3/controllers/Medical_backpanel.php b/old_code_ci3/controllers/Medical_backpanel.php new file mode 100644 index 0000000..d5f854a --- /dev/null +++ b/old_code_ci3/controllers/Medical_backpanel.php @@ -0,0 +1,2168 @@ +load->view('Medical/Med_back_Panel'); + } + + public function Med_old_invoice() + { + $this->load->view('Medical/Invoice_med_list'); + } + + public function Stock() + { + $sql = "select * from med_supplier"; + $query = $this->db->query($sql); + $data['supplier_data'] = $query->result(); + + $this->load->view('Medical/Stock/stock_search', $data); + } + + public function store_stock() + { + $sql = "select * from med_supplier"; + $query = $this->db->query($sql); + $data['supplier_data'] = $query->result(); + + $sql = "select * from med_formulation order by formulation_length"; + $query = $this->db->query($sql); + $data['med_formulation'] = $query->result(); + + $this->load->view('Medical/Store/store_stock_search', $data); + } + + public function stock_details() + { + $sql = "select * from med_supplier"; + $query = $this->db->query($sql); + $data['supplier_data'] = $query->result(); + + $this->load->view('Medical/Store/stock_store_statement', $data); + } + + public function store_Stock_result() + { + $item_name = trim($this->input->post('txtsearch')); + $chk_reorder = $this->input->post('chk_reorder'); + + $HAVING = ""; + + if ($chk_reorder == "on") { + $HAVING = " HAVING SUM(s.total_unit-s.total_lost_unit-s.total_sale_unit-s.total_return_unit)<=p.re_order_qty"; + } + + $where = " (s.total_unit-s.total_lost_unit-s.total_sale_unit-s.total_return_unit)>=0 "; + + if ($item_name <> '') { + $where .= " and (p.item_name like '%" . $item_name . "%' or p.genericname like '%" . $item_name . "%' )"; + } + + $schedule_id = $this->input->post('schedule_id'); + + if ($schedule_id == '') { + } else { + $where .= " and (1<>1 "; + foreach ($schedule_id as $row) { + if ($row == 1) { + $where .= " or p.schedule_h=1 "; + } + + if ($row == 2) { + $where .= " or p.schedule_h1=1 "; + } + + if ($row == 3) { + $where .= " or p.schedule_x=1 "; + } + + if ($row == 4) { + $where .= " or p.schedule_g=1 "; + } + + if ($row == 5) { + $where .= " or p.narcotic=1 "; + } + + if ($row == 6) { + $where .= " or p.high_risk=1 "; + } + } + $where .= ")"; + } + + $where .= " and m.date_of_invoice>date_add(curdate(),interval -24 month) "; + + $sql = "SELECT p.id, p.item_name,p.genericname, + IFNULL(s.item_code,0) AS item_found, + ifnull(s.packing,p.packing) as packing, + SUM(s.total_unit-s.total_sale_unit-s.total_lost_unit-s.total_return_unit) as C_Unit_Stock_Qty, + Concat(TRUNCATE(SUM(s.total_unit-s.total_sale_unit-s.total_lost_unit-s.total_return_unit)/s.packing,0), + ':', + MOD(SUM(s.total_unit-s.total_sale_unit-s.total_lost_unit-s.total_return_unit),s.packing)) as C_Pak_Qty, + sum(s.total_unit) as P_Unit_Qty, + sum(s.total_unit)/s.packing as Pak_qty, + sum(s.total_sale_unit) as sale_unit, + sum(s.total_sale_unit)/s.packing as C_Pak_Sale_Qty, + p.re_order_qty, + s.total_lost_unit + FROM (med_product_master p + JOIN purchase_invoice_item s ON p.id=s.item_code AND s.remove_item=0 AND s.item_return=0) + JOIN purchase_invoice m ON s.purchase_id=m.id and p.is_continue=1 + WHERE " . $where . " group by p.id,s.packing " . $HAVING . " order by p.Item_name "; + $query = $this->db->query($sql); + $data['stock_list'] = $query->result(); + + + $this->load->view('Medical/Store/Stock_search_result', $data); + } + + public function store_Stock_result_datewise() + { + $item_name = trim($this->input->post('txtsearch')); + $chk_reorder = $this->input->post('chk_reorder'); + + $supplier_id = $this->input->post('input_supplier'); + $opd_date_range = $this->input->post('opd_date_range'); + + $rangeArray = explode("S", $opd_date_range); + $minRange = $rangeArray[0]; + $maxRange = $rangeArray[1]; + + $HAVING = ""; + + if ($chk_reorder == "on") { + $HAVING = " HAVING SUM(s.total_unit-s.total_lost_unit-s.total_sale_unit-s.total_return_unit)<=p.re_order_qty"; + } + + $where = " 1=1 "; + + if ($item_name <> '') { + $where .= " and p.item_name like '%" . $item_name . "%' "; + } + + if ($opd_date_range <> '') { + $where .= " and s.stock_date between '" . $minRange . "' and '" . $maxRange . "'"; + } + + if ($supplier_id > 0) { + $where .= " and m.sid=$supplier_id"; + } + + $where .= " and m.date_of_invoice>date_add(curdate(),interval -24 month) "; + + $sql = "SELECT p.id, p.item_name, IFNULL(s.item_code,0) AS item_found, + ifnull(s.packing,p.packing) as packing, + SUM(s.tqty) AS total_pak_qty, + SUM(s.net_amount) AS purchase_cost, + SUM(s.total_unit) AS total_unit, + SUM(s.total_unit-s.total_sale_unit-s.total_lost_unit-s.total_return_unit) as C_Unit_Stock_Qty, + SUM((s.total_unit-s.total_sale_unit-s.total_lost_unit-s.total_return_unit))/s.packing as C_Pak_Qty, + sum(s.total_unit) as P_Unit_Qty, sum(s.total_unit)/s.packing as Pak_qty, + sum(s.total_sale_unit) as sale_unit, sum(s.total_sale_unit)/s.packing as C_Pak_Sale_Qty, + p.re_order_qty, s.total_lost_unit + FROM (med_product_master p JOIN purchase_invoice_item s ON p.id=s.item_code and s.item_return=0) + JOIN purchase_invoice m ON s.purchase_id=m.id + WHERE " . $where . " group by p.id,s.packing " . $HAVING . " order by p.Item_name"; + $query = $this->db->query($sql); + $data['stock_list'] = $query->result(); + + $data['date_range'] = $opd_date_range; + $data['supplier_id'] = $supplier_id; + + $this->load->view('Medical/Store/stock_store_statement_data', $data); + } + + public function store_Stock_result_datewise_excel($opd_date_range, $item_name='-', $supplier_id = '') + { + + $rangeArray = explode("S", $opd_date_range); + $minRange = $rangeArray[0]; + $maxRange = $rangeArray[1]; + + + $where = " 1=1 "; + + if ($item_name <> '') { + $where .= " and p.item_name like '%" . $item_name . "%' "; + } + + if ($opd_date_range <> '') { + $where .= " and s.stock_date between '" . $minRange . "' and '" . $maxRange . "'"; + } + + if ($supplier_id > 0) { + $where .= " and m.sid=$supplier_id"; + } + + $where .= " and m.date_of_invoice>date_add(curdate(),interval -24 month) "; + + $sql = "SELECT p.*, IFNULL(s.item_code,0) AS item_found, + ifnull(s.packing,p.packing) as packing, + SUM(s.tqty) AS total_pak_qty, + SUM(s.net_amount) AS purchase_cost, + SUM(s.total_unit) AS total_unit, + SUM(s.total_unit-s.total_sale_unit-s.total_lost_unit-s.total_return_unit) as C_Unit_Stock_Qty, + SUM((s.total_unit-s.total_sale_unit-s.total_lost_unit-s.total_return_unit))/s.packing as C_Pak_Qty, + sum(s.total_unit) as P_Unit_Qty, sum(s.total_unit)/s.packing as Pak_qty, + sum(s.total_sale_unit) as sale_unit, sum(s.total_sale_unit)/s.packing as C_Pak_Sale_Qty, + s.total_lost_unit,s.expiry_date, + SUM(TRUNCATE((s.total_unit-s.total_sale_unit-s.total_lost_unit-s.total_return_unit),0)*s.purchase_unit_rate) AS Stock_Cost, + s.purchase_unit_rate ,s.mrp,s.batch_no,s.CGST_per + FROM (med_product_master p JOIN purchase_invoice_item s ON p.id=s.item_code and s.item_return=0) + JOIN purchase_invoice m ON s.purchase_id=m.id + WHERE " . $where . " group by p.id,s.packing,s.batch_no order by p.Item_name"; + $query = $this->db->query($sql); + $stock_list = $query->result(); + + $content = ""; + $content .= ' + + + + + + + + + + + + + + + + + + '; + + $total_stock_value = 0; + + foreach ($stock_list as $row) { + + /* if ($row->C_Pak_Qty <= $row->re_order_qty) { + $tr_color = 'style="color:rgb(243, 7, 7);"'; + } else { + $tr_color = ''; + } */ + + $tr_color = ''; + + $content .= ' + + + + + + + + + + + + + + '; + $total_stock_value += $row->Stock_Cost; + } + + $content .= ' + + + '; + + $content .= '
Item NameGeneric NameMRPBatchExpiryCurrent Pak.Current Unit QtyTotal Sale Pak.Total Sale Unit QtyPackage/Re-Order QtyPurchase Unit RateGSTStock Cost
' . $row->item_name . '' . $row->genericname . '' . $row->mrp . '' . $row->batch_no . '' . $row->expiry_date . '' . $row->C_Pak_Qty . '' . $row->C_Unit_Stock_Qty . '' . $row->C_Pak_Sale_Qty . '' . $row->sale_unit . '' . $row->packing . '' . $row->purchase_unit_rate . '' . $row->CGST_per*2 . '' . $row->Stock_Cost . '
Total Stock Cost' . $total_stock_value . '
'; + + //echo $content; + ExportExcel($content, 'Report_Medical_store_stock'); + } + + public function Stock_result_excel($chk_reorder, $item_name, $schedule_id) + { + $HAVING = ""; + $where = " 1=1 "; + + if ($chk_reorder == "on") { + $HAVING = " HAVING (SUM(TRUNCATE((p.total_unit-p.total_sale_unit-p.total_lost_unit-p.total_return_unit)/p.packing,0)))<=m.re_order_qty"; + }else{ + $where .=" and (p.total_unit-p.total_lost_unit-p.total_sale_unit-p.total_return_unit)>0 "; + } + + + + if (strlen(urldecode($item_name))>2) { + $where .= " and m.item_name like '%" . urldecode($item_name) . "%' "; + } + + if ($schedule_id <>0 ) { + + $schedule_id = explode("S", $schedule_id); + if (count($schedule_id) > 0) { + $where .= " ( "; + } + foreach ($schedule_id as $row) { + if ($row == 1) { + $where .= " or m.schedule_h=1 "; + } + + if ($row == 2) { + $where .= " or m.schedule_h1=1 "; + } + + if ($row == 3) { + $where .= " or m.schedule_x=1 "; + } + + if ($row == 4) { + $where .= " or m.schedule_g=1 "; + } + + if ($row == 5) { + $where .= " or m.narcotic=1 "; + } + } + if (count($schedule_id) > 0) { + $where .= " ) "; + } + } + + + + $where .= " and i.date_of_invoice>date_add(curdate(),interval -24 month) "; + + $sql = "SELECT m.item_name, m.id,m.genericname, + SUM(p.tqty) AS Pak_qty, + SUM(p.total_unit) AS P_Unit_Qty, + m.packing, + SUM(TRUNCATE((p.total_unit-p.total_sale_unit)/p.packing,0)) AS C_Pak_Qty, + SUM(p.total_sale_unit) AS sale_unit, + SUM(TRUNCATE((p.total_sale_unit)/p.packing,0)) AS C_Pak_Sale_Qty, + m.re_order_qty, + SUM(p.total_unit-p.total_sale_unit) AS C_Unit_Stock_Qty, + SUM(TRUNCATE((p.total_unit-p.total_sale_unit-p.total_lost_unit-p.total_return_unit),0)*p.purchase_unit_rate) AS Stock_Cost, + p.purchase_unit_rate + FROM (med_product_master m JOIN purchase_invoice_item p + ON m.id=p.item_code and m.is_continue=1 and p.item_return=0 AND p.remove_item=0) + JOIN purchase_invoice i ON p.purchase_id=i.id + WHERE " . $where . " group by m.id,p.purchase_unit_rate,p.packing " . $HAVING . " order by m.Item_name"; + + //echo $sql; + + $query = $this->db->query($sql); + $stock_list = $query->result(); + + $content = ""; + //$content=$sql; + + $content .= ' + + + + + + + + + + + + + + '; + + $total_stock_value = 0; + + foreach ($stock_list as $row) { + + if ($row->C_Pak_Qty <= $row->re_order_qty) { + $tr_color = 'style="color:rgb(243, 7, 7);"'; + } else { + $tr_color = ''; + } + + $content .= ' + + + + + + + + + + '; + $total_stock_value += $row->Stock_Cost; + } + + $content .= ' + + + '; + + $content .= '
Item NameGeneric NameCurrent Pak.Current Unit QtyTotal Sale Pak.Total Sale Unit QtyPackage/Re-Order QtyPurchase Unit RateStock Cost
' . $row->item_name . '' . $row->genericname . '' . $row->C_Pak_Qty . '' . $row->C_Unit_Stock_Qty . '' . $row->C_Pak_Sale_Qty . '' . $row->sale_unit . '' . $row->packing . '' . $row->purchase_unit_rate . '' . $row->Stock_Cost . '
Total Stock Cost' . $total_stock_value . '
'; + + //echo $content; + ExportExcel($content, 'Report_Medical_store_stock'); + } + + public function Stock_result_excel_2($supplier_id, $opd_date_range, $item_name, $chk_reorder, $schedule_id = '') + { + + $HAVING = ""; + $where = " 1=1 "; + + if ($chk_reorder == "on") { + $HAVING = " HAVING SUM(s.total_unit-s.total_lost_unit-s.total_sale_unit-s.total_return_unit)<=p.re_order_qty"; + }else{ + $where .=" and (s.total_unit-s.total_lost_unit-s.total_sale_unit-s.total_return_unit)>0 "; + } + + + + if (($item_name <> '-') || strlen(trim($item_name)) > 0) { + $where .= " and p.item_name like '%" . $item_name . "%' "; + } + + if (!($opd_date_range == '' || $opd_date_range <> '0')) { + $rangeArray = explode("S", $opd_date_range); + $minRange = $rangeArray[0]; + $maxRange = $rangeArray[1]; + + $where .= " and s.stock_date between '" . $minRange . "' and '" . $maxRange . "'"; + } + + if ($supplier_id > 0) { + $where .= " and m.sid=$supplier_id"; + } + + if ($schedule_id == '') { + } else { + + $where .= " and (1<>1 "; + $schedule_id = explode("S", $schedule_id); + foreach ($schedule_id as $row) { + if ($row == 1) { + $where .= " or p.schedule_h=1 "; + } + + if ($row == 2) { + $where .= " or p.schedule_h1=1 "; + } + + if ($row == 3) { + $where .= " or p.schedule_x=1 "; + } + + if ($row == 4) { + $where .= " or p.schedule_g=1 "; + } + + if ($row == 5) { + $where .= " or p.narcotic=1 "; + } + } + $where .= ")"; + } + + + + $sql = "SELECT p.item_name, p.id,p.genericname, + SUM(s.tqty) AS Pak_qty, + SUM(s.total_unit) AS P_Unit_Qty, + s.packing, + SUM(TRUNCATE((s.total_unit-s.total_lost_unit-s.total_sale_unit-s.total_return_unit)/s.packing,0)) AS C_Pak_Qty, + SUM(s.total_sale_unit) AS sale_unit, + SUM(TRUNCATE((s.total_sale_unit)/s.packing,0)) AS C_Pak_Sale_Qty, + p.re_order_qty, + SUM(s.total_unit-s.total_lost_unit-s.total_sale_unit-s.total_return_unit) AS C_Unit_Stock_Qty, + SUM(TRUNCATE((s.total_unit-s.total_lost_unit-s.total_sale_unit-s.total_return_unit),0)*s.purchase_unit_rate) AS Stock_Cost + FROM (med_product_master p JOIN purchase_invoice_item s ON p.id=s.item_code and s.item_return=0) + JOIN purchase_invoice m ON s.purchase_id=m.id + WHERE " . $where . " group by s.id " . $HAVING . " order by p.Item_name"; + $query = $this->db->query($sql); + $stock_list = $query->result(); + + echo $sql; + + + $content = ""; + $content .= ' + + + + + + + + + + + '; + + foreach ($stock_list as $row) { + + if ($row->C_Pak_Qty <= $row->re_order_qty) { + $tr_color = 'style="background-color: #999999;"'; + } else { + $tr_color = ''; + } + + $content .= ' + + + + + + + '; + } + + $content .= '
Item NameTotal Unit QtyCurrent Unit QtyTotal Sale Unit QtyPackage/Re-Order QtyStock Cost
' . $row->item_name . '' . $row->P_Unit_Qty . '' . $row->C_Unit_Stock_Qty . '' . $row->sale_unit . '' . $row->packing . '' . $row->Stock_Cost . '
'; + + //echo $content; + ExportExcel($content, 'Report_Medical_store_stock'); + } + + public function Stock_result_excel_3($supplier_id, $opd_date_range, $item_name, $chk_reorder, $schedule_id = "") + { + + $HAVING = ""; + $where = " 1=1 "; + + if ($chk_reorder == "on") { + $HAVING = " HAVING SUM(p.total_unit-p.total_lost_unit-p.total_sale_unit-p.total_return_unit)<=p.re_order_qty"; + }else{ + $where .=" and (p.total_unit-p.total_lost_unit-p.total_sale_unit-p.total_return_unit)>0 "; + } + + if (strlen(urldecode($item_name))>2) { + $where .= " and m.item_name like '%" . urldecode($item_name) . "%' "; + } + + + + if (!($opd_date_range == '' || $opd_date_range == '0')) { + $rangeArray = explode("S", $opd_date_range); + $minRange = $rangeArray[0]; + $maxRange = $rangeArray[1]; + + $where .= " and s.stock_date between '" . $minRange . "' and '" . $maxRange . "'"; + } + + if ($supplier_id > 0) { + $where .= " and m.sid=$supplier_id"; + } + + if ($schedule_id == '') { + } else { + + $where .= " and (1<>1 "; + $schedule_id = explode("S", $schedule_id); + foreach ($schedule_id as $row) { + if ($row == 1) { + $where .= " or p.schedule_h=1 "; + } + + if ($row == 2) { + $where .= " or p.schedule_h1=1 "; + } + + if ($row == 3) { + $where .= " or p.schedule_x=1 "; + } + + if ($row == 4) { + $where .= " or p.schedule_g=1 "; + } + + if ($row == 5) { + $where .= " or p.narcotic=1 "; + } + } + $where .= ")"; + } + + $sql = "SELECT m.item_name, m.id,m.genericname,m.formulation,p.expiry_date,p.mrp,p.CGST_per, SUM(p.tqty) AS Pak_qty, SUM(p.total_unit) AS P_Unit_Qty, p.batch_no,p.selling_unit_rate,p.packing, + SUM(TRUNCATE((p.total_unit-p.total_sale_unit-p.total_lost_unit-p.total_return_unit)/p.packing,0)) AS C_Pak_Qty, SUM(p.total_sale_unit) AS sale_unit, SUM(TRUNCATE((p.total_sale_unit)/p.packing,0)) AS C_Pak_Sale_Qty, m.re_order_qty, + SUM(p.total_unit-p.total_sale_unit-p.total_lost_unit-p.total_return_unit) AS C_Unit_Stock_Qty, SUM(TRUNCATE((p.total_unit-p.total_sale_unit-p.total_lost_unit-p.total_return_unit),0)*p.purchase_unit_rate) AS Stock_Cost, p.purchase_unit_rate , + max(p.HSNCODE) AS HSNCODE + FROM (med_product_master m JOIN purchase_invoice_item p ON m.id=p.item_code and m.is_continue=1 and p.item_return=0 AND p.remove_item=0) + JOIN purchase_invoice i ON p.purchase_id=i.id + WHERE " . $where . " group by m.id,p.purchase_unit_rate,p.packing,p.batch_no,p.expiry_date " . $HAVING . " order by p.Item_name"; + $query = $this->db->query($sql); + $stock_list = $query->result(); + + + $content = ""; + //$content = $sql; + $content .= ' + + + + + + + + + + + + + + + + + + + '; + + foreach ($stock_list as $row) { + + if ($row->C_Pak_Qty <= $row->re_order_qty) { + $tr_color = 'style="background-color: #999999;"'; + } else { + $tr_color = ''; + } + + $content .= ' + + + + + + + + + + + + + + + '; + } + + $content .= '
Item NameCompostion Name (Salt Name)FormulationBatch No.ExpiryPackagePurchase Unit QtyPurchase Unit RateSale Unit QtySale Unit RateMRPCur. QtyGST PerHSNCODE
' . $row->item_name . '' . $row->genericname . '' . $row->formulation . '' . $row->batch_no . '' . $row->expiry_date . '' . $row->packing . '' . $row->P_Unit_Qty . '' . $row->purchase_unit_rate . '' . $row->sale_unit . '' . $row->selling_unit_rate . '' . $row->mrp . '' . $row->C_Unit_Stock_Qty . '' . $row->CGST_per . '' . $row->HSNCODE . '
'; + + //echo $content; + ExportExcel($content, 'Report_Medical_store_stock'); + } + + + public function get_product_stock($product_id, $remove_item = 0) + { + $supplier_id = $this->input->post('input_supplier'); + $date_range = $this->input->post('date_range'); + + $product_pak = $this->input->post('product_pak'); + + $where = "1=1 "; + + if ($date_range <> '0') { + $rangeArray = explode("S", $date_range); + $minRange = $rangeArray[0]; + $maxRange = $rangeArray[1]; + + $where .= " and p.date_of_invoice between '" . $minRange . "' and '" . $maxRange . "'"; + } + + if ($supplier_id > 0) { + $where .= " and m.sid=$supplier_id"; + } + + $where .= " and i.item_code=$product_id and i.packing=$product_pak "; + + $sql = "SELECT i.id,s.name_supplier,s.short_name,i.Item_name, + p.Invoice_no,p.date_of_invoice,i.mrp,i.packing, + i.batch_no,i.expiry_date,i.purchase_price,i.purchase_unit_rate, + i.qty,i.qty_free,i.tqty,i.total_unit,i.total_sale_unit, + i.total_return_unit,i.total_lost_unit, + (i.total_unit-i.total_sale_unit-i.total_lost_unit-i.total_return_unit) as cur_unit + FROM (purchase_invoice p JOIN purchase_invoice_item i ON p.id=i.purchase_id and i.item_return=0) + JOIN med_supplier s ON p.sid=s.sid + WHERE $where and remove_item=$remove_item + Order by p.id"; + + $query = $this->db->query($sql); + $data['product_purchase_detail'] = $query->result(); + + //echo $sql; + + $this->load->view('Medical/Store/Stock_Item_history', $data); + } + + public function get_product_stock_removed($product_id, $remove_item = 0) + { + $supplier_id = $this->input->post('input_supplier'); + $date_range = $this->input->post('date_range'); + + $where = "1=1 "; + + if ($date_range <> '0') { + $rangeArray = explode("S", $date_range); + + $minRange = $rangeArray[0]; + $maxRange = $rangeArray[1]; + + $where .= " and p.date_of_invoice between '" . $minRange . "' and '" . $maxRange . "'"; + } else { + $where .= " and p.date_of_invoice>=date_add(curdate(),interval -1 year)"; + } + + if ($supplier_id > 0) { + $where .= " and m.sid=$supplier_id"; + } + + $where .= " and i.item_code=$product_id"; + + $sql = "SELECT i.id,s.name_supplier,s.short_name,i.Item_name, + p.Invoice_no,p.date_of_invoice,i.mrp, + i.batch_no,i.expiry_date,i.purchase_price,i.purchase_unit_rate, + i.qty,i.qty_free,i.tqty,i.total_unit,i.total_sale_unit, + i.total_return_unit,i.total_lost_unit, + (i.total_unit-i.total_sale_unit-i.total_lost_unit) as cur_unit + 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 $where and remove_item=1 + Order by p.id"; + + $query = $this->db->query($sql); + $data['product_purchase_detail'] = $query->result(); + + $this->load->view('Medical/Store/Stock_Item_history_removed', $data); + } + + public function get_product_stock_return($product_id) + { + $supplier_id = $this->input->post('input_supplier'); + $date_range = $this->input->post('date_range'); + + $where = "1=1 "; + + if ($date_range <> '0') { + $rangeArray = explode("S", $date_range); + + $minRange = $rangeArray[0]; + $maxRange = $rangeArray[1]; + + $where .= " and p.date_of_invoice between '" . $minRange . "' and '" . $maxRange . "'"; + } else { + $where .= " and p.date_of_invoice>=date_add(curdate(),interval -1 year)"; + } + + if ($supplier_id > 0) { + $where .= " and m.sid=$supplier_id"; + } + + $where .= " and i.item_code=$product_id"; + + $sql = "SELECT m.p_r_invoice_no, m.date_of_invoice,m.insert_datetime,i.Item_name,i.qty,s.name_supplier + FROM (purchase_return_invoice m JOIN purchase_return_invoice_item i ON m.id=i.purchase_inv_id) + JOIN med_supplier s ON m.sid=s.sid + WHERE i.item_code=$product_id"; + $query = $this->db->query($sql); + $data['return_purchase'] = $query->result(); + + $sql = "SELECT m.Invoice_no, m.date_of_invoice,m.insert_time,i.Item_name,i.qty,s.name_supplier,i.packing + FROM (purchase_invoice m JOIN purchase_invoice_item i ON m.id=i.purchase_id) + JOIN med_supplier s ON m.sid=s.sid + WHERE i.item_return=1 and i.item_code=$product_id"; + $query = $this->db->query($sql); + $data['return_invoice_purchase'] = $query->result(); + + + $this->load->view('Medical/Store/Stock_Item_history_return', $data); + } + + + public function Org_Bills() + { + $sql = "select * from hc_insurance where id>1 and active=1 "; + $query = $this->db->query($sql); + $data['data_insurance'] = $query->result(); + + $this->load->view('Medical/Report/Report_org_invoice_list', $data); + } + + public function Org_Bills_Report($date_range, $Insurance_id, $output = 0) + { + $rangeArray = explode("S", $date_range); + $minRange = $rangeArray[0]; + $maxRange = $rangeArray[1]; + + $where = " "; + + $where .= " and m.inv_date between '" . $minRange . "' and '" . $maxRange . "'"; + + if ($Insurance_id > 0) { + $where .= " and i.id = " . $Insurance_id; + } + + $sql = "select m.inv_med_code,o.case_id_code,p.p_code,p.p_fname,m.net_amount,i.ins_company_name + from ((invoice_med_master m join patient_master p on m.patient_id=p.id) + join organization_case_master o on m.case_id=o.id) + join hc_insurance i on o.insurance_id=i.id + where m.case_id>1 and m.case_credit=1 " . $where . " "; + $query = $this->db->query($sql); + $data_insurance = $query->result(); + + $content = ""; // $sql; + + $total_amt = 0; + + $content .= ' + + + + + + + + '; + + foreach ($data_insurance as $row) { + $content .= ' + + + + + + + '; + $total_amt = $total_amt + $row->net_amount; + } + + $content .= ' + + + + + + + '; + $content .= '
Inv. IDOrg.CodeP CodeP NameAmountOrg. Name
' . $row->inv_med_code . '' . $row->case_id_code . '' . $row->p_code . '' . $row->p_fname . '' . $row->net_amount . '' . $row->ins_company_name . '
Total' . $total_amt . '
'; + + if ($output == 0) { + create_report_pdf_landscape($content, 'Med_Invoice_org'); + } else { + ExportExcel($content, 'Med_Invoice_org'); + } + } + + + public function Stock_qty_result() + { + $supplier_id = $this->input->post('input_supplier'); + $item_name = $this->input->post('txtsearch'); + $store_id = $this->input->post('input_store_id'); + $chk_reorder = $this->input->post('chk_reorder'); + + $HAVING = ""; + + if ($chk_reorder == "on") { + $HAVING = " HAVING (sum(i.total_unit) - sum(if(ss.sale_qty is NULL,0,ss.sale_qty)))<=pm.re_order_qty"; + } + + $where = " remove_item=0 "; + + if ($supplier_id > 0) { + $where .= " and s.sid = " . $supplier_id; + } + + + if ($item_name <> '') { + $where .= " and i.Item_name like '%" . $item_name . "%' "; + } + + $sql = "SELECT i.Item_name,i.item_code ,sum(distinct i.tqty), + pm.re_order_qty, + sum(i.total_unit) as T_unit, + sum(if(ss.sale_qty is NULL,0,ss.sale_qty)) sal_qty, + GROUP_CONCAT(distinct s.name_supplier) AS supplier_names + FROM (((purchase_invoice_item i join purchase_invoice p on i.purchase_id=p.id ) + join med_supplier s on s.sid=p.sid) + JOIN med_product_master pm ON i.item_code=pm.id AND pm.is_continue=1) + LEFT JOIN + (SELECT item_code,sum(qty) AS sale_qty FROM inv_med_item GROUP BY item_code ) + AS ss ON i.item_code= ss.item_code + Where " . $where . " group by i.item_code " . $HAVING . " order by i.Item_name"; + $query = $this->db->query($sql); + $data['stock_list'] = $query->result(); + + $this->load->view('Medical/Stock/Stock_search_qty_result', $data); + } + + + + + public function Report_Med_patient() + { + $this->load->view('Medical/Report/Report_Med_patient'); + } + + public function drug_patient_distribute($date_range, $item_name, $schedule_id, $output = 0) + { + $rangeArray = explode("S", $date_range); + $minRange = $rangeArray[0]; + $maxRange = $rangeArray[1]; + + $item_name = urldecode($item_name); + //$item_name=$this->input->post('txtsearch'); + + $where = " "; + + $where .= " m.inv_date between '" . $minRange . "' and '" . $maxRange . "'"; + + $schedule_id = explode("S", $schedule_id); + + if ($item_name <> '-') { + $where .= " and (t.item_Name like '%" . $item_name . "%' or t.batch_no ='" . $item_name . "') "; + } else if ($schedule_id > 0) { + $where .= " and (1<>1 "; + foreach ($schedule_id as $row) { + if ($row == 1) { + $where .= " or p.schedule_h=1 "; + } + + if ($row == 2) { + $where .= " or p.schedule_h1=1 "; + } + + if ($row == 3) { + $where .= " or p.schedule_x=1 "; + } + + if ($row == 4) { + $where .= " or p.schedule_g=1 "; + } + + if ($row == 5) { + $where .= " or p.narcotic=1 "; + } + + if ($row == 6) { + $where .= " or p.high_risk=1 "; + } + } + $where .= ")"; + } else { + $where .= " and 1<>1"; + } + + + $sql = "select t.item_Name,m.inv_med_code,m.id as m_id,date_format(m.inv_date,'%d-%m-%Y') as str_inv_date, + date_format(t.expiry,'%m-%Y') as exp_date, + m.patient_id,m.patient_code,m.inv_name,m.ipd_id,m.ipd_code, t.batch_no,sum(if(t.sale_return=0,t.qty,t.qty*-1)) as t_qty, + TRIM(',' FROM Concat(if(p.schedule_h=1,'schedule_h,',''), + if(p.schedule_h1=1,'schedule_h1,',''), + if(p.narcotic=1,'narcotic,',''), + if(p.schedule_x=1,'schedule_x,',''), + if(p.schedule_g=1,'schedule_g,',''))) as shed_x_h + from (invoice_med_master m join inv_med_item t on m.id=t.inv_med_id) + join med_product_master p on p.id=t.item_code + where " . $where . " group by t.item_Name,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->m_id == '') { + $content .= ''; + $content .= ' '; + $content .= ' '; + $content .= ''; + } else { + if ($Head_Content <> $row->item_Name) { + $content .= ''; + $content .= ' '; + $content .= ''; + $Head_Content = $row->item_Name; + } + + $content .= ''; + $content .= ' '; + $content .= ' '; + $content .= ' '; + $content .= ' '; + $content .= ' '; + $content .= ' '; + $content .= ' '; + $content .= ''; + } + } + + $content .= '
Inv.No.Inv.DateIPD No.P Code/NameExp. DateBatchQty
Total Qty : ' . $row->t_qty . '
' . $row->item_Name . '[ ' . $row->shed_x_h . ' ]
' . $row->inv_med_code . '' . $row->str_inv_date . '' . $row->ipd_code . '' . $row->patient_code . ' / ' . $row->inv_name . '' . $row->exp_date . '' . $row->batch_no . '' . $row->t_qty . '
'; + + if ($output == 0) { + $this->load->library('m_pdf'); + + $this->m_pdf->pdf->setBasePath(base_url('/')); + $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'); + } + } + + + + 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 Invoice_med_show($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, + IFNULL(GET_AGE_BY_DOB(dob),age) 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/Invoice_OLD_Master', $data); + } + + public function update_rate() + { + $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( + 'rate_update' => $this->input->post('input_dis_amt'), + 'rate_update_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_rate_final($invoice_id); + #$this->Medical_M->update_invoice_final($invoice_id); + + } + + + public function update_stock_adjust() + { + $item_id = $this->input->post('item_id'); + $qty = $this->input->post('qty'); + + $user = $this->ion_auth->user()->row(); + $user_id = $user->id; + $user_name = $user->first_name . '' . $user->last_name; + + $data_stock_adjuct = array( + 'item_id' => $item_id, + 'qty' => $qty, + 'date_of_adjust' => date('Y-m-d'), + 'update_by' => $user_name . '[' . $user_id . ']' + ); + + + $this->load->model('Medical_M'); + + $ins_id = $this->Medical_M->update_purchase_item_stock_adjust($data_stock_adjuct, $item_id); + + echo $ins_id; + } + + public function remove_stock_item() + { + $item_id = $this->input->post('item_id'); + + $user = $this->ion_auth->user()->row(); + $user_id = $user->id; + $user_name = $user->first_name . '' . $user->last_name; + + $data_stock_adjuct = array( + 'item_id' => $item_id, + 'date_of_adjust' => date('Y-m-d'), + 'qty' => '0', + 'update_by' => $user_name . '[' . $user_id . ']' + ); + + $this->load->model('Medical_M'); + + $ins_id = $this->Medical_M->update_remove_status_item($data_stock_adjuct, $item_id); + + echo $ins_id; + } + + public function add_stock_item() + { + $item_id = $this->input->post('item_id'); + + $user = $this->ion_auth->user()->row(); + $user_id = $user->id; + $user_name = $user->first_name . '' . $user->last_name; + + $data_stock_adjuct = array( + 'item_id' => $item_id, + 'date_of_adjust' => date('Y-m-d'), + 'qty' => '0', + 'update_by' => $user_name . '[' . $user_id . ']' + ); + + $this->load->model('Medical_M'); + + $ins_id = $this->Medical_M->add_removed_item($data_stock_adjuct, $item_id); + + echo $ins_id; + } + + public function Report_IPD_CreditBills() + { + $this->load->view('Medical/Report/Med_Report_IPD_Credit'); + } + + //Supplier Ledger + + public function SupplierAccount() + { + $sql = "SELECT m.sid,m.name_supplier,m.short_name, + SUM(if(l.credit_debit=0,l.amount,l.amount*-1)) AS Tot_Balance, + date_format(MAX(if(l.credit_debit=0 AND l.purchase_id>0,l.tran_date,'')),'%d-%m-%Y') AS Last_InvDate, + date_format(MAX(if(l.credit_debit=1 AND l.purchase_id=0,l.tran_date,'')),'%d-%m-%Y') AS Last_Payment + FROM med_supplier m left JOIN med_supplier_ledger l ON m.sid=l.supplier_id + GROUP BY m.sid + ORDER BY m.name_supplier"; + $query = $this->db->query($sql); + $data['supplier_data'] = $query->result(); + + $this->load->view('Medical/Purchase/supplier_account', $data); + } + + public function SupplierAccount_led($sid) + { + $sql = "SELECT m.sid,m.name_supplier,m.short_name, + SUM(if(l.credit_debit=0,l.amount,l.amount*-1)) AS Tot_Balance, + date_format(MAX(if(l.credit_debit=0 AND l.purchase_id>0,l.tran_date,'')),'%d-%m-%Y') AS Last_InvDate, + date_format(MAX(if(l.credit_debit=1 AND l.purchase_id=0,l.tran_date,'')),'%d-%m-%Y') AS Last_Payment + FROM med_supplier m left JOIN med_supplier_ledger l ON m.sid=l.supplier_id + where m.sid=$sid"; + $query = $this->db->query($sql); + $data['supplier_data'] = $query->result(); + + $this->load->view('Medical/Purchase/supplier_account_detail', $data); + } + + function search_result_tran($s_id, $date_range = '') + { + + if ($date_range == '') { + $date_range = $this->input->post('led_date_range'); + } + + $rangeArray = explode("S", $date_range); + $minRange = $rangeArray[0]; + $maxRange = $rangeArray[1]; + + $where = " date(l.tran_date) BETWEEN '$minRange' AND '$maxRange' "; + + $sql = " SELECT l.*, + CONCAT_WS('/',b.bank_account_name,b.bank_name) AS mode_desc + FROM (med_supplier_ledger l JOIN bank_account_master b ON l.bank_id=b.bank_id) + Where l.supplier_id=$s_id and $where order by tran_date desc"; + $query = $this->db->query($sql); + $data['med_supplier_ledger'] = $query->result(); + + + $sql = " SELECT sum(if(credit_debit=0,amount,amount*-1)) as Balance + FROM med_supplier_ledger l + Where l.supplier_id=$s_id and date(l.tran_date) <'$minRange' "; + $query = $this->db->query($sql); + $supplier_balance_till_date = $query->result(); + + $data['balance_till_date'] = $supplier_balance_till_date[0]->Balance; + + $sql = " SELECT sum(if(credit_debit=0,amount,amount*-1)) as Balance + FROM med_supplier_ledger l + Where l.supplier_id=$s_id and date(l.tran_date) <='$maxRange' "; + $query = $this->db->query($sql); + $supplier_balance_till_date = $query->result(); + $data['balance_till_date_close'] = $supplier_balance_till_date[0]->Balance; + + $sql = " SELECT sum(if(credit_debit=0,amount,0)) as cr_total, + sum(if(credit_debit=1,amount,0)) as dr_total + FROM med_supplier_ledger l + Where l.supplier_id=$s_id and $where "; + $query = $this->db->query($sql); + $supplier_data_total_cr_dr = $query->result(); + + $data['cr_total'] = $supplier_data_total_cr_dr[0]->cr_total; + $data['dr_total'] = $supplier_data_total_cr_dr[0]->dr_total; + + $data['s_id'] = $s_id; + $data['date_range'] = $date_range; + + $this->load->view('Medical/Purchase/ledger_data', $data); + } + + function add_entry($s_id) + { + $this->load->model('Medical_M'); + + $user = $this->ion_auth->user()->row(); + $user_id = $user->id; + $user_name = $user->first_name . '' . $user->last_name . '[' . $user_id . ']'; + + if (isset($_POST) && count($_POST) > 0) { + $params = array( + 'supplier_id' => $s_id, + 'credit_debit' => $this->input->post('cr_dr_type'), + 'tran_date' => str_to_MysqlDate($this->input->post('tran_date')), + 'amount' => $this->input->post('amount'), + 'bank_id' => $this->input->post('mode_type'), + 'tran_desc' => $this->input->post('ref_cust_id'), + 'tran_desc' => $this->input->post('tran_desc'), + 'insert_by_id' => $user_id, + 'insert_by' => $user_name, + ); + + $insert_id = $this->Medical_M->insert_med_supplier_ledger($params); + redirect('Medical_backpanel/SupplierAccount_led/' . $s_id); + } else { + $data['s_id'] = $s_id; + + $sql = "select * from bank_account_master"; + $query = $this->db->query($sql); + $data['bank_account_master'] = $query->result(); + + + + $this->load->view('Medical/Purchase/ledger_add_entry', $data); + } + } + + function edit_entry($tran_id) + { + + $this->load->model('Medical_M'); + + $user = $this->ion_auth->user()->row(); + $user_id = $user->id; + $user_name = $user->first_name . '' . $user->last_name . '[' . $user_id . ']'; + + $sql = "select * from med_supplier_ledger where id=$tran_id"; + $query = $this->db->query($sql); + $data['med_supplier_ledger'] = $query->result(); + + $s_id = $data['med_supplier_ledger'][0]->supplier_id; + + if (isset($_POST) && count($_POST) > 0) { + $params = array( + 'credit_debit' => $this->input->post('cr_dr_type'), + 'tran_date' => str_to_MysqlDate($this->input->post('tran_date')), + 'amount' => $this->input->post('amount'), + 'bank_id' => $this->input->post('mode_type'), + 'tran_desc' => $this->input->post('ref_cust_id'), + 'tran_desc' => $this->input->post('tran_desc'), + 'insert_by_id' => $user_id, + 'insert_by' => $user_name, + ); + + $this->Medical_M->update_med_supplier_ledger($params, $tran_id); + redirect('Medical_backpanel/SupplierAccount_led/' . $s_id); + } else { + + $sql = "select * from bank_account_master"; + $query = $this->db->query($sql); + $data['bank_account_master'] = $query->result(); + + $data['tran_id'] = $tran_id; + + $this->load->view('Medical/Purchase/ledger_edit_entry', $data); + } + } + + // Return Invoice + public function Purchase_return() + { + $this->load->view('Medical/Stock/purchase_return'); + } + + public function PurchaseReturnNew() + { + $sql = "select * from med_supplier order by name_supplier"; + $query = $this->db->query($sql); + $data['supplier_data'] = $query->result(); + + $this->load->view('Medical/Stock/new_purchase_return_invoice', $data); + } + + public function PurchaseReturnInvoice() + { + $sdata = trim($this->input->post('txtsearch')); + + $sdata = preg_replace('/[^A-Za-z0-9_ \-]/', '', $sdata); + + if (trim($sdata) == '') { + $sql = "select p.id,p.p_r_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 + from (purchase_return_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.p_r_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 + from (purchase_return_invoice p join med_supplier s on p.sid=s.sid) + where (p.p_r_invoice_no LIKE '%" . $sdata . "' " . $numric_condition . " ) + group by p.id + order by p.id desc limit 50"; + } + + $query = $this->db->query($sql); + $data['purchase_return_invoice'] = $query->result(); + + $this->load->view('Medical/Stock/purchase_supp_list', $data); + } + + + public function CreatePurchaseReturn() + { + if (!$this->input->is_ajax_request()) { + exit('no valid req.'); + } + + + $sid = $this->input->post('input_supplier'); + $d_invoice = $this->input->post('datepicker_invoice'); + + $where = " where sid=$sid"; + + $Udata = array( + 'sid' => $sid, + 'date_of_invoice' => str_to_MysqlDate($d_invoice), + ); + + $this->load->model('Medical_M'); + + $inser_id = $this->Medical_M->add_purchase_return_invoice($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; + } + + public function PurchaseReturnInvoiceEdit($inv_id) + { + $sql = "select p.id,p.p_r_invoice_no as 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.status as inv_status + from purchase_return_invoice p join med_supplier s on p.sid=s.sid + where p.id=" . $inv_id; + $query = $this->db->query($sql); + $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 + 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); + $data['purchase_return_invoice_item'] = $query->result(); + + $data['inv_id'] = $inv_id; + + $data['content'] = $this->load->view('Medical/Stock/purchase_return_invoice_item', $data, true); + + $this->load->view('Medical/Stock/purchase_return_invoice_edit', $data); + } + + public function PurchaseReturn_invoice_item_list($inv_id) + { + $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 + 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); + $data['purchase_return_invoice_item'] = $query->result(); + + $sql = "select * from purchase_return_invoice where id='" . $inv_id . "' "; + $query = $this->db->query($sql); + $data['purchase_return_invoice'] = $query->result(); + + $this->load->view('Medical/Stock/purchase_return_invoice_item', $data); + } + + public function Purchase_Invoice_product($supp_id) + { + $data['supp_id'] = $supp_id; + + $this->load->view('Medical/Stock/purchase_product_search', $data); + } + + public function Purchase_Invoice_old($supp_id) + { + $sdata = trim($this->input->post('txtsearch')); + + $sdata = preg_replace('/[^A-Za-z0-9_ \-]/', '', $sdata); + + if (trim($sdata) == '') { + $sql = "select p.id as pur_id,p.Invoice_no,p.date_of_invoice, + if(i.expiry_date0 + and p.date_of_invoice>=date_add(curdate(),interval -1 year) + order by p.id desc "; + } else { + + $numric_condition = ""; + + if (is_numeric($sdata)) { + $numric_condition = " OR p.Invoice_no=" . $sdata; + } + + $sql = "select p.id as pur_id,p.Invoice_no,p.date_of_invoice, + if(i.expiry_date0 + and p.date_of_invoice>=date_add(curdate(),interval -1 year) + order by p.id desc "; + } + + $query = $this->db->query($sql); + $data['purchase_list'] = $query->result(); + + $this->load->view('Medical/Stock/purchase_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'); + + $rbatch_no = $this->input->post('rbatch_no'); + $rexpiry_dt = $this->input->post('rexpiry_dt'); + + $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 purchase_invoice_item where id='" . $item_id . "' "; + $query = $this->db->query($sql); + $purchase_invoice_item = $query->result(); + + $update = 0; + $msg_box = ""; + + if (count($purchase_invoice_item) > 0) { + $total_unit = $purchase_invoice_item[0]->total_unit; + $total_sale_unit = $purchase_invoice_item[0]->total_sale_unit; + $total_return_unit = $purchase_invoice_item[0]->total_return_unit; + $total_lost_unit = $purchase_invoice_item[0]->total_lost_unit; + + $cur_unit_qty = $total_unit - $total_sale_unit - $total_return_unit - $total_lost_unit; + + if ($cur_unit_qty > 0) { + $insert_data = array( + 'purchase_inv_id' => $inv_id, + 'purchase_item_id' => $item_id, + 'item_code' => $purchase_invoice_item[0]->item_code, + 'Item_name' => $purchase_invoice_item[0]->Item_name, + 'batch_no_r' => $rbatch_no, + 'expiry_date_r' => $rexpiry_dt, + 'qty' => $rqty + ); + + $this->Medical_M->add_purchase_return_invoiceitem($insert_data); + $update = 1; + $msg_box = "Item Added"; + } else { + $update = 0; + $msg_box = "Current Item Qty is " . $cur_unit_qty; + } + } else { + $update = 0; + $msg_box = "No item found"; + } + + $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 + 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); + $data['purchase_return_invoice_item'] = $query->result(); + + $content = $this->load->view('Medical/Stock/purchase_return_invoice_item', $data, true); + + $rvar = array( + 'update' => $update, + 'msg_text' => $msg_box, + 'content' => $content + ); + + $encode_data = json_encode($rvar); + echo $encode_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,t.purchase_id + 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 + 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['l_purchase_id'] = htmlentities(stripslashes($row['purchase_id'])); + //$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_batch($item_id) + { + if (isset($_GET['term'])) { + $q = strtolower($_GET['term']); + + $sql = "SELECT t.batch_no + FROM med_product_master p + JOIN purchase_invoice_item t + where t.item_code=$item_id and t.batch_no 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['batch_no'])); + $new_row['value'] = htmlentities(stripslashes($row['batch_no'])); + + //$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 remove_item_invoice($itemid) + { + $this->load->model('Medical_M'); + + $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 purchase_return_invoice_item where id='" . $itemid . "' "; + $query = $this->db->query($sql); + $purchase_return_invoice_item = $query->result(); + + $update = 0; + $msg_box = ""; + + $content = ""; + + if (count($purchase_return_invoice_item) > 0) { + $purchase_invoice_item_id = $purchase_return_invoice_item[0]->id; + $r_qty = $purchase_return_invoice_item[0]->qty; + $inv_id = $purchase_return_invoice_item[0]->purchase_inv_id; + + + + $this->Medical_M->delete_purchase_return_invoiceitem($itemid); + + $update = 1; + $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 + 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); + $data['purchase_return_invoice_item'] = $query->result(); + + $content = $this->load->view('Medical/Stock/purchase_return_invoice_item', $data, true); + } else { + $update = 0; + $msg_box = "No item found"; + } + + $rvar = array( + 'update' => $update, + 'msg_text' => $msg_box, + 'content' => $content + ); + + $encode_data = json_encode($rvar); + echo $encode_data; + } + + //Transer Sale Item Purchase ID to Other + + public function Expire_stock() + { + $sql = "select p.id as pur_id,p.Invoice_no,p.date_of_invoice, + if(i.expiry_date0 + and p.date_of_invoice>=date_add(curdate(),interval -1 year) + and i.expiry_datedb->query($sql); + $data['purchase_list'] = $query->result(); + + //echo 'hello'; + $this->load->view('Medical/Stock/expiry_stock_list', $data); + } + + public function stocktransfer() + { + $this->load->view('Medical/Stock/stock_transfer'); + } + + public function merge_product() + { + $this->load->view('Medical/Stock/merge_product'); + } + + public function product_info($product_id) + { + $sql = "select * from med_product_master where id=$product_id"; + $query = $this->db->query($sql); + $product_info = $query->result(); + + if (count($product_info) > 0) { + + $rvar = array( + 'product_id' => $product_info[0]->id, + 'product_name' => $product_info[0]->item_name, + 'formulation' => $product_info[0]->formulation, + 'genericname' => $product_info[0]->genericname, + + ); + } else { + $rvar = array( + 'product_id' => 0, + ); + } + + $encode_data = json_encode($rvar); + + echo $encode_data; + } + + public function product_merged() + { + $from_prod_id = $this->input->post('from_product_id'); + $to_prod_id = $this->input->post('to_product_id'); + + $this->load->model('Medical_M'); + $this->Medical_M->merge_product($from_prod_id, $to_prod_id); + + $rvar = array( + 'ssno' => 0, + ); + + $encode_data = json_encode($rvar); + + echo $encode_data; + } + + public function ssno_info($ssno) + { + $sql = "select * from purchase_invoice_item where id=$ssno"; + $query = $this->db->query($sql); + $product_info = $query->result(); + + if (count($product_info) > 0) { + $total_current_unit = $product_info[0]->total_unit - $product_info[0]->total_sale_unit - $product_info[0]->total_lost_unit + $product_info[0]->total_return_unit; + + $rvar = array( + 'ssno' => $ssno, + 'item_code' => $product_info[0]->item_code, + 'Item_name' => $product_info[0]->Item_name, + 'batch_no' => $product_info[0]->batch_no, + 'purchase_price' => $product_info[0]->purchase_price, + 'tqty' => $product_info[0]->tqty, + 'total_unit' => $product_info[0]->total_unit, + 'total_current_unit' => $total_current_unit, + 'total_sale_unit' => $product_info[0]->total_sale_unit, + ); + } else { + $rvar = array( + 'ssno' => 0, + ); + } + + $encode_data = json_encode($rvar); + + echo $encode_data; + } + + public function ssno_transfer() + { + $from_ssno = $this->input->post('from_ssno'); + $to_ssno = $this->input->post('to_ssno'); + $tqty = $this->input->post('tqty'); + + $this->load->model('Medical_M'); + $this->Medical_M->transfer_ssno($from_ssno, $to_ssno, $tqty); + + $rvar = array( + 'ssno' => 0, + ); + + $encode_data = json_encode($rvar); + + echo $encode_data; + } + + + function search_result_tran_print($s_id, $date_range = '') + { + + if ($date_range == '') { + $date_range = $this->input->post('led_date_range'); + } + + $rangeArray = explode("S", $date_range); + $minRange = $rangeArray[0]; + $maxRange = $rangeArray[1]; + + $where = " date(l.tran_date) BETWEEN '$minRange' AND '$maxRange' "; + + $sql = "Select * from med_supplier where sid=$s_id"; + $query = $this->db->query($sql); + $data['med_supplier'] = $query->result(); + + $data['Statement_between'] = MysqlDate_to_str($minRange) . " AND " . MysqlDate_to_str($maxRange); + + $sql = " SELECT l.*, + CONCAT_WS('/',b.bank_account_name,b.bank_name) AS mode_desc + FROM (med_supplier_ledger l JOIN bank_account_master b ON l.bank_id=b.bank_id) + Where l.supplier_id=$s_id and $where order by tran_date,l.id "; + $query = $this->db->query($sql); + $data['med_supplier_ledger'] = $query->result(); + + + $sql = " SELECT sum(if(credit_debit=0,amount,amount*-1)) as Balance + FROM med_supplier_ledger l + Where l.supplier_id=$s_id and date(l.tran_date) <'$minRange' "; + $query = $this->db->query($sql); + $supplier_balance_till_date = $query->result(); + + $data['balance_till_date'] = $supplier_balance_till_date[0]->Balance; + + $sql = " SELECT sum(if(credit_debit=0,amount,amount*-1)) as Balance,Max(l.tran_date) as Last_date_tran + FROM med_supplier_ledger l + Where l.supplier_id=$s_id and date(l.tran_date) <='$maxRange' "; + $query = $this->db->query($sql); + $supplier_balance_till_date = $query->result(); + + $data['balance_till_date_close'] = $supplier_balance_till_date[0]->Balance; + $data['LAst_date_tran'] = $supplier_balance_till_date[0]->Last_date_tran; + + $sql = " SELECT sum(if(credit_debit=0,amount,0)) as cr_total, + sum(if(credit_debit=1,amount,0)) as dr_total + FROM med_supplier_ledger l + Where l.supplier_id=$s_id and $where "; + $query = $this->db->query($sql); + $supplier_data_total_cr_dr = $query->result(); + + $data['cr_total'] = $supplier_data_total_cr_dr[0]->cr_total; + $data['dr_total'] = $supplier_data_total_cr_dr[0]->dr_total; + + $data['s_id'] = $s_id; + + $content = $this->load->view('Medical/Purchase/ledger_data_print', $data, True); + + $this->load->library('m_pdf'); + + $this->m_pdf->pdf->setBasePath(base_url('/')); + $file_name = 'Report-Ledger-' . $s_id . '-' . date('Ymdhis') . ".pdf"; + $filepath = $file_name; + $this->m_pdf->pdf->WriteHTML($content); + $this->m_pdf->pdf->Output($filepath, "I"); + } + + function Print_bill_on_uhid() + { + $this->load->view('Medical/print_bill_on_uhid'); + } + + function uhid_report($date_range, $p_code) + { + $rangeArray = explode("S", $date_range); + $minRange = $rangeArray[0]; + $maxRange = $rangeArray[1]; + + $sql = "select * from patient_master_exten + where p_code='" . trim($p_code) . "'"; + $query = $this->db->query($sql); + $data['patient_master'] = $query->result(); + + if (count($data['patient_master']) > 0) { + $pid = $data['patient_master'][0]->id; + } else { + $pid = 0; + } + + if ($pid > 0) { + $sql = "Select id from invoice_med_master where patient_id=$pid and ipd_credit=0 and case_credit=0 and inv_date between '$minRange' AND '$maxRange'"; + $query = $this->db->query($sql); + $invoice_med_master = $query->result(); + + $content = ""; + + $net_amount = "0.0"; + $paid_amount = "0.0"; + $balance_amount = "0.0"; + + foreach ($invoice_med_master as $row) { + $inv_id = $row->id; + + $this->db->query("SELECT f_cash_opd_pre_data(" . $inv_id . ")"); + $this->db->query("CALL f_update_med_GST(" . $inv_id . ")"); + + $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,(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, + (twdisc_amount) as twdisc_amount, + (i.disc_amount+i.disc_whole) as d_amt, + (i.CGST+i.SGST) as gst, + (i.CGST_per+i.SGST_per) as gst_per ,i.sale_return + from inv_med_item i join invoice_med_master m + on i.inv_med_id=m.id + where m.id=$inv_id order by i.sale_return,id"; + $query = $this->db->query($sql); + $data['inv_items'] = $query->result(); + + $sql = "select *, + date_format(inv_date,'%d-%m-%Y') as str_inv_date, + (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_med_master'] = $query->result(); + + $data['Doc_name'] = ""; + + if ($data['invoice_med_master'][0]->doc_id > 0) { + $doc_id = $data['invoice_med_master'][0]->doc_id; + + $sql = "select * from doctor_master + where id=$doc_id"; + $query = $this->db->query($sql); + $doctor_master = $query->result(); + + $data['Doc_name'] = $doctor_master[0]->p_title . ' ' . $doctor_master[0]->p_fname; + } else { + $data['Doc_name'] = $data['invoice_med_master'][0]->doc_name; + } + + $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(); + + $net_amount += $data['invoice_med_master'][0]->net_amount; + $paid_amount += $data['invoice_med_master'][0]->payment_received; + $balance_amount += $data['invoice_med_master'][0]->payment_balance; + + $content .= $this->load->view('Medical/Print/medical_bill_print_format_single', $data, TRUE); + + $content .= "
"; + } + + $content .= "Total Net Amount : " . $net_amount . " / "; + $content .= "Paid Amount : " . $paid_amount . " / "; + $content .= "Balance Amount : " . $balance_amount; + } else { + $content = "No Record found"; + } + + + + //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 = false; + + $file_name = 'Report-MedicalBill_' . $inv_id . '_' . date('Ymdhis') . ".pdf"; + + $filepath = $file_name; + + $this->m_pdf->pdf->WriteHTML($content); + + //download it. + $this->m_pdf->pdf->Output($filepath, "I"); + } + + function invoice_item_log() + { + $this->load->view('Medical/Stock/invoice_item_log'); + } + + function invoice_item_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 m.inv_med_code,m.inv_date,m.inv_name,m.log, + GROUP_CONCAT(DISTINCT CONCAT_WS('#',d.item_Name,d.qty,d.price,d.twdisc_amount,d.delete_time,d.delete_by) SEPARATOR ';' ) AS del_item_list, + GROUP_CONCAT(DISTINCT CONCAT_WS('#',p.credit_debit,p.amount,l.update_log) SEPARATOR ';') AS payment_log + FROM ((invoice_med_master m JOIN inv_med_item_delete d ON d.inv_med_id=m.id) + LEFT JOIN payment_history_medical p ON m.id=p.Medical_invoice_id) + Left JOIN paymentmedical_history_log l ON p.id=l.pay_id + WHERE DATE(d.delete_time) BETWEEN '".$minRange."' and '".$maxRange."' AND m.ipd_id=0 + GROUP BY m.id"; + + $query = $this->db->query($sql); + $data['Invoice_history_log']= $query->result(); + + //echo $sql; + $data['opd_date_range']=$opd_date_range; + + $this->load->view('Medical/Stock/invoice_item_log_data',$data); + } +} diff --git a/old_code_ci3/controllers/Mobile_app.php b/old_code_ci3/controllers/Mobile_app.php new file mode 100644 index 0000000..b2366f8 --- /dev/null +++ b/old_code_ci3/controllers/Mobile_app.php @@ -0,0 +1,384 @@ +load->database(); + $this->load->helper(array('cookie','url','language')); + + // Load form helper library + //$this->load->helper('form'); + + // Load form validation library + //$this->load->library('form_validation'); + + // Load session library + $this->load->library('session'); + + $this->load->helper('security'); + + } + + public function index() + { + $this->load->view('Mobile_app/index'); + } + + public function load_dash() + { + $session_set_value = $this->session->all_userdata(); + if (isset($session_set_value['remember_me']) && $session_set_value['remember_me'] == "1") { + $this->load->view('Mobile_app/dash_main'); + } else { + redirect('Mobile_app/select_doctor_login'); + } + } + + public function select_doctor_login() + { + $sql="select d.id ,d.p_fname ,group_concat(m.SpecName) as SpecName + from doctor_master d join doc_spec s join med_spec m on d.id =s.doc_id + and s.med_spec_id =m.id + where d.active=1 group by d.id "; + $query = $this->db->query($sql); + + $data['doctor_data']= $query->result(); + + $this->load->view('Mobile_app/select_doctor',$data); + } + + public function login($doc_id=0) + { + // Retrieve session data + $session_set_value = $this->session->all_userdata(); + + $data['doc_id'] = $doc_id; + + $sql="select d.id ,d.p_fname ,group_concat(m.SpecName) as SpecName + from doctor_master d join doc_spec s join med_spec m on d.id =s.doc_id and s.med_spec_id =m.id + where d.active=1 and d.id=$doc_id group by d.id "; + $query = $this->db->query($sql); + $data['doctor_data_profile']= $query->result(); + + // Check for remember_me data in retrieved session data + if (isset($session_set_value['remember_me']) && $session_set_value['remember_me'] == "1") { + //$this->load->view('admin_page'); + $this->load->view('Mobile_app/dash_main',$data); + } else { + + // Check for validation + $this->form_validation->set_rules('password', 'Pin Number', 'trim|required|xss_clean'); + + if ($this->form_validation->run() == FALSE) { + //$this->load->view('login_form'); + $this->load->view('Mobile_app/login',$data); + } else { + $username = $doc_id; + $password = $this->input->post('password'); + + $sql = "SELECT * + FROM doctor_master + WHERE id=$username and login_pin='$password'"; + + $query = $this->db->query($sql); + $data_login= $query->result(); + + if (count($data_login)>0) { + $this->session->set_userdata('remember_me', TRUE); + + $sess_data = array( + 'p_fname'=> $data_login[0]->p_fname, + 'p_mname'=> $data_login[0]->p_mname, + 'doc_id' => $data_login[0]->id, + 'username' => $username, + 'password' => $password + ); + + $this->session->set_userdata('logged_in', $sess_data); + //$this->load->view('admin_page'); + + + + $data['user'] = 1; + $this->load->view('Mobile_app/dash_main',$data); + + } else { + $data['error_message'] = 'Invalid Pin'; + + $this->load->view('Mobile_app/login', $data); + } + } + } + } + + public function logout() + { + // Destroy session data + $this->session->sess_destroy(); + $data['message_display'] = 'Successfully Logout'; + redirect('Mobile_app/select_doctor_login'); + } + + + //Customer Search + function patient_index_all($day=-1,$doc_id=0) + { + $data['doc_id']=$doc_id; + $data['day']=$day; + + $data['_view'] = ''; + + $this->load->view('Mobile_app/patient_page',$data); + } + + function patient_index($day=0,$doc_id=0) + { + if($doc_id==0) + { + $where=""; + }else{ + $where=" and o.doc_id = ".$doc_id; + } + + if($day>=0){ + $where_date=" and date(o.opd_book_date) = DATE_ADD(CURDATE(),INTERVAL -".$day." DAY)"; + } + + $sql = "SELECT p.*,Date_Format(o.last_opdvisit_date,'%d-%m-%Y %H:%i') AS last_date_visit, + o.*, + if(date(o.opd_book_date)=curdate(),1,0) as opd_today + FROM (patient_master_exten p + JOIN opd_master o ON p.id=o.p_id) + WHERE 1=1 $where_date $where + Group by p.id + order by o.opd_id desc"; + + $query = $this->db->query($sql); + $data['data']= $query->result(); + + $data['doc_id']=$doc_id; + $data['day']=$day; + + $data['sql']= $sql; + + $data['_view'] = 'Mobile_app/patient_search_v'; + + $this->load->view('Mobile_app/patient_page',$data); + } + + function patient_search() + { + $doc_id=$this->input->post('doc_id'); + $day=$this->input->post('day'); + $sdata=$this->input->post('data_search'); + + $where="1=1 "; + + if($doc_id==0) + { + $where.=""; + }else{ + $where.=" and o.doc_id = ".$doc_id; + } + + if($day>=0){ + $where_date=" and date(o.opd_book_date) = DATE_ADD(CURDATE(),INTERVAL -".$day." DAY)"; + }else{ + $where_date=""; + } + + $sdata = preg_replace('/[^A-Za-z0-9 _\-]/', '', trim($sdata)); + + if(is_numeric($sdata)) + { + $where.=" and (mphone1 = '".$sdata."' or udai='".$sdata."' or p_code like '%".$sdata."')" ; + }elseif (filter_var($sdata, FILTER_VALIDATE_EMAIL)) { + $where.=" email1 = '".$sdata."'" ; + }else{ + $where.=" and (p_fname like '%".$sdata."%' or + SUBSTRING_INDEX(p_fname,' ',1) sounds like '".$sdata."')"; + } + + $sql = "SELECT p.*,Date_Format(o.last_opdvisit_date,'%d-%m-%Y %H:%i') AS last_date_visit, + o.*, + if(date(o.opd_book_date)=curdate(),1,0) as opd_today + FROM (patient_master_exten p + JOIN opd_master o ON p.id=o.p_id) + WHERE ".$where." ".$where_date." + order by o.opd_id desc "; + + $query = $this->db->query($sql); + $data['data']= $query->result(); + + $data['sql']= $sql; + + $this->load->view('Mobile_app/patient_search_v',$data); + + + + } + + function patient_index_opd() + { + if (isset($_POST['search'])){ + + $doc_id=$this->input->post('doc_id'); + $day=$this->input->post('day'); + $sdata=$this->input->post('search'); + + if($doc_id==0) + { + $where="1=1 "; + }else{ + $where=" o.doc_id = ".$doc_id; + } + + if($day>=0){ + $where_date=" and date(o.opd_book_date) = DATE_ADD(CURDATE(),INTERVAL -".$day." DAY)"; + }else{ + $where_date=" and date(o.opd_book_date) > DATE_ADD(CURDATE(),INTERVAL -180 DAY)"; + } + + $sdata = preg_replace('/[^A-Za-z0-9 _\-]/', '', trim($sdata)); + + if(is_numeric($sdata)) + { + $where.=" and (mphone1 = '".$sdata."' or udai='".$sdata."' or p_code like '%".$sdata."')" ; + }elseif (filter_var($sdata, FILTER_VALIDATE_EMAIL)) { + $where.=" and email1 = '".$sdata."'" ; + }else{ + $where.=" and (p_fname like '%".$sdata."%' or + SUBSTRING_INDEX(p_fname,' ',1) sounds like '".$sdata."')"; + } + + $sql = "SELECT p.*,Date_Format(p.last_visit,'%d-%m-%Y %H:%i') AS last_date_visit, + o.doc_name, + if(date(o.opd_book_date)=curdate(),1,0) as opd_today + FROM (patient_master_exten p + JOIN opd_master o ON p.id=o.p_id) + WHERE ".$where." ".$where_date." Group by p.id + order by o.opd_id desc "; + + $query = $this->db->query($sql); + $data['data']= $query->result(); + + $data['sql']= $sql; + + $content=$this->load->view('Mobile_app/patient_search_v',$data,TRUE); + + echo $content; + echo $sql; + + } + } + + + function person_record($pno) + { + $sql="select * from patient_master_exten where id=".$pno; + $query = $this->db->query($sql); + $data['data']= $query->result(); + + $sql="select *,date_format(apointment_date,'%d-%m-%Y') as str_apointment_date + from opd_master where p_id=".$pno; + $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, + 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 + from hc_insurance_card i join hc_insurance m on i.insurance_id=m.id + where m.active=1 and 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 p_id=".$pno; + $query = $this->db->query($sql); + $data['case_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"; + + 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; + + $sql="select * from file_upload_data where pid=".$pno." order by id desc"; + $query = $this->db->query($sql); + $data['opd_file_list']= $query->result(); + + $this->load->view('Mobile_app/patient_opd_profile',$data); + + } + + + public function show_profile_opd($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 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(); + + $this->load->view('Mobile_app/person_file_show',$data); + } + + public function take_opd_picture($opd_id,$pno) + { + $data['opd_id']=$opd_id; + $data['pno']=$pno; + + $sql="select * from patient_master_exten where id=".$pno; + $query = $this->db->query($sql); + $data['data']= $query->result(); + + $sql="select o.* from opd_master o where o.opd_id=$opd_id"; + $query = $this->db->query($sql); + $data['opd_master']= $query->result(); + + + $this->load->view('Mobile_app/opd_scan',$data); + } + + //IPD Panel + + public function ipd_panel($doc_id=0) + { + $sql="select * from v_ipd_list + where FIND_IN_SET($doc_id,doc_list)>0 + and (ipd_status=0 or (ipd_status=1 and discharge_date>date_add(sysdate(),interval -15 day)))" ; + $query = $this->db->query($sql); + $data['ipd_data']= $query->result(); + + $sql="select * from v_ipd_list + where (ipd_status=0 or (ipd_status=1 and discharge_date>date_add(sysdate(),interval -15 day)))" ; + $query = $this->db->query($sql); + $data['ipd_data_all']= $query->result(); + + $this->load->view('Mobile_app/ipd_panel',$data); + } + +} + diff --git a/old_code_ci3/controllers/OcasePathLap.php b/old_code_ci3/controllers/OcasePathLap.php new file mode 100644 index 0000000..6d5fb69 --- /dev/null +++ b/old_code_ci3/controllers/OcasePathLap.php @@ -0,0 +1,650 @@ +input->is_ajax_request()) { exit('no valid req.'); } + + $this->load->model('invoice_M'); + $this->load->model('Payment_M'); + + $sql="select * from invoice_master where id='".$this->input->post('lab_invoice_id')."'"; + $query = $this->db->query($sql); + $inv_master= $query->result(); + + $invoice_id=$this->input->post('lab_invoice_id'); + + $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'); + $amountbalanace=0.00; + + if($amountpaid < $inv_master[0]->net_amount )-$amountpaid; + { + $amountbalanace=$inv_master[0]->net_amount; + } + + 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('d/m/Y H:m:s'), + 'remark'=>$pay_remark, + 'update_by'=>$user_name.'['.$user_id.']' + ); + + $insert_id=$this->Payment_M->insert($paydata); + + $data = array( + + 'payment_mode'=> '1', + 'payment_status'=>'1', + 'invoice_status'=>'1', + 'payment_mode_desc'=>'Cash', + 'payment_id'=>$insert_id, + 'confirm_invoice'=>date('d/m/Y H:m:s'), + 'prepared_by'=>$user_name.'['.$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); + 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', + 'payof_type'=>'2', + 'payof_id'=>$invoice_id, + 'payof_code'=>$inv_master[0]->invoice_code, + 'credit_debit'=>'0', + 'amount'=>$amountpaid, + 'payment_date'=>date('d/m/Y H:m: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') + ); + + $insert_id=$this->Payment_M->insert($paydata); + + $data = array( + 'payment_mode'=> '2', + 'payment_status'=>'1', + 'invoice_status'=>'1', + 'payment_mode_desc'=>'Bank Card', + 'payment_id'=>$insert_id, + 'confirm_invoice'=>date('d/m/Y H:m:s'), + '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'), + 'prepared_by'=>$user_name.'['.$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); + 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', + 'payment_mode_desc'=>'IPD Credit', + 'confirm_invoice'=>date('d/m/Y H:m:s'), + 'ipd_id'=>$this->input->post('ipd_id'), + 'prepared_by'=>$user_name.'['.$user_id.']' + + ); + + $this->invoice_M->update( $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'=> '3', + 'payment_status'=>'1', + 'invoice_status'=>'1', + 'payment_mode_desc'=>'Org.Case Credit', + 'confirm_invoice'=>date('d/m/Y H:m:s'), + 'insurance_case_id'=>$this->input->post('case_id'), + 'prepared_by'=>$user_name.'['.$user_id.']' + + ); + + $this->invoice_M->update( $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')==0) + { + + } + } + + public function edit_org_invoice($invoice_id) + { + $sql="select * from hc_item_type"; + $query = $this->db->query($sql); + $data['labitemtype']= $query->result(); + + $sql="select * from doctor_master where active=1"; + $query = $this->db->query($sql); + $data['doclist']= $query->result(); + + $sql="select * from invoice_master where id=".$inser_id; + $query = $this->db->query($sql); + $data['invoiceMaster']= $query->result(); + + $sql="select i.*,t.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(); + + $ins_comp_id=$data['invoiceMaster'][0]->insurance_id; + + if($ins_comp_id<2) + { + $sql="select id,Concat(idesc,' : [',amount,']') as sdesc from hc_items where itype=1"; + }else{ + $sql="select id,Concat(idesc,' : [',amount1,']',if(hc_insurance_id=0,'','-INS')) as sdesc from v_hc_items_with_insurance + where itype=1 and hc_insurance_id in (0,".$ins_comp_id.")"; + } + + $query = $this->db->query($sql); + $data['labitem']= $query->result(); + + $this->load->view('Invoice/Organization_Invoice_PathLab',$data); + } + + 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."' "; + $query = $this->db->query($sql); + $data['person_info']= $query->result(); + + $sql="select * from hc_item_type"; + $query = $this->db->query($sql); + $data['labitemtype']= $query->result(); + + $ins_comp_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(); + + $sql="select * from doctor_master where active=1"; + $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 id,Concat(idesc,' : [',amount1,']',if(hc_insurance_id=0,'','-INS')) as sdesc from v_hc_items_with_insurance + where itype=1 and hc_insurance_id in (0,".$ins_comp_id.") order by idesc "; + } + + $query = $this->db->query($sql); + $data['labitem']= $query->result(); + + $this->load->model('invoice_M'); + + $sql="select count(*) as no_invoice 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($data['chk_draft_invoice'][0]->no_invoice<1) + { + $data['insert_invoice'] = array( + 'attach_type' => '0', + 'attach_id' => $pno, + 'inv_date' => str_to_MysqlDate(date('d/m/Y')), + 'inv_name' => $data['person_info'][0]->p_fname, + 'insurance_id' => $ins_comp_id, + 'insurance_card_id' => $ins_id, + 'insurance_cash' => $data['insurance'][0]->path_cash, + 'insurance_credit' => $data['insurance'][0]->path_credit, + 'inv_a_code' => $data['person_info'][0]->p_code + ); + $inser_id=$this->invoice_M->create_invoice( $data['insert_invoice']); + }else{ + $sql="select id from invoice_master where invoice_status=0 and attach_id=".$pno; + $query = $this->db->query($sql); + $data['invoice_id']= $query->result(); + + $inser_id=$data['invoice_id'][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.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(); + } + + $this->load->view('Invoice/Organization_Invoice_PathLab',$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 id,Concat(idesc,' : [',amount1,']',if(hc_insurance_id=0,'','-INS')) as sdesc from v_hc_items_with_insurance + where itype=".$tid." and hc_insurance_id in (0,".$ins_id.") order by 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 '
+ '; + + echo '
'; + + + } + + 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 update_refer_doc() + { + $invoice_id=$this->input->post('inv_id'); + $doc_id=$this->input->post('doc_id'); + + 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; + } + + $dataupdate = array( + 'refer_by_id' => $doc_id, + 'refer_by_other' => $refername + ); + + $this->load->model('Invoice_M'); + $this->Invoice_M->update($dataupdate,$invoice_id); + } + + + public function showinvoice($invoice_id) + { + $sql="select i.*,t.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(); + + $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; + $query = $this->db->query($sql); + $data['patient_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 ipd_master where ipd_status=0 and p_id=".$data['invoice_master'][0]->attach_id; + $query = $this->db->query($sql); + $data['ipd_master']= $query->result(); + + $sql="select * from organization_case_master where status=0 and p_id=".$data['invoice_master'][0]->attach_id; + $query = $this->db->query($sql); + $data['case_master']= $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(); + + $discount_amount=$data['invoice_master'][0]->discount_amount ; + $total_amount=$data['invoiceGtotal'][0]->Gtotal; + $net_amount=$total_amount-$discount_amount; + $paid_amount=$data['payment_history'][0]->paid_amount; + $balance_amount=$net_amount-$paid_amount; + + if($balance_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 * from invoice_master where id=".$invoice_id; + $query = $this->db->query($sql); + $data['invoice_master']= $query->result(); + + $this->load->view('Invoice/Organization_Invoice_PathLab_final_V',$data); + } + + public function showitem($type) + { + $this->load->model('invoice_M'); + + if($type>0) + { + $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 id,Concat(idesc,' : [',amount1,']',if(hc_insurance_id=0,'','-INS')) as sdesc,amount1 from v_hc_items_with_insurance + where id=".$this->input->post('itype_name_id')." and hc_insurance_id in (0,".$ins_id.")"; + + $query = $this->db->query($sql); + $data['itemlist']= $query->result(); + + $item_rate=$data['itemlist'][0]->amount1; + + $amount_value=$this->input->post('input_qty')*$item_rate; + + } + else + { + $sql="select id,Concat(idesc,' : [',amount,']') 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; + + $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 + ); + + $inser_id=$this->invoice_M->addinvoiceitem( $data['insert_invoice_item']); + + }else{ + $this->db->delete("invoice_item", "id=".$this->input->post('itemid')); + } + + $sql="select i.*,t.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'); + $query = $this->db->query($sql); + $data['invoiceDetails']= $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(); + + echo ' + + + + + + + + + '; + + $srno=0; + + foreach($data['invoiceDetails'] as $row) + { + $srno=$srno+1; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + + echo ''; + } + + echo ''; + + echo ' + + + + + + + + +
#Item GroupCharge NameRateQtyAmount
'.$srno.''.$row->desc.''.$row->item_name.''.$row->item_rate.''.$row->item_qty.''.$row->item_amount.'
#Gross Total'.$data['invoiceGtotal'][0]->Gtotal.'
'; + } + + public function invoice_print($invoice_id) + { + $sql="select i.*,t.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(); + + $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; + $query = $this->db->query($sql); + $data['patient_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 organization_case_master where id=".$data['invoice_master'][0]->insurance_case_id; + $query = $this->db->query($sql); + $data['case_master']= $query->result(); + + $sql="select *,(case payment_mode when 1 Then 'cash' when 2 then 'Bank Card' when 3 then 'Org Credit' else 'Pending' end) 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(); + + $this->load->view('Invoice/Organization_invoice_print_v',$data); + } + +} \ No newline at end of file diff --git a/old_code_ci3/controllers/Ocasemaster.php b/old_code_ci3/controllers/Ocasemaster.php new file mode 100644 index 0000000..477e4bf --- /dev/null +++ b/old_code_ci3/controllers/Ocasemaster.php @@ -0,0 +1,672 @@ +db->query($sql); + $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."' "; + + $query = $this->db->query($sql); + $data['person_info']= $query->result(); + + $sql="select * from hc_item_type"; + + $query = $this->db->query($sql); + $data['labitemtype']= $query->result(); + + $sql="select id,Concat(idesc,' : [',amount1,']',if(hc_insurance_id>0,'Ins.','Cash')) as sdesc from v_hc_items_with_insurance where itype=1 and hc_insurance_id in (0,".$data['or_case_master'][0]->insurance_id.")"; + $query = $this->db->query($sql); + $data['labitem']= $query->result(); + + $this->load->model('invoice_M'); + + $sql="select count(*) as no_invoice from invoice_master where invoice_status=0 and case_id=".$caseid; + $query = $this->db->query($sql); + $data['chk_draft_invoice']= $query->result(); + + if($data['chk_draft_invoice'][0]->no_invoice<1) + { + $data['insert_invoice'] = array( + 'attach_type' => '0', + 'attach_id' => $data['or_case_master'][0]->p_id, + 'case_id' => $caseid, + 'inv_date' => str_to_MysqlDate(date('d/m/Y')), + 'inv_name' => $data['person_info'][0]->p_fname, + 'inv_a_code' => $data['person_info'][0]->p_code + ); + $inser_id=$this->invoice_M->create_invoice( $data['insert_invoice']); + }else{ + $sql="select id from invoice_master where invoice_status=0 and attach_id=".$data['or_case_master'][0]->p_id; + $query = $this->db->query($sql); + $data['invoice_id']= $query->result(); + + $inser_id=$data['invoice_id'][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.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(); + } + + $this->load->view('Invoice/Organization_Invoice_PathLab',$data); + } + + public function create() { + if (!$this->input->is_ajax_request()) { exit('no valid req.'); } + + $FormRules = array( + array( + 'field' => 'input_mphone1', + 'label' => 'Phone Number', + 'rules' => 'required|min_length[10]|max_length[30]' + ), + array( + 'field' => 'input_name', + 'label' => 'Name', + 'rules' => 'required|min_length[2]|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[2]|max_length[50]' + ) + ); + + $this->form_validation->set_rules($FormRules); + + if ($this->form_validation->run() == TRUE) + { + $ins_id=$this->input->post('Insurance_id'); + $case_type=$this->input->post('case_type'); + + $sql="select * from hc_insurance where id=".$ins_id; + $query = $this->db->query($sql); + $data['data_insurance']= $query->result(); + + $ins_id_name = $data['data_insurance'][0]->ins_company_name; + + $this->load->model('Ocasemaster_M'); + $data = array( + 'p_phone_number' => $this->input->post('input_mphone1'), + 'p_name' => $this->input->post('input_name'), + 'p_gender' => $this->input->post('optionsRadios_gender'), + 'date_registration' => str_to_MysqlDate($this->input->post('datepicker_dob')), + 'p_id' => $this->input->post('p_id'), + 'case_type' => $this->input->post('case_type'), + 'insurance_card_id'=>$this->input->post('inc_card_id'), + 'insurance_no' => $this->input->post('input_insurance_id'), + 'insurance_no_1' => $this->input->post('input_insurance_no_1'), + 'insurance_no_2' => $this->input->post('input_insurance_no_2'), + 'insurance_no_3' => $this->input->post('input_insurance_no_3'), + 'insurance_card_name' => $this->input->post('input_card_holder_name'), + 'insurance_id' => $this->input->post('Insurance_id'), + 'insurance_company_name' => $ins_id_name + ); + + $sql="select * from organization_case_master + where status=0 and case_type=$case_type and p_id=".$this->input->post('p_id'); + $query = $this->db->query($sql); + $chk_data= $query->result(); + + if(count($chk_data)>0) + { + $inser_id=$chk_data[0]->id; + + }else{ + $inser_id=$this->Ocasemaster_M->insert($data); + } + + if($case_type==1) + { + $sql="select * from ipd_master + where case_id=0 and ipd_status=0 and p_id=".$this->input->post('p_id'); + $query = $this->db->query($sql); + $ipd_master= $query->result(); + + if(count($ipd_master)>0) + { + $this->load->model('Ipd_M'); + $update_ipd=array( + 'case_id'=>$inser_id + ); + $this->Ipd_M->update($update_ipd,$ipd_master[0]->id); + + $update_org=array( + 'ipd_id'=>$ipd_master[0]->id + ); + $this->Ocasemaster_M->update($update_org,$inser_id); + } + } + + $rvar=array( + 'insertid' =>$inser_id, + 'p_id'=> $this->input->post('p_id'), + 'ins_id'=>$ins_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 load($caseid) + { + $sql="select * from organization_case_master where id='".$caseid."' "; + $query = $this->db->query($sql); + $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."' "; + $query = $this->db->query($sql); + $data['data']= $query->result(); + + $sql="select * from hc_insurance"; + $query = $this->db->query($sql); + $data['data_insurance']= $query->result(); + + $this->load->view('Invoice/Case_Form_profile_V',$data); + } + + public function newcase($p_no,$ins_id,$case_type=0) + { + $sql="select * from hc_insurance where id=".$ins_id; + $query = $this->db->query($sql); + $data['data_insurance']= $query->result(); + + $sql="select * from hc_insurance_card where p_id=".$p_no." and insurance_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 organization_case_master + where case_type=$case_type and p_id='".$p_no."' and status=0 "; + $query = $this->db->query($sql); + $data['org_case_master']= $query->result(); + + if($query->num_rows()<1) + { + $new_case=1; + }else{ + $new_case=0; + } + + $data['case_type']=$case_type; + + $this->db->where('id', $p_no); + $this->db->from('patient_master'); + $query = $this->db->get(); + $data['data']= $query->result(); + + $sql="select * from hc_insurance "; + $query = $this->db->query($sql); + $data['insurance_list']= $query->result(); + + + if($new_case==1) + { + $this->load->view('Invoice/Case_Form_V',$data); + } + else{ + $this->load->view('Invoice/Case_Form_profile_V',$data); + } + + } + + + + public function open_case($org_ID,$case_type=0) + { + $sql="select * from organization_case_master + where case_type=$case_type and id= $org_ID"; + $query = $this->db->query($sql); + $data['org_case_master']= $query->result(); + + $ins_id_org=$data['org_case_master'][0]->insurance_id; + $p_no=$data['org_case_master'][0]->p_id; + + $sql="select * from hc_insurance_card where p_id=".$p_no." order by id desc"; + $query = $this->db->query($sql); + $data['hc_insurance_card']= $query->result(); + + $ins_id=$data['hc_insurance_card'][0]->insurance_id; + + $sql="select * from hc_insurance where id=".$ins_id; + $query = $this->db->query($sql); + $data['data_insurance']= $query->result(); + + + $sql="select * from hc_insurance "; + $query = $this->db->query($sql); + $data['insurance_list']= $query->result(); + + $data['ipd_id']=0; + $data['case_type']=$case_type; + + if($case_type==1) + { + $sql="select * from ipd_master where case_id=$org_ID"; + $query = $this->db->query($sql); + $ipd_master= $query->result(); + + if(count($ipd_master)>0) + { + $data['ipd_id']=$ipd_master[0]->id; + } + } + + $this->db->where('id', $p_no); + $this->db->from('patient_master'); + $query = $this->db->get(); + $data['data']= $query->result(); + + $this->load->view('Invoice/Case_Form_profile_V',$data); + + } + + public function update() { + if (!$this->input->is_ajax_request()) { exit('no valid req.'); } + + $FormRules = array( + array( + 'field' => 'input_mphone1', + 'label' => 'Phone Number', + 'rules' => 'required|min_length[10]|max_length[30]' + ), + array( + 'field' => 'input_name', + 'label' => 'Name', + 'rules' => 'required|min_length[2]|max_length[30]' + ), + array( + 'field' => 'input_insurance_id', + 'label' => 'Insurance No', + 'rules' => 'required|min_length[2]|max_length[30]' + ), + array( + 'field' => 'datepicker_dob', + 'label' => 'Date of Registration', + 'rules' => 'required|min_length[2]|max_length[30]' + ), + array( + 'field' => 'input_card_holder_name', + 'label' => 'Insurance Card Holder Name', + 'rules' => 'required|min_length[2]|max_length[50]' + ) + ); + + $this->form_validation->set_rules($FormRules); + + if ($this->form_validation->run() == TRUE) + { + $ins_id=$this->input->post('Insurance_id'); + $p_id=$this->input->post('patient_id'); + $case_type=$this->input->post('case_type'); + $case_id=$this->input->post('c_id'); + + $sql="select * from hc_insurance where id=".$ins_id; + $query = $this->db->query($sql); + $data['data_insurance']= $query->result(); + + $ins_id_name = $data['data_insurance'][0]->ins_company_name; + + $sql="select * from organization_case_master where id=$case_id"; + $query = $this->db->query($sql); + $org_case_master= $query->result(); + + $this->load->model('Ocasemaster_M'); + $data = array( + 'p_phone_number' => $this->input->post('input_mphone1'), + 'p_name' => $this->input->post('input_name'), + 'p_gender' => $this->input->post('optionsRadios_gender'), + 'date_registration' => str_to_MysqlDate($this->input->post('datepicker_dob')), + 'remark' => $this->input->post('remark'), + 'insurance_no' => $this->input->post('input_insurance_id'), + 'insurance_no_1' => $this->input->post('input_insurance_no_1'), + 'insurance_no_2' => $this->input->post('input_insurance_no_2'), + 'insurance_no_3' => $this->input->post('input_insurance_no_3'), + 'insurance_card_name' => $this->input->post('input_card_holder_name'), + 'insurance_id' => $ins_id, + 'insurance_company_name' => $ins_id_name + ); + + $inser_id=$this->Ocasemaster_M->update($data,$case_id); + + if($case_type==0) + { + $this->db->query("CALL p_org_update($case_id)"); + } + + if($case_type==1 && $org_case_master[0]->ipd_id==0) + { + $sql="select * from ipd_master where ipd_status=0 and case_id=0 and p_id=".$p_id; + $query = $this->db->query($sql); + $ipd_master= $query->result(); + + if(count($ipd_master)>0) + { + $this->load->model('Ipd_M'); + $update_ipd=array( + 'case_id'=>$this->input->post('c_id') + ); + $this->Ipd_M->update($update_ipd,$ipd_master[0]->id); + + $update_org=array( + 'ipd_id'=>$ipd_master[0]->id + ); + $this->Ocasemaster_M->update($update_org,$inser_id); + + $update_ins_card=array( + 'insurance_id'=>$ins_id, + 'insurance_id'=>$ins_id_name, + ); + $this->Ocasemaster_M->update($update_org,$inser_id); + } + } + + + $rvar=array( + 'update' =>1, + 'showcontent'=> Show_Alert('success','Saved','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 confirm_payment() + { + if (!$this->input->is_ajax_request()) { exit('no valid req.'); } + + $this->load->model('invoice_M'); + + $showcontent1='
+
+ Print +
+
+ Payment Method by : '; + + $showcontent2='
'; + + if($this->input->post('mode')==1) + { + + $data = array( + + 'payment_mode'=> '1', + 'payment_status'=>'1' + + ); + + $this->invoice_M->update( $data,$this->input->post('oid')); + + $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_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) + { + $data = array( + 'payment_mode'=> '2', + 'payment_status'=>'1', + 'card_bank'=>$this->input->post('input_card_mac'), + 'card_remark'=>$this->input->post('input_card_digit'), + 'card_tran_id'=>$this->input->post('input_card_tran') + ); + $this->Opd_M->update( $data,$this->input->post('oid')); + + $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', + 'ech_clam_id'=>$this->input->post('input_claim_id'), + + ); + + $this->invoice_M->update( $data,$this->input->post('oid')); + + $status='ECHS Credit'; + $showcontent=$showcontent1.$status.$showcontent2; + + $rvar=array( + 'update' =>1, + 'showcontent'=>$showcontent + ); + + $encode_data = json_encode($rvar); + echo $encode_data; + } + + if($this->input->post('mode')==0) + { + + } + } + + public function list_pathtest_bytype() + { + $tid=$this->input->post('itype_idv'); + $insid=$this->input->post('insurance_id'); + + $sql="select id,Concat(idesc,' : [',amount1,']',if(hc_insurance_id>0,'Ins.','Cash')) as sdesc from v_hc_items_with_insurance where itype='".$tid."' and hc_insurance_id in (0,".$insid.")"; + $query = $this->db->query($sql); + $data['labitem']= $query->result(); + + echo '
+ +
'; + + } + + public function showinvoice($invoice_id) + { + $sql="select i.*,t.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(); + + $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; + $query = $this->db->query($sql); + $data['patient_master']= $query->result(); + + $this->load->view('Invoice_PathLab_final_V',$data); + } + + public function showitem($type) + { + $this->load->model('invoice_M'); + + if($type>0) + { + $sql="select * from v_hc_items_with_insurance where id=".$this->input->post('itype_name_id'); + $query = $this->db->query($sql); + $data['itemlist']= $query->result(); + + $amount_value=$this->input->post('input_qty')*$data['itemlist'][0]->amount; + $amount_value2=$this->input->post('input_qty')*$data['itemlist'][0]->amount1; + + $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]->idesc, + 'item_rate' => $data['itemlist'][0]->amount, + 'item_added_date' => str_to_MysqlDate(date('d/m/Y')), + 'item_qty' => $this->input->post('input_qty'), + 'item_amount' => $amount_value, + 'item_amount1' => $amount_value2 + ); + + $inser_id=$this->invoice_M->addinvoiceitem( $data['insert_invoice_item']); + + }else{ + + $this->db->delete("invoice_item", "id=".$this->input->post('itemid')); + } + + $sql="select i.*,t.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'); + $query = $this->db->query($sql); + $data['invoiceDetails']= $query->result(); + + $sql="select sum(if(item_amount1>0,item_amount1,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(); + + echo ' + + + + + + + + + + '; + + $srno=1; + + foreach($data['invoiceDetails'] as $row) + { + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + $srno=$srno+1; + echo ''; + } + + echo ' + + + + + + + + +
#TypeTest NameRateQtyCash AmtINS Amount
'.$srno.''.$row->desc.''.$row->item_name.''.$row->item_rate.''.$row->item_qty.''.$row->item_amount.''.$row->item_amount1.'
#Gross Total'.$data['invoiceGtotal'][0]->Gtotal.'
'; + + } + + + + +} \ No newline at end of file diff --git a/old_code_ci3/controllers/Opd.php b/old_code_ci3/controllers/Opd.php new file mode 100644 index 0000000..4816383 --- /dev/null +++ b/old_code_ci3/controllers/Opd.php @@ -0,0 +1,2186 @@ +load->library("Pdf"); + } + + public function addopd($pno,$org_case_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(); + + $sql="select d.id ,d.p_fname ,group_concat(m.SpecName) as SpecName + from doctor_master d join doc_spec s join med_spec m on d.id =s.doc_id and s.med_spec_id =m.id + where d.active=1 group by d.id "; + $query = $this->db->query($sql); + $data['doc_spec_l']= $query->result(); + + $data['org_case_id']=$org_case_id; + + if($org_case_id>0) + { + $sql="SELECT * + from organization_case_master + where id= $org_case_id"; + $query = $this->db->query($sql); + $data['org_case_master']= $query->result(); + } + + $this->load->view('opd_appointment_V',$data); + } + + + + public function showfee() + { + $doc_id=$this->input->post('doc_id'); + $p_id=$this->input->post('pid'); + $org_case_id=$this->input->post('org_case_id'); + + $sql="select * + from doctor_master + where id=$doc_id"; + $query = $this->db->query($sql); + $doctor_master= $query->result(); + + $no_opd_days=5-1; + + if(count($doctor_master)>0) + { + $no_opd_days=$doctor_master[0]->opd_valid_no_days-1; + } + + $sql="select d.id ,d.p_fname ,group_concat(m.SpecName) as SpecName,if(d.gender=1,'Male','Female') as xGender + from doctor_master d join doc_spec s join med_spec m on d.id =s.doc_id and s.med_spec_id =m.id + where d.active=1 and d.id=".$doc_id." group by d.id "; + $query = $this->db->query($sql); + $doc_info= $query->result(); + + $sql="SELECT * from opd_master where p_id=".$p_id." and doc_id=".$doc_id." + and apointment_date >= date_add(curdate(),interval -$no_opd_days day) and opd_fee_type<>3"; + $query = $this->db->query($sql); + $opd_running= $query->result(); + + $sql="SELECT * from opd_master where p_id=".$p_id." "; + $query = $this->db->query($sql); + $opd_old= $query->result(); + + $fee_type_list="4,0"; + + $fee_type_select=1; + + if(count($opd_old)>0) + { + if(count($opd_running)>0) + { + $fee_type_select=3; + $fee_type_list.=",3"; + }else{ + $fee_type_select=2; + $fee_type_list.=",2"; + } + + }else{ + $fee_type_select=1; + $fee_type_list.=",1"; + } + + $content=''; + + $content.= '

Doctor Name : '.$doc_info[0]->p_fname.' / Specialization: '.$doc_info[0]->SpecName.' / + Gender : '.$doc_info[0]->xGender.'

'; + $content.= ''; + + + $sql="SELECT d.*,if(d.doc_fee_desc='',t.fee_type,d.doc_fee_desc) AS fee_desc + FROM doc_opd_fee d JOIN doc_fee_type t ON d.doc_fee_type=t.id + WHERE doc_id=".$doc_id." and t.id in (".$fee_type_list.")"; + + $query = $this->db->query($sql); + $data['doc_fee_a']= $query->result(); + + $sql="SELECT d.*,if(d.doc_fee_desc='',t.fee_type,d.doc_fee_desc) AS fee_desc + FROM doc_opd_fee d JOIN doc_fee_type t ON d.doc_fee_type=t.id + WHERE doc_id=".$doc_id." and t.id not in (".$fee_type_list.")"; + + $query = $this->db->query($sql); + $data['doc_fee_b']= $query->result(); + + + + $checked=''; + + foreach($data['doc_fee_a'] as $row) + { + if($row->id==$fee_type_select) + { + $checked='checked'; + } + + $content.= '
'; + } + + $content.="
"; + + $other_content=''; + + foreach($data['doc_fee_b'] as $row) + { + if($row->id==$fee_type_select) + { + $checked='checked'; + } + + $other_content.= '
'; + } + + $content.='
'; + $content.='
+ +
+
+ '.$other_content.' +
+
+
+
'; + + $rvar=array( + 'csrfName' => $this->security->get_csrf_token_name(), + 'csrfHash' => $this->security->get_csrf_hash(), + 'content'=>$content + ); + + $encode_data = json_encode($rvar); + + echo $encode_data ; + + } + + public function invoice($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 'ECHS Credit' else 'Pending' end) as Payment_type_str + from opd_master where opd_id=".$opdid; + $query = $this->db->query($sql); + $data['opd_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['opd_master'][0]->p_id."' "; + + $query = $this->db->query($sql); + $data['patient_master']= $query->result(); + + $sql="select * from organization_case_master + where status=0 and case_type=0 and p_id=".$data['patient_master'][0]->id; + $query = $this->db->query($sql); + $data['case_master']= $query->result(); + + $sql="select * from hc_insurance where id=".$data['opd_master'][0]->insurance_id; + $query = $this->db->query($sql); + $data['insurance']= $query->result(); + + $sql="select * from refund_order where refund_process=0 and refund_type=1 and refund_type_id=".$opdid; + $query = $this->db->query($sql); + $data['refund_order']= $query->result(); + + if(count($data['refund_order'])>0) + { + $data['refund_status']=1; // Refund Pending + }else{ + $data['refund_status']=0 ; //No Pending + } + + $sql="select sum(if(credit_debit=0,amount,amount*-1)) as paid_amount from payment_history where payof_type=1 and payof_id=".$opdid; + $query = $this->db->query($sql); + $data['payment_history']= $query->result(); + + $data['paid_amount']=0; + + if($data['payment_history'][0]->paid_amount=='' || $data['payment_history'][0]->paid_amount==0 ) + { + $data['paid_amount']=0; + }else{ + $data['paid_amount']=$data['payment_history'][0]->paid_amount; + } + + $opd_fee_gross_amount=$data['opd_master'][0]->opd_fee_amount; + + if($data['opd_master'][0]->payment_mode==4) + { + $data['pending_amount']=0; + }else{ + $data['pending_amount']=$opd_fee_gross_amount-$data['paid_amount']; + } + + $sql="select d.id ,d.p_fname ,group_concat(m.SpecName) as SpecName + from doctor_master d join doc_spec s join med_spec m on d.id =s.doc_id and s.med_spec_id =m.id + where d.active=1 group by d.id "; + $query = $this->db->query($sql); + $data['doc_spec_l']= $query->result(); + + $sql="select s.id,s.pay_type,m.bank_name + From hospital_bank m join hospital_bank_payment_source s on m.id=s.bank_id"; + $query = $this->db->query($sql); + $data['bank_data']= $query->result(); + + $this->load->view('opd_invoice_V',$data); + + } + + public function invoice_print($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); + $data['opd_master']= $query->result(); + + $sql="select *,if(gender=1,'Male','Female') as xgender, + GET_AGE_2(dob,age,age_in_month,estimate_dob,'".$data['opd_master'][0]->apointment_date."') AS age from patient_master where id='".$data['opd_master'][0]->p_id."' "; + + $query = $this->db->query($sql); + $data['patient_master']= $query->result(); + + $sql="select * from hc_insurance where id=".$data['opd_master'][0]->insurance_id; + $query = $this->db->query($sql); + $data['insurance']= $query->result(); + + if($data['opd_master'][0]->insurance_case_id>0) + { + $sql="select * from organization_case_master where id=".$data['opd_master'][0]->insurance_case_id; + $query = $this->db->query($sql); + $data['case_master']= $query->result(); + } + + $this->load->view('invoice_print_v',$data); + } + + + + public function opd_lettre_print($opdid) + { + $sql="Select * from opd_master where opd_id=$opdid"; + $query = $this->db->query($sql); + $opd_master= $query->result(); + + $doc_id=0; + $no_opd_days=5-1; + + if(count($opd_master)>0){ + + $doc_id=$opd_master[0]->doc_id; + + $sql="select * + from doctor_master + where id=$doc_id"; + $query = $this->db->query($sql); + $doctor_master= $query->result(); + + if(count($doctor_master)>0) + { + $no_opd_days=$doctor_master[0]->opd_valid_no_days-1; + } + } + + $sql="select *,date_format(apointment_date,'%d-%m-%Y') as str_apointment_date, + date_format(date_add(apointment_date,interval $no_opd_days 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); + $data['opd_master']= $query->result(); + + $sql="select *,if(gender=1,'M','F') as xgender, + GET_AGE_2(dob,age,age_in_month,estimate_dob,'".$data['opd_master'][0]->apointment_date."') AS age from patient_master where id='".$data['opd_master'][0]->p_id."' "; + $query = $this->db->query($sql); + $data['patient_master']= $query->result(); + + $sql="select *,date_format(date_add(apointment_date,interval $no_opd_days day),'%d-%m-%Y') as opd_Exp_Date from opd_master + where p_id=".$data['opd_master'][0]->p_id." and opd_id < ".$opdid." + order by opd_id desc limit 1"; + $query = $this->db->query($sql); + $data['old_opd']= $query->result(); + + $sql="select * from hc_insurance where id=".$data['opd_master'][0]->insurance_id; + $query = $this->db->query($sql); + $data['insurance']= $query->result(); + + if($data['opd_master'][0]->insurance_case_id>0) + { + $sql="select * from organization_case_master where id=".$data['opd_master'][0]->insurance_case_id; + $query = $this->db->query($sql); + $data['case_master']= $query->result(); + } + + $this->load->view('opd_letter_head',$data); + } + + + public function confirm_opd() + { + $this->load->model('Opd_M'); + + $user = $this->ion_auth->user()->row(); + $user_id = $user->id; + $user_name_info = $user->first_name.' '. $user->last_name.'['.date('d-m-Y H:i:s').']'; + + $sql="select * from patient_master where id=".$this->input->post('pid'); + $query = $this->db->query($sql); + $data['person_info']= $query->result(); + + $sql="select d.id ,d.p_fname ,group_concat(m.SpecName) as SpecName,if(d.gender=1,'Male','Female') as xGender + from doctor_master d join doc_spec s join med_spec m on d.id =s.doc_id and s.med_spec_id =m.id + where d.active=1 and d.id=".$this->input->post('doc_id')." group by d.id "; + $query = $this->db->query($sql); + $data['doc_info']= $query->result(); + + $sql="select * from doc_opd_fee where id=".$this->input->post('fee_id'); + $query = $this->db->query($sql); + $data['doc_fee']= $query->result(); + + $sql="select * from opd_master where p_id=".$this->input->post('pid')." order by opd_id desc"; + $query = $this->db->query($sql); + $data['opd_master']= $query->result(); + + $last_Vist_date=''; + + if(count($data['opd_master'])>0) + { + $last_Vist_date=$data['opd_master'][0]->apointment_date; + } + + $opd_fee_amount=$data['doc_fee'][0]->amount; + $opd_fee_desc=$data['doc_fee'][0]->doc_fee_desc; + $echs_credit=0; + + $doc_id=$this->input->post('doc_id'); + + $data['insert'] = array( + 'p_id' => $this->input->post('pid'), + 'P_name' => strtoupper($data['person_info'][0]->p_fname), + 'doc_id' => $this->input->post('doc_id'), + 'insurance_id' => '0', + 'opd_fee_id' => $this->input->post('fee_id'), + 'opd_fee_amount' => $opd_fee_amount, + 'opd_fee_gross_amount' => $opd_fee_amount, + 'opd_fee_desc' => $opd_fee_desc, + 'doc_name' => $data['doc_info'][0]->p_fname, + 'opd_fee_type' =>$data['doc_fee'][0]->doc_fee_type, + 'apointment_date' =>str_to_MysqlDate($this->input->post('datepicker_appointment')), + 'doc_spec' => $data['doc_info'][0]->SpecName, + 'prepared_by' => $user_name_info, + ); + + $data['patient_master'] = array( + 'last_visit' => str_to_MysqlDate($this->input->post('datepicker_appointment')), + ); + + if(count($data['opd_master'])>0) + { + $data['insert']=array_merge($data['insert'],array('last_opdvisit_date'=>$data['opd_master'][0]->apointment_date)); + } + + $inser_id=$this->Opd_M->insert( $data['insert']); + + if($inser_id>0) + { + $this->load->model('Patient_M'); + $this->Patient_M->update($data['patient_master'],$this->input->post('pid')); + } + + $rvar=array( + 'insertid' =>$inser_id, + 'error_text'=>'OPD Register', + 'csrfName' => $this->security->get_csrf_token_name(), + 'csrfHash' => $this->security->get_csrf_hash(), + ); + + $encode_data = json_encode($rvar); + echo $encode_data; + + } + + public function confirm_payment() + { + if (!$this->input->is_ajax_request()) { exit('no valid req.'); } + + $this->load->model('Opd_M'); + $this->load->model('Payment_M'); + + $user = $this->ion_auth->user()->row(); + $user_id = $user->id; + $user_name_info = $user->first_name.''. $user->last_name.'['.date('d-m-Y H:i:s').']'; + + $submit_page=$this->input->post('spid'); + $oid=$this->input->post('oid'); + + $sql="select * from opd_master where opd_id='".$oid."'"; + $query = $this->db->query($sql); + $opd_master= $query->result(); + + $sql="select COALESCE(SUM(if(credit_debit=0,amount,amount*-1)),0) AS opd_pay + from payment_history where payof_id='$oid' and payof_type=1"; + $query = $this->db->query($sql); + $chk_payment= $query->result(); + + $pending_amt=$opd_master[0]->opd_fee_amount-$chk_payment[0]->opd_pay; + + $pay_remark=''; + if($opd_master[0]->opd_discount>0) + { + $pay_remark='Dis.Amt.:'.$opd_master[0]->opd_disc_remark.' /Amount: '. $opd_master[0]->opd_discount.'/Update:'.$opd_master[0]->opd_disc_update_by; + } + + if($this->input->post('mode')==0) + { + $paydata = array( + 'payment_mode'=> '0', + 'payof_type'=>'1', + 'payof_id'=>$this->input->post('oid'), + 'payof_code'=>$opd_master[0]->opd_code, + 'credit_debit'=>'0', + 'amount'=>$opd_master[0]->opd_fee_amount, + 'payment_date'=>date('Y-m-d H:i:s'), + 'remark'=>$pay_remark, + 'update_by'=>$user_name_info.' ['.$user_id.']', + 'update_by_id'=>$user_id, + 'insert_code'=>$submit_page + ); + + $insert_id=$this->Payment_M->insert($paydata); + + $data = array( + 'payment_mode'=> '0', + 'payment_status'=>'1', + 'payment_mode_desc'=>'No Cost', + 'payment_id'=>$insert_id, + 'confirm_pay_opd'=>date('Y-m-d H:i:s'), + 'prepared_by_id'=>$user_id + ); + + $this->Opd_M->update( $data,$this->input->post('oid')); + + $status='Zero Cost'; + + + $rvar=array( + 'update' =>1, + 'showcontent'=>$status, + ); + + $encode_data = json_encode($rvar); + echo $encode_data; + } + + if($this->input->post('mode')==1 && $pending_amt>0) + { + $paydata = array( + 'payment_mode'=> '1', + 'payof_type'=>'1', + 'payof_id'=>$this->input->post('oid'), + 'payof_code'=>$opd_master[0]->opd_code, + 'credit_debit'=>'0', + 'amount'=>$opd_master[0]->opd_fee_amount, + 'payment_date'=>date('Y-m-d H:i:s'), + 'remark'=>$pay_remark, + 'update_by'=>$user_name_info.' ['.$user_id.']', + 'update_by_id'=>$user_id, + 'insert_code'=>$submit_page + ); + + $insert_id=$this->Payment_M->insert($paydata); + + $data = array( + 'payment_mode'=> '1', + 'payment_status'=>'1', + 'payment_mode_desc'=>'Cash', + 'payment_id'=>$insert_id, + 'confirm_pay_opd'=>date('Y-m-d H:i:s'), + 'prepared_by_id'=>$user_id + ); + + $this->Opd_M->update( $data,$this->input->post('oid')); + + $status='CASH'; + + $rvar=array( + 'update' =>1, + 'showcontent'=>$status, + ); + + $encode_data = json_encode($rvar); + echo $encode_data; + } + + if($this->input->post('mode')==2 && $pending_amt>0 ) + { + $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', + 'payof_type'=>'1', + 'payof_id'=>$this->input->post('oid'), + 'payof_code'=>$opd_master[0]->opd_code, + 'credit_debit'=>'0', + 'amount'=>$opd_master[0]->opd_fee_amount, + 'payment_date'=>date('Y-m-d H:i:s'), + 'remark'=>$pay_remark, + 'update_by'=>$user_name_info.' ['.$user_id.']', + 'pay_bank_id'=>$this->input->post('cbo_pay_type'), + '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', + 'payment_mode_desc'=>'Bank/Online', + 'confirm_pay_opd'=>date('Y-m-d H:i:s'), + 'payment_id'=>$insert_id, + 'prepared_by_id'=>$user_id + ); + + $this->Opd_M->update( $data,$this->input->post('oid')); + + $status='Bank Card'; + + $rvar=array( + 'update' =>1, + 'showcontent'=>$status, + + ); + + $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')==4) + { + $data = array( + + 'payment_mode'=> '4', + 'payment_status'=>'1', + 'payment_mode_desc'=>'Org.Case Credit', + 'confirm_pay_opd'=>date('d/m/Y H:m:s'), + 'insurance_case_id'=>$this->input->post('case_id'), + 'prepared_by_id'=>$user_id + ); + + $this->Opd_M->update( $data,$this->input->post('oid')); + + $status='Org. Case Credit'; + + + $rvar=array( + 'update' =>1, + 'showcontent'=>$status, + ); + + $encode_data = json_encode($rvar); + echo $encode_data; + } + } + + public function update_discount() + { + $oid=$this->input->post('oid'); + + $opd_discount=$this->input->post('input_dis_amt'); + + $user = $this->ion_auth->user()->row(); + $user_id = $user->id; + $user_name = $user->first_name.''. $user->last_name; + + $sql="select * from opd_master where opd_id=".$oid; + $query = $this->db->query($sql); + $data['opd_master']= $query->result(); + + $opd_fee_amount=$data['opd_master'][0]->opd_fee_gross_amount-$opd_discount; + + $dataupdate = array( + 'opd_discount' => $this->input->post('input_dis_amt'), + 'opd_disc_remark' => $this->input->post('input_dis_desc'), + 'opd_fee_amount' => $opd_fee_amount, + 'opd_disc_update_by'=>$user_name.'['.$user_id.']' + ); + + $this->load->model('Opd_M'); + $this->Opd_M->update($dataupdate,$oid); + + } + + public function update_doc_date() + { + $oid=$this->input->post('oid'); + + $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'); + + + $doc_name_id=$this->input->post('doc_name_id'); + $datepicker_opddate=str_to_MysqlDate($this->input->post('datepicker_opddate')); + $doc_opd_fee=$this->input->post('opd_fee_amt'); + + + $sql="select * from opd_master where opd_id=".$oid; + $query = $this->db->query($sql); + $data['opd_master']= $query->result(); + + $sql="select d.id ,d.p_fname ,group_concat(m.SpecName) as SpecName,if(d.gender=1,'Male','Female') as xGender + from doctor_master d join doc_spec s join med_spec m on d.id =s.doc_id and s.med_spec_id =m.id + where d.active=1 and d.id=".$doc_name_id." group by d.id "; + $query = $this->db->query($sql); + $data['doc_info']= $query->result(); + + $opd_fee_amount=$doc_opd_fee-$data['opd_master'][0]->opd_discount; + + $dataupdate = array( + 'doc_id' => $doc_name_id, + 'doc_name' => $data['doc_info'][0]->p_fname, + 'doc_spec' => $data['doc_info'][0]->SpecName, + 'apointment_date' => $datepicker_opddate, + 'opd_fee_gross_amount'=>$doc_opd_fee, + 'opd_fee_amount'=>$opd_fee_amount + ); + + $this->load->model('Opd_M'); + $this->Opd_M->update($dataupdate,$oid); + + $sql="select * from opd_master where opd_id=".$oid; + $query = $this->db->query($sql); + $data['opd_master']= $query->result(); + + $sql="select * from payment_history where payof_type=1 and payof_id=".$oid." and id=".$data['opd_master'][0]->payment_id; + $query = $this->db->query($sql); + $payment_history= $query->result(); + + if(count($payment_history)>0) + { + $amount_diff=$payment_history[0]->amount-$opd_fee_amount; + if($amount_diff<>0) + { + $pay_remark=$payment_history[0]->remark." /Update OPD Rate Difference ".$amount_diff." :By ".$user_name; + + $paydata = array( + 'amount'=>$data['opd_master'][0]->opd_fee_amount, + 'remark'=>$pay_remark, + ); + $this->load->model('Payment_M'); + $this->Payment_M->update($paydata,$payment_history[0]->id); + } + + } + + } + + public function opd_load_doc($opdid) + { + $data['opdid']=$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); + $data['opd_master']= $query->result(); + + $sql="select *,if(gender=1,'Male','Female') as xgender, + GET_AGE_2(dob,age,age_in_month,estimate_dob,'".$data['opd_master'][0]->apointment_date."') AS age + from patient_master where id='".$data['opd_master'][0]->p_id."' "; + $query = $this->db->query($sql); + $data['person_info']= $query->result(); + + $this->load->view('Person/OPD_file_upload',$data); + } + + + public function save_image($opdid) + { + $filename = 'OPD-'.$opdid.'-'.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; + + //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('File_M'); + + $file_insert_id=$this->File_M->insert($data['upload_data']); + + $sql="select * from opd_master where opd_id=".$opdid; + $query = $this->db->query($sql); + $opd_master= $query->result(); + + $pid=0; + $ipd_id=0; + $org_id=0; + + if(count($opd_master)>0) + { + $pid=$opd_master[0]->p_id; + $org_id=$opd_master[0]->insurance_case_id; + } + + $udata = array( + 'upload_by'=> $user_name, + 'pid'=>$pid, + 'opd_id'=>$opdid, + 'ipd_id'=>$ipd_id, + 'case_id'=>$org_id, + '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'); + + $opdstatus=2; + + if($opdstatus=='2') + { + $status_str='Visit Done'; + }elseif($opdstatus=='3') + { + $status_str='Visit Cancel'; + } + + $opd_status_remark=$status_str.' Update By:'.$user_name; + + $dataupdate = array( + 'opd_status' => $opdstatus, + 'opd_status_remark' => $opd_status_remark + ); + + $this->load->model('Opd_M'); + $this->Opd_M->update($dataupdate,$opdid); + } + + echo $filename; + } + } + public function save_image_mobile($opdid) + { + $filename = 'OPD-'.$opdid.'-'.time() . '.jpg'; + + $folder_name='uploads/'.date('Ymd'); + + if (!file_exists($folder_name)) { + mkdir($folder_name, 0777, true); + } + + + $user_id = '0'; + $user_name = 'Mobile'; + + //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('userfile')) { + $error = array('error' => $this->upload->display_errors()); + echo $error['error']; + }else{ + $data = array('upload_data' => $this->upload->data()); + + //print_r($data); + + $this->load->model('File_M'); + + $file_insert_id=$this->File_M->insert($data['upload_data']); + + $sql="select * from opd_master where opd_id=".$opdid; + $query = $this->db->query($sql); + $opd_master= $query->result(); + + $pid=0; + $ipd_id=0; + $org_id=0; + + if(count($opd_master)>0) + { + $pid=$opd_master[0]->p_id; + $org_id=$opd_master[0]->insurance_case_id; + } + + $udata = array( + 'upload_by'=> $user_name, + 'pid'=>$pid, + 'opd_id'=>$opdid, + 'ipd_id'=>$ipd_id, + 'case_id'=>$org_id, + 'upload_by_id'=>$user_id + ); + + if($file_insert_id>0) + { + $this->File_M->update($udata,$file_insert_id); + + $opdstatus=2; + + if($opdstatus=='2') + { + $status_str='Visit Done'; + }elseif($opdstatus=='3') + { + $status_str='Visit Cancel'; + } + + $opd_status_remark=$status_str.' Update By:'.$user_name; + + $dataupdate = array( + 'opd_status' => $opdstatus, + 'opd_status_remark' => $opd_status_remark + ); + + $this->load->model('Opd_M'); + $this->Opd_M->update($dataupdate,$opdid); + } + + echo 'File Upload successfully'; + } + } + + public function save_image_mobile_bak($opdid) + { + $filename = 'OPD-'.$opdid.'-'.time() . '.jpg'; + + $folder_name='uploads/'.date('Ymd'); + + if (!file_exists($folder_name)) { + mkdir($folder_name, 0777, true); + } + + + $user_id = '0'; + $user_name = 'Mobile'; + + //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); + + $img = $_POST['userfile']; + $img = str_replace('data:image/jpeg;base64,', '', $img); + $img = str_replace(' ', '+', $img); + $data = base64_decode($img); + + $file = $folder_name . '.jpeg'; + + $success = file_put_contents($file, $data); + + print $success ? $file : 'Unable to save the file.'; + + if (!$success) { + $data = array('upload_data' => $this->upload->data()); + print_r($data); + + $error = array('error' => $this->upload->display_errors()); + echo $error['error']; + }else{ + $data = array('upload_data' => $this->upload->data()); + + print_r($data); + + $this->load->model('File_M'); + + $file_insert_id=$this->File_M->insert($data['upload_data']); + + $sql="select * from opd_master where opd_id=".$opdid; + $query = $this->db->query($sql); + $opd_master= $query->result(); + + $pid=0; + $ipd_id=0; + $org_id=0; + + if(count($opd_master)>0) + { + $pid=$opd_master[0]->p_id; + $org_id=$opd_master[0]->insurance_case_id; + } + + $udata = array( + 'upload_by'=> $user_name, + 'pid'=>$pid, + 'opd_id'=>$opdid, + 'ipd_id'=>$ipd_id, + 'case_id'=>$org_id, + 'upload_by_id'=>$user_id + ); + + if($file_insert_id>0) + { + $this->File_M->update($udata,$file_insert_id); + + $opdstatus=2; + + if($opdstatus=='2') + { + $status_str='Visit Done'; + }elseif($opdstatus=='3') + { + $status_str='Visit Cancel'; + } + + $opd_status_remark=$status_str.' Update By:'.$user_name; + + $dataupdate = array( + 'opd_status' => $opdstatus, + 'opd_status_remark' => $opd_status_remark + ); + + $this->load->model('Opd_M'); + $this->Opd_M->update($dataupdate,$opdid); + } + + echo 'File Upload successfully'; + } + } + + public function opd_file_hide($file_id) + { + $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('File_M'); + + $this->File_M->update($udata,$file_id); + + redirect('/Opd/opd_file_last_list'); + } + + public function opd_file_last_list($opdid='') + { + $user = $this->ion_auth->user()->row(); + $upload_by_id = $user->id; + + if($opdid=='') + { + $sql="select f.id,f.full_path,date_format(f.insert_date,'%d/%m/%Y-%H:%i') as strinsert_date, + f.file_ext,p.p_fname,p.str_age from file_upload_data f join patient_master_exten p on f.pid=p.id + where show_type=0 and upload_by_id=".$upload_by_id." order by id desc limit 5"; + }else{ + $sql="select f.id,f.full_path,date_format(f.insert_date,'%d/%m/%Y-%H:%i') as strinsert_date, + f.file_ext,p.p_fname,p.str_age from file_upload_data f join patient_master_exten p on f.pid=p.id + where show_type=0 and opd_id=$opdid and upload_by_id=$upload_by_id order by id desc limit 5"; + } + + $query = $this->db->query($sql); + $data['opd_file_list']= $query->result(); + + $this->load->view('Person/scan_opd_list',$data); + } + + public function opd_file_list($opdid) + { + $sql="select * from file_upload_data where show_type=0 and opd_id=".$opdid; + $query = $this->db->query($sql); + $data['opd_file_list']= $query->result(); + + $sql="select * from file_opd_rec where opd_id=".$opdid; + $query = $this->db->query($sql); + $file_opd_rec= $query->result(); + + foreach($file_opd_rec as $row) + { + $full_path=$row->full_path; + $file_v_no=$row->v_no; + + $start_no=stripos($full_path,$file_v_no); + $end_no=strlen($full_path); + + $folder_name=substr($full_path,0,$start_no); + + $files_info = get_dir_file_info($folder_name); + + foreach($files_info as $key => $value) { + $find_file=number_format(substr_count($value['name'],$file_v_no),0); + if($find_file==1) + { + $index_key=str_replace($file_v_no.'_','',$value['name']); + $index_key=str_replace('.webm','',$index_key); + + $file_list[$index_key] = $value['name']; + } + } + + ksort($file_list); + + $prev_file=''; + $current_file=''; + foreach($file_list as $key => $value) { + $current_file=$folder_name.'/'.$value; + if(strlen($prev_file)>0) + { + //First File + $objFH = fopen( $prev_file, "rb" ); + $strBuffer1 = fread( $objFH, filesize( $prev_file) ); + fclose( $objFH ); + + //Second File + $objFH = fopen( $current_file, "rb" ); + $strBuffer2 = fread( $objFH, filesize( $current_file) ); + fclose( $objFH ); + + // manipulate buffers here... + $strBuffer3 = $strBuffer1 . $strBuffer2; + + // open for write/binary-safe + $objFH = fopen( $current_file, "wb" ); + fwrite( $objFH, $strBuffer3 ); + fclose( $objFH ); + + //Delete prev File + unlink($prev_file); + + $prev_file=$current_file; + + $data_upload = array( + 'opd_id' => $opd_id, + 'full_path' => $current_file, + ); + + $this->load->model('FileOPDRec_M'); + + $this->FileOPDRec_M->insert($data_upload,$file_v_no); + } + + } + + + + } + + $sql="select * from file_opd_rec where opd_id=".$opdid; + $query = $this->db->query($sql); + $data['file_opd_rec']= $query->result(); + + $this->load->view('Person/opd_file_show',$data); + + } + + public function opd_file_upload($opdid) + { + $data['opdid']=$opdid; + + $this->load->view('Person/opd_scanfile_upload',$data); + } + + public function opd_scanfiles_upload($opdid) + { + + $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; + + $output_dir = $folder_name; + + if(isset($_FILES["myfile"])) + { + $ret = array(); + + $error = $_FILES["myfile"]["error"]; + + // upload single file + if(!is_array($_FILES["myfile"]["name"])) //single file + { + $filename = 'OPD-'.$opdid.'-'.time() .$_FILES["myfile"]["name"]; + $config['upload_path'] = $folder_name; + $config['file_name'] = $filename; + $config['allowed_types'] = 'gif|jpg|png|jpeg|pdf|doc'; + + $this->load->library('upload', $config); + echo $filename; + //move_uploaded_file($_FILES["myfile"]["tmp_name"],$output_dir.$fileName); + + if (!$this->upload->do_upload('myfile')) { + $error = array('error' => $this->upload->display_errors()); + echo $error['error']; + }else{ + $data = array('upload_data' => $this->upload->data()); + $this->load->model('File_M'); + $file_insert_id=$this->File_M->insert($data['upload_data']); + + $sql="select * from opd_master where opd_id=".$opdid; + $query = $this->db->query($sql); + $opd_master= $query->result(); + + $pid=0; + $ipd_id=0; + $org_id=0; + + if(count($opd_master)>0) + { + $pid=$opd_master[0]->p_id; + $org_id=$opd_master[0]->insurance_case_id; + } + + $udata = array( + 'opd_id'=>$opdid, + 'pid'=>$pid, + 'ipd_id'=>$ipd_id, + 'case_id'=>$org_id + ); + + if($file_insert_id>0) + { + $this->File_M->update($udata,$file_insert_id); + } + + } + + $ret[]= $_FILES["myfile"]["name"]; + } + else + { + // Handle Multiple files + $fileCount = count($_FILES["myfile"]["name"]); + for($i=0; $i<$fileCount; $i++) + { + $filename = 'OPD-'.$opdid.'-'.$i.'-'.time() .$_FILES["myfile"]["name"]; + + //$fileName = $_FILES["myfile"]["name"][$i]; + //move_uploaded_file($_FILES["myfile"]["tmp_name"][$i],$output_dir.$fileName); + + if (!$this->upload->do_upload($_FILES["myfile"]["tmp_name"][$i])) { + $error = array('error' => $this->upload->display_errors()); + echo $error['error']; + }else{ + $data = array('upload_data' => $this->upload->data()); + $this->load->model('File_M'); + $file_insert_id=$this->File_M->insert($data['upload_data']); + + $sql="select * from opd_master where opd_id=".$opdid; + $query = $this->db->query($sql); + $opd_master= $query->result(); + + $pid=0; + $ipd_id=0; + $org_id=0; + + if(count($opd_master)>0) + { + $pid=$opd_master[0]->p_id; + $ipd_id=$opd_master[0]->ipd_id; + $org_id=$opd_master[0]->insurance_case_id; + } + + $udata = array( + 'upload_by'=> $user_name, + 'pid'=>$pid, + 'opd_id'=>$opdid, + 'ipd_id'=>$ipd_id, + 'case_id'=>$org_id + ); + + if($file_insert_id>0) + { + $this->File_M->update($udata,$file_insert_id); + } + } + + $ret[]= $_FILES["myfile"]["name"][$i]; + } + } + // output file names as comma seperated strings to display status + echo json_encode($ret); + } + } + + public function opd_status($opdid,$opdstatus) + { + $user = $this->ion_auth->user()->row(); + $user_id = $user->id; + $user_name = $user->first_name.''. $user->last_name.':T-'.date('d-m-Y h:m:s'); + + $status_str=""; + + if($opdstatus=='2') + { + $status_str='Visit Done'; + }elseif($opdstatus=='3') + { + $status_str='Visit Cancel'; + } + + $opd_status_remark=$status_str.' Update By:'.$user_name; + + $dataupdate = array( + 'opd_status' => $opdstatus, + 'opd_status_remark' => $opd_status_remark + ); + + $this->load->model('Opd_M'); + $this->Opd_M->update($dataupdate,$opdid); + } + + public function get_appointment($opd_date='') + { + if($opd_date=='') + { + $opd_date=date('Y-m-d'); + + } + + $data["opd_date"]=$opd_date; + + $sql="select group_concat(DISTINCT o.doc_id ) as doc_list_opd + from (doctor_master d join doc_spec s join med_spec m on d.id=s.doc_id and m.id=s.med_spec_id) + join opd_master o on d.id=o.doc_id and o.apointment_date='".$opd_date."'"; + $query = $this->db->query($sql); + $doc_opd= $query->result(); + + if(count($doc_opd)>0) + { + $doc_opd_list=$doc_opd[0]->doc_list_opd; + }else{ + $doc_opd_list="0"; + } + + if($doc_opd_list=='') + { + $doc_opd_list="0"; + } + + $sql="select d.id as doc_id, d.p_fname,count(DISTINCT o.opd_id) as No_opd, + group_concat(DISTINCT m.SpecName) as Spec, + count( DISTINCT CASE o.opd_status WHEN 1 THEN o.opd_id END) as count_wait, + count( DISTINCT CASE o.opd_status WHEN 2 THEN o.opd_id END) as count_visit, + count( DISTINCT CASE o.opd_status WHEN 3 THEN o.opd_id END) as count_cancel, + MOD(d.id,5) as color_code + from (doctor_master d join doc_spec s join med_spec m on d.id=s.doc_id and m.id=s.med_spec_id) + left join opd_master o on d.id=o.doc_id and o.apointment_date='".$opd_date."' + where o.doc_id in (".$doc_opd_list.") + group by d.p_fname having count(DISTINCT o.opd_id)>0 "; + $query = $this->db->query($sql); + $data['doc_master']= $query->result(); + + + $data['color']=array( + '0' => 'bg-yellow', + '1' => 'bg-red', + '2' => 'bg-green', + '3' => 'bg-gray', + '4' => 'bg-orange', + '5' => 'bg-blue' + ); + $data['content']=$this->load->view('dashboard/opd_appointment_panel',$data,True); + + $this->load->view('dashboard/appointment',$data); + } + + public function get_appointment_data($opd_date='') + { + if($opd_date=='') + { + $opd_date=date('Y-m-d'); + + } + + $data["opd_date"]=$opd_date; + + $sql="select group_concat(DISTINCT o.doc_id ) as doc_list_opd + from (doctor_master d join doc_spec s join med_spec m on d.id=s.doc_id and m.id=s.med_spec_id) + join opd_master o on d.id=o.doc_id and o.apointment_date='".$opd_date."'"; + $query = $this->db->query($sql); + $doc_opd= $query->result(); + + if(count($doc_opd)>0) + { + $doc_opd_list=$doc_opd[0]->doc_list_opd; + }else{ + $doc_opd_list="0"; + } + + if($doc_opd_list=='') + { + $doc_opd_list="0"; + } + + $sql="select d.id as doc_id, d.p_fname,count(DISTINCT o.opd_id) as No_opd, + group_concat(DISTINCT m.SpecName) as Spec, + count( DISTINCT CASE o.opd_status WHEN 1 THEN o.opd_id END) as count_wait, + count( DISTINCT CASE o.opd_status WHEN 2 THEN o.opd_id END) as count_visit, + count( DISTINCT CASE o.opd_status WHEN 3 THEN o.opd_id END) as count_cancel, + MOD(d.id,5) as color_code + from (doctor_master d join doc_spec s join med_spec m on d.id=s.doc_id and m.id=s.med_spec_id) + left join opd_master o on d.id=o.doc_id and o.apointment_date='".$opd_date."' + where o.doc_id in (".$doc_opd_list.") + group by d.p_fname having count(DISTINCT o.opd_id)>0 "; + $query = $this->db->query($sql); + $data['doc_master']= $query->result(); + + + $data['color']=array( + '0' => 'bg-yellow', + '1' => 'bg-red', + '2' => 'bg-green', + '3' => 'bg-gray', + '4' => 'bg-orange', + '5' => 'bg-blue' + ); + $this->load->view('dashboard/opd_appointment_panel',$data); + } + + + public function opd_display($doc_id=1) + { + $opd_date=date('Y-m-d'); + + $data["opd_date"]=$opd_date; + + $sql=" SELECT o.opd_id,o.opd_code,p.id,p.p_code,o.P_name,m.queue_no,o.opd_fee_desc,o.payment_status, + 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) + JOIN opd_prescription m ON o.opd_id=m.opd_id) + LEFT JOIN payment_history h ON o.opd_id=h.payof_id AND h.payof_type=1 + WHERE ( o.apointment_date = '".$opd_date."' ) + and o.opd_status=1 and o.doc_id ='".$doc_id."' + GROUP BY o.opd_id + ORDER BY opd_id "; + + $query = $this->db->query($sql); + $data['opd_list_1']= $query->result(); + + $doc_id=2; + + $sql=" SELECT o.opd_id,o.opd_code,p.id,p.p_code,o.P_name,m.queue_no,o.opd_fee_desc,o.payment_status, + 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) + JOIN opd_prescription m ON o.opd_id=m.opd_id) + LEFT JOIN payment_history h ON o.opd_id=h.payof_id AND h.payof_type=1 + WHERE ( o.apointment_date = '".$opd_date."' ) + and o.opd_status=1 and o.doc_id ='".$doc_id."' + GROUP BY o.opd_id + ORDER BY opd_id "; + + $query = $this->db->query($sql); + $data['opd_list_2']= $query->result(); + + $data['color']=array(); + + $sql="select id,color_name,code_code from color"; + $query = $this->db->query($sql); + $color= $query->result(); + + foreach($color as $aRow) + { + array_push($data['color'],$aRow->code_code); + } + + $data['color1']=array( + '0' => 'bg-yellow', + '1' => 'bg-red', + '2' => 'bg-green', + '3' => 'bg-gray', + '4' => 'bg-orange', + '5' => 'bg-blue' + ); + + $this->load->view('dashboard/opd_display',$data); + } + + public function opd_cancel($opdid) + { + $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=$this->input->post('input_remark'); + + $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=1 and payof_id=".$opdid; + $query = $this->db->query($sql); + $payment_history= $query->result(); + + $sql="select * from opd_master + where opd_id=".$opdid; + $query = $this->db->query($sql); + $opd_master= $query->result(); + + $sql="select * from refund_order + where refund_process=0 and refund_type=1 and refund_type_id=".$opdid; + $query = $this->db->query($sql); + $refund_order= $query->result(); + + $insert_id=0; + + if(count($payment_history)>0 && count($refund_order)<1) + { + if($payment_history[0]->paid_amount>0 && $opd_master[0]->opd_status==1) + { + $RefundRequest = array( + 'refund_type' => 1, + 'refund_type_id' => $opdid, + 'refund_type_code' => $opd_master[0]->opd_code, + 'refund_type_reason' => 'Cancel OPD', + 'approved_by_id' => $user_id, + 'approved_by' => $user_name, + 'refund_amount' => $payment_history[0]->paid_amount + ); + + $this->load->model('Payment_M'); + $insert_id=$this->Payment_M->insert_refundorder($RefundRequest); + } + }else{ + $insert_id=1; + } + + $dataupdate = array( + 'opd_status' => '3', + 'opd_status_remark' => $opd_status_remark + ); + + $this->load->model('Opd_M'); + $this->Opd_M->update($dataupdate,$opdid); + + echo $insert_id; + + } + + public function opd_crorg($opdid,$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=1 and payof_id=".$opdid; + $query = $this->db->query($sql); + $payment_history= $query->result(); + + $sql="select * from opd_master where opd_id=".$opdid; + $query = $this->db->query($sql); + $opd_master= $query->result(); + + $sql="select * from refund_order where refund_process=0 and refund_type=1 and refund_type_id=".$opdid; + $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 && $opd_master[0]->opd_status==1) + { + $RefundRequest = array( + 'refund_type' => 1, + 'refund_type_id' => $opdid, + 'refund_type_code' => $opd_master[0]->opd_code, + 'refund_type_reason' => 'Cr. to Org.', + 'approved_by_id' => $user_id, + 'approved_by' => $user_name, + 'refund_amount' => $payment_history[0]->paid_amount + ); + + $this->load->model('Payment_M'); + $this->Payment_M->insert_refundorder($RefundRequest); + } + } + + $dataupdate = array( + 'payment_mode' => 3, + 'payment_id' => 0, + 'insurance_case_id' => $org_code_id, + ); + + $this->load->model('Opd_M'); + $this->Opd_M->update($dataupdate,$opdid); + } + + public function opd_discount_update($opdid) + { + $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_discount=$this->input->post('input_dis_amt'); + $opd_disc_remark=$this->input->post('input_dis_desc'); + + $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=1 and payof_id=".$opdid; + $query = $this->db->query($sql); + $payment_history= $query->result(); + + $sql="select * from opd_master where opd_id=".$opdid; + $query = $this->db->query($sql); + $opd_master= $query->result(); + + $sql="select * from refund_order where refund_process=0 and refund_type=1 and refund_type_id=".$opdid; + $query = $this->db->query($sql); + $refund_order= $query->result(); + + if(count($payment_history)>0 && count($refund_order)<1) + { + $opd_fee_amount=$opd_master[0]->opd_fee_gross_amount-$opd_discount; + + if($payment_history[0]->paid_amount>0 && $opd_master[0]->opd_status==1 && $opd_fee_amount>=0 && $opd_discount>0) + { + $RefundRequest = array( + 'refund_type' => 1, + 'refund_type_id' => $opdid, + 'refund_type_code' => $opd_master[0]->opd_code, + 'refund_type_reason' => 'Discount', + 'approved_by_id' => $user_id, + 'approved_by' => $user_name, + 'refund_amount' => $opd_discount, + 'patient_id' => $opd_master[0]->p_id, + 'patient_name' =>$opd_master[0]->P_name + ); + + $this->load->model('Payment_M'); + $this->Payment_M->insert_refundorder($RefundRequest); + } + + if($opd_fee_amount>=0) + { + $dataupdate = array( + 'opd_discount' => $opd_discount, + 'opd_disc_remark' => $opd_disc_remark, + 'opd_fee_amount' => $opd_fee_amount, + 'opd_disc_update_by'=>$user_name.'['.$user_id.']' + ); + + $this->load->model('Opd_M'); + $this->Opd_M->update($dataupdate,$opdid); + } + } + } + + public function scan_opd_desktop() + { + $this->load->view('Person/opd_scan_desktop'); + } + + public function search_scan_opd() + { + $sdata=$this->input->post('txtsearch'); + + $sdata = preg_replace('/[^A-Za-z0-9 _\-]/', '', trim($sdata)); + + if(is_numeric($sdata)) + { + $where=" (mphone1 = '".$sdata."' or udai='".$sdata."' or p_code like '%".$sdata."')" ; + }elseif (filter_var($sdata, FILTER_VALIDATE_EMAIL)) { + $where=" email1 = '".$sdata."'" ; + }else{ + $where=" (p_fname like '%".$sdata."%' or + SUBSTRING_INDEX(p_fname,' ',1) sounds like '".$sdata."')"; + } + + $sql = "SELECT p.*,o.opd_id, + o.doc_name,o.opd_code,Date_Format(o.opd_book_date,'%d-%m-%Y') as App_Date, + if(MAX(date(o.opd_book_date))=curdate(),Date_Format(MAX(o.opd_book_date),'%d-%m-%Y %H:%i'),0) as opd_today + FROM (patient_master_exten p JOIN opd_master o ON p.id=o.p_id) + WHERE ".$where." Group by o.opd_id + order by o.opd_id desc "; + + + $query = $this->db->query($sql); + $data['opd_list']= $query->result(); + + $this->load->view('Person/opd_scan_search',$data); + } + + + + public function SelectOPD($opdid) + { + + $sql = "select o.opd_id, o.doc_name,o.opd_code,o.P_name,o.p_id,Date_Format(o.apointment_date,'%d-%m-%Y') as App_Date, + p.p_code,p.mphone1,p.email1 ,if(o.insurance_id>1,'Org.','Direct') as Inv_Type, + m.mode_desc as PaymentMode,o.payment_mode + from (opd_master o join patient_master p on o.p_id=p.id ) join payment_mode m on o.payment_mode=m.id + WHERE o.opd_id=".$opdid; + + $query = $this->db->query($sql); + $opd_data= $query->result(); + + if(count($opd_data)>0) + { + echo 'OPD Code :'.$opd_data[0]->opd_code ; + echo ' Doctor Name : Dr.'.$opd_data[0]->doc_name ; + echo ' OPD Date :'.$opd_data[0]->App_Date ; + echo ' Patient Name :'.$opd_data[0]->P_name ; + echo ' Patient Code :'.$opd_data[0]->p_code ; + } + } + + public function get_appointment_list($doc_id,$opd_date='') + { + if($opd_date=='') + { + $opd_date=date('Y-m-d'); + } + + $data["opd_date"]=$opd_date; + + $data["doc_id"]=$doc_id; + + $sql="select d.p_fname,count(DISTINCT o.opd_id) as No_opd, d.id as doc_id, + group_concat(DISTINCT m.SpecName) as Spec, + count( DISTINCT CASE o.opd_status WHEN 1 THEN o.opd_id END) as count_wait, + count( DISTINCT CASE o.opd_status WHEN 2 THEN o.opd_id END) as count_visit, + count( DISTINCT CASE o.opd_status WHEN 3 THEN o.opd_id END) as count_cancel, + MOD(d.id,5) as color_code + from (doctor_master d join doc_spec s join med_spec m on d.id=s.doc_id + and m.id=s.med_spec_id)left join opd_master o on d.id=o.doc_id and o.apointment_date='".$opd_date."' + where d.id ='".$doc_id."' group by d.id"; + + $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, + 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) + LEFT JOIN payment_history h ON o.opd_id=h.payof_id AND h.payof_type=1 + WHERE m.id is null and ( o.apointment_date = '".$opd_date."' ) + and o.opd_status=1 and o.doc_id ='".$doc_id."' + GROUP BY o.opd_id ORDER BY opd_code desc "; + + $query = $this->db->query($sql); + $data['opd_list_0']= $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,p.p_rname, + m.current_queue_no,m.id,o.opd_fee_amount + FROM ((opd_master o JOIN patient_master p ON o.p_id=p.id) + JOIN opd_prescription m ON o.opd_id=m.opd_id) + LEFT JOIN payment_history h ON o.opd_id=h.payof_id AND h.payof_type=1 + WHERE ( o.apointment_date = '".$opd_date."' ) + and o.opd_status=1 and o.doc_id ='".$doc_id."' + GROUP BY o.opd_id + ORDER BY opd_id "; + + $query = $this->db->query($sql); + $data['opd_list_1']= $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_fee_amount, + 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) + JOIN opd_prescription m ON o.opd_id=m.opd_id) + LEFT JOIN payment_history h ON o.opd_id=h.payof_id AND h.payof_type=1 + WHERE ( o.apointment_date = '".$opd_date."' ) + and o.opd_status=2 and o.doc_id ='".$doc_id."' + GROUP BY o.opd_id + ORDER BY opd_code "; + + $query = $this->db->query($sql); + $data['opd_list_2']= $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_fee_amount, + 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) + JOIN opd_prescription m ON o.opd_id=m.opd_id) + LEFT JOIN payment_history h ON o.opd_id=h.payof_id AND h.payof_type=1 + WHERE ( o.apointment_date = '".$opd_date."' ) + and o.opd_status=3 and o.doc_id ='".$doc_id."' + GROUP BY o.opd_id + ORDER BY opd_code "; + + $query = $this->db->query($sql); + $data['opd_list_3']= $query->result(); + + $sql="select id,color_name,code_code from color"; + $query = $this->db->query($sql); + $color= $query->result(); + + $data['color']=array(); + + foreach($color as $aRow) + { + array_push($data['color'],$aRow->code_code); + } + + $data['color1']=array( + '0' => 'bg-yellow', + '1' => 'bg-red', + '2' => 'bg-green', + '3' => 'bg-gray', + '4' => 'bg-orange', + '5' => 'bg-blue' + ); + + $data['doc_master_panel']=$this->load->view('dashboard/opd_queue_status_total',$data,true); + $data['tab0']=$this->load->view('dashboard/opd_queue_status_tab_0',$data,true); + $data['tab1']=$this->load->view('dashboard/opd_queue_status_tab_1',$data,true); + $data['tab2']=$this->load->view('dashboard/opd_queue_status_tab_2',$data,true); + $data['tab3']=$this->load->view('dashboard/opd_queue_status_tab_3',$data,true); + + + $this->load->view('dashboard/opd_list_doc',$data); + } + + + public function update_appointment_panel_bak() + { + $doc_id=$this->input->post('doc_id'); + $opd_date=$this->input->post('opd_date'); + + if($opd_date=='') + { + $opd_date=date('Y-m-d'); + } + + $sql="SELECT o.opd_id,o.opd_code,p.id,p.p_code,o.P_name,m.queue_no,o.opd_fee_desc,o.payment_status, + 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) + LEFT JOIN payment_history h ON o.opd_id=h.payof_id AND h.payof_type=1 + WHERE m.id is null and ( o.apointment_date = '".$opd_date."' ) + and o.opd_status=1 and o.doc_id ='".$doc_id."' + GROUP BY o.opd_id ORDER BY opd_code desc "; + + $query = $this->db->query($sql); + $opd_list_0= $query->result(); + + $sql=" SELECT o.opd_id,o.opd_code,p.id,p.p_code,o.P_name,m.queue_no,o.opd_fee_desc,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) + JOIN opd_prescription m ON o.opd_id=m.opd_id) + LEFT JOIN payment_history h ON o.opd_id=h.payof_id AND h.payof_type=1 + WHERE ( o.apointment_date = '".$opd_date."' ) + and o.opd_status=1 and o.doc_id ='".$doc_id."' + GROUP BY o.opd_id + ORDER BY opd_id desc "; + + $query = $this->db->query($sql); + $opd_list_1= $query->result(); + + $sql="SELECT o.opd_id,o.opd_code,p.id,p.p_code,o.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) + JOIN opd_prescription m ON o.opd_id=m.opd_id) + LEFT JOIN payment_history h ON o.opd_id=h.payof_id AND h.payof_type=1 + WHERE ( o.apointment_date = '".$opd_date."' ) + and o.opd_status=2 and o.doc_id ='".$doc_id."' + GROUP BY o.opd_id + ORDER BY opd_code desc"; + + $query = $this->db->query($sql); + $opd_list_2= $query->result(); + + $sql="SELECT o.opd_id,o.opd_code,p.id,p.p_code,o.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) + JOIN opd_prescription m ON o.opd_id=m.opd_id) + LEFT JOIN payment_history h ON o.opd_id=h.payof_id AND h.payof_type=1 + WHERE ( o.apointment_date = '".$opd_date."' ) + and o.opd_status=3 and o.doc_id ='".$doc_id."' + GROUP BY o.opd_id + ORDER BY opd_code desc "; + + $query = $this->db->query($sql); + $opd_list_3= $query->result(); + + $sql="select d.p_fname,count(DISTINCT o.opd_id) as No_opd, d.id as doc_id, + group_concat(DISTINCT m.SpecName) as Spec, + count( DISTINCT CASE o.opd_status WHEN 1 THEN o.opd_id END) as count_wait, + count( DISTINCT CASE o.opd_status WHEN 2 THEN o.opd_id END) as count_visit, + count( DISTINCT CASE o.opd_status WHEN 3 THEN o.opd_id END) as count_cancel, + MOD(d.id,5) as color_code + from (doctor_master d join doc_spec s join med_spec m on d.id=s.doc_id + and m.id=s.med_spec_id)left join opd_master o on d.id=o.doc_id and o.apointment_date='".$opd_date."' + where d.id ='".$doc_id."' group by d.id"; + + $query = $this->db->query($sql); + $doc_master= $query->result(); + + $sql="select id,color_name,code_code from color"; + $query = $this->db->query($sql); + $color= $query->result(); + + $data['color']=array(); + + foreach($color as $aRow) + { + array_push($data['color'],$aRow->code_code); + } + + $data['color1']=array( + '0' => 'bg-yellow', + '1' => 'bg-red', + '2' => 'bg-green', + '3' => 'bg-gray', + '4' => 'bg-orange', + '5' => 'bg-blue' + ); + + //Doctor Panel + $doc_master_panel=''; + + //Master View + $Master_View='
+
+

##HEAD_NAME##

+
+ +
+ + ##CONTENT## +
+
+
'; + + //On Booking List + $tab0=''; + $srno=0; + foreach($opd_list_0 as $row) + { + $tab0.=' + '.$row->opd_id.' + '.$row->opd_code.' + '.$row->P_name.' + '.$row->Paymode.' + '; + if($row->payment_status==1) { + $tab0.=' + '; + }else{ + $tab0.=' + Go For Payment

'; + } + $tab0.=' + + + '; + } + + + $Master_View_head=str_replace("##HEAD_NAME##","On Booking List",$Master_View); + $tab0=str_replace("##CONTENT##",$tab0,$Master_View_head); + + //OnWaiting List + + $tab1=''; + $srno=0; + foreach($opd_list_1 as $row) + { + $tab1.=' + '.$row->queue_no.' + '.$row->opd_code.' + '.$row->P_name.' + '.$row->opd_fee_desc.'/'.$row->Paymode.' + + + + + + + +'; +} + +$Master_View_head=str_replace("##HEAD_NAME##","On Waiting List",$Master_View); +$tab1=str_replace("##CONTENT##",$tab1,$Master_View_head); + +//Visited List +$tab2=''; + +$srno=0; +foreach($opd_list_2 as $row) +{ +$tab2.=' + '.$row->opd_id.' + '.$row->opd_code.' + '.$row->P_name.' + '.$row->opd_fee_desc.'/'.$row->Paymode.' + + + + + + +'; +} + +$Master_View_head=str_replace("##HEAD_NAME##","Visited List",$Master_View); +$tab2=str_replace("##CONTENT##",$tab2,$Master_View_head); + +//Cancel List +$tab3=''; +$srno=0; +foreach($opd_list_3 as $row) +{ +$tab3.=' + '.$row->opd_id.' + '.$row->opd_code.' + '.$row->P_name.' + '.$row->opd_fee_desc.'/'.$row->Paymode.' + + + + '; + }else{ + $tab0.=' + Go For Payment

'; + } + $tab0.=' + + + '; + } + + + $Master_View_head=str_replace("##HEAD_NAME##","On Booking List",$Master_View); + $tab0=str_replace("##CONTENT##",$tab0,$Master_View_head); + + //OnWaiting List + + $tab1=''; + $srno=0; + foreach($opd_list_1 as $row) + { + $tab1.=' + '.$row->queue_no.' + '.$row->opd_code.' + '.$row->P_name.' + '.$row->opd_fee_desc.'/'.$row->Paymode.' + + + + + + + + '; + } + + $Master_View_head=str_replace("##HEAD_NAME##","On Waiting List",$Master_View); + $tab1=str_replace("##CONTENT##",$tab1,$Master_View_head); + + //Visited List + $tab2=''; + + $srno=0; + foreach($opd_list_2 as $row) + { + $tab2.=' + '.$row->opd_id.' + '.$row->opd_code.' + '.$row->P_name.' + '.$row->opd_fee_desc.'/'.$row->Paymode.' + + + + + '; + } + + $Master_View_head=str_replace("##HEAD_NAME##","Visited List",$Master_View); + $tab2=str_replace("##CONTENT##",$tab2,$Master_View_head); + + //Cancel List + $tab3=''; + $srno=0; + foreach($opd_list_3 as $row) + { + $tab3.=' + '.$row->opd_id.' + '.$row->opd_code.' + '.$row->P_name.' + '.$row->opd_fee_desc.'/'.$row->Paymode.' + + + + + '; + } + + $Master_View_head=str_replace("##HEAD_NAME##","Visited List",$Master_View); + $tab3=str_replace("##CONTENT##",$tab3,$Master_View_head); + + $rvar=array( + 'update' =>1, + 'doc_master_panel'=> $doc_master_panel, + 'tab0' => $tab0, + 'tab1' => $tab1, + 'tab2' => $tab2, + 'tab3' => $tab3, + ); + + $encode_data = json_encode($rvar); + echo $encode_data; + + } + + + + } \ No newline at end of file diff --git a/old_code_ci3/controllers/Opd_online_api.php b/old_code_ci3/controllers/Opd_online_api.php new file mode 100644 index 0000000..00bdefe --- /dev/null +++ b/old_code_ci3/controllers/Opd_online_api.php @@ -0,0 +1,290 @@ +db->query($sql); + $data= $query->result(); + + }else{ + $sql="select * from patient_master limit 10"; + $query = $this->db->query($sql); + $data= $query->result(); + } + + if(!$data) + { + $rvar=array( + "no_record" =>0, + ); + $encode_data = json_encode($rvar); + $data= $encode_data; + } + + $this->response($data, REST_Controller::HTTP_OK); + } + + public function patient_code_get($p_code="0") + { + $data=null; + + if(!empty($p_code)){ + $sql="select * from patient_master where p_code='$p_code'"; + $query = $this->db->query($sql); + $data= $query->result(); + } + + if(!$data) + { + $rvar=array( + 'no_record' =>0, + ); + $encode_data = json_encode($rvar); + $data= $encode_data; + } + $this->response($data, REST_Controller::HTTP_OK); + } + + public function patient_list_get($p_code="0") + { + $data=null; + + if(!empty($p_code) || strlen($p_code)>3){ + $sql="select * from patient_master where p_code like '%$p_code' order by id desc limit 20"; + $query = $this->db->query($sql); + $data= $query->result(); + } + + if(!$data) + { + $rvar=array( + 'no_record' =>0, + ); + $encode_data = json_encode($rvar); + $data= $encode_data; + } + $this->response($data, REST_Controller::HTTP_OK); + } + + public function patient_phone_get($phone_number) + { + $data=null; + + if(!empty($phone_number)){ + $sql="select * from patient_master where mphone1='$phone_number' and mphone1<>''"; + $query = $this->db->query($sql); + $data= $query->result(); + } + + if(!$data) + { + $rvar=array( + 'no_record' =>0, + ); + $encode_data = json_encode($rvar); + $data= $encode_data; + } + $this->response($data, REST_Controller::HTTP_OK); + } + + public function patient_phone_list_get($phone_number) + { + $data=null; + + if(!empty($phone_number)){ + $sql="select * from patient_master where mphone1 like '$phone_number%' and mphone1<>'' order by id desc limit 20 "; + $query = $this->db->query($sql); + $data= $query->result(); + } + + if(!$data) + { + $rvar=array( + 'no_record' =>0, + ); + $encode_data = json_encode($rvar); + $data= $encode_data; + } + $this->response($data, REST_Controller::HTTP_OK); + } + + public function patient_create_post() + { + $data = array( + 'mphone1' => $this->input->post('mphone1'), + 'p_fname' => strtoupper($this->input->post('p_fname')), + 'gender' => $this->input->post('gender'), + 'p_relative' => $this->input->post('p_relative'), + 'p_rname' => strtoupper($this->input->post('p_rname')), + 'dob' => $this->input->post('dob'), + 'estimate_dob' => 'estimate_dob', + + ); + + $this->load->model('Patient_M'); + + $inser_id=$this->Patient_M->insert($data); + + if($inser_id>0) + { + $sql="Select * from patient_master where id=".$inser_id; + $query = $this->db->query($sql); + $data= $query->result(); + + if(count($data)>0) + { + $rvar=[ + 'New_UHID' =>$data[0]->id, + 'p_code' => $data[0]->p_code, + ]; + }else{ + $rvar=[ + 'New_UHID' =>0, + ]; + } + }else{ + $rvar=[ + 'New_UHID' =>0, + ]; + } + + $response_data = json_encode($rvar); + $response_data = $rvar; + //$response_data = $data; + + $this->response($response_data, REST_Controller::HTTP_OK); + + } + + public function opd_register_post() + { + + $user_name_info = 'OnlineUser ['.date('d-m-Y H:i:s').']'; + $p_id= $this->input->post('hospital_patient_id'); + $doc_id= $this->input->post('hospital_doc_id'); + $appointment_date= $this->input->post('appointment_date'); + $opd_fee= $this->input->post('opd_fee'); + + //var_dump($this->input->post()); + + $sql="select * from patient_master where id=".$p_id; + $query = $this->db->query($sql); + $data['person_info']= $query->result(); + + $sql="select d.id ,d.p_fname ,group_concat(m.SpecName) as SpecName,if(d.gender=1,'Male','Female') as xGender + from doctor_master d join doc_spec s join med_spec m on d.id =s.doc_id and s.med_spec_id =m.id + where d.active=1 and d.id=".$doc_id." group by d.id "; + $query = $this->db->query($sql); + $data['doc_info']= $query->result(); + + $sql="select * from opd_master where p_id=".$p_id." order by opd_id desc"; + $query = $this->db->query($sql); + $data['opd_master']= $query->result(); + + $sql="select * from opd_master where p_id=$p_id and apointment_date='$appointment_date' and doc_id=$doc_id "; + $query = $this->db->query($sql); + $opd_master_exit= $query->result(); + + $this->load->model('Opd_M'); + + $last_Vist_date=''; + + if(count($data['opd_master'])>0) + { + $last_Vist_date=$data['opd_master'][0]->apointment_date; + } + + $opd_fee_amount=$this->input->post('opd_fee'); + $opd_fee_desc="Online Booked"; + + + $data['insert'] = array( + 'p_id' => $p_id, + 'P_name' => strtoupper($data['person_info'][0]->p_fname), + 'doc_id' => $doc_id, + 'insurance_id' => '0', + 'opd_fee_id' => '0', + 'opd_fee_amount' => $opd_fee_amount, + 'opd_fee_gross_amount' => $opd_fee_amount, + 'opd_fee_desc' => $opd_fee_desc, + 'doc_name' => $data['doc_info'][0]->p_fname, + 'opd_fee_type' =>0, + 'apointment_date' =>$appointment_date, + 'doc_spec' => $data['doc_info'][0]->SpecName, + 'prepared_by' => $user_name_info, + 'payment_status'=>1, + 'payment_mode_desc'=> 'Online', + 'online_book'=> 1, + ); + + $data['patient_master'] = array( + 'last_visit' => $appointment_date, + ); + + if(count($data['opd_master'])>0) + { + $data['insert']=array_merge($data['insert'],array('last_opdvisit_date'=>$data['opd_master'][0]->apointment_date)); + } + + $inser_id=0; + + if(count($opd_master_exit)==0){ + $inser_id=$this->Opd_M->insert( $data['insert']); + }else{ + $inser_id=$opd_master_exit[0]->opd_id; + } + + + if($inser_id>0) + { + $this->load->model('Patient_M'); + $this->Patient_M->update_online($data['patient_master'],$p_id); + + $sql="select * from opd_master where opd_id=".$inser_id; + $query = $this->db->query($sql); + $opd_book= $query->result(); + + if(count($opd_book)>0) + { + $rvar=[ + 'OPD_ID' =>$opd_book[0]->opd_id, + 'DOC_NAME' =>$opd_book[0]->doc_name, + 'BOOKNO' =>$opd_book[0]->opd_id.'-'.$opd_book[0]->opd_no, + 'BOOKDATE' =>MysqlDate_to_str($opd_book[0]->apointment_date), + 'PHONENO' =>$data['person_info'][0]->mphone1, + ]; + }else{ + $rvar=[ + 'OPD_ID' =>0, + ]; + } + }else{ + $rvar=[ + 'OPD_ID' =>0, + ]; + } + + $response_data = json_encode($rvar); + $response_data = $rvar; + + $this->response($response_data, REST_Controller::HTTP_OK); + } + +} \ No newline at end of file diff --git a/old_code_ci3/controllers/Opd_prescription.php b/old_code_ci3/controllers/Opd_prescription.php new file mode 100644 index 0000000..24c372e --- /dev/null +++ b/old_code_ci3/controllers/Opd_prescription.php @@ -0,0 +1,2976 @@ +load->model('Prescription_M'); + $this->load->model('Patient_M'); + } + + // Prescription + public function create_revist_opd($opdid) + { + $user = $this->ion_auth->user()->row(); + $user_id = $user->id; + $user_name = $user->first_name.''. $user->last_name.'['.$user_id.']'; + + $sql="select *,if(apointment_date>date_add(CURDATE(),interval -7 day),0,1) as Exp_date from opd_master_exten where opd_id=".$opdid; + $query = $this->db->query($sql); + $data['opd_master']= $query->result(); + + $pno=$data['opd_master'][0]->p_id; + $doc_id=$data['opd_master'][0]->doc_id; + $opd_date=$data['opd_master'][0]->apointment_date; + $Exp_date=$data['opd_master'][0]->Exp_date; + + $opd_status=$data['opd_master'][0]->opd_status; + + $sql="select max(queue_no) as max_queue from opd_prescription where date_opd_visit=curdate() and doc_id='".$doc_id."'"; + $query = $this->db->query($sql); + $max_queue= $query->result(); + + if(count($max_queue)>0) + { + $max_queue_no=$max_queue[0]->max_queue; + }else{ + $max_queue_no=0; + } + + $max_queue_no=$max_queue_no+1; + + $sql="select * from opd_prescription where visit_status=0 and HCODE=".HCODE." and opd_id=".$opdid; + $query = $this->db->query($sql); + $data['opd_prescription']= $query->result(); + + $msg_send=""; + + if(count($data['opd_prescription'])==0 ) + { + if($Exp_date==0 && $opd_status==2) + { + $datainsert = array( + 'HCODE' => HCODE, + 'opd_id' => $opdid, + 'p_id' => $pno, + 'revisit'=>'1', + 'queue_no'=>$max_queue_no, + 'date_opd_visit'=>date('Y-m-d'), + 'update_by'=>$user_name + ); + + $this->Prescription_M->insert_opd_prescription($datainsert); + + $msg_send="OPD Created"; + + }elseif($opd_status==1){ + $msg_send="OPD Pending"; + }else{ + $msg_send="OPD Expired"; + } + + }else{ + $msg_send="Revisit Already Created :"; + } + + echo $msg_send; + } + + public function create_opd_queue($opdid) + { + $user = $this->ion_auth->user()->row(); + $user_id = $user->id; + $user_name = $user->first_name.''. $user->last_name.'['.$user_id.']'; + + $sql="select * + from opd_master + where opd_id=".$opdid; + $query = $this->db->query($sql); + $data['opd_master']= $query->result(); + + $pno=$data['opd_master'][0]->p_id; + $doc_id=$data['opd_master'][0]->doc_id; + $opd_date=$data['opd_master'][0]->apointment_date; + + $opd_status=$data['opd_master'][0]->opd_status; + + $sql="select max(queue_no) as max_queue from opd_prescription + where date_opd_visit=curdate() and doc_id='".$doc_id."'"; + $query = $this->db->query($sql); + $max_queue= $query->result(); + + if(count($max_queue)>0) + { + $max_queue_no=$max_queue[0]->max_queue; + }else{ + $max_queue_no=0; + } + + $max_queue_no=$max_queue_no+1; + + $sql="select * from opd_prescription where visit_status=0 and opd_id=".$opdid; + $query = $this->db->query($sql); + $data['opd_prescription']= $query->result(); + + $msg_send=""; + + if(count($data['opd_prescription'])==0 ) + { + if($opd_status==1) + { + $datainsert = array( + 'opd_id' => $opdid, + 'p_id' => $pno, + 'revisit'=>'0', + 'queue_no'=>$max_queue_no, + 'doc_id'=>$doc_id, + 'date_opd_visit'=>date('Y-m-d'), + 'update_by'=>$user_name + ); + + $this->Prescription_M->insert_opd_prescription($datainsert); + + $msg_send="OPD in Queue Now"; + }else{ + $msg_send="OPD Already Done, Create Revisit"; + } + + }else{ + $msg_send="OPD Already in Queue"; + } + + echo $msg_send; + } + + public function show_profile_opd($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 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(); + + //$this->load->view('Person/person_file_show',$data); + + $this->load->view('dashboard/OPD_old_prescription',$data); + + } + + public function show_old_Prescribed($p_id,$currect_opd) + { + + $sql="select o.* from opd_master o + where o.p_id=$p_id and o.opd_id<>$currect_opd order by o.opd_id desc"; + $query = $this->db->query($sql); + $data['opd_master']= $query->result(); + + $sql="select * from opd_prescription where opd_id=$currect_opd"; + $query = $this->db->query($sql); + $current_opd_master= $query->result(); + + $data['doc_id']=$current_opd_master[0]->doc_id; + $data['opd_id']=$current_opd_master[0]->opd_id; + $data['opd_session_id']=$current_opd_master[0]->id; + $data['p_id']=$current_opd_master[0]->p_id; + + $this->load->view('dashboard/opd_prescription_suggest_panel/rx_patient_old_medicine',$data); + + } + + + public function show_medical_item($p_id) + { + $data['p_id']=$p_id; + + $sql="SELECT * + from invoice_med_master + WHERE patient_id=$p_id + ORDER BY id desc"; + $query = $this->db->query($sql); + $data['invoice_med_master']= $query->result(); + + $this->load->view('dashboard/opd_medical_bill',$data); + + } + + public function show_profile_investigation($p_id) + { + $data['p_id']=$p_id; + + $sql="SELECT i.id,i.inv_date,i.invoice_code,GROUP_CONCAT(t.item_name) as Item_list,i.net_amount, + i.attach_id, + date_format(i.inv_date,'%d-%m-%Y') as inv_date_str + FROM invoice_master i JOIN invoice_item t ON i.id=t.inv_master_id + WHERE i.attach_id=$p_id + GROUP BY i.id "; + $query = $this->db->query($sql); + $data['invoice_master']= $query->result(); + + //$this->load->view('Person/person_file_show',$data); + + $this->load->view('dashboard/Investigation_history',$data); + + } + + public function Prescription($opdid) + { + $user = $this->ion_auth->user()->row(); + $user_id = $user->id; + $user_name = $user->first_name.''. $user->last_name.'['.$user_id.']'; + + $sql="select * from opd_master where opd_id=".$opdid; + $query = $this->db->query($sql); + $data['opd_master']= $query->result(); + + $pno=$data['opd_master'][0]->p_id; + $doc_id=$data['opd_master'][0]->doc_id; + + $sql="select d.id,d.p_code,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,d.register_date,d.add1,d.add2,d.city, + d.state,d.country,d.active, group_concat(distinct m.SpecName) as SpecName + 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=".$doc_id." group by d.id"; + + $query = $this->db->query($sql); + $data['doc_master']= $query->result(); + + $sql="SELECT m.mor_id,m.morbidities,c.p_id + FROM morbidities_master m left JOIN patient_morbidities c ON m.mor_id=c.morbidities AND c.p_id=$pno + Where m.active=1"; + $query = $this->db->query($sql); + $data['morbidities']= $query->result(); + + + $sql="select * from opd_prescription where visit_status=0 and opd_id=".$opdid; + $query = $this->db->query($sql); + $data['opd_prescription']= $query->result(); + + $sql="select * + from patient_master_exten where id=".$pno; + $query = $this->db->query($sql); + $data['data']= $query->result(); + + $sql="select * + from patient_master where id=".$pno; + $query = $this->db->query($sql); + $data['Pdata']= $query->result(); + + $sql="select * from invprofiles "; + $query = $this->db->query($sql); + $data['invprofiles']= $query->result(); + + $sql="select * from investigation where short_name<>'' order by short_name,sort_id "; + $query = $this->db->query($sql); + $data['short_investigation']= $query->result(); + + $sql="select * from complaints_master where show_in_short=1 order by Name "; + $query = $this->db->query($sql); + $data['short_complaint']= $query->result(); + + $data['doc_id']=$doc_id; + + if(count($data['opd_prescription'])==0) + { + $datainsert = array( + 'opd_id' => $opdid, + 'p_id' => $pno, + 'doc_id'=>$doc_id, + 'update_by'=>$user_name + ); + + $this->Prescription_M->insert_opd_prescription($datainsert); + + $sql="select * from opd_prescription where session_id=0 and opd_id=".$opdid; + $query = $this->db->query($sql); + $data['opd_prescription']= $query->result(); + } + + //old Data from Last OPD + $sql="Select * from opd_prescription where p_id=$pno and opd_id<$opdid order by opd_id desc limit 1"; + $query = $this->db->query($sql); + $opd_prescription_old= $query->result(); + + $data['old_complaint_list']=array(); + $data['old_diagnosis_list']=array(); + $data['old_Provisional_diagnosis_list']=array(); + + if(count($opd_prescription_old)>0) + { + $str_complaint=trim(trim($opd_prescription_old[0]->complaints,',')); + if(strlen($str_complaint)>1) + { + $data['old_complaint_list']=explode(',',$str_complaint); + } + + $str_diagnosis=trim(trim($opd_prescription_old[0]->diagnosis,',')); + if(strlen($str_diagnosis)>1){ + $data['old_diagnosis_list']=explode(',',$str_diagnosis); + } + + $str_Provisional_diagnosis=trim(trim($opd_prescription_old[0]->Provisional_diagnosis,',')); + if(strlen($str_Provisional_diagnosis)>1){ + $data['old_Provisional_diagnosis_list']=explode(',',$str_Provisional_diagnosis); + } + } + + $opd_session_id=$data['opd_prescription'][0]->id; + + $data['p_id']=$pno; + $data['opd_id']=$opdid; + $data['opd_session_id']=$opd_session_id; + + $this->load->view('dashboard/OPDPrescription',$data); + } + + public function get_finding_exam() + { + if (isset($_GET['term'])){ + $q = strtolower($_GET['term']); + + $sql="select distinct Finding_Examinations from opd_prescription where Finding_Examinations 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['Finding_Examinations'])); + $new_row['value']=htmlentities(stripslashes($row['Finding_Examinations'])); + + //$new_row['sql']=$sql; + $row_set[] = $new_row; //build an array + } + echo json_encode($row_set); //format the array into json data + } + } + } + + public function show_profile_image($p_id,$opd_id,$doc_id) + { + $data['p_id']=$p_id; + + $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 , + if(date_add(insert_date,interval 12 hour)>sysdate(),1,0) as p_edit + from patient_master where id=".$p_id; + $query = $this->db->query($sql); + $data['data']= $query->result(); + + $data['opd_id']=$opd_id; + $data['doc_id']=$doc_id; + + + $this->load->view('dashboard/person_profile_photo_from_doctor',$data); + } + + public function prescribed_dose($opd_id,$opd_session_id) + { + $sql="SELECT * ,d.dose_show_sign AS dose_shed,dw.dose_sign_desc AS dose_when, + df.dose_sign_desc AS dose_frequency,d_on.dose_sign_desc AS dose_where + FROM (((opd_prescrption_prescribed pt + LEFT JOIN opd_dose_shed d ON pt.dosage=d.dose_shed_id) + LEFT JOIN opd_dose_when dw ON pt.dosage_when=dw.dose_when_id) + LEFT JOIN opd_dose_frequency df ON pt.dosage_freq=df.dose_freq_id) + LEFT JOIN opd_dose_where d_on ON pt.dosage_where=d_on.dose_where_id + where pt.opd_pre_id=".$opd_session_id; + $query = $this->db->query($sql); + $data['opd_drug']= $query->result(); + + $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(); + + $sql="SELECT o.id,o.next_visit_desc,DATE_ADD(CURDATE(),INTERVAL o.no_of_days DAY) AS next_date, + Concat(next_visit_desc,' (', Date_Format(DATE_ADD(CURDATE(),INTERVAL o.no_of_days DAY),'%d-%m-%Y') ,')') as next_visit_day + FROM opd_nextvisit o order by no_of_days"; + $query = $this->db->query($sql); + $data['opd_nextvisit']= $query->result(); + + $data['opd_dose_duration']=''; + foreach($opd_dose_duration as $row) + { + $data['opd_dose_duration'].='"'.$row->duration.'",'; + } + + $data['med_formulation']=''; + foreach($med_formulation as $row) + { + $data['med_formulation'].='"'.$row->formulation.'",'; + } + + + $sql="select * from opd_dose_remark"; + $query = $this->db->query($sql); + $opd_dose_remark= $query->result(); + + $data['opd_dose_remark']=''; + foreach($opd_dose_remark as $row) + { + $data['opd_dose_remark'].='"'.$row->dose_remark.'",'; + } + + + $sql="select * from opd_advice"; + $query = $this->db->query($sql); + $data['opd_advise']= $query->result(); + + $sql="select * from opd_master where opd_id=$opd_id"; + $query = $this->db->query($sql); + $data['opd_master']= $query->result(); + + $sql="select * + from opd_prescription_advice where opd_id=$opd_id"; + $query = $this->db->query($sql); + $data['opd_patient_advice']= $query->result(); + + $data['advice_given']=$this->load->view('dashboard/opd_prescribed_advice',$data,true); + + $sql="select * from opd_prescription where opd_id=$opd_id"; + $query = $this->db->query($sql); + $data['opd_prescription']= $query->result(); + + $data['doc_id']=$data['opd_master'][0]->doc_id; + $data['opd_id']=$opd_id; + $data['opd_session_id']=$opd_session_id; + $data['p_id']=$data['opd_master'][0]->p_id; + + $this->load->view('dashboard/opd_prescribed_dose',$data); + + } + + + function add_patient_advice() + { + if (!$this->input->is_ajax_request()) { exit('no valid req.'); } + + $opd_id=$this->input->post('opd_id'); + $opd_pre_id=$this->input->post('opd_session_id'); + + $advice_id=$this->input->post('advice_id'); + + $sql="select * from opd_advice where id=$advice_id"; + $query = $this->db->query($sql); + $opd_advice= $query->result(); + + $opd_advice_text=""; + $opd_advice_text_hindi=""; + + if(count($opd_advice)>0){ + $opd_advice_text=$opd_advice[0]->advice; + $opd_advice_text_hindi=$opd_advice[0]->advice_hindi; + } + + $data_insert=array( + 'opd_id'=>$opd_id, + 'opd_pre_id'=>$opd_pre_id, + 'advice_id'=>$advice_id, + 'advice_txt'=>$opd_advice_text, + 'advice_txt_hindi'=>$opd_advice_text_hindi, + ); + + + $this->Prescription_M->insert_opd_patient_advice($data_insert); + + $sql="select * + from opd_prescription_advice where opd_id=$opd_id"; + $query = $this->db->query($sql); + $data['opd_patient_advice']= $query->result(); + + $this->load->view('dashboard/opd_prescribed_advice',$data); + + + } + + function del_patient_advice($advice_id) + { + if (!$this->input->is_ajax_request()) { exit('no valid req.'); } + + $sql="select * from opd_prescription_advice where id=$advice_id"; + $query = $this->db->query($sql); + $opd_advice= $query->result(); + + $opd_id=$opd_advice[0]->opd_id; + + + $this->Prescription_M->remove_opd_patient_advice($advice_id); + + $sql="select * + from opd_prescription_advice where opd_id=$opd_id"; + $query = $this->db->query($sql); + $data['opd_patient_advice']= $query->result(); + + $this->load->view('dashboard/opd_prescribed_advice',$data); + + } + + public function get_invprofiles($invPCode) + { + if($invPCode=='') + { + $invPCode="0"; + }else{ + $invPCode = str_replace('-',',',$invPCode); + } + + $sql="select p.Code as p_Code,p.Name,i.Name,i.Code as i_Code + from (invprofiles p join invtprofiles j on p.Code=j.ProfileCode ) + join investigation i on i.Code=j.InvestigationCode + where p.Code in (".$invPCode.") + order by p.Name,j.printOrder"; + $query = $this->db->query($sql); + $invprofiles= $query->result(); + + $content=""; + + foreach($invprofiles as $row) + { + $content.= '
+ +
'; + } + + $content.=''; + + echo $content; + } + + public function add_AdviseInvest($invACode,$opdSession) + { + $rangeArray = explode("-",$invACode); + + foreach($rangeArray as $value) + { + $sql="select * from opd_prescription_investigation + where opd_pre_id=".$opdSession." and investigation_code=".$value." order by investigation_name"; + $query = $this->db->query($sql); + $invChk= $query->result(); + + if(count($invChk)==0) + { + $sql="select * + from investigation + where Code='".$value."' "; + $query = $this->db->query($sql); + $invprofiles= $query->result(); + + $investigation_name=""; + if(count($invprofiles)>0) + { + $investigation_name=$invprofiles[0]->Name; + } + + $datainsert = array( + 'opd_pre_id' => $opdSession, + 'investigation_code' => $value, + 'investigation_name' => $investigation_name + ); + + + $this->Prescription_M->insert_p_investigation($datainsert); + } + } + + $sql="select * from opd_prescription_investigation + where opd_pre_id=".$opdSession." order by investigation_name"; + $query = $this->db->query($sql); + $invOPDprofiles= $query->result(); + + $content=""; + + foreach($invOPDprofiles as $row) + { + $content.= ' + + + + '; + } + $content.="
'.$row->investigation_name.' Remove
"; + echo $content; + } + + public function Remove_AdviseInvest($invACode,$opdSession) + { + $sql="select * from opd_prescription_investigation + where opd_pre_id=".$opdSession." and investigation_code=".$invACode." "; + + $query = $this->db->query($sql); + $invChk= $query->result(); + + + + if(count($invChk)>0) + { + $this->Prescription_M->remove_p_investigation($invChk[0]->id); + } + + $sql="select * from opd_prescription_investigation + where opd_pre_id=".$opdSession." order by investigation_name"; + $query = $this->db->query($sql); + $invOPDprofiles= $query->result(); + + $content=""; + + foreach($invOPDprofiles as $row) + { + $content.= ' + + + + '; + } + $content.="
'.$row->investigation_name.' Remove
"; + echo $content; + } + + 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 + } + } + } + + + 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_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_investigation(){ + if (isset($_GET['term'])){ + $q = strtolower($_GET['term']); + + $sql="select * from investigation where Name like '%".$q."%' or short_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['investigation_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 vital_data($opd_session_id) + { + $sql="select * from opd_prescription where id=".$opd_session_id; + $query = $this->db->query($sql); + $opd_prescription= $query->result(); + + $content="

"; + + if($opd_prescription[0]->bp<>'') + { + $content.="BP :".$opd_prescription[0]->bp." / ".$opd_prescription[0]->diastolic."
"; + } + + if($opd_prescription[0]->pulse<>'') + { + $content.="Pulse :".$opd_prescription[0]->pulse."
"; + } + + if($opd_prescription[0]->temp<>'') + { + $content.="Temp :".$opd_prescription[0]->temp." C"."
"; + } + + if($opd_prescription[0]->spo2<>'') + { + $content.="SpO2 :".$opd_prescription[0]->spo2." %"."
"; + } + + if($opd_prescription[0]->glucose<>'') + { + $content.="Blood Sugar :".$opd_prescription[0]->glucose."
"; + } + + $content.="

"; + + echo $content; + + } + + public function get_remark($p_id) + { + $sql="select * from patient_remark where p_id=".$p_id." Order by id desc"; + $query = $this->db->query($sql); + $patient_remark= $query->result(); + + $content=""; + + foreach($patient_remark as $row) + { + $content.="

".nl2br($row->remark)."
"; + $content.="Update By:".$row->insert_by."
"; + } + + $data['content']= $content; + + + } + + public function patient_remark($p_id) + { + $sql="select *,Date_Format(insert_datetime,'%d/%m/%Y %H:%i') as ins_time from patient_remark where p_id=".$p_id." Order by id desc"; + $query = $this->db->query($sql); + $data['patient_remark']= $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 + FROM patient_tag_assign a JOIN tag_master t ON a.tag_id=t.id + WHERE isdelete=0 and a.p_id=$p_id"; + $query = $this->db->query($sql); + $data['patient_tag_list']= $query->result(); + + $data['p_id']=$p_id; + + $this->load->view('dashboard/patient_remark',$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 10"; + + $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'])); + $new_row['med_id']=htmlentities(stripslashes($row['id'])); + $new_row['item_name']=htmlentities(stripslashes($row['item_name'])); + $new_row['formulation']=htmlentities(stripslashes($row['formulation'])); + $new_row['genericname']=htmlentities(stripslashes($row['genericname'])); + + $new_row['dosage']=htmlentities(stripslashes($row['dosage'])); + $new_row['dosage_when']=htmlentities(stripslashes($row['dosage_when'])); + $new_row['dosage_freq']=htmlentities(stripslashes($row['dosage_freq'])); + $new_row['no_of_days']=htmlentities(stripslashes($row['no_of_days'])); + $new_row['qty']=htmlentities(stripslashes($row['qty'])); + $new_row['remark']=htmlentities(stripslashes($row['remark'])); + + $row_set[] = $new_row; //build an array + } + }else{ + $row_set[] =''; + } + + 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() + { + if (!$this->input->is_ajax_request()) { exit('no valid req.'); } + + $user = $this->ion_auth->user()->row(); + $user_update_info = $user->first_name.''. $user->last_name.'['.$user->id.']'.date('d-m-Y H:i:s'); + + $opd_session_id=$this->input->post('opd_session_id'); + $opd_id=$this->input->post('opd_id'); + $input_Examinations=$this->input->post('input_Examinations'); + $input_Prescriber=$this->input->post('input_Prescriber'); + + $p_id=$this->input->post('p_id'); + + $input_complaints=trim($this->input->post('input_complaints')); + $input_Investigation=trim($this->input->post('input_Investigation')); + $input_diagnosis=trim($this->input->post('input_diagnosis')); + $input_Provisional_diagnosis=trim($this->input->post('input_Provisional_diagnosis')); + + $input_BP=$this->input->post('input_BP'); + $input_Diastolic=$this->input->post('input_Diastolic'); + $input_Height=$this->input->post('input_Height'); + $input_Weight=$this->input->post('input_Weight'); + $input_Waist=$this->input->post('input_Waist'); + $input_RR=$this->input->post('input_RR'); + + $input_Tempature=$this->input->post('input_Tempature'); + $input_Pulse=$this->input->post('input_Pulse'); + + $input_SPO2=$this->input->post('input_SPO2'); + $input_glucose=$this->input->post('input_glucose'); + + $opd_prescription_paediatric_chk=$this->input->post('opd_prescription_paediatric_chk'); + $opd_prescription_pregnancy_chk=$this->input->post('opd_prescription_pregnancy_chk'); + $opd_prescription_lactation_chk=$this->input->post('opd_prescription_lactation_chk'); + $opd_prescription_liver_insufficiency_chk=$this->input->post('opd_prescription_liver_insufficiency_chk'); + $opd_prescription_renal_insufficiency_chk=$this->input->post('opd_prescription_renal_insufficiency_chk'); + $opd_prescription_pulmonary_insufficiency_chk=$this->input->post('opd_prescription_pulmonary_insufficiency_chk'); + $opd_prescription_corona_suspected_chk=$this->input->post('opd_prescription_corona_suspected_chk'); + $opd_prescription_dengue_chk=$this->input->post('opd_prescription_dengue_chk'); + + $opd_prescription_smoking_chk=$this->input->post('opd_prescription_smoking_chk'); + $opd_prescription_alcohol_chk=$this->input->post('opd_prescription_alcohol_chk'); + $opd_prescription_drug_chk=$this->input->post('opd_prescription_drug_chk'); + + + $input_pallor=$this->input->post('input_pallor'); + $input_Icterus=$this->input->post('input_Icterus'); + $input_cyanosis=$this->input->post('input_cyanosis'); + $input_clubbing=$this->input->post('input_clubbing'); + $input_edema=$this->input->post('input_edema'); + + $pain_value=$this->input->post('pain_value'); + + $morbidities = $this->input->post('morbidities_list'); + + $morbidities_list = explode("-", $morbidities); + + $sql="select * from opd_prescription where opd_id=".$opd_id." and id=".$opd_session_id; + $query = $this->db->query($sql); + $dataRec= $query->result(); + + $content="Nothing Done"; + + if(count($dataRec)>0) + { + $dataupdate = array( + 'Finding_Examinations' => strtoupper($input_Examinations), + 'Prescriber_Remarks' => strtoupper($input_Prescriber), + 'bp' => $input_BP, + 'diastolic' => $input_Diastolic, + 'pulse' => $input_Pulse, + 'height' => $input_Height, + 'weight' => $input_Weight, + 'waist' => $input_Waist, + 'temp' => $input_Tempature, + 'rr_min' => $input_RR, + 'spo2' => $input_SPO2, + 'glucose' => $input_glucose, + 'update_by' => $user_update_info, + + 'complaints' => strtoupper($input_complaints), + 'Investigation' => strtoupper($input_Investigation), + 'diagnosis' => strtoupper($input_diagnosis), + 'Provisional_diagnosis' => strtoupper($input_Provisional_diagnosis), + + 'paediatric' => $opd_prescription_paediatric_chk, + 'pregnancy' => $opd_prescription_pregnancy_chk, + 'lactation' => $opd_prescription_lactation_chk, + 'liver_insufficiency' => $opd_prescription_liver_insufficiency_chk, + 'renal_insufficiency' => $opd_prescription_renal_insufficiency_chk, + 'pulmonary_insufficiency' => $opd_prescription_pulmonary_insufficiency_chk, + 'corona_suspected'=> $opd_prescription_corona_suspected_chk, + 'dengue'=> $opd_prescription_dengue_chk, + + 'pallor' => strtoupper($input_pallor), + 'Icterus' => strtoupper($input_Icterus), + 'cyanosis' => strtoupper($input_cyanosis), + 'clubbing' => strtoupper($input_clubbing), + 'edema' => strtoupper($input_edema), + + 'pain_value' => $pain_value, + + ); + + $dataPatientMaster=array( + 'is_smoking' => $opd_prescription_smoking_chk, + 'is_alcohol'=> $opd_prescription_alcohol_chk, + 'is_drug_abuse'=> $opd_prescription_drug_chk, + ); + + $this->Prescription_M->update_opd_prescription($dataupdate,$opd_session_id); + + $this->Patient_M->update($dataPatientMaster,$p_id); + + $sql="SELECT m.mor_id,m.morbidities + FROM morbidities_master m Where m.active=1"; + $query = $this->db->query($sql); + $morbidities_data= $query->result(); + + + foreach($morbidities_data as $row){ + if(in_array($row->mor_id,$morbidities_list)){ + $this->Prescription_M->update_patient_morbidities($p_id,$row->mor_id,0); + }else{ + $this->Prescription_M->update_patient_morbidities($p_id,$row->mor_id,1); + } + } + + $content="Update Done"; + } + + echo $content; + } + + public function save_prescribed_extra() + { + if (!$this->input->is_ajax_request()) { exit('no valid req.'); } + + + $opd_session_id=$this->input->post('opd_session_id'); + + $advice=$this->input->post('input_advice'); + $next_visit=$this->input->post('input_next_visit'); + $refer_to=$this->input->post('input_refer_to'); + + $sql="select * from opd_prescription where id=".$opd_session_id; + $query = $this->db->query($sql); + $dataRec= $query->result(); + + $content="Nothing Done"; + + if(count($dataRec)>0) + { + $dataupdate = array( + 'advice' => $advice, + 'next_visit' => $next_visit, + 'refer_to'=> $refer_to, + ); + + + $this->Prescription_M->update_opd_prescription($dataupdate,$opd_session_id); + + $content="Update Done"; + } + + echo $content; + } + + + + + + + //Medical + + public function add_medical() + { + 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_med_name=strtoupper($this->input->post('input_med_name')); + $input_med_type=$this->input->post('input_med_type'); + $input_dosage=$this->input->post('input_dosage'); + $input_dosage_when=$this->input->post('input_dosage_when'); + $input_dosage_freq=$this->input->post('input_dosage_freq'); + $input_dose_where=$this->input->post('input_dose_where'); + $input_no_of_days=$this->input->post('input_no_of_days'); + $input_qty=$this->input->post('input_qty'); + $input_remark=strtoupper($this->input->post('input_remark')); + $hid_med_id=$this->input->post('hid_med_id'); + $opd_session_id=$this->input->post('opd_session_id'); + $opd_med_item_id=$this->input->post('opd_med_item_id'); + + $insert_master = array( + 'item_name' => $input_med_name, + 'formulation' => $input_med_type, + ); + + if($hid_med_id==0) + { + $sql="Select * from opd_med_master Where Trim(item_name)='$input_med_name'"; + $query = $this->db->query($sql); + $opd_med_master= $query->result(); + + if(count($opd_med_master)>0){ + $hid_med_id=$opd_med_master[0]->id; + }else{ + $hid_med_id=$this->Prescription_M->insert_med_master($insert_master); + } + } + + $datainsert = array( + 'opd_pre_id' => $opd_session_id, + 'med_name' => $input_med_name, + 'med_id' => $hid_med_id, + 'med_type' => $input_med_type, + 'dosage' => $input_dosage, + 'dosage_when' => $input_dosage_when, + 'dosage_freq' => $input_dosage_freq, + 'dosage_where' => $input_dose_where, + 'qty' => $input_qty, + 'no_of_days' => $input_no_of_days, + 'remark' => $input_remark, + 'update_by' => $user_name + ); + + $update_master = array( + 'formulation' => $input_med_type, + 'dosage' => $input_dosage, + 'dosage_when' => $input_dosage_when, + 'dosage_freq' => $input_dosage_freq, + 'dosage_where' => $input_dose_where, + 'qty' => $input_qty, + 'no_of_days' => $input_no_of_days, + 'remark' => $input_remark, + ); + + $this->Prescription_M->update_med_master($update_master,$hid_med_id); + + if($opd_med_item_id>0) + { + $this->Prescription_M->update_p_medical($datainsert,$opd_med_item_id); + }else{ + $this->Prescription_M->insert_p_medical($datainsert); + } + + $content=""; + + $sql="SELECT * ,d.dose_show_sign AS dose_shed,dw.dose_sign_desc AS dose_when, + df.dose_sign_desc AS dose_frequency,d_on.dose_sign_desc AS dose_where + FROM (((opd_prescrption_prescribed pt + LEFT JOIN opd_dose_shed d ON pt.dosage=d.dose_shed_id) + LEFT JOIN opd_dose_when dw ON pt.dosage_when=dw.dose_when_id) + LEFT JOIN opd_dose_frequency df ON pt.dosage_freq=df.dose_freq_id) + LEFT JOIN opd_dose_where d_on ON pt.dosage_where=d_on.dose_where_id + where pt.opd_pre_id=".$opd_session_id; + $query = $this->db->query($sql); + $data['opd_drug']= $query->result(); + + $content=$this->load->view('dashboard/opd_prescription_med_list',$data,TRUE); + + echo $content; + + } + + public function medical_Select() + { + 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'); + + $opd_session_id=$this->input->post('opd_session_id'); + $rec_id=$this->input->post('med_prec_id'); + + $sql="select * from opd_prescrption_prescribed + where id=".$rec_id." and opd_pre_id=".$opd_session_id; + $query = $this->db->query($sql); + $dataRec= $query->result(); + + $rvar=array( + "id" => $dataRec[0]->id, + "opd_session_id" => $opd_session_id, + "med_name" => $dataRec[0]->med_name, + "med_type" => $dataRec[0]->med_type, + "dosage" => $dataRec[0]->dosage, + "dosage_when" => $dataRec[0]->dosage_when, + "dosage_freq" => $dataRec[0]->dosage_freq, + "no_of_days" => $dataRec[0]->no_of_days, + "qty" => $dataRec[0]->qty, + "remark" => $dataRec[0]->remark, + ); + + $encode_data = json_encode($rvar); + echo $encode_data; + + } + + public function medical_prescribed_Remove($p_med_id,$opd_session_id) + { + if (!$this->input->is_ajax_request()) { exit('no valid req.'); } + + + + $sql="select * from opd_prescrption_prescribed + where id=$p_med_id"; + $query = $this->db->query($sql); + $dataRec= $query->result(); + + if(count($dataRec)>0) + { + $this->load->model('Doctor_M'); + $this->Prescription_M->remove_p_medical($p_med_id); + } + + $content=""; + + $sql="SELECT * ,d.dose_show_sign AS dose_shed,dw.dose_sign_desc AS dose_when, + df.dose_sign_desc AS dose_frequency,d_on.dose_sign_desc AS dose_where + FROM (((opd_prescrption_prescribed pt + LEFT JOIN opd_dose_shed d ON pt.dosage=d.dose_shed_id) + LEFT JOIN opd_dose_when dw ON pt.dosage_when=dw.dose_when_id) + LEFT JOIN opd_dose_frequency df ON pt.dosage_freq=df.dose_freq_id) + LEFT JOIN opd_dose_where d_on ON pt.dosage_where=d_on.dose_where_id + where pt.opd_pre_id=".$opd_session_id; + $query = $this->db->query($sql); + $data['opd_drug']= $query->result(); + + $content=$this->load->view('dashboard/opd_prescription_med_list',$data,TRUE); + + echo $content; + } + + public function update_medical() + { + 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'); + + $medical_remarks=$this->input->post('medical_remarks'); + $opd_session_id=$this->input->post('opd_session_id'); + $rec_id=$this->input->post('invACode'); + + $sql="select * from opd_prescrption_prescribed + where id=".$rec_id." and opd_pre_id=".$opd_session_id; + $query = $this->db->query($sql); + $dataRec= $query->result(); + + $content="Nothing Done"; + + if(count($dataRec)>0) + { + $dataupdate = array( + 'remark' => $medical_remarks, + 'update_by' => $user_name + ); + + + $this->Prescription_M->update_p_medical($dataupdate,$rec_id); + + $content="Update Done"; + } + + echo $content; + } + + + public function remove_medical($p_med_id,$rx_group_id) + { + if (!$this->input->is_ajax_request()) { exit('no valid req.'); } + + $sql="select * from opd_prescrption_prescribed_template + where id=$p_med_id"; + $query = $this->db->query($sql); + $dataRec= $query->result(); + + if(count($dataRec)>0) + { + $this->load->model('Doctor_M'); + $this->Doctor_M->remove_p_medical($p_med_id); + } + + $sql="select * from opd_prescription_template + Where id=$rx_group_id"; + $query = $this->db->query($sql); + $data['opd_prescription_template']= $query->result(); + + $sql="SELECT * ,d.dose_show_sign AS dose_shed,dw.dose_sign_desc AS dose_when, + df.dose_sign_desc AS dose_frequency,d_on.dose_sign_desc AS dose_where + FROM (((opd_prescrption_prescribed_template pt + LEFT JOIN opd_dose_shed d ON pt.dosage=d.dose_shed_id) + LEFT JOIN opd_dose_when dw ON pt.dosage_when=dw.dose_when_id) + LEFT JOIN opd_dose_frequency df ON pt.dosage_freq=df.dose_freq_id) + LEFT JOIN opd_dose_where d_on ON pt.dosage_where=d_on.dose_where_id + Where rx_group_id=$rx_group_id"; + $query = $this->db->query($sql); + $data['opd_prescrption_prescribed_template']= $query->result(); + + $this->load->view('dashboard/opd_prescription_suggest_panel/rx_group_medicine_list',$data); + } + + + public function opd_prescription_print($opdid,$opd_session_id,$print_type=0) + { + + $user = $this->ion_auth->user()->row(); + $user_id = $user->id; + $user_name = $user->first_name.''. $user->last_name.'['.$user_id.']'; + + $sql="Select * from opd_master where opd_id=$opdid"; + $query = $this->db->query($sql); + $opd_master= $query->result(); + + $pno=$opd_master[0]->p_id; + + $doc_id=0; + $no_opd_days=5-1; + + if(count($opd_master)>0){ + + $doc_id=$opd_master[0]->doc_id; + + $sql="select d.* ,group_concat(m.SpecName) as SpecName + FROM (doctor_master d left JOIN doc_spec s on d.id =s.doc_id) + join med_spec m on s.med_spec_id =m.id + WHERE d.id=$doc_id "; + $query = $this->db->query($sql); + $doctor_master= $query->result(); + + if(count($doctor_master)>0) + { + $no_opd_days=$doctor_master[0]->opd_valid_no_days-1; + } + } + + $sql="SELECT o.*,DATE_FORMAT(o.apointment_date,'%d-%m-%Y') as str_apointment_date, + + date_format(date_add(o.apointment_date,interval $no_opd_days day),'%d-%m-%Y') as opd_Exp_Date, + date_format(opd_book_date,'%d-%m-%Y %H:%i') as str_opd_book_date , + (case o.payment_status when 1 Then 'Cash' when 2 then 'Bank Card' when 3 then 'Org. Credit' else 'Pending' end) as Payment_type_str , + d.doc_sign,DATE_FORMAT(o.last_opdvisit_date,'%d-%m-%Y') as str_last_opdvisit_date, + d.opd_print_format + from opd_master o JOIN doctor_master d ON o.doc_id=d.id where opd_id=".$opdid; + $query = $this->db->query($sql); + $opd_master= $query->result(); + + $data['opd_master']=$opd_master; + + $sql="select * from opd_prescription where opd_id=".$opdid." and id=".$opd_session_id; + $query = $this->db->query($sql); + $opd_prescription= $query->result(); + + $sql="select * from opd_prescription_advice where opd_id=".$opdid." and opd_pre_id=".$opd_session_id; + $query = $this->db->query($sql); + $opd_prescription_advice= $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 str_age, + date_format(last_visit,'%d-%m-%Y %H:%i') as last_visit_str + from patient_master where id='".$opd_master[0]->p_id."' "; + $query = $this->db->query($sql); + $pdata= $query->result(); + + $sql="Select count(*) as rec_opd from opd_master where p_id=$pno"; + $query = $this->db->query($sql); + $no_opd= $query->result(); + + $total_no_visit=$no_opd[0]->rec_opd; + + $data['patient_master']=$pdata; + $patient_master=$pdata; + + $total_no_visit=$no_opd[0]->rec_opd+$patient_master[0]->no_of_visit; + + $sql="select *,date_format(date_add(apointment_date,interval $no_opd_days 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 doc_id=".$opd_master[0]->doc_id." + and apointment_date >= date_add(sysdate(),interval -$no_opd_days day) and opd_fee_type<>3"; + $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 .""; + } + + $last_opdvisit_date=""; + + if($opd_master[0]->last_opdvisit_date=='') + { + if($patient_master[0]->last_visit=='') + { + $last_opdvisit_date=""; + }else{ + $last_opdvisit_date='
Last Visit :'.$patient_master[0]->last_visit_str; + } + + + }else{ + $last_opdvisit_date='
Last Visit :'.$opd_master[0]->str_last_opdvisit_date; + } + + $sql="SELECT group_concat(m.short_name) AS m_name + FROM morbidities_master m JOIN patient_morbidities c ON m.mor_id=c.morbidities AND c.p_id=".$pno; + $query = $this->db->query($sql); + $patient_morbidities= $query->result(); + + $data['morbidities']=""; + + if($patient_morbidities[0]->m_name<>'') + { + $data['morbidities']=$patient_morbidities[0]->m_name; + } + + $data['Complication']=''; + if($opd_prescription[0]->pregnancy==1) + { + $data['Complication'].='Pregnancy,'; + } + + if($opd_prescription[0]->lactation==1) + { + $data['Complication'].='Lactation,'; + } + + if($opd_prescription[0]->liver_insufficiency==1) + { + $data['Complication'].='Liver insufficiency,'; + } + + if($opd_prescription[0]->renal_insufficiency==1) + { + $data['Complication'].='Renal Insufficiency,'; + } + + if($opd_prescription[0]->pulmonary_insufficiency==1) + { + $data['Complication'].='Pulmonary Insufficiency,'; + } + + if($opd_prescription[0]->corona_suspected==1) + { + $data['Complication'].='Corona Suspected,'; + } + + if($opd_prescription[0]->dengue==1) + { + $data['Complication'].='Dengue,'; + } + + $data['Addiction']=''; + + if($patient_master[0]->is_smoking==1) + { + $data['Addiction'].='Smoking,'; + } + + if($patient_master[0]->is_alcohol==1) + { + $data['Addiction'].='Alcoholic,'; + } + + if($patient_master[0]->is_drug_abuse==1) + { + $data['Addiction'].='Drug Abuse,'; + } + + + + $data['exp_date']=$exp_date; + $data['last_opdvisit_date']=$last_opdvisit_date; + + $data['doc_name']='Dr. '.$opd_master[0]->doc_name; + $data['doc_sign']=nl2br($opd_master[0]->doc_sign); + $data['SpecName']=$doctor_master[0]->SpecName; + + + $data['pName']=$patient_master[0]->title .' '.strtoupper($patient_master[0]->p_fname) ; + $data['pRelative']=$patient_master[0]->p_relative.' '.strtoupper($patient_master[0]->p_rname) ; + $data['age_sex']=$patient_master[0]->str_age.' / '.$patient_master[0]->xgender; + $data['opd_no']=$opd_master[0]->opd_code; + $data['opd_date']=$opd_master[0]->str_apointment_date; + + $data['opd_fee']= 'Rs.'.$opd_master[0]->opd_fee_amount .' '.$opd_master[0]->opd_fee_desc ; + $data['opd_fee_desc']= $opd_master[0]->opd_fee_desc ; + + $data['opd_sr_no']=$opd_master[0]->opd_no; + + $data['str_opd_book_date']=$opd_master[0]->str_opd_book_date; + + + $data['short_info']='Sr No.: '.$opd_master[0]->opd_no .' +
OPD Fee : Rs.'.$opd_master[0]->opd_fee_amount .' '.$opd_master[0]->opd_fee_desc .'
+ UHID : '.$patient_master[0]->p_code.'
+ P Add. :'.$patient_master[0]->add1.','.$patient_master[0]->city.''; + + $data['short_info_1']='Sr No.: '.$opd_master[0]->opd_no .' + / OPD Fee : Rs.'.$opd_master[0]->opd_fee_amount .' '.$opd_master[0]->opd_fee_desc .' / + UHID : '.$patient_master[0]->p_code.' / No. of Visit : '.$total_no_visit.'
'.$last_opdvisit_date; + + $data['uhid_no']=$patient_master[0]->p_code; + $data['phoneno']=$patient_master[0]->mphone1; + $data['p_address']=$patient_master[0]->add1.','.$patient_master[0]->city.''; + $data['total_no_visit']=$total_no_visit; + $data['exp_date']=$exp_date; + + $data['opd_book_date']=$opd_master[0]->opd_book_date; + $sql="SELECT pt.* ,d.dose_show_sign AS dose_shed,d.dose_show_desc AS dose_shed_hindi, + dw.dose_sign_desc AS dose_when,dw.dose_sign_hindi AS dose_when_hindi, + df.dose_sign_desc AS dose_frequency,df.dose_sign_hindi AS dose_frequency_hindi, + d_on.dose_sign_desc AS dose_where,d_on.dose_sign_hindi AS dose_where_hindi, + m.genericname + FROM ((((opd_prescrption_prescribed pt + LEFT JOIN opd_dose_shed d ON pt.dosage=d.dose_shed_id) + LEFT JOIN opd_dose_when dw ON pt.dosage_when=dw.dose_when_id) + LEFT JOIN opd_dose_frequency df ON pt.dosage_freq=df.dose_freq_id) + LEFT JOIN opd_dose_where d_on ON pt.dosage_where=d_on.dose_where_id) + LEFT JOIN opd_med_master m ON pt.med_id =m.id + where opd_pre_id=".$opd_session_id; + $query = $this->db->query($sql); + $opd_p_prescribed= $query->result(); + + $top_content=""; + $barContent=""; + + $top_content.="

OPD No.:".$opd_master[0]->opd_code." / Date : ".$opd_master[0]->str_apointment_date."

"; + $top_content.="

Patient ID :".$pdata[0]->p_code."
+ Patient Name : ".$pdata[0]->p_fname."
+ Gender: ".$pdata[0]->xgender."
+ Age:".$pdata[0]->str_age."

"; + + $barContent.="OPD No:".$opd_master[0]->opd_code. PHP_EOL ."OD:".$opd_master[0]->str_apointment_date. PHP_EOL ."Doc.:".$opd_master[0]->doc_name."[".$opd_master[0]->doc_spec."]". PHP_EOL ; + $barContent.="PID:".$pdata[0]->p_code. PHP_EOL ."PN:".$pdata[0]->p_fname."/".$pdata[0]->xgender."/A:".$pdata[0]->str_age. PHP_EOL; + + $vital_content=""; + + if($opd_prescription[0]->pulse<>'') + { + $vital_content.=" Pulse : ".$opd_prescription[0]->pulse." bpm"; + } + + if($opd_prescription[0]->diastolic<>'') + { + + if($opd_prescription[0]->bp<>'') + { + $vital_content.=" BP : ".$opd_prescription[0]->bp; + } + + $vital_content.="/".$opd_prescription[0]->diastolic; + + $vital_content.=" mmHg"; + } + + if($opd_prescription[0]->spo2<>'') + { + $vital_content.=" / SpO2: ".$opd_prescription[0]->spo2." %"; + } + + if($opd_prescription[0]->temp<>'') + { + $vital_content.=" / Temp: ".$opd_prescription[0]->temp." F"; + } + + + if($opd_prescription[0]->weight<>'') + { + $vital_content.=" / Weight : ".$opd_prescription[0]->weight." KG"; + } + + if($opd_prescription[0]->height<>'') + { + $vital_content.=" / Height : ".$opd_prescription[0]->height." cm"; + } + + $vital_content="

".$vital_content."

"; + + $Complaint=""; + + if($opd_prescription[0]->complaints!='') + { + $Complaint="Complaint : "; + $Complaint.=''.nl2br(trim(trim($opd_prescription[0]->complaints),",")).'
'; + } + + $painscale=""; + + if($opd_prescription[0]->pain_value>0) + { + $painscale="Pain Scale : "; + $pain_value=$opd_prescription[0]->pain_value; + if($pain_value==1){ + $painscale.='Mild Pain'; + }elseif($pain_value==2){ + $painscale.='Moderate'; + }elseif($pain_value==3){ + $painscale.='Intence'; + }elseif($pain_value==4){ + $painscale.='Worst Pain Possible'; + } + } + + + $data['painscale_img']=''; + if($opd_prescription[0]->pain_value>=0) + { + $data['painscale_img']=''; + } + + $Provisional_diagnosis=""; + + if($opd_prescription[0]->Provisional_diagnosis!='') + { + $Provisional_diagnosis="Provisional Diagnosis : "; + $Provisional_diagnosis.=' '.nl2br(trim(trim($opd_prescription[0]->Provisional_diagnosis),",")).'
'; + + } + + $diagnosis=""; + + if($opd_prescription[0]->diagnosis!='') + { + $diagnosis="Diagnosis : "; + $diagnosis.=' '.nl2br(trim(trim($opd_prescription[0]->diagnosis),",")).'
'; + + } + + $investigation=""; + if($opd_prescription[0]->investigation!='') + { + $investigation="Investigation Advised : "; + $investigation.=' '.nl2br(trim(trim($opd_prescription[0]->investigation),",")).'
'; + } + + + $Finding_Examinations=""; + + if($opd_prescription[0]->Finding_Examinations!='') + { + $Finding_Examinations="Findings :
"; + $Finding_Examinations.=' '.nl2br(trim(trim($opd_prescription[0]->Finding_Examinations),",")).'
'; + + } + + $Prescriber_Remarks=""; + + if($opd_prescription[0]->Prescriber_Remarks!='') + { + $Prescriber_Remarks="Prescriber Diagnosis :
"; + $Prescriber_Remarks.=' '.nl2br(trim(trim($opd_prescription[0]->Prescriber_Remarks),",")).'
'; + + } + + + $advice=""; + + if(($opd_prescription[0]->advice!='') || count($opd_prescription_advice)>0) + { + $advice="Advice : "; + } + + if($opd_prescription[0]->advice!='') + { + $advice.=''.nl2br($opd_prescription[0]->advice).'
'; + } + + foreach($opd_prescription_advice as $row){ + $advice.=''.$row->advice_txt_hindi.'
'; + } + + $next_visit=""; + + if($opd_prescription[0]->next_visit!='') + { + $next_visit="Next Visit : "; + $next_visit.=''.$opd_prescription[0]->next_visit.'
'; + } + + $refer_to=""; + + if($opd_prescription[0]->refer_to!='') + { + $refer_to="Refer To : "; + $refer_to.=''.$opd_prescription[0]->refer_to.'
'; + } + + $medical=''; + $sr_no=1; + if(count($opd_p_prescribed)>0) + { + $medical="

Rx :

"; + $medical.= ' + + + + + + + '; + + foreach($opd_p_prescribed as $row) + { + $medical_extend=""; + + $medical.=' + + + + + '; + $medical.=' + + '; + + $sr_no=$sr_no+1; + + } + $medical.="
Medicine NameDosageQtyDay
'.$sr_no.' - '.$row->med_type.' '.$row->med_name.''.$row->dose_shed.' / '.$row->dose_shed_hindi.' '.$row->dose_when_hindi.' '.$row->dose_frequency_hindi.''.$row->qty.''.$row->no_of_days.'
'; + if(strlen($row->genericname)>0 || strlen($row->remark)>0 || strlen($row->dose_shed_hindi)>0) + { + if(strlen($row->genericname)>1) + { + $medical.='

Composition : '.$row->genericname.'

'; + } + + if(strlen($row->remark)>0) + { + $medical.='

Notes : '.$row->remark.'

'; + } + } + + $medical.='
"; + } + + + $doctor=""; + $doctor.='

Dr. '.$opd_master[0]->doc_name.'
['.$opd_master[0]->doc_spec.']

'; + + $data['Complaint']= trim(trim($Complaint),",") ; + $data['diagnosis']= trim(trim($diagnosis),","); + $data['Provisional_diagnosis']= trim(trim($Provisional_diagnosis),","); + $data['investigation']= trim(trim($investigation),","); + $data['medical']= trim(trim($medical),","); + $data['doctor']= trim(trim($doctor),","); + $data['top_content']= trim(trim($top_content),","); + $data['vital_content']= trim(trim($vital_content),","); + + $data['Finding_Examinations']= trim(trim($Finding_Examinations),","); + $data['Prescriber_Remarks']= trim(trim($Prescriber_Remarks),","); + + $data['advice']= trim(trim($advice),","); + $data['next_visit']= trim(trim($next_visit),","); + $data['refer_to']= trim(trim($refer_to),","); + + $data['painscale']=$painscale; + + + $this->load->library('M_pdf'); + + $file_name='Prescription-Rx-'.$opd_master[0]->opd_code."-".date('Ymdhis').".pdf"; + + //$filepath=$folder_name.'/'.$file_name; + + //$this->load->view('Medical/medical_bill_print_format',$data); + + if($print_type==0) + { + $print_format=$doctor_master[0]->rx_plain_paper; + $content=$this->load->view('/dashboard/'.$print_format,$data,TRUE); + }elseif($print_type==1){ + $print_format=$doctor_master[0]->rx_blank_letter_head; + $content=$this->load->view('/dashboard/'.$print_format,$data,TRUE); + }else{ + $print_format=$doctor_master[0]->rx_pre_print_letter_head_format; + $content=$this->load->view('/dashboard/'.$print_format,$data,TRUE); + } + + // OPD Visit Done + $user = $this->ion_auth->user()->row(); + $user_id = $user->id; + $user_name = $user->first_name.''. $user->last_name.':T-'.date('d-m-Y h:m:s'); + + $status_str='Visit Done : Auto'; + $opd_status_remark=$status_str.' Update By:'.$user_name; + + $dataupdate = array( + 'opd_status' => 2, + 'opd_status_remark' => $opd_status_remark + ); + + $this->load->model('Opd_M'); + $this->Opd_M->update($dataupdate,$opdid); + + // OPD Visit Done End Here + + $this->m_pdf->pdf->shrink_tables_to_fit = 1; + //echo $content; + //generate the PDF from the given html + $this->m_pdf->pdf->WriteHTML($content); + + //download it. + $this->m_pdf->pdf->Output($file_name,"I"); + + } + + public function upload_video() + { + $folder_name='uploads/opdvideo/'.date('Ymd'); + + if (!file_exists($folder_name)) { + mkdir($folder_name, 0777, true); + } + + + if(isset($_FILES["audiovideo"])){ + // Define a name for the file + $fileName = "myaudiovideo.webm"; + + // In this case the current directory of the PHP script + $uploadDirectory = $folder_name.'/'. $fileName; + + // Move the file to your server + if (!move_uploaded_file($_FILES["audiovideo"]["tmp_name"], $uploadDirectory)) { + echo("Couldn't upload video !"); + } + else{ + echo("File Moved"); + } + } + elseif(isset($_FILES["audio"])){ + // Define a name for the file + $fileName = "myaudio.webm"; + + // In this case the current directory of the PHP script + $uploadDirectory = $folder_name.'/'. $fileName; + + // Move the file to your server + if (!move_uploaded_file($_FILES["audio"]["tmp_name"], $uploadDirectory)) { + echo("Couldn't upload video !"); + } + else{ + echo("File Moved"); + } + } + elseif(isset($_FILES["video"])){ + // Define a name for the file + $fileName = "myvideo.webm"; + + // In this case the current directory of the PHP script + $uploadDirectory = $folder_name.'/'. $fileName; + + // Move the file to your server + if (!move_uploaded_file($_FILES["video"]["tmp_name"], $uploadDirectory)) { + echo("Couldn't upload video !"); + } + else{ + echo("File Moved"); + } + } + elseif(isset($_FILES["stream"])){ + // Define a name for the file + $fileName = $_POST["name"]; + $file_number = $_POST["file_number"]; + $opd_id=$_POST["opd_id"]; + $file_name_id=$_POST["file_name_id"]; + + $folder_name=$folder_name.'/'.$opd_id; + + if (!file_exists($folder_name)) { + mkdir($folder_name, 0777, true); + } + // In this case the current directory of the PHP script + $uploadDirectory = $folder_name.'/'. $fileName.'.webm'; + + // Move the file to your server + if (!move_uploaded_file($_FILES["stream"]["tmp_name"], $uploadDirectory)) { + echo("Couldn't upload video !"); + } + else{ + //update last file + $last_file_number=$file_number-1; + $strFile2 = $folder_name.'/'."Main_video_".$file_number.'.webm'; + $strFile1 = $folder_name.'/'."Main_video_".$last_file_number.'.webm'; + + $final_file=$folder_name.'/'.$file_name_id.'_'.$file_number.'.webm'; + + $last_final_file=$folder_name.'/'.$file_name_id.'_'.$last_file_number.'.webm'; + + if($last_file_number>0) + { + $last_final_file=$folder_name.'/'.$file_name_id.'_'.$last_file_number.'.webm'; + } + + $chk_file=file_exists($last_final_file); + if($chk_file==1) + { + //First File + $objFH = fopen( $last_final_file, "rb" ); + $strBuffer1 = fread( $objFH, filesize( $last_final_file) ); + fclose( $objFH ); + + //Second File + $objFH = fopen( $strFile2, "rb" ); + $strBuffer2 = fread( $objFH, filesize( $strFile2) ); + fclose( $objFH ); + + // manipulate buffers here... + $strBuffer3 = $strBuffer1 . $strBuffer2; + + // open for write/binary-safe + $objFH = fopen( $final_file, "wb" ); + fwrite( $objFH, $strBuffer3 ); + fclose( $objFH ); + + unlink($last_final_file); + unlink($strFile2); + //unlink($strFile1); + }else{ + + //Second File + $objFH = fopen( $strFile2, "rb" ); + $strBuffer2 = fread( $objFH, filesize( $strFile2) ); + fclose($objFH); + + // manipulate buffers here... + $strBuffer3 = $strBuffer2; + + // open for write/binary-safe + $objFH = fopen( $final_file, "wb" ); + fwrite( $objFH, $strBuffer3 ); + fclose( $objFH ); + + echo 'File Not Found'; + unlink($strFile2); + } + + $data_upload = array( + 'opd_id' => $opd_id, + 'full_path' => $final_file, + ); + + $this->load->model('FileOPDRec_M'); + + $this->FileOPDRec_M->insert($data_upload,$file_name_id); + + echo("Success"); + + + } + } + else{ + echo "No file uploaded"; + } + } + + //Suggest Panel + + function new_rx_group($doc_id=0) + { + $data['doc_id']=$doc_id; + $this->load->view('dashboard/opd_prescription_suggest_panel/rx_group_new',$data); + } + + function rx_group($opd_id,$doc_id) + { + $data['opd_id']=$opd_id; + $data['doc_id']=$doc_id; + + $this->load->view('dashboard/opd_prescription_suggest_panel/rx_group_save',$data); + } + + function rx_group_select($rx_group_id) + { + $opd_session_id = $this->input->post('opd_session_id'); + $rx_group_id=$this->input->post('rx_group_id'); + + $user = $this->ion_auth->user()->row(); + $user_id = $user->id; + $user_name = $user->first_name.''. $user->last_name.'['.$user_id.']'.date('d-m-Y H:i:s'); + + + + $sql="select * from opd_prescrption_prescribed_template + Where rx_group_id=$rx_group_id"; + $query = $this->db->query($sql); + $prescrption_prescribed= $query->result(); + + if(count($prescrption_prescribed)>0 && $rx_group_id>0) + { + foreach($prescrption_prescribed as $row) + { + $prescrption_prescribed_data=array( + 'opd_pre_id' => $opd_session_id, + 'med_id' => $row->med_id, + 'med_name' => $row->med_name, + 'med_type' => $row->med_type, + 'dosage' => $row->dosage, + 'dosage_when' => $row->dosage_when, + 'dosage_freq' => $row->dosage_freq, + 'qty' => $row->qty, + 'no_of_days' => $row->no_of_days, + 'remark' => $row->remark, + 'update_by' => $user_name, + ); + + $this->Prescription_M->insert_p_medical($prescrption_prescribed_data); + + } + } + + $content=""; + + $sql="SELECT * ,d.dose_show_sign AS dose_shed,dw.dose_sign_desc AS dose_when, + df.dose_sign_desc AS dose_frequency,d_on.dose_sign_desc AS dose_where + FROM (((opd_prescrption_prescribed pt + LEFT JOIN opd_dose_shed d ON pt.dosage=d.dose_shed_id) + LEFT JOIN opd_dose_when dw ON pt.dosage_when=dw.dose_when_id) + LEFT JOIN opd_dose_frequency df ON pt.dosage_freq=df.dose_freq_id) + LEFT JOIN opd_dose_where d_on ON pt.dosage_where=d_on.dose_where_id + where pt.opd_pre_id=".$opd_session_id; + $query = $this->db->query($sql); + $data['opd_drug']= $query->result(); + + $content=$this->load->view('dashboard/opd_prescription_med_list',$data,TRUE); + + echo $content; + } + + function add_medicince_opd($opd_pre_prescribed_id,$opd_session_id) + { + + $user = $this->ion_auth->user()->row(); + $user_id = $user->id; + $user_name = $user->first_name.''. $user->last_name.'['.$user_id.']'.date('d-m-Y H:i:s'); + + + + $sql="select * from opd_prescrption_prescribed + Where id=$opd_pre_prescribed_id"; + $query = $this->db->query($sql); + $prescrption_prescribed= $query->result(); + + foreach($prescrption_prescribed as $row) + { + $prescrption_prescribed_data=array( + 'opd_pre_id' => $opd_session_id, + 'med_id' => $row->med_id, + 'med_name' => $row->med_name, + 'med_type' => $row->med_type, + 'dosage' => $row->dosage, + 'dosage_when' => $row->dosage_when, + 'dosage_freq' => $row->dosage_freq, + 'dosage_where' => $row->dosage_where, + 'qty' => $row->qty, + 'no_of_days' => $row->no_of_days, + 'remark' => $row->remark, + 'update_by' => $user_name, + ); + + $this->Prescription_M->insert_p_medical($prescrption_prescribed_data); + + } + + $content=""; + + $sql="SELECT * ,d.dose_show_sign AS dose_shed,dw.dose_sign_desc AS dose_when, + df.dose_sign_desc AS dose_frequency,d_on.dose_sign_desc AS dose_where + FROM (((opd_prescrption_prescribed pt + LEFT JOIN opd_dose_shed d ON pt.dosage=d.dose_shed_id) + LEFT JOIN opd_dose_when dw ON pt.dosage_when=dw.dose_when_id) + LEFT JOIN opd_dose_frequency df ON pt.dosage_freq=df.dose_freq_id) + LEFT JOIN opd_dose_where d_on ON pt.dosage_where=d_on.dose_where_id + where pt.opd_pre_id=".$opd_session_id; + $query = $this->db->query($sql); + $data['opd_drug']= $query->result(); + + $content=$this->load->view('dashboard/opd_prescription_med_list',$data,TRUE); + + echo $content; + } + + function add_medicine_opd_all($current_opd_id,$opd_session_id) + { + + $user = $this->ion_auth->user()->row(); + $user_id = $user->id; + $user_name = $user->first_name.''. $user->last_name.'['.$user_id.']'.date('d-m-Y H:i:s'); + + + + $sql="select * from opd_prescrption_prescribed + Where opd_pre_id=$opd_session_id"; + $query = $this->db->query($sql); + $prescrption_prescribed= $query->result(); + + if(count($prescrption_prescribed)>0) + { + foreach($prescrption_prescribed as $row) + { + $prescrption_prescribed_data=array( + 'opd_pre_id' => $current_opd_id, + 'med_id' => $row->med_id, + 'med_name' => $row->med_name, + 'med_type' => $row->med_type, + 'dosage' => $row->dosage, + 'dosage_when' => $row->dosage_when, + 'dosage_freq' => $row->dosage_freq, + 'qty' => $row->qty, + 'no_of_days' => $row->no_of_days, + 'remark' => $row->remark, + 'update_by' => $user_name, + ); + + $this->Prescription_M->insert_p_medical($prescrption_prescribed_data); + + } + } + + $content=""; + + $sql="SELECT * ,d.dose_show_sign AS dose_shed,dw.dose_sign_desc AS dose_when, + df.dose_sign_desc AS dose_frequency,d_on.dose_sign_desc AS dose_where + FROM (((opd_prescrption_prescribed pt + LEFT JOIN opd_dose_shed d ON pt.dosage=d.dose_shed_id) + LEFT JOIN opd_dose_when dw ON pt.dosage_when=dw.dose_when_id) + LEFT JOIN opd_dose_frequency df ON pt.dosage_freq=df.dose_freq_id) + LEFT JOIN opd_dose_where d_on ON pt.dosage_where=d_on.dose_where_id + where pt.opd_pre_id=".$opd_session_id; + $query = $this->db->query($sql); + $data['opd_drug']= $query->result(); + + $content=$this->load->view('dashboard/opd_prescription_med_list',$data,TRUE); + + echo $content; + } + + + + function save_rx_group_list($doc_id=0) + { + $sql="SELECT p.*,group_concat(m.med_name SEPARATOR '
' ) AS med_name_list + from opd_prescription_template p LEFT JOIN opd_prescrption_prescribed_template m + ON p.id=m.rx_group_id + WHERE p.doc_id=$doc_id or p.doc_id=0 + GROUP BY p.id"; + $query = $this->db->query($sql); + $data['rx_group_list']= $query->result(); + + $data['Color']=array( + 'bg-primary text-white', + 'bg-secondary text-white', + 'bg-success text-white', + 'bg-danger text-white', + 'bg-warning text-dark', + 'bg-info text-white', + 'bg-light text-dark', + 'bg-dark text-white', + 'bg-white text-dark', + ); + + $this->load->view('dashboard/opd_prescription_suggest_panel/rx_group_list',$data); + } + + function save_rx_group_show($rx_id) + { + $user = $this->ion_auth->user()->row(); + $user_id = $user->id; + $user_name = $user->first_name.''. $user->last_name.'['.$user_id.']'; + + $sql="select * from opd_prescription_template where id=$rx_id"; + $query = $this->db->query($sql); + $rx_master= $query->result(); + + $sql="select * from opd_prescrption_prescribed_template where rx_group_id=$rx_id"; + $query = $this->db->query($sql); + $rx_prescribed= $query->result(); + + $this->load->view('dashboard/opd_prescription_suggest_panel/opd_prev',$data); + + } + + + function update_opd_queue($opd_session_id) + { + $sql="select * from opd_prescription where id=$opd_session_id"; + $query = $this->db->query($sql); + $opd_prescription= $query->result(); + + if(count($opd_prescription)>0){ + $doc_id=$opd_prescription[0]->doc_id; + $date_opd_visit=$opd_prescription[0]->date_opd_visit; + + $this->load->model('Opd_M'); + $this->Opd_M->update_opd_queue_no($opd_session_id,$doc_id,$date_opd_visit); + } + + echo 'Queue Update'; + + } + + function rx_group_panel() + { + $sql="select * from opd_prescription_template order by rx_group_name"; + $query = $this->db->query($sql); + $data['rx_master']= $query->result(); + + $this->load->view('dashboard/rx_group',$data); + + } + + + function rx_group_list() + { + $sql="select * from opd_prescription_template order by rx_group_name"; + $query = $this->db->query($sql); + $data['rx_master']= $query->result(); + + $this->load->view('dashboard/rx_group_list',$data); + + } + + function save_rx_group_edit($rx_id) + { + + $sql="select * from opd_prescription_template where id=$rx_id"; + $query = $this->db->query($sql); + $data['rx_master']= $query->result(); + + $sql="select * from opd_prescrption_prescribed_template where rx_group_id=$rx_id"; + $query = $this->db->query($sql); + $data['rx_prescribed']= $query->result(); + + $this->load->view('dashboard/opd_prescription_suggest_panel/rx_group_show',$data); + + } + + + + function save_rx_group_from_opd_prescription() + { + $opd_id = $this->input->post('opd_session_id'); + $rx_group_name=$this->input->post('rx_group_name'); + $doc_id=$this->input->post('doc_id'); + + $this->load->model('Doctor_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'); + + $sql="select * from opd_prescription + Where id=$opd_id"; + $query = $this->db->query($sql); + $opd_prescription= $query->result(); + + echo $sql; + + $rx_group_id=0; + + if(count($opd_prescription)>0) + { + $opd_prescription_data=array( + 'rx_group_name' => $rx_group_name, + 'doc_id' => $doc_id, + 'update_by' => $user_name, + 'Finding_Examinations' => $opd_prescription[0]->Finding_Examinations, + 'Prescriber_Remarks' => $opd_prescription[0]->Prescriber_Remarks, + 'complaints' => $opd_prescription[0]->complaints, + 'diagnosis' => $opd_prescription[0]->diagnosis, + 'investigation' => $opd_prescription[0]->investigation, + ); + + $opd_pre_id=$opd_prescription[0]->id; + + $rx_group_id=$this->Doctor_M->insert_opd_prescription_template($opd_prescription_data); + + $sql="select * from opd_prescrption_prescribed + Where opd_pre_id=$opd_pre_id"; + $query = $this->db->query($sql); + $prescrption_prescribed= $query->result(); + + if(count($prescrption_prescribed)>0 && $rx_group_id>0) + { + foreach($prescrption_prescribed as $row) + { + $prescrption_prescribed_data=array( + 'rx_group_id' => $rx_group_id, + 'med_id' => $row->med_id, + 'med_name' => $row->med_name, + 'med_type' => $row->med_type, + 'dosage' => $row->dosage, + 'dosage_when' => $row->dosage_when, + 'dosage_freq' => $row->dosage_freq, + 'qty' => $row->qty, + 'no_of_days' => $row->no_of_days, + 'remark' => $row->remark, + 'update_by' => $user_name, + ); + + $rx_group_sub=$this->Doctor_M->insert_opd_prescrption_prescribed_template($prescrption_prescribed_data); + } + } + } + + echo $rx_group_id; + } + + function save_rx_group() + { + $rx_group_name = $this->input->post('input_rx_group_name'); + $complaints=$this->input->post('input_complaints'); + $diagnosis=$this->input->post('input_diagnosis'); + $investigation=$this->input->post('input_investigation'); + $Finding_Examinations=$this->input->post('input_Finding_Examinations'); + $id=$this->input->post('hid_rx_id'); + + $this->load->model('Doctor_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'); + + $opd_prescription_data=array( + 'rx_group_name' => $rx_group_name, + 'update_by' => $user_name, + 'Finding_Examinations' => $Finding_Examinations, + 'complaints' => $complaints, + 'diagnosis' => $diagnosis, + 'investigation' => $investigation, + ); + + if($id>0) + { + $this->Doctor_M->update_opd_prescription_template($opd_prescription_data,$id); + $rx_group_id=$id; + $show_text="Data Saved"; + }else{ + $rx_group_id=$this->Doctor_M->insert_opd_prescription_template($opd_prescription_data); + $show_text="Data Added"; + } + + $rvar=array( + 'insertid' =>$rx_group_id, + 'show_text'=>$show_text + ); + + + echo json_encode($rvar); + + } + + function rx_group_medicine($rx_group_id) + { + $sql="select * from opd_prescription_template + Where id=$rx_group_id"; + $query = $this->db->query($sql); + $data['opd_prescription_template']= $query->result(); + + $sql="SELECT * ,d.dose_show_sign AS dose_shed,dw.dose_sign_desc AS dose_when, + df.dose_sign_desc AS dose_frequency,d_on.dose_sign_desc AS dose_where + FROM (((opd_prescrption_prescribed_template pt + LEFT JOIN opd_dose_shed d ON pt.dosage=d.dose_shed_id) + LEFT JOIN opd_dose_when dw ON pt.dosage_when=dw.dose_when_id) + LEFT JOIN opd_dose_frequency df ON pt.dosage_freq=df.dose_freq_id) + LEFT JOIN opd_dose_where d_on ON pt.dosage_where=d_on.dose_where_id + Where rx_group_id=$rx_group_id"; + $query = $this->db->query($sql); + $data['opd_prescrption_prescribed_template']= $query->result(); + + $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(); + + $data['rx_group_id']=$rx_group_id; + + $this->load->view('dashboard/opd_prescription_suggest_panel/rx_group_medicine',$data); + + } + + + function rx_opd_medicine() + { + $sql="SELECT * ,d.dose_show_sign AS dose_shed,dw.dose_sign_desc AS dose_when, + df.dose_sign_desc AS dose_frequency,d_on.dose_sign_desc AS dose_where + FROM (((opd_med_master pt + LEFT JOIN opd_dose_shed d ON pt.dosage=d.dose_shed_id) + LEFT JOIN opd_dose_when dw ON pt.dosage_when=dw.dose_when_id) + LEFT JOIN opd_dose_frequency df ON pt.dosage_freq=df.dose_freq_id) + LEFT JOIN opd_dose_where d_on ON pt.dosage_where=d_on.dose_where_id + Order by pt.item_name"; + $query = $this->db->query($sql); + $data['opd_med_master']= $query->result(); + + $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(); + + + + $this->load->view('dashboard/opd_prescription_suggest_panel/opd_medicine_panel',$data); + + } + + + function rx_group_medicine_save($rx_group_id) + { + $this->load->model('Doctor_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'); + + $med_name = $this->input->post('input_med_name'); + $med_type=$this->input->post('input_med_type'); + $dosage=$this->input->post('input_dosage'); + $dosage_when=$this->input->post('input_dosage_when'); + $dosage_freq=$this->input->post('input_dosage_freq'); + $no_of_days=$this->input->post('input_no_of_days'); + $qty=$this->input->post('input_qty'); + $remark=$this->input->post('input_remark'); + $med_id=$this->input->post('hid_med_id'); + $dosage_where=$this->input->post('input_dose_where'); + $genericname=$this->input->post('input_genericname'); + + $rx_group_id=$rx_group_id; + $hid_p_med_id=$this->input->post('hid_p_med_id'); + + $insert_master = array( + 'item_name' => $med_name, + 'formulation' => $med_type, + 'dosage' => $dosage, + 'dosage_when' => $dosage_when, + 'dosage_freq' => $dosage_freq, + 'dosage_where' => $dosage_where, + 'genericname' => $genericname, + 'qty' => $qty, + 'no_of_days' => $no_of_days, + 'remark' => $remark, + 'genericname' => $genericname + ); + + if($med_id==0) + { + $med_id=$this->Prescription_M->insert_med_master($insert_master); + }else{ + $update_master = array( + 'dosage' => $dosage, + 'dosage_when' => $dosage_when, + 'dosage_freq' => $dosage_freq, + 'dosage_where' => $dosage_where, + 'qty' => $qty, + 'no_of_days' => $no_of_days, + 'remark' => $remark, + 'genericname' => $genericname + ); + + $this->Prescription_M->update_med_master($update_master,$med_id); + } + + $prescrption_prescribed_data=array( + 'rx_group_id' => $rx_group_id, + 'med_id' => $med_id, + 'med_name' => $med_name, + 'med_type' => $med_type, + 'dosage' => $dosage, + 'dosage_when' => $dosage_when, + 'dosage_freq' => $dosage_freq, + 'qty' => $qty, + 'no_of_days' => $no_of_days, + 'remark' => $remark, + 'dosage_where'=>$dosage_where, + 'update_by' => $user_name, + ); + + if($hid_p_med_id>0) + { + $rx_group_id_INSERT=$this->Doctor_M->update_opd_prescrption_prescribed_template($prescrption_prescribed_data,$hid_p_med_id); + $show_text="Data Update"; + }else{ + $rx_group_id_INSERT=$this->Doctor_M->insert_opd_prescrption_prescribed_template($prescrption_prescribed_data); + $show_text="Data Added"; + } + + $sql="select * from opd_prescrption_prescribed_template + Where id=$rx_group_id"; + $query = $this->db->query($sql); + $data['prescrption_prescribed']= $query->result(); + + $sql="SELECT * ,d.dose_show_sign AS dose_shed,dw.dose_sign_desc AS dose_when, + df.dose_sign_desc AS dose_frequency,d_on.dose_sign_desc AS dose_where + FROM (((opd_prescrption_prescribed_template pt + LEFT JOIN opd_dose_shed d ON pt.dosage=d.dose_shed_id) + LEFT JOIN opd_dose_when dw ON pt.dosage_when=dw.dose_when_id) + LEFT JOIN opd_dose_frequency df ON pt.dosage_freq=df.dose_freq_id) + LEFT JOIN opd_dose_where d_on ON pt.dosage_where=d_on.dose_where_id + Where rx_group_id=$rx_group_id"; + $query = $this->db->query($sql); + $data['opd_prescrption_prescribed_template']= $query->result(); + + $this->load->view('dashboard/opd_prescription_suggest_panel/rx_group_medicine_list',$data); + + } + + + public function medical_Select_prescription_template() + { + if (!$this->input->is_ajax_request()) { exit('no valid req.'); } + + $p_med_id=$this->input->post('p_med_id'); + + $sql="select * from opd_prescrption_prescribed_template + where id=$p_med_id"; + $query = $this->db->query($sql); + $prescribed_template= $query->result(); + + $rvar=array( + "med_id" => $prescribed_template[0]->med_id, + "med_name" => $prescribed_template[0]->med_name, + "med_type" => $prescribed_template[0]->med_type, + "dosage" => $prescribed_template[0]->dosage, + "dosage_when" => $prescribed_template[0]->dosage_when, + "dosage_freq" => $prescribed_template[0]->dosage_freq, + "qty" => $prescribed_template[0]->qty, + "no_of_days" => $prescribed_template[0]->no_of_days, + "remark" => $prescribed_template[0]->remark, + "p_med_id"=>$p_med_id, + 'genericname'=>$prescribed_template[0]->genericname, + ); + + $encode_data = json_encode($rvar); + echo $encode_data; + + } + + function patient_glucose_data($p_id) + { + $sql="Select p.id,Date_Format(p.test_datetime,'%d-%m-%Y') AS test_date, + if(p.test_type=0,p.test_value,'') AS r_sugar, + if(p.test_type=1,p.test_value,'') AS f_sugar, + if(p.test_type=2,p.test_value,'') AS a_sugar + from patient_glucose_chart p + where p.p_id=$p_id order by p.test_datetime desc"; + $query = $this->db->query($sql); + $data['patient_glucose_data']= $query->result(); + + $data['p_id']=$p_id; + + $this->load->view('dashboard/patient_glucose_data',$data); + } + + function add_glucose_value($p_id) + { + + + $patient_glucose_data=array( + 'p_id' => $p_id, + 'test_datetime'=> str_to_MysqlDate($this->input->post('datepicker_dot')), + 'test_value' => $this->input->post('input_glucose_value'), + 'test_type' => $this->input->post('input_test_type'), + ); + + $rx_group_id_INSERT=$this->Prescription_M->insert_patient_glucose_chart($patient_glucose_data); + + $send_error=validation_errors(); + $rvar=array( + 'insertid' =>$rx_group_id_INSERT, + 'msg'=>$send_error + ); + $encode_data = json_encode($rvar); + echo $encode_data; + } + + function patient_glucose_data_del($p_id,$g_id) + { + + $this->Prescription_M->remove_patient_glucose_chart($g_id); + + $sql="Select p.id,Date_Format(p.test_datetime,'%d-%m-%Y') AS test_date, + if(p.test_type=0,p.test_value,'') AS r_sugar, + if(p.test_type=1,p.test_value,'') AS f_sugar, + if(p.test_type=2,p.test_value,'') AS a_sugar + from patient_glucose_chart p + where p.p_id=$p_id order by p.test_datetime desc"; + $query = $this->db->query($sql); + $data['patient_glucose_data']= $query->result(); + + $data['p_id']=$p_id; + + $content=$this->load->view('dashboard/patient_glucose_data',$data,true); + + echo $content; + } + + function patient_investigation_data($p_id) + { + $sql="Select p.* + from patient_investigation p + where p.p_id=$p_id order by p.date_investigation desc"; + $query = $this->db->query($sql); + $data['patient_investigation_data']= $query->result(); + + $data['p_id']=$p_id; + + $this->load->view('dashboard/patient_investigation',$data); + } + + function add_investigation_value($p_id) + { + + + $normal_range=''; + $isbold=''; + $out_range=''; + + $patient_investigation_data=array( + 'p_id' => $p_id, + 'date_investigation'=> str_to_MysqlDate($this->input->post('datepicker_investigation')), + 'investigation_id' => $this->input->post('input_investigation_ID'), + 'investigation_name' => $this->input->post('input_investigation'), + 'result' => $this->input->post('input_investigation_value'), + 'result_text' => $this->input->post('input_investigation_report'), + 'normal_range' => $normal_range, + 'isbold' => $isbold, + 'out_range' => $out_range, + ); + + $investigation_INSERT=$this->Prescription_M->insert_patient_investigation($patient_investigation_data); + + $send_error=validation_errors(); + $rvar=array( + 'insertid' =>$investigation_INSERT, + 'msg'=>$send_error + ); + $encode_data = json_encode($rvar); + echo $encode_data; + } + + + function patient_investigation_value_del($p_id,$inv_id) + { + + $this->Prescription_M->remove_patient_investigation($inv_id); + + $sql="Select p.* + from patient_investigation p + where p.p_id=$p_id order by p.date_investigation desc"; + $query = $this->db->query($sql); + $data['patient_investigation_data']= $query->result(); + + $data['p_id']=$p_id; + + $content=$this->load->view('dashboard/patient_investigation',$data,true); + + echo $content; + + } + + function doc_online($doc_id) + { + $sql="Select * from doctor_master where id=$doc_id"; + $query = $this->db->query($sql); + $doctor_master= $query->result(); + + $data['doc_name']=$doctor_master[0]->p_fname; + $data['doc_id']=$doc_id; + + $this->load->view('center_room/center_room',$data); + + } + + // OPD Medicince + + function opd_medicince() + { + $sql="Select id,item_name,formulation,genericname,company_name from opd_med_master order by item_name"; + $query = $this->db->query($sql); + $data['opd_med_master']= $query->result(); + + $this->load->view('OPD/opd_medicince',$data); + } + + function opd_medicince_remove($med_id) + { + $this->Prescription_M->remove_med_master($med_id); + echo 'Item Deleted'; + } + + function opd_medicince_show($med_id) + { + $sql="Select * from opd_med_master where id=$med_id"; + $query = $this->db->query($sql); + $opd_med_master= $query->result(); + + if(count($opd_med_master)>0) + { + echo ''.$opd_med_master[0]->id.' + '.$opd_med_master[0]->formulation.' '.$opd_med_master[0]->item_name.' + '.$opd_med_master[0]->genericname.' + '.$opd_med_master[0]->company_name.' + Edit + Remove'; + }else{ + echo ' + + + + + '; + } + + } + + function opd_medicince_edit($med_id) + { + $sql="Select * from opd_med_master where id=$med_id"; + $query = $this->db->query($sql); + $data['opd_med_master']= $query->result(); + + if (isset($data['opd_med_master'][0]->id)) { + if (isset($_POST) && count($_POST) > 0) { + + $company_id=$this->input->post('company_id'); + $formulation = $this->input->post('formulation'); + + $sql="Select * from med_company where id=$company_id"; + $query = $this->db->query($sql); + $med_company= $query->result(); + + if(count($med_company)>0){ + $company_name=$med_company[0]->company_name; + }else{ + $company_name=''; + } + + $sql="Select * from med_formulation where formulation='$formulation'"; + $query = $this->db->query($sql); + $med_formulation= $query->result(); + + if(count($med_formulation)>0){ + $med_formulation_id=$med_formulation[0]->id; + }else{ + $med_formulation_id=0; + } + + $params = array( + 'item_name' => $this->input->post('item_name'), + 'formulation' => $this->input->post('formulation'), + 'formulation_id' => $med_formulation_id, + 'company_id' => $company_id, + 'company_name' => $company_name, + 'genericname' => $this->input->post('genericname'), + ); + + $this->Prescription_M->update_med_master($params,$med_id); + + echo 'Data Updated'; + } else { + $sql="Select * from med_company order by company_name"; + $query = $this->db->query($sql); + $data['med_company']= $query->result(); + + $sql="Select * from med_formulation order by formulation_length"; + $query = $this->db->query($sql); + $data['med_formulation']= $query->result(); + + $this->load->view('OPD/opd_medicince_edit',$data); + } + } else { + echo 'The Medicince you are trying to edit does not exist.'; + } + + + } + + function opd_medicince_add() + { + if (isset($_POST) && count($_POST) > 0) { + + $company_id=$this->input->post('company_id'); + $formulation = $this->input->post('formulation'); + + + $sql="Select * from med_company where id=$company_id"; + $query = $this->db->query($sql); + $med_company= $query->result(); + + if(count($med_company)>0){ + $company_name=$med_company[0]->company_name; + }else{ + $company_name=''; + } + + $sql="Select * from med_formulation where formulation='$formulation'"; + $query = $this->db->query($sql); + $med_formulation= $query->result(); + + if(count($med_formulation)>0){ + $med_formulation_id=$med_formulation[0]->id; + }else{ + $med_formulation_id=0; + } + + $params = array( + 'item_name' => $this->input->post('item_name'), + 'formulation' => $this->input->post('formulation'), + 'formulation_id' => $med_formulation_id, + 'company_id' => $company_id, + 'company_name' => $company_name, + 'genericname' => $this->input->post('genericname'), + ); + + $this->Prescription_M->insert_med_master($params); + + echo 'Data Insert'; + } else { + $sql="Select * from med_company order by company_name"; + $query = $this->db->query($sql); + $data['med_company']= $query->result(); + + $sql="Select * from med_formulation order by formulation_length"; + $query = $this->db->query($sql); + $data['med_formulation']= $query->result(); + + $this->load->view('OPD/opd_medicince_add',$data); + } + + + } + + + +} \ No newline at end of file diff --git a/old_code_ci3/controllers/Opd_print.php b/old_code_ci3/controllers/Opd_print.php new file mode 100644 index 0000000..ff04e0a --- /dev/null +++ b/old_code_ci3/controllers/Opd_print.php @@ -0,0 +1,904 @@ +db->query($sql); + $opd_master= $query->result(); + + $doc_id=0; + $no_opd_days=5-1; + + if(count($opd_master)>0){ + + $doc_id=$opd_master[0]->doc_id; + + $sql="select * + from doctor_master + where id=$doc_id"; + $query = $this->db->query($sql); + $doctor_master= $query->result(); + + $sql="select d.* ,group_concat(m.SpecName) as SpecName + FROM (doctor_master d left JOIN doc_spec s on d.id =s.doc_id) + join med_spec m on s.med_spec_id =m.id + WHERE d.id=$doc_id "; + $query = $this->db->query($sql); + $doctor_master= $query->result(); + + if(count($doctor_master)>0) + { + $no_opd_days=$doctor_master[0]->opd_valid_no_days-1; + } + } + + $sql="SELECT o.*,DATE_FORMAT(o.apointment_date,'%d-%m-%Y') as str_apointment_date, + date_format(opd_book_date,'%d-%m-%Y %H:%i') as str_opd_book_date , + date_format(date_add(o.apointment_date,interval $no_opd_days day),'%d-%m-%Y') as opd_Exp_Date, + (case o.payment_status when 1 Then 'Cash' when 2 then 'Bank Card' when 3 then 'Org. Credit' else 'Pending' end) as Payment_type_str , + d.doc_sign,DATE_FORMAT(o.last_opdvisit_date,'%d-%m-%Y') as str_last_opdvisit_date, + d.opd_print_format + from opd_master o JOIN doctor_master d ON o.doc_id=d.id where opd_id=".$opdid; + $query = $this->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 , + date_format(last_visit,'%d-%m-%Y') as last_visit_str + from patient_master where id='".$opd_master[0]->p_id."' "; + $query = $this->db->query($sql); + $patient_master= $query->result(); + + $pid=$opd_master[0]->p_id; + + $sql="Select count(*) as rec_opd from opd_master where p_id=$pid"; + $query = $this->db->query($sql); + $no_opd= $query->result(); + + $data['patient_master']=$patient_master; + + $total_no_visit=$no_opd[0]->rec_opd+$patient_master[0]->no_of_visit; + + $sql="select *,date_format(date_add(apointment_date,interval $no_opd_days day),'%d-%m-%Y') as opd_Exp_Date + from opd_master where p_id=".$opd_master[0]->p_id." and doc_id=".$opd_master[0]->doc_id." + and apointment_date >= date_add(sysdate(),interval -$no_opd_days day) and opd_fee_type<>3"; + $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; + + $data['case_id']=''; + + 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; + + if(count($case_master)>0){ + $data['case_id']="Org. Case ID : ".$case_master[0]->case_id_code; + } + } + + $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 .""; + } + + if($opd_master[0]->last_opdvisit_date=='') + { + if($patient_master[0]->last_visit=='') + { + $last_opdvisit_date=""; + }else{ + $last_opdvisit_date='
Last Visit :'.$patient_master[0]->last_visit_str; + } + + + }else{ + $last_opdvisit_date='
Last Visit :'.$opd_master[0]->str_last_opdvisit_date; + } + + $data['last_opdvisit_date']=$last_opdvisit_date; + + $data['exp_date']=$exp_date; + + $data['doc_info']='Dr. '.$opd_master[0]->doc_name.'
'.nl2br($opd_master[0]->doc_sign); + $data['SpecName']=$doctor_master[0]->SpecName; + $data['str_opd_book_date']=$opd_master[0]->str_opd_book_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.'
+ Mob :'.$patient_master[0]->mphone1 .'
+ Address :'.$patient_master[0]->add1.','.$patient_master[0]->add2.' ,'.$patient_master[0]->city.' +
+ Sr No.: '.$opd_master[0]->opd_no .'
+ UHID : '.$patient_master[0]->p_code.' '.$old_uhid.'
+ OPD No.: '.$opd_master[0]->opd_code.'
+ Date: '.$opd_master[0]->str_apointment_date .'
'.$exp_date.'
+ OPD Fee: '.$opd_master[0]->opd_fee_amount .' ['.$opd_master[0]->opd_fee_desc .'] + +
+ Dr. '.$opd_master[0]->doc_name.'
+ '.$doctor_master[0]->SpecName.'
+ '.nl2br($doctor_master[0]->doc_sign).' +
+
No. of Visit : '.$total_no_visit.'
+
'; + //echo $content; + + + $data['content']=$content; + + $content_3=' + + + + + +
+ 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).'
+ Gender/Age : '.$patient_master[0]->xgender.' / '.$patient_master[0]->age.'
+ Phone No. :'.$patient_master[0]->mphone1 .'
+ Address :'.$patient_master[0]->add1.','.$patient_master[0]->add2.' ,'.$patient_master[0]->city.' +
+ 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 .' + '.$last_opdvisit_date.'
+ No. of Visit : '.$total_no_visit.$exp_date.' +
+ '; + + $data['content_3']=$content_3; + + + $content_4=' + + + + + +
+ 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.'
+ Phone No. :'.$patient_master[0]->mphone1 .'
+ Address :'.$patient_master[0]->add1.','.$patient_master[0]->add2.' ,'.$patient_master[0]->city.' +
+ Sr No.: '.$opd_master[0]->opd_no .'
+ UHID : '.$patient_master[0]->p_code.' '.$old_uhid.'
+ OPD No.: '.$opd_master[0]->opd_code.'
+ Date: '.$opd_master[0]->str_apointment_date .' + '.$last_opdvisit_date.'
+ No. of Visit : '.$total_no_visit.'
'.$exp_date.' +
+ '; + + $data['content_4']=$content_4; + + $data['pName']=$patient_master[0]->title .' '.strtoupper($patient_master[0]->p_fname) ; + $data['pRelative']=$patient_master[0]->p_relative.' '.strtoupper($patient_master[0]->p_rname) ; + $data['age_sex']=$patient_master[0]->age.' / '.$patient_master[0]->xgender; + $data['opd_no']=$opd_master[0]->opd_code; + $data['opd_date']=$opd_master[0]->str_apointment_date; + + $data['opd_fee']= 'Rs.'.$opd_master[0]->opd_fee_amount .' '.$opd_master[0]->opd_fee_desc ; + + $data['opd_fee_desc']= $opd_master[0]->opd_fee_desc ; + + $data['opd_sr_no']=$opd_master[0]->opd_no; + + $data['short_info']='Sr No.: '.$opd_master[0]->opd_no .' +
OPD Fee : Rs.'.$opd_master[0]->opd_fee_amount .' '.$opd_master[0]->opd_fee_desc .'
+ UHID : '.$patient_master[0]->p_code.'
+ P Add. :'.$patient_master[0]->add1.','.$patient_master[0]->city.''; + + $data['short_info_1']='Sr No.: '.$opd_master[0]->opd_no .' + / OPD Fee : Rs.'.$opd_master[0]->opd_fee_amount .' '.$opd_master[0]->opd_fee_desc .' / + UHID : '.$patient_master[0]->p_code.' / No. of Visit : '.$total_no_visit.'
'.$last_opdvisit_date; + + $data['uhid_no']=$patient_master[0]->p_code; + $data['phoneno']=$patient_master[0]->mphone1; + $data['p_address']=$patient_master[0]->add1.','.$patient_master[0]->city.''; + $data['opd_fee']= 'Rs.'.$opd_master[0]->opd_fee_amount .' '.$opd_master[0]->opd_fee_desc ; + $data['total_no_visit']=$total_no_visit; + $data['exp_date']=$exp_date; + + $data['opd_book_date']=$opd_master[0]->opd_book_date; + + $this->load->library('m_pdf'); + + $file_name='opd_parchi-'.$opdid.'-'.date('Ymdhis').".pdf"; + + $filepath=$file_name; + + if($opd_master[0]->opd_print_format==''){ + $print_content=$this->load->view('dashboard/opd_print_parcha',$data,TRUE); + }else{ + $print_content=$this->load->view('dashboard/'.$opd_master[0]->opd_print_format,$data,TRUE); + } + + //echo $print_content; + + $this->m_pdf->pdf->WriteHTML($print_content); + + //download it. + $this->m_pdf->pdf->Output($filepath,"I"); + + } + + public function opd_blank_print($opdid) + { + $bar_content=""; + + $sql="Select * from opd_master where opd_id=$opdid"; + $query = $this->db->query($sql); + $opd_master= $query->result(); + + $p_id=$opd_master[0]->p_id; + + $sql="Select count(*) as No_visit from opd_master where p_id=$p_id"; + $query = $this->db->query($sql); + $no_of_opd_data= $query->result(); + + $no_of_visit=$no_of_opd_data[0]->No_visit; + + $doc_id=0; + $no_opd_days=5-1; + + if(count($opd_master)>0){ + + $doc_id=$opd_master[0]->doc_id; + + $sql="select * + from doctor_master + where id=$doc_id"; + $query = $this->db->query($sql); + $doctor_master= $query->result(); + + if(count($doctor_master)>0) + { + $no_opd_days=$doctor_master[0]->opd_valid_no_days-1; + } + } + + + $sql="SELECT o.*,DATE_FORMAT(o.apointment_date,'%d-%m-%Y') as str_apointment_date, + date_format(date_add(o.apointment_date,interval $no_opd_days day),'%d-%m-%Y') as opd_Exp_Date, + (case o.payment_status when 1 Then 'Cash' when 2 then 'Bank Card' when 3 then 'Org. Credit' else 'Pending' end) as Payment_type_str , + d.doc_sign,DATE_FORMAT(o.last_opdvisit_date,'%d-%m-%Y') as str_last_opdvisit_date, + d.opd_print_format,d.opd_blank_print + from opd_master o JOIN doctor_master d ON o.doc_id=d.id where opd_id=".$opdid; + $query = $this->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 $no_opd_days 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 doc_id=".$opd_master[0]->doc_id." + and apointment_date >= date_add(sysdate(),interval -$no_opd_days day) and opd_fee_type<>3"; + $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 .""; + } + + if($opd_master[0]->last_opdvisit_date=='') + { + $last_opdvisit_date=""; + }else{ + $last_opdvisit_date='Last Visit :'.$opd_master[0]->str_last_opdvisit_date; + } + + $data['exp_date']=$exp_date; + + $bar_content.=$patient_master[0]->p_code.'/'.$patient_master[0]->title .' '.strtoupper($patient_master[0]->p_fname); + $bar_content.='/'.$opd_master[0]->opd_no.'/'.$opd_master[0]->str_apointment_date.'/'.date('dmYHis'); + + $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).'
+ Gender/Age : '.$patient_master[0]->xgender.' / '.$patient_master[0]->age.'
+ Phone No. :'.$patient_master[0]->mphone1 .'
+
+ 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.'
+
+ Address :'.$patient_master[0]->add1.','.$patient_master[0]->add2.' ,'.$patient_master[0]->city.' + '.$last_opdvisit_date.'
+ No. of Visit : '.$no_of_visit.' +
+ '; + $data['content']=$content; + + $content_2=' + + + + + + +
+ UHID : '.$patient_master[0]->p_code.' '.$old_uhid.'
+ Name : '.$patient_master[0]->title .' '.strtoupper($patient_master[0]->p_fname).'
+ Gender : '.$patient_master[0]->xgender.' / Age : '.$patient_master[0]->age.'
+ '.$patient_master[0]->p_relative.' '.strtoupper($patient_master[0]->p_rname).'
+
+ Phone No. :'.$patient_master[0]->mphone1 .'
+ Address :'.$patient_master[0]->add1.','.$patient_master[0]->add2.'
'.$patient_master[0]->city.' +
No. of Visit : '.$no_of_visit.' +
'.$last_opdvisit_date.' +
+ 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 .' +
+ '; + //echo $content; + + $data['content_2']=$content_2; + + $content_3=' + + + + + +
+ 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).'
+ Gender/Age : '.$patient_master[0]->xgender.' / '.$patient_master[0]->age.'
+ Phone No. :'.$patient_master[0]->mphone1 .'
+ Address :'.$patient_master[0]->add1.','.$patient_master[0]->add2.' ,'.$patient_master[0]->city.' +
+ 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 .' + '.$last_opdvisit_date.'
+ No. of Visit : '.$no_of_visit.' +
+ '; + + $data['content_3']=$content_3; + + $content_4=' + + + + + +
+ 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).'
+ Gender/Age : '.$patient_master[0]->xgender.' / '.$patient_master[0]->age.'
+ Phone No. :'.$patient_master[0]->mphone1 .'
+ Address :'.$patient_master[0]->add1.','.$patient_master[0]->add2.' ,'.$patient_master[0]->city.' +
+ Sr No.: '.$opd_master[0]->opd_no .'
+ OPD No.: '.$opd_master[0]->opd_code.'
+ Date: '.$opd_master[0]->str_apointment_date .' + '.$last_opdvisit_date.'
+ No. of Visit : '.$no_of_visit.' +
+ '; + + $data['content_4']=$content_4; + + + $data['patient_master']=$patient_master; + $data['opd_master']=$opd_master; + + $this->load->library('m_pdf'); + + //$this->m_pdf->pdf->SetWatermarkText(H_Name); + //$this->m_pdf->pdf->showWatermarkText = false; + + $file_name='opd_parchi-'.$opdid.'-'.date('Ymdhis').".pdf"; + + $filepath=$file_name; + + //$print_content=$this->load->view('dashboard/opd_letter_head_print',$data,TRUE); + + $print_content=$this->load->view('dashboard/'.$opd_master[0]->opd_blank_print,$data,TRUE); + + //echo $print_content; + + $this->m_pdf->pdf->WriteHTML($print_content); + + //download it. + $this->m_pdf->pdf->Output($filepath,"I"); + + } + + + + public function opd_day_care($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 *,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 doc_id=".$opd_master[0]->doc_id." + and apointment_date > date_add(sysdate(),interval -5 day) and opd_fee_type<>3"; + $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(); + + 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; + } + + + $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.'
+
+ Date: '.$opd_master[0]->str_apointment_date .'
+ Admit Time: ____________________
+ Discharge Time: ___________________
+
'; + + //echo $content; + $data['content']=$content; + $data['patient_master']=$patient_master; + $data['opd_master']=$opd_master; + + $this->load->library('m_pdf'); + + $file_name='opd_parchi-'.$opdid.'-'.date('Ymdhis').".pdf"; + + $filepath=$file_name; + + $print_content=$this->load->view('dashboard/day_care_format',$data,TRUE); + + //echo $print_content; + + $this->m_pdf->pdf->WriteHTML($print_content); + + //download it. + $this->m_pdf->pdf->Output($filepath,"I"); + + } + + public function opd_Cont_print($opdid) + { + $sql="Select * from opd_master where opd_id=$opdid"; + $query = $this->db->query($sql); + $opd_master= $query->result(); + + $doc_id=0; + $no_opd_days=5-1; + + if(count($opd_master)>0){ + + $doc_id=$opd_master[0]->doc_id; + + $sql="select * + from doctor_master + where id=$doc_id"; + $query = $this->db->query($sql); + $doctor_master= $query->result(); + + if(count($doctor_master)>0) + { + $no_opd_days=$doctor_master[0]->opd_valid_no_days-1; + } + } + + $sql="select *,date_format(apointment_date,'%d-%m-%Y') as str_apointment_date, + date_format(date_add(apointment_date,interval $no_opd_days 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 $no_opd_days 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 *,date_format(date_add(apointment_date,interval $no_opd_days 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 doc_id=".$opd_master[0]->doc_id." + and apointment_date >= date_add(sysdate(),interval -$no_opd_days day) and opd_fee_type<>3"; + $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(); + + 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.'
+ P.No. :'.$patient_master[0]->mphone1 .'
+
+ 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.' +
+ Dr. '.$opd_master[0]->doc_name.' + '.nl2br($opd_master[0]->doc_sign).' +
'; + + //echo $content; + + $this->load->library('m_pdf'); + + $file_name='opd_parchi-'.$opdid.'-'.date('Ymdhis').".pdf"; + + $filepath=$file_name; + + //$print_content=$this->load->view('dashboard/day_care_format',$data,TRUE); + + //echo $print_content; + + $this->m_pdf->pdf->WriteHTML($content); + + //download it. + $this->m_pdf->pdf->Output($filepath,"I"); + + } + + public function invoice_print_pdf($opdid) + { + $sql="Select * from opd_master where opd_id=$opdid"; + $query = $this->db->query($sql); + $opd_master= $query->result(); + + $doc_id=0; + $no_opd_days=5-1; + + if(count($opd_master)>0){ + + $doc_id=$opd_master[0]->doc_id; + + $sql="select * + from doctor_master + where id=$doc_id"; + $query = $this->db->query($sql); + $doctor_master= $query->result(); + + if(count($doctor_master)>0) + { + $no_opd_days=$doctor_master[0]->opd_valid_no_days-1; + } + } + + $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 Invoice Receipt

'; + + $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.'
+ Print Time : '.date('d-m-Y H:i:s').' +
+ +
'; + $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 +
'; + + $data['content']=$content; + + $data['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')); + + //load mPDF library + + $this->load->library('m_pdf'); + + $file_name='opd_parchi-'.$opdid.'-'.date('Ymdhis').".pdf"; + + $filepath=$file_name; + + $print_content=$this->load->view('dashboard/opd_invoice_print',$data,TRUE); + + //$print_content=$content; + + + //echo $print_content; + $this->m_pdf->pdf->SetJS('this.print();'); + + $this->m_pdf->pdf->WriteHTML($print_content); + + //download it. + $this->m_pdf->pdf->Output($filepath,"I"); + } + +} diff --git a/old_code_ci3/controllers/Opdcase.php b/old_code_ci3/controllers/Opdcase.php new file mode 100644 index 0000000..29359b0 --- /dev/null +++ b/old_code_ci3/controllers/Opdcase.php @@ -0,0 +1,218 @@ +db->query($sql); + $data['person_info']= $query->result(); + + $sql="select d.id ,d.p_fname ,group_concat(m.SpecName) as SpecName + from doctor_master d join doc_spec s join med_spec m on d.id =s.doc_id and s.med_spec_id =m.id + where d.active=1 group by d.id "; + $query = $this->db->query($sql); + $data['doc_spec_l']= $query->result(); + + $sql="select * from hc_insurance_card where p_id='".$pno."' "; + $query = $this->db->query($sql); + $data['insurance_card']= $query->result(); + + $this->load->view('opd_app_insurance_V',$data); + } + + public function showfee() + { + $sql="select * from doc_opd_fee where doc_id=".$this->input->post('doc_id'); + $query = $this->db->query($sql); + $data['doc_fee_a']= $query->result(); + + $sql="select d.id ,d.p_fname ,group_concat(m.SpecName) as SpecName,if(d.gender=1,'Male','Female') as xGender + from doctor_master d join doc_spec s join med_spec m on d.id =s.doc_id and s.med_spec_id =m.id + where d.active=1 and d.id=".$this->input->post('doc_id')." group by d.id "; + $query = $this->db->query($sql); + $doc_info= $query->result(); + + $content=''; + + $content.= '

Name : '.$doc_info[0]->p_fname.' / Specialization: '.$doc_info[0]->SpecName.' / + Gender : '.$doc_info[0]->xGender.'

'; + $content.= ''; + + $sql="select * from hc_insurance where id=".$this->input->post('insurance_id'); + $query = $this->db->query($sql); + $data['opd_fee_a']= $query->result(); + + foreach($data['opd_fee_a'] as $row) + { + $content.= '
'; + } + + $content.=""; + + $rvar=array( + 'csrfName' => $this->security->get_csrf_token_name(), + 'csrfHash' => $this->security->get_csrf_hash(), + 'content'=>$content + ); + + $encode_data = json_encode($rvar); + + echo $encode_data ; + } + + public function invoice($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 'ECHS Credit' else 'Pending' end) as Payment_type_str from opd_master where opd_id=".$opdid; + $query = $this->db->query($sql); + $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."' "; + + $query = $this->db->query($sql); + $data['patient_master']= $query->result(); + + $sql="select * from ipd_master where ipd_status=0 and p_id=".$data['opd_master'][0]->p_id; + $query = $this->db->query($sql); + $data['ipd_master']= $query->result(); + + $sql="select * from organization_case_master + where status=0 and case_type=0 and p_id=".$data['patient_master'][0]->id; + $query = $this->db->query($sql); + $data['case_master']= $query->result(); + + $sql="select * from hc_insurance where id=".$data['opd_master'][0]->insurance_id; + $query = $this->db->query($sql); + $data['insurance']= $query->result(); + + $sql="select * from refund_order where refund_process=0 and refund_type=1 and refund_type_id=".$opdid; + $query = $this->db->query($sql); + $data['refund_order']= $query->result(); + + if(count($data['refund_order'])>0) + { + $data['refund_status']=1; // Refund Pending + }else{ + $data['refund_status']=0 ; //No Pending + } + + $sql="select sum(if(credit_debit=0,amount,amount*-1)) as paid_amount from payment_history where payof_type=1 and payof_id=".$opdid; + $query = $this->db->query($sql); + $data['payment_history']= $query->result(); + + $data['paid_amount']=0; + + if($data['payment_history'][0]->paid_amount=='' || $data['payment_history'][0]->paid_amount==0 ) + { + $data['paid_amount']=0; + }else{ + $data['paid_amount']=$data['payment_history'][0]->paid_amount; + } + + $opd_fee_gross_amount=$data['opd_master'][0]->opd_fee_amount; + + if($data['opd_master'][0]->payment_mode==4) + { + $data['pending_amount']=0; + }else{ + $data['pending_amount']=$opd_fee_gross_amount-$data['paid_amount']; + } + + + $this->load->view('opd_invoice_V',$data); + } + + public function invoice_print($opdid) + { + $sql="select * from opd_master where opd_id=".$opdid; + $query = $this->db->query($sql); + $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."' "; + + $query = $this->db->query($sql); + $data['patient_master']= $query->result(); + + $sql="select * from hc_insurance where id=".$data['opd_master'][0]->insurance_id; + $query = $this->db->query($sql); + $data['insurance']= $query->result(); + + if($data['opd_master'][0]->insurance_case_id>0) + { + $sql="select * from organization_case_master where id=".$data['opd_master'][0]->insurance_case_id; + $query = $this->db->query($sql); + $data['case_master']= $query->result(); + } + + $this->load->view('invoice_print_v',$data); + } + + public function confirm_opd() + { + $this->load->model('Opd_M'); + + $sql="select * from patient_master where id=".$this->input->post('pid'); + $query = $this->db->query($sql); + $data['person_info']= $query->result(); + + $sql="select d.id ,d.p_fname ,group_concat(m.SpecName) as SpecName,if(d.gender=1,'Male','Female') as xGender + from doctor_master d join doc_spec s join med_spec m on d.id =s.doc_id and s.med_spec_id =m.id + where d.active=1 and d.id=".$this->input->post('doc_id')." group by d.id "; + $query = $this->db->query($sql); + $data['doc_info']= $query->result(); + + $sql="select * from hc_insurance where id=".$this->input->post('insurance_id'); + $query = $this->db->query($sql); + $data['doc_fee']= $query->result(); + + $opd_fee_amount=$data['doc_fee'][0]->opd_fee; + $opd_fee_desc=$data['doc_fee'][0]->opd_desc; + + $data['insert'] = array( + 'p_id' => $this->input->post('pid'), + 'P_name' => $data['person_info'][0]->p_fname, + 'doc_id' => $this->input->post('doc_id'), + 'insurance_id' => $this->input->post('insurance_id'), + 'opd_fee_id' => $this->input->post('fee_id'), + 'opd_fee_amount' => $opd_fee_amount, + 'opd_fee_gross_amount' => $opd_fee_amount, + 'opd_fee_desc' => $opd_fee_desc, + 'doc_name' => $data['doc_info'][0]->p_fname, + 'doc_spec' => $data['doc_info'][0]->SpecName, + 'apointment_date' =>str_to_MysqlDate($this->input->post('datepicker_appointment')), + 'opd_fee_type' => '1' + ); + + $inser_id=$this->Opd_M->insert( $data['insert']); + + $rvar=array( + 'insertid' =>$inser_id + ); + + $encode_data = json_encode($rvar); + echo $encode_data; + + } + + public function confirm_payment() + { + + } + } \ No newline at end of file diff --git a/old_code_ci3/controllers/Org_Packing.php b/old_code_ci3/controllers/Org_Packing.php new file mode 100644 index 0000000..2fd91f3 --- /dev/null +++ b/old_code_ci3/controllers/Org_Packing.php @@ -0,0 +1,602 @@ +load->view('Org/Org_packing'); + } + + public function Search_packing() + { + $sdata=trim($this->input->post('txtsearch')); + + if(trim($sdata)=='') + { + $sql="SELECT p.id,date_format(p.date_of_create,'%d-%m-%Y') AS d_o_c, + p.label_no,p.files_status,COUNT(c.id) AS No_Rec, + if(p.org_type=0,'OPD','IPD') as list_type + FROM org_packing p left JOIN organization_case_master c ON p.id=c.packing_id + GROUP BY p.id + ORDER BY p.date_of_create desc limit 50"; + }else{ + + $numric_condition=""; + + if(is_numeric($sdata)) + { + $numric_condition=" OR p.Invoice_no=".$sdata ; + } + + $sql="SELECT p.id,date_format(p.date_of_create,'%d-%m-%Y') AS d_o_c, + p.label_no,p.files_status,COUNT(c.id) AS No_Rec, + if(p.org_type=0,'OPD','IPD') as list_type + FROM org_packing p left JOIN organization_case_master c ON p.id=c.packing_id + where (p.label_no LIKE '%".$sdata."%' ".$numric_condition." ) + GROUP BY p.id + ORDER BY p.date_of_create desc limit 50"; + } + + $query = $this->db->query($sql); + $data['packing_list']= $query->result(); + + $this->load->view('Org/Search_result',$data); + + } + + public function PackingNew() + { + $this->load->view('Org/new_Org_Packing'); + + } + + public function PackingEdit($id) + { + $data['id']=$id; + + $sql="select * from org_packing where id=$id"; + $query = $this->db->query($sql); + $data['org_packing']= $query->result(); + + $this->load->view('Org/edit_Org_Packing',$data); + + } + + public function CreatePackNew() + { + if (!$this->input->is_ajax_request()) { exit('no valid req.'); } + + $FormRules = array( + array( + 'field' => 'input_packingcode', + 'label' => 'Invoice No', + 'rules' => 'required|min_length[3]|max_length[30]' + ) + ); + + $this->form_validation->set_rules($FormRules); + + if ($this->form_validation->run() == TRUE) + { + + $invoice_code=$this->input->post('input_packingcode'); + $org_type=$this->input->post('cbo_billtype'); + $datepicker_packing=$this->input->post('datepicker_packing'); + + if(is_numeric($invoice_code)) + $where=" where label_no=".$invoice_code ; + else + $where=" where label_no='".$invoice_code."'"; + + $sql="select count(*) as no_rec from org_packing ".$where; + $query = $this->db->query($sql); + $chk_rec= $query->result(); + + if($chk_rec[0]->no_rec==0) + { + $Udata = array( + 'date_of_create'=> str_to_MysqlDate($datepicker_packing), + 'label_no'=> $invoice_code, + 'org_type'=>$org_type + ); + + $this->load->model('Ocasemaster_M'); + + $inser_id=$this->Ocasemaster_M->insert_org_pack($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 EditPack() + { + if (!$this->input->is_ajax_request()) { exit('no valid req.'); } + + $FormRules = array( + array( + 'field' => 'input_packingcode', + 'label' => 'Invoice No', + 'rules' => 'required|min_length[3]|max_length[30]' + ) + ); + + $this->form_validation->set_rules($FormRules); + + if ($this->form_validation->run() == TRUE) + { + + $invoice_code=$this->input->post('input_packingcode'); + $org_type=$this->input->post('cbo_billtype'); + $datepicker_packing=$this->input->post('datepicker_packing'); + $id=$this->input->post('packing_id'); + + if(is_numeric($invoice_code)) + $where=" label_no=".$invoice_code ; + else + $where=" label_no='".$invoice_code."'"; + + $sql="select count(*) as no_rec from org_packing where id<>$id and ".$where; + $query = $this->db->query($sql); + $chk_rec= $query->result(); + + if($chk_rec[0]->no_rec==0) + { + $Udata = array( + 'date_of_create'=> str_to_MysqlDate($datepicker_packing), + 'label_no'=> $invoice_code, + 'org_type'=>$org_type + ); + + $this->load->model('Ocasemaster_M'); + + $inser_id=$this->Ocasemaster_M->update_org_pack($Udata,$id); + $send_msg="Update 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 PackNewEdit($id) + { + $sql="select * + from org_packing + where id=".$id; + $query = $this->db->query($sql); + $data['org_packing']= $query->result(); + + $sql="SELECT o.*,o.case_id_code,o.insurance_company_name, + p.p_code,p.p_fname,p.age,o.insurance_no,o.insurance_no_1, + if(o.case_type=0,'OPD','IPD') as IPD_OPD + FROM organization_case_master o JOIN patient_master_exten p ON o.p_id=p.id + WHERE o.packing_id=$id + ORDER BY o.packing_short"; + $query = $this->db->query($sql); + $data['org_packing_list']= $query->result(); + + $data['packing_id']=$id; + + $data['org_packing_list']=$this->load->view('Org/org_packing_list',$data,true); + + $this->load->view('Org/Org_item_Edit',$data); + } + + public function PackMasterEdit($id) + { + $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 Pack_list($packing_id) + { + $sql="SELECT o.*,o.case_id_code,o.insurance_company_name, + p.p_code,p.p_fname,p.age,o.insurance_no,o.insurance_no_1, + if(o.case_type=0,'OPD','IPD') as IPD_OPD + FROM organization_case_master o JOIN patient_master_exten p ON o.p_id=p.id + WHERE o.packing_id=$packing_id + ORDER BY o.packing_short"; + $query = $this->db->query($sql); + $data['org_packing_list']= $query->result(); + + $data['packing_id']=$packing_id; + + $this->load->view('Org/org_packing_list',$data); + + } + + + public function Add_list($org_id,$packing_id) + { + $user = $this->ion_auth->user()->row(); + $user_id = $user->id; + $user_name = $user->first_name.''. $user->last_name.' ['.date('d-m-Y h:i:s').']'; + + $sql="SELECT * + FROM organization_case_master o + WHERE o.packing_id=$packing_id and id=$org_id"; + $query = $this->db->query($sql); + $org_check= $query->result(); + + + $sql="SELECT Max(o.packing_short) as m_short + FROM organization_case_master o + WHERE o.packing_id=$packing_id + ORDER BY o.packing_short"; + $query = $this->db->query($sql); + $org_short_max= $query->result(); + + $max_short_no=$org_short_max[0]->m_short; + + $max_short_no=$max_short_no+1; + + $dataupdate = array( + 'packing_id' => $packing_id, + 'packing_update_by'=> $user_name, + 'packing_short' => $max_short_no + ); + + $this->load->model('Ocasemaster_M'); + + if(count($org_check)>0) + { + $send_msg="Already Added"; + }else{ + $this->Ocasemaster_M->update($dataupdate,$org_id); + $send_msg="Added Successfully"; + } + + $sql="SELECT o.*,o.case_id_code,o.insurance_company_name, + p.p_code,p.p_fname,p.age,o.insurance_no,o.insurance_no_1, + if(o.case_type=0,'OPD','IPD') as IPD_OPD + FROM organization_case_master o JOIN patient_master_exten p ON o.p_id=p.id + WHERE o.packing_id=$packing_id + ORDER BY o.packing_short"; + $query = $this->db->query($sql); + $data['org_packing_list']= $query->result(); + + $data['packing_id']=$packing_id; + + $this->load->view('Org/org_packing_list',$data); + } + + public function remove_item_packing($org_id,$packing_id) + { + $user = $this->ion_auth->user()->row(); + $user_id = $user->id; + $user_name = $user->first_name.''. $user->last_name.' ['.date('d-m-Y h:i:s').']'; + + $dataupdate = array( + 'packing_id' => 0, + 'packing_update_by'=> $user_name, + 'packing_short' => 0 + ); + + $this->load->model('Ocasemaster_M'); + + $this->Ocasemaster_M->update($dataupdate,$org_id); + $send_msg="Remove Successfully"; + + $sql="SELECT o.*,o.case_id_code,o.insurance_company_name, + p.p_code,p.p_fname,p.age,o.insurance_no,o.insurance_no_1, + if(o.case_type=0,'OPD','IPD') as IPD_OPD + FROM organization_case_master o JOIN patient_master_exten p ON o.p_id=p.id + WHERE o.packing_id=$packing_id + ORDER BY o.packing_short"; + $query = $this->db->query($sql); + $data['org_packing_list']= $query->result(); + + $data['packing_id']=$packing_id; + + $this->load->view('Org/org_packing_list',$data); + } + + public function Print_List($Packing_id,$output=0) + { + $sql="SELECT * + FROM organization_case_master + WHERE packing_id=$Packing_id"; + $query = $this->db->query($sql); + $org_master= $query->result(); + + if($org_master[0]->case_type==0) + { + redirect('/Org_Packing/Print_opd_List/'.$Packing_id.'/'.$output); + }else{ + redirect('/Org_Packing/Print_ipd_List/'.$Packing_id.'/'.$output); + } + } + + function Print_opd_List($Packing_id,$output=0) + { + $sql="SELECT org.*, group_concat(opd.doc_name) AS Doc_name, + p.p_code,p.p_fname,p.age, + if(org.case_type=0,'OPD','IPD') as IPD_OPD, + (org.inv_opd_amt+org.inv_opd_charge_amt+inv_opd_med_amt) AS claim_amt, + if(opd.opd_id IS NULL,Date_Format(MIN(i.inv_date),'%d-%m-%Y'),Date_Format(MIN(opd.apointment_date),'%d-%m-%Y')) AS opd_date + FROM ((organization_case_master org JOIN patient_master_exten p ON org.p_id=p.id) + LEFT JOIN opd_master opd ON org.id=opd.insurance_case_id) + LEFT JOIN invoice_master i ON org.id=i.insurance_case_id + WHERE org.packing_id=$Packing_id + GROUP BY org.id + ORDER BY org.packing_short"; + $query = $this->db->query($sql); + $org_packing_list= $query->result(); + + $data['Packing_id']=$Packing_id; + + $content=""; + + $content.=''; + + $content.=' + + + + + + + + + + + + + + '; + $sr_no=0; + + foreach($org_packing_list as $row) + { + $sr_no=$sr_no+1; + $content.=' + + + + + + + + + + + + '; + } + + $content.="
Set No.Sr.NoClaim IDBill No.Name of PatientOPD DateConsultant NameSub. DateAmount ClaimedPassed Amt.Ded. amt
'.$row->packing_short.''.$sr_no.''.$row->insurance_no_1.''.$row->id.''.$row->p_fname.''.$row->opd_date.''.$row->Doc_name.''.$row->org_submit_date.''.$row->claim_amt.''.$row->final_approve_amount.'
"; + + if($output==0) + { + $this->load->library('m_pdf'); + + $file_name='Report-ORG-'.date('Ymdhis').".pdf"; + $filepath=$file_name; + $this->m_pdf->pdf->WriteHTML($content); + $this->m_pdf->pdf->Output($filepath,"I"); + }else{ + ExportExcel($content,'OPD_Org_List'.date('Ymdhis')); + } + } + + function Print_ipd_List($Packing_id,$output=0) + { + $sql="SELECT org.*,ipd.doc_name AS Doc_name, + p.p_code,p.p_fname,p.age, + if(org.case_type=0,'OPD','IPD') as IPD_OPD, + ipd.net_amount AS claim_amt, + ipd.str_register_date,ipd.str_discharge_date,org.org_submit_date,ipd.ipd_code, + DATE_FORMAT(org.org_submit_date,'%d-%m-%Y') AS str_org_submit_date, + ipd.id as ipd_id + FROM ((organization_case_master org JOIN patient_master_exten p ON org.p_id=p.id) + JOIN v_ipd_list ipd ON ipd.id=org.ipd_id) + WHERE org.packing_id=$Packing_id + ORDER BY org.packing_short"; + $query = $this->db->query($sql); + $org_packing_list= $query->result(); + + $sql="Select * from org_packing where id=$Packing_id"; + $query = $this->db->query($sql); + $org_packing= $query->result(); + + $org_packing_set=$org_packing[0]->label_no; + + $data['Packing_id']=$Packing_id; + + $content=""; + + $content.=''; + + $content.=' + + + + + + + + + + + + + + + + '; + $sr_no=0; + + foreach($org_packing_list as $row) + { + $sr_no=$sr_no+1; + $content.=' + + + + + + + + + + + + + + '; + } + + $content.="
Set No.Sr.NoIPD No.Claim IDBill No.Name of PatientAdmit. Dt.Discharge Dt.Sub. DateConsultant NameAmount ClaimedPassed Amt.Ded. amt
'.$org_packing_set.''.$sr_no.''.$row->ipd_code.''.$row->insurance_no_1.''.$row->ipd_id.''.$row->p_fname.''.$row->str_register_date.''.$row->str_discharge_date.''.$row->str_org_submit_date.''.$row->Doc_name.''.$row->claim_amt.''.$row->final_approve_amount.'
"; + + if($output==0) + { + $this->load->library('m_pdf'); + + $file_name='Report-ipd_org-'.date('Ymdhis').".pdf"; + $filepath=$file_name; + $this->m_pdf->pdf->WriteHTML($content); + $this->m_pdf->pdf->Output($filepath,"I"); + }else{ + ExportExcel($content,'OPD_Org_List'.date('Ymdhis')); + } + + } + + public function org_case_search() + { + + $search_string = $this->input->post('data_search'); + $data['packing_id']=$this->input->post('packing_id'); + + $sql="select * + from org_packing + where id=".$data['packing_id']; + $query = $this->db->query($sql); + $data['org_packing']= $query->result(); + + $list_type=$data['org_packing'][0]->org_type; + $data['list_type']=$list_type; + + if(strlen($search_string)>3) + { + + if($list_type==0) + { + $sql="SELECT o.*,o.case_id_code,o.insurance_company_name, + p.p_code,p.p_fname,p.age,o.insurance_no,o.insurance_no_1, + if(o.case_type=0,'OPD','IPD') as IPD_OPD + FROM organization_case_master o JOIN patient_master_exten p ON o.p_id=p.id + WHERE o.case_type=0 and (o.case_id_code LIKE '%$search_string' + OR o.insurance_no='$search_string' + OR o.insurance_no_1='$search_string' + OR o.ipd_id='$search_string') + ORDER BY o.id Limit 10"; + }else{ + $sql="SELECT o.*,o.case_id_code,o.insurance_company_name, p.p_code,p.p_fname,p.age,o.insurance_no, + o.insurance_no_1, if(o.case_type=0,'OPD','IPD') as IPD_OPD + FROM (organization_case_master o JOIN patient_master_exten p ON o.p_id=p.id ) + JOIN ipd_master i ON o.ipd_id=i.id + WHERE o.case_type=1 and (o.case_id_code LIKE '%$search_string' + OR o.insurance_no='$search_string' + OR o.insurance_no_1='$search_string' + OR i.ipd_code LIKE '%$search_string') + ORDER BY o.id Limit 10"; + } + + $query = $this->db->query($sql); + $data['org_list']= $query->result(); + + $this->load->view('Org/org_list',$data); + + + }else{ + echo 'Search with Min 4 Char.'; + } + + } + + +} diff --git a/old_code_ci3/controllers/OrganizationInvoice.php b/old_code_ci3/controllers/OrganizationInvoice.php new file mode 100644 index 0000000..2ee9759 --- /dev/null +++ b/old_code_ci3/controllers/OrganizationInvoice.php @@ -0,0 +1,368 @@ +input->is_ajax_request()) { exit('no valid req.'); } + + $this->load->model('invoice_M'); + + $showcontent1='
+
+ Print +
+
+ Payment Method by : '; + $showcontent2='
'; + + if($this->input->post('mode')==1) + { + + $data = array( + + 'payment_mode'=> '1', + 'payment_status'=>'1' + + ); + + $this->invoice_M->update( $data,$this->input->post('oid')); + + $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_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) + { + $data = array( + 'payment_mode'=> '2', + 'payment_status'=>'1', + 'card_bank'=>$this->input->post('input_card_mac'), + 'card_remark'=>$this->input->post('input_card_digit'), + 'card_tran_id'=>$this->input->post('input_card_tran') + ); + $this->Opd_M->update( $data,$this->input->post('oid')); + + $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', + 'ech_clam_id'=>$this->input->post('input_claim_id'), + + ); + + $this->invoice_M->update( $data,$this->input->post('oid')); + + $status='ECHS Credit'; + $showcontent=$showcontent1.$status.$showcontent2; + + $rvar=array( + 'update' =>1, + 'showcontent'=>$showcontent + ); + + $encode_data = json_encode($rvar); + echo $encode_data; + } + + if($this->input->post('mode')==0) + { + + } + } + + 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."' "; + + $query = $this->db->query($sql); + $data['person_info']= $query->result(); + + $sql="select * from hc_item_type"; + + $query = $this->db->query($sql); + $data['labitemtype']= $query->result(); + + $ins_comp_id=0; + + if($ins_id>1) + { + $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(); + } + + if($ins_comp_id<2) + { + $sql="select id,Concat(idesc,' : [',amount,']') as sdesc from hc_items where itype=1"; + }else{ + $sql="select id,Concat(idesc,' : [',amount1,']',if(hc_insurance_id=0,'','-INS')) as sdesc from v_hc_items_with_insurance + where itype=1 and hc_insurance_id in (0,".$ins_comp_id.")"; + } + + $query = $this->db->query($sql); + $data['labitem']= $query->result(); + + $this->load->model('invoice_M'); + + $sql="select count(*) as no_invoice from invoice_master where invoice_status=0 and attach_id=".$pno; + $query = $this->db->query($sql); + $data['chk_draft_invoice']= $query->result(); + + if($data['chk_draft_invoice'][0]->no_invoice<1) + { + $data['insert_invoice'] = array( + 'attach_type' => '0', + 'attach_id' => $pno, + 'inv_date' => str_to_MysqlDate(date('d/m/Y')), + 'inv_name' => $data['person_info'][0]->p_fname, + 'ins_id' => $ins_comp_id, + 'inv_a_code' => $data['person_info'][0]->p_code + ); + $inser_id=$this->invoice_M->create_invoice( $data['insert_invoice']); + }else{ + $sql="select id from invoice_master where invoice_status=0 and attach_id=".$pno; + $query = $this->db->query($sql); + $data['invoice_id']= $query->result(); + + $inser_id=$data['invoice_id'][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.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(); + } + + $this->load->view('Invoice_PathLab',$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 id,Concat(idesc,' : [',amount1,']',if(hc_insurance_id=0,'','-INS')) as sdesc from v_hc_items_with_insurance + where itype=".$tid." and hc_insurance_id in (0,".$ins_id.")"; + + }else{ + $sql="select id,Concat(idesc,' : [',amount,']') as sdesc from hc_items where itype=".$tid; + } + + $query = $this->db->query($sql); + $data['labitem']= $query->result(); + + echo '
+ +
'; + + } + + + + public function showinvoice($invoice_id) + { + $sql="select i.*,t.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(); + + $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; + $query = $this->db->query($sql); + $data['patient_master']= $query->result(); + + + $this->load->view('Invoice_PathLab_final_V',$data); + } + + public function showitem($type) + { + $this->load->model('invoice_M'); + + if($type>0) + { + $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 id,Concat(idesc,' : [',amount1,']',if(hc_insurance_id=0,'','-INS')) as sdesc,amount1 from v_hc_items_with_insurance + where id=".$this->input->post('itype_name_id')." and hc_insurance_id in (0,".$ins_id.")"; + + $query = $this->db->query($sql); + $data['itemlist']= $query->result(); + + $item_rate=$data['itemlist'][0]->amount1; + + $amount_value=$this->input->post('input_qty')*$item_rate; + + } + else + { + $sql="select id,Concat(idesc,' : [',amount,']') 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; + + $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 + ); + + $inser_id=$this->invoice_M->addinvoiceitem( $data['insert_invoice_item']); + + }else{ + $this->db->delete("invoice_item", "id=".$this->input->post('itemid')); + } + + $sql="select i.*,t.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'); + $query = $this->db->query($sql); + $data['invoiceDetails']= $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(); + + echo ' + + + + + + + + + '; + + $srno=1; + + foreach($data['invoiceDetails'] as $row) + { + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + $srno=$srno+1; + echo ''; + } + + echo ' + + + + + + + + +
#TypeTest NameRateQtyAmount
'.$srno.''.$row->desc.''.$row->item_name.''.$row->item_rate.''.$row->item_qty.''.$row->item_amount.'
#Gross Total'.$data['invoiceGtotal'][0]->Gtotal.'
'; + } + + + +} \ No newline at end of file diff --git a/old_code_ci3/controllers/Orgcase.php b/old_code_ci3/controllers/Orgcase.php new file mode 100644 index 0000000..89c05ae --- /dev/null +++ b/old_code_ci3/controllers/Orgcase.php @@ -0,0 +1,1255 @@ +input->post('txtsearch'); + + $sdata = preg_replace('/[^A-Za-z0-9]/', '', $sdata); + + $sql = "select c.id,c.p_id,c.case_id_code,sum(o.opd_fee_amount) as OPD_Amount,sum(i.net_amount) as Invoice_Amount, + c.insurance_company_name,c.p_name,p.p_code,c.date_registration,insurance_card_name, + (case c.status when 0 then 'Pending' + when 1 then 'Ready for submission' + when 2 then 'Submitted' + when 3 then 'Payment Done' + else 'Other' end) as str_status, + Date_Format(c.date_registration,'%d-%m-%Y') as date_registration_in + from (organization_case_master c join patient_master p on c.p_id=p.id ) + left join opd_master o on c.id=o.insurance_case_id + left join invoice_master i on c.id=i.insurance_case_id + group by c.id "; + + if($sdata!='') + { + $sql.=" WHERE case_id_code = '".$sdata."' or p_name like '%".$sdata."%' or + p_code = '".$sdata." order by c.id desc limit 20"; + }else + { + $sql.=" order by c.id desc limit 20"; + } + + $query = $this->db->query($sql); + $data['searchdata']= $query->result(); + + $this->load->view('Invoice/Case_List',$data); + } + + public function search_all() + { + $this->load->view('Invoice/case_list_all'); + } + + public function case_invoice($casecode,$print=0,$caseid=0,$med_include=1) + { + if($caseid<1) + { + $sql="select * from organization_case_master where case_id_code='".$casecode."'"; + }else{ + $sql="select * from organization_case_master where id='".$caseid."'"; + } + + $query = $this->db->query($sql); + $data['orgcase']= $query->result(); + + $pno=$data['orgcase'][0]->p_id; + $caseid=$data['orgcase'][0]->id; + + $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."' "; + + $query = $this->db->query($sql); + $data['person_info']= $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(); + + //$sql="select * from v_case_invoice v + // where v.id=".$caseid." order by Charge_type,Adate "; + + //$query = $this->db->query($sql); + //$data['showinvoice']= $query->result(); + + $sql="select * from v_case_invoice_1 v + where v.id=".$caseid." order by Charge_type,Adate "; + $query = $this->db->query($sql); + $data['showinvoice1']= $query->result(); + + $sql="select * from v_case_invoice_2 v + where v.id=".$caseid." order by Charge_type,Adate "; + $query = $this->db->query($sql); + $data['showinvoice2']= $query->result(); + + //$sql="select sum(amount) as GTotal from v_case_invoice v + // where v.id=".$caseid." "; + //$query = $this->db->query($sql); + //$data['invoiceGtotal']= $query->result(); + + $sql="select m.*,m.id as med_id + from invoice_med_master m join ipd_master p join organization_case_master o + on m.ipd_id=p.id and p.case_id=o.id and m.ipd_credit=1 and m.ipd_credit_type=1 + where o.id=".$caseid." "; + + $query = $this->db->query($sql); + $data['MedInvoice_data']= $query->result(); + + $sql="select sum(m.net_amount) as Med_Amount,o.id ,count(m.id) as no_inv + from invoice_med_master m join ipd_master p join organization_case_master o + on m.ipd_id=p.id and p.case_id=o.id and m.ipd_credit=1 and m.ipd_credit_type=1 + where o.id=".$caseid." group by o.id "; + + $query = $this->db->query($sql); + $data['MedInvoice']= $query->result(); + + if(count($data['MedInvoice'])==0) + { + $sql="select m.* ,m.id as med_id + from invoice_med_master m join organization_case_master o + on m.case_id=o.id and m.case_credit=1 + where o.id=".$caseid." "; + + $query = $this->db->query($sql); + $data['MedInvoice_data']= $query->result(); + + $sql="select sum(m.net_amount) as Med_Amount,o.id ,count(m.id) as no_inv + from invoice_med_master m join organization_case_master o + on m.case_id=o.id and m.case_credit=1 + where o.id=".$caseid." group by o.id "; + + $query = $this->db->query($sql); + $data['MedInvoice']= $query->result(); + } + + $data['med_include']=$med_include; + + $sql="select p.* ,date_format(payment_date,'%d-%m-%Y') as str_date, + if(credit_debit=0,if(payment_mode=1,'CASH','BANK'),if(payment_mode=1,'CASH RETURN','BANK RETURN')) as Pay_mode + from payment_history p + where p.payof_type=3 and p.payof_id=$caseid"; + $query = $this->db->query($sql); + $data['payment_history']= $query->result(); + + + if($print>0) + { + $this->load->library('m_pdf'); + $file_name='Org_Invoice_-'.$casecode.'-'.date('Ymdhis').".pdf"; + $filepath=$file_name; + $this->m_pdf->curlAllowUnsafeSslRequests = true; + $this->m_pdf->useSubstitutions = false; + $print_content=$this->load->view('Invoice/caseinvoice_print_V',$data,TRUE); + //echo $print_content; + $this->m_pdf->pdf->WriteHTML($print_content); + //download it. + $this->m_pdf->pdf->Output($filepath,"I"); + + }else{ + $this->load->view('Invoice/caseinvoice_V',$data); + } + + } + + public function case_invoice_ipd($caseid) + { + $sql="select * from organization_case_master where id='".$caseid."'"; + $query = $this->db->query($sql); + $data['orgcase']= $query->result(); + + $pno=$data['orgcase'][0]->p_id; + $caseid=$data['orgcase'][0]->id; + + $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."' "; + + $query = $this->db->query($sql); + $data['person_info']= $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(); + + //$sql="select * from v_case_invoice v + // where v.id=".$caseid." order by Charge_type,Adate "; + + //$query = $this->db->query($sql); + //$data['showinvoice']= $query->result(); + + $sql="select * from v_case_invoice_1 v + where v.id=".$caseid." order by Charge_type,Adate "; + $query = $this->db->query($sql); + $data['showinvoice1']= $query->result(); + + $sql="select * from v_case_invoice_2 v + where v.id=".$caseid." order by Charge_type,Adate "; + $query = $this->db->query($sql); + $data['showinvoice2']= $query->result(); + + $this->load->view('Invoice/caseinvoice_ipd_V',$data); + + } + + public function ORG_info(){ + + $org_no = $this->input->post('input_org_no'); + + $sql="select * from organization_case_master + where case_type=0 and case_id_code='$org_no' "; + $query = $this->db->query($sql); + $data_org= $query->result(); + + if(count($data_org)>0) + { + $UHID=$data_org[0]->p_id; + + $sql="select * from patient_master_exten where id='$UHID' "; + $query = $this->db->query($sql); + $data_person= $query->result(); + + $Patient_id=$data_person[0]->id; + $Patient_info=$data_person[0]->p_code.'/'.$data_person[0]->p_fname.' '.$data_person[0]->p_relative.' '.$data_person[0]->p_rname.' /Age :'.$data_person[0]->str_age; + + $org_info=$Patient_info.'/'.$data_org[0]->insurance_company_name. + '/Reg.:'.$data_org[0]->insurance_no_1.'/Reg.Dt:'.$data_org[0]->date_registration; + + $org_id=$data_org[0]->id; + + }else{ + $org_id=0; + $org_info=''; + + } + + $rvar=array( + 'org_id' =>$org_id, + 'org_info'=>$org_info + ); + + $encode_data = json_encode($rvar); + echo $encode_data; + + } + + public function update_itemrateqty() + { + $item_type_id=$this->input->post('item_type_id'); + $item_id=$this->input->post('item_id'); + + $rate=$this->input->post('rate'); + $orgcode=$this->input->post('orgcode'); + $insurance_id=$this->input->post('insurance_id'); + $master_item_id=$this->input->post('master_item_id'); + + $sql="select * from invoice_item + where id=".$item_id." "; + $query = $this->db->query($sql); + $invoice_item= $query->result(); + + $qty=0; + + if(count($invoice_item)>0) + { + $qty=$invoice_item[0]->item_qty; + } + + $this->load->model('invoice_M'); + + $amount_value=$qty * $rate; + + $data['update_invoice_item'] = array( + 'item_qty' => $qty, + 'item_rate' => $rate, + 'item_amount' => $amount_value, + 'org_code' => $orgcode + ); + + $inser_id=$this->invoice_M->update_item( $data['update_invoice_item'],$item_id); + + $this->load->model('item_M'); + + $data['update_insurance_item'] = array( + 'hc_items_id' => $master_item_id, + 'hc_insurance_id' => $insurance_id, + 'amount1' => $amount_value, + '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(count($chkitem)>0 ) + { + $insDone=$this->item_M->update_in_item( $data['update_insurance_item'],$chkitem[0]->id); + }else{ + $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); + $data['invoiceitem']= $query->result(); + + $invoice_id=0; + + if(count($data['invoiceitem'])>0) + { + $invoice_id=$data['invoiceitem'][0]->inv_master_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 *,(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; + $balance_amount=$net_amount; + + $dataupdate = array( + 'total_amount' => $total_amount, + 'net_amount' => $net_amount + ); + + $this->load->model('Invoice_M'); + $this->Invoice_M->update($dataupdate,$invoice_id); + + } + + public function update_status() + { + if (!$this->input->is_ajax_request()) { exit('no valid req.'); } + + $this->load->model('Ocasemaster_M'); + + $case_id=$this->input->post('caseid'); + + $user = $this->ion_auth->user()->row(); + $user_id = $user->id; + $user_name = $user->first_name.''. $user->last_name; + + $sql="select * from organization_case_master where id='".$case_id."'"; + $query = $this->db->query($sql); + $case_master= $query->result(); + + $log=$case_master[0]->log.'\nUpdate Status:'.$this->input->post('status').'-Upd By:'.$user_name.'['.$user_id.']'.date('d/m/Y H:m:s'); + + $status=$this->input->post('status'); + + $org_submit_date= str_to_MysqlDate($this->input->post('org_submit_date')); + + $data = array( + 'status'=> $status, + 'log'=>$log, + ); + + if($status==1) + { + $data['org_submit_date']=$org_submit_date; + } + + $this->Ocasemaster_M->update( $data,$case_id); + + } + + public function org_contingent_update() + { + 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; + + $htmldata=$this->input->post('HTMLData'); + $case_id=$this->input->post('case_id'); + + $this->load->model('Ocasemaster_M'); + $data['master'] = array( + 'contingent_bill' => $htmldata, + 'contingent_update_by' => $user_name + ); + + $case_id=$this->input->post('case_id'); + $this->Ocasemaster_M->update($data['master'],$case_id); + + $rvar=array( + 'update' =>'1', + 'msg' => 'Update Done '.$case_id + ); + $encode_data = json_encode($rvar); + echo $encode_data; + + } + + public function case_invoice_print($caseid) + { + + $sql="select * from organization_case_master where id=".$caseid; + $query = $this->db->query($sql); + $data['orgcase']= $query->result(); + + $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."' "; + + $query = $this->db->query($sql); + $data['person_info']= $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(); + + $sql="select * from v_case_invoice v + where v.id=".$caseid." order by s_Date "; + + $query = $this->db->query($sql); + $data['showinvoice']= $query->result(); + + $sql="select sum(amount) as GTotal from v_case_invoice v + where v.id=".$caseid." "; + $query = $this->db->query($sql); + $data['invoiceGtotal']= $query->result(); + + $this->load->view('Invoice/caseinvoice_V',$data); + + } + + public function getCaseTable() + { + + $requestData= $_REQUEST; + + $columns = array( + // datatable column index => database column name + 0 =>'case_id_code', + 1 => 'Reg_No', + 2 => 'p_f_info', + 3 => 'date_registration', + 4=> 'insurance_card_name', + 5=> 'insurance_company_name', + 6=> 'str_status' + ); + + // getting total number records without any search + $sql_f_all = "select c.id,c.p_id,c.case_id_code,Concat(c.insurance_no,'/',c.insurance_no_1) as Reg_No, + c.insurance_company_name,Concat(c.p_name,'
','[',p_code,if(i.id is null,'',concat('/',i.ipd_code)),']') as p_f_info,p.p_code, + c.date_registration,c.insurance_card_name,c.status, + (case c.status when 0 then 'Pending' + when 1 then 'Ready for submission' + when 2 then 'submitted' else 'Other' end) as str_status,c.insurance_id, + Date_Format(c.date_registration,'%d-%m-%Y') as date_registration_in ,i.ipd_code "; + + $sql_count="Select count(*) as no_rec "; + + $sql_from=" from ((organization_case_master c join patient_master p on c.p_id=p.id ) + left join ipd_master i on c.id=i.case_id and p.id=i.p_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 c.case_type=0 "; + + $sql_where_flag=0; + + // getting records as per search parameters + if( !empty($requestData['columns'][0]['search']['value']) ){ //CaseCode-InsuranceCard-ClaimNo + $sql_where.=" AND case_id_code LIKE '%".$requestData['columns'][0]['search']['value']."' "; + $sql_where_flag=1; + } + + if( !empty($requestData['columns'][1]['search']['value']) ){ //p_code-P-Name + $sql_where.=" AND ( p.p_fname LIKE '%".$requestData['columns'][1]['search']['value']."%' "; + $sql_where.=" OR p.mphone1 LIKE '".$requestData['columns'][1]['search']['value']."' "; + $sql_where.=" OR i.ipd_code LIKE '%".$requestData['columns'][1]['search']['value']."' "; + $sql_where.=" OR p_code LIKE '%".$requestData['columns'][1]['search']['value']."' )"; + $sql_where_flag=1; + } + + if( !empty($requestData['columns'][2]['search']['value']) ){ //insurance_card_name + $sql_where.=" AND c.insurance_card_name LIKE '%".$requestData['columns'][2]['search']['value']."%' "; + $sql_where_flag=1; + } + + //if( !empty($requestData['columns'][3]['search']['value']) ){ //insurance_company_name + // $sql_where.=" AND insurance_company_name LIKE '%".$requestData['columns'][3]['search']['value']."%' "; + // $sql_where_flag=1; + //} + + if( !empty($requestData['columns'][3]['search']['value'])){ //insurance_card_name + + if($requestData['columns'][3]['search']['value'] < 0){ + $sql_where.=" AND c.insurance_id not in (1,2,53,63) "; + $sql_where_flag=1;} + + if($requestData['columns'][3]['search']['value']>0){ + $sql_where.=" AND c.insurance_id = '".$requestData['columns'][3]['search']['value']."' "; + $sql_where_flag=1;} + } + + + if( !empty($requestData['columns'][4]['search']['value']) ){ //insurance_company_name + $sql_where.=" AND ( c.insurance_no LIKE '".$requestData['columns'][4]['search']['value']."%' "; + $sql_where.=" OR c.insurance_no_1 LIKE '".$requestData['columns'][4]['search']['value']."%' ) "; + $sql_where_flag=1; + } + + if( !empty($requestData['columns'][5]['search']['value'])){ //insurance_card_name + $sql_where.=" AND c.status = '".$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=" group by c.id 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 contingent_bill($caseid,$print=0) + { + $sql="select * from organization_case_master where id='".$caseid."'"; + $query = $this->db->query($sql); + $data['orgcase']= $query->result(); + + $pno=$data['orgcase'][0]->p_id; + $caseid=$data['orgcase'][0]->id; + $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."' "; + + $query = $this->db->query($sql); + $data['person_info']= $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(); + + $content=$data['orgcase'][0]->contingent_bill; + + if($print==1) + { + //echo $content; + $page_head=""; + + $content=$page_head.$content; + //create_report_pdf($content,'Report_1.pdf'); + $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{ + $this->load->view('Invoice/Org_Contingent_bill',$data); + } + + } + + + public function create_contingent_bill($caseid) + { + $sql="select * from organization_case_master where id='".$caseid."'"; + $query = $this->db->query($sql); + $data['orgcase']= $query->result(); + + $pno=$data['orgcase'][0]->p_id; + $caseid=$data['orgcase'][0]->id; + $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."' "; + + $query = $this->db->query($sql); + $data['person_info']= $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(); + + $sql="select * from v_case_invoice v + where v.id=".$caseid." order by Charge_type,Adate "; + + $query = $this->db->query($sql); + $data['showinvoice']= $query->result(); + + $sql="select sum(amount) as GTotal from v_case_invoice v + where v.id=".$caseid." "; + $query = $this->db->query($sql); + $data['invoiceGtotal']= $query->result(); + + $content=""; + + + $content.='

CLAIM ID : '.$claim_id.'

'; + $content.="

Name of Hospital : ".H_Name."

"; + + $content.='

CONTINGENT BILL

'; + + $content.=''; + $content.=''; + $content.=''; + $content.=''; + $content.=''; + $content.='
Voucher No. ______________________________Date : ………………………
Amount of allotment : Rs.……………………………
Amount expended and for which bills have already been submitted for payment :Rs.……………………………
Balance of allotment excliding the amount of this bills :Rs.……………………………
'; + $content.='

Expenditure an account of : Treatment/ Super Treatment/ Special investigation / Consultant fee

'; + + $content.=''; + $content.=''; + $content.=''; + $content.=''; + $content.=''; + $content.=''; + + $content.=''; + $content.="'; + $content.="'; + $content.="'; + $content.=''; + $content.='
In respect of
Name of Patient: '.strtoupper($data['orgcase'][0]->p_name).'
Relation : '.strtoupper($data['orgcase'][0]->relation_with_cardholder).'Service No.: '.strtoupper($data['orgcase'][0]->insurance_no_2).'
ESM Name : ".strtoupper($data['orgcase'][0]->insurance_card_name).'ECHS CARD No. : ".strtoupper($data['orgcase'][0]->insurance_no).'Rank : ".strtoupper($data['orgcase'][0]->card_remark).'
'; + + $content.='

Authority:
'; + $content.='Government of India letter No. 24 (3)/03/US/(WE)/D (Res) (i) dated 08 Sep 2003
'; + $content.='Government of India letter No. 24 (8)/03/US/(WE)/D (Res) dated 19 Dec 2003
'; + $content.='Central Organization ECHS Letter NoB/49773/AG/ECHS dated 25 May 2004.

'; + + $sql='select c.id,c.case_id_code,c.p_id,sum(o.opd_fee_amount) as tamount, + count(o.opd_id) as item_qty,Min(o.opd_fee_amount) as rate + from opd_master o join organization_case_master c on o.insurance_case_id=c.id + where opd_status in (1,2) and id='.$caseid.' group by c.id'; + + $query = $this->db->query($sql); + $opd= $query->result(); + + $sql="select i.item_type,t.`desc` AS item_name,sum(i.item_amount) as tamount,sum(i.item_qty) as unit,i.item_rate + from invoice_master m join invoice_item i join hc_item_type t + on m.id=i.inv_master_id and i.item_type=t.itype_id + where item_type=34 and m.ipd_include=1 and invoice_status=1 and + insurance_case_id=$caseid + group by i.item_type"; + $query = $this->db->query($sql); + $data['invoice_list_1']= $query->result(); + + $sql="select i.item_type,t.`desc` AS item_name,sum(i.item_amount) as tamount,sum(i.item_qty) as unit,i.item_rate + from invoice_master m join invoice_item i join hc_item_type t + on m.id=i.inv_master_id and i.item_type=t.itype_id + where item_type not in (34,35) and m.ipd_include=1 and invoice_status=1 and + insurance_case_id=$caseid + group by i.item_type"; + $query = $this->db->query($sql); + $data['invoice_list_2']= $query->result(); + + $sql="select i.item_type,t.`desc` AS item_name,sum(i.item_amount) as tamount,sum(i.item_qty) as unit,i.item_rate + from invoice_master m join invoice_item i join hc_item_type t + on m.id=i.inv_master_id and i.item_type=t.itype_id + where item_type=35 and m.ipd_include=1 and invoice_status=1 and + insurance_case_id=$caseid + group by i.item_type"; + $query = $this->db->query($sql); + $data['invoice_list_3']= $query->result(); + + $sql="select i.item_type,i.item_name,t.group_desc,sum(i.item_amount) as tamount,sum(i.item_qty) as unit, + i.item_rate + FROM (ipd_master m join ipd_invoice_item i on m.id=i.ipd_id) + join ipd_item_type t ON i.item_type=t.itype_id + and i.item_type=t.itype_id + WHERE i.package_id=0 and t.itype_id=2 AND m.case_id=$caseid + group by i.item_type"; + $query = $this->db->query($sql); + $data['ipd_invoice_list_1']= $query->result(); + + $sql="select i.item_type,i.item_name,t.group_desc,sum(i.item_amount) as tamount,sum(i.item_qty) as unit, + i.item_rate + FROM (ipd_master m join ipd_invoice_item i on m.id=i.ipd_id) + join ipd_item_type t ON i.item_type=t.itype_id + and i.item_type=t.itype_id + WHERE i.package_id=0 and t.itype_id not in (2,6) AND m.case_id=$caseid + group by i.item_type"; + $query = $this->db->query($sql); + $data['ipd_invoice_list_2']= $query->result(); + + $sql="select i.item_type,i.item_name,t.group_desc,sum(i.item_amount) as tamount,sum(i.item_qty) as unit, + i.item_rate + FROM (ipd_master m join ipd_invoice_item i on m.id=i.ipd_id) + join ipd_item_type t ON i.item_type=t.itype_id + and i.item_type=t.itype_id + WHERE i.package_id=0 and t.itype_id=6 AND m.case_id=$caseid + group by i.item_type"; + $query = $this->db->query($sql); + $data['ipd_invoice_list_3']= $query->result(); + + $sql="select sum(m.net_amount) as Med_Amount,o.id ,count(m.id) as no_inv + from invoice_med_master m join ipd_master p join organization_case_master o + on m.ipd_id=p.id and p.case_id=o.id and m.ipd_credit=1 and m.ipd_credit_type=1 + where o.id=".$caseid." group by o.id "; + $query = $this->db->query($sql); + $data['MedInvoice']= $query->result(); + + $sql="SELECT p.* + FROM ipd_package p JOIN ipd_master m ON p.ipd_id=m.id + WHERE m.case_id=$caseid"; + $query = $this->db->query($sql); + $data['ipd_package']= $query->result(); + + + if(count($data['MedInvoice'])==0) + { + $sql="select sum(m.net_amount) as Med_Amount,o.id ,count(m.id) as no_inv + from invoice_med_master m join organization_case_master o + on m.case_id=o.id and m.case_credit=1 + where o.id=".$caseid." group by o.id "; + + $query = $this->db->query($sql); + $data['MedInvoice']= $query->result(); + } + + $sql="select p.* from ipd_master p join organization_case_master o + on p.case_id=o.id where o.id=". $caseid; + $query = $this->db->query($sql); + $IPDMaster= $query->result(); + + $tableHead=' + + + + + + + + + '; + $tbody=""; + $srno=0; + $total_gross_bill=0.00; + + if(count($opd)>0) + { + $srno=$srno+1; + $tbody.=''; + $tbody.=' + + '; + $tbody.=""; + $total_gross_bill=$total_gross_bill+$opd[0]->tamount; + } + + foreach($data['ipd_package'] as $row) + { + $srno=$srno+1; + $tbody.=''; + $tbody.=' + '; + $tbody.=""; + $total_gross_bill=$total_gross_bill+$row->package_Amount; + } + + foreach($data['invoice_list_1'] as $row) + { + if($row->item_type<>'') + { + $srno=$srno+1; + $tbody.=''; + $tbody.=' + '; + $tbody.=""; + $total_gross_bill=$total_gross_bill+$row->tamount; + } + } + + foreach($data['ipd_invoice_list_1'] as $row) + { + if($row->item_type<>'') + { + $srno=$srno+1; + $tbody.=''; + $tbody.=' + '; + $tbody.=""; + $total_gross_bill=$total_gross_bill+$row->tamount; + } + } + + foreach($data['invoice_list_2'] as $row) + { + if($row->item_type<>'') + { + $srno=$srno+1; + $tbody.=''; + $tbody.=' + '; + $tbody.=""; + $total_gross_bill=$total_gross_bill+$row->tamount; + } + } + + foreach($data['ipd_invoice_list_2'] as $row) + { + if($row->item_type<>'') + { + $srno=$srno+1; + $tbody.=''; + $tbody.=' + '; + $tbody.=""; + $total_gross_bill=$total_gross_bill+$row->tamount; + } + } + + foreach($data['invoice_list_3'] as $row) + { + if($row->item_type<>'') + { + $srno=$srno+1; + $tbody.=''; + $tbody.=' + '; + $tbody.=""; + $total_gross_bill=$total_gross_bill+$row->tamount; + } + } + + foreach($data['ipd_invoice_list_3'] as $row) + { + if($row->item_type<>'') + { + $srno=$srno+1; + $tbody.=''; + $tbody.=' + '; + $tbody.=""; + $total_gross_bill=$total_gross_bill+$row->tamount; + } + } + + + + foreach($data['ipd_invoice_list_2'] as $row) + { + if($row->item_type<>'') + { + $srno=$srno+1; + $tbody.=''; + $tbody.=' + '; + $tbody.=""; + $total_gross_bill=$total_gross_bill+$row->tamount; + } + } + + if(count($data['MedInvoice'])>0) + { + $srno=$srno+1; + $tbody.=''; + $tbody.=' + + '; + $tbody.=''; + $total_gross_bill=$total_gross_bill+$data['MedInvoice'][0]->Med_Amount; + } + + $tbody.=''; + + if(count($IPDMaster)>0) + { + if($IPDMaster[0]->chargeamount1>0) + { + $tbody.=''; + $tbody.=' + '; + $tbody.=''; + $total_gross_bill=$total_gross_bill+$IPDMaster[0]->chargeamount1; + } + + if($IPDMaster[0]->chargeamount2>0) + { + $tbody.=''; + $tbody.=' + '; + $tbody.=''; + $total_gross_bill=$total_gross_bill+$IPDMaster[0]->chargeamount2; + } + + if($IPDMaster[0]->Discount>0) + { + $tbody.=''; + $tbody.=' + '; + $tbody.=''; + $total_gross_bill=$total_gross_bill-$IPDMaster[0]->Discount; + } + + if($IPDMaster[0]->Discount2>0) + { + $tbody.=''; + $tbody.=' + '; + $tbody.=''; + $total_gross_bill=$total_gross_bill-$IPDMaster[0]->Discount2; + } + + if($IPDMaster[0]->Discount3>0) + { + $tbody.=''; + $tbody.=' + '; + $tbody.=''; + $total_gross_bill=$total_gross_bill-$IPDMaster[0]->Discount3; + } + + } + + $tableFooter=""; + $tableFooter.=''; + + $tableFooter.="
Sr.No.DateDetails of ExpenditureNumber or QuantityRatePerAmount
'.$srno.''.date('Y-m-d').'OPD'.$opd[0]->rate.''.$opd[0]->item_qty.''.$opd[0]->rate.'CGHS'.$opd[0]->tamount.'
'.$srno.''.date('Y-m-d').'Package :'.$row->package_name.''.$row->package_Amount.'1'.$row->package_Amount.'CGHS'.$row->package_Amount.'
'.$srno.''.date('Y-m-d').''.$row->item_name.''.$row->item_rate.''.$row->unit.''.$row->item_rate.'CGHS'.$row->tamount.'
'.$srno.''.date('Y-m-d').''.$row->item_name.''.$row->item_rate.''.$row->unit.''.$row->item_rate.'CGHS'.$row->tamount.'
'.$srno.''.date('Y-m-d').''.$row->item_name.''.$row->item_rate.''.$row->unit.''.$row->item_rate.'CGHS'.$row->tamount.'
'.$srno.''.date('Y-m-d').''.$row->item_name.''.$row->item_rate.''.$row->unit.''.$row->item_rate.'CGHS'.$row->tamount.'
'.$srno.''.date('Y-m-d').''.$row->item_name.''.$row->item_rate.''.$row->unit.''.$row->item_rate.'CGHS'.$row->tamount.'
'.$srno.''.date('Y-m-d').''.$row->item_name.''.$row->item_rate.''.$row->unit.''.$row->item_rate.'CGHS'.$row->tamount.'
'.$srno.''.date('Y-m-d').''.$row->item_name.''.$row->item_rate.''.$row->unit.''.$row->item_rate.'CGHS'.$row->tamount.'
'.$srno.''.date('Y-m-d').'Medicine'.$data['MedInvoice'][0]->Med_Amount.''.$data['MedInvoice'][0]->no_inv.''.$data['MedInvoice'][0]->Med_Amount.''.$data['MedInvoice'][0]->Med_Amount.'
Gross Total '.Round($total_gross_bill,0).'
'.$IPDMaster[0]->charge1.''.$IPDMaster[0]->chargeamount1.'
'.$IPDMaster[0]->charge2.''.$IPDMaster[0]->chargeamount2.'
'.$IPDMaster[0]->Discount_Remark.''.$IPDMaster[0]->Discount.'
'.$IPDMaster[0]->Discount_Remark2.''.$IPDMaster[0]->Discount3.'
'.$IPDMaster[0]->Discount_Remark3.''.$IPDMaster[0]->Discount3.'
Net Total '.Round($total_gross_bill,0).'
"; + + $content.=$tableHead.$tbody.$tableFooter; + + $content.="

Net Amount due(In words) : Rs. ".number_to_word(Round($total_gross_bill,0))."

"; + + $content.=""; + $content.="
Date : ......................Pre Received Payment
From : ...........................................
"; + + $content.='

Certified that
'; + $content.='

  1. Certified that above have been claimed on the basis of approved charges as noted in MOA signed for the treatment of ECHS member.
  2. '; + $content.='
  3. The rate is/are fair and reasonable and less than CGHS rates
  4. '; + $content.='
  5. The expenditure incurred is debatable to major Head 2076 Minor head 107, Sub Head E-Medical treatment related expenditure code head 365/00.
  6. '; + $content.='
  7. The expenditure has been incurred the interest of Ex-Serviceman

'; + + $content.=''; + $content.='
Vetted and Recommended / Not RecommendedSig of OIC ECHS Polyclinic

Date : ......................

Place: ......................
.....................
'; + + $dataupdate = array( + 'contingent_bill' => $content + ); + + $this->load->model('Ocasemaster_M'); + $this->Ocasemaster_M->update($dataupdate,$caseid); + + $sql="select * from organization_case_master where id='".$caseid."'"; + $query = $this->db->query($sql); + $data['orgcase']= $query->result(); + + echo 'Created'; + + //create_report_pdf($content,'Report_1.pdf'); + + } + + public function org_confirm_payment() + { + $amount_r=$this->input->post('amount_r'); + $amount_d=$this->input->post('amount_d'); + $amount_claim=$this->input->post('amount_claim'); + $amount_tds=$this->input->post('amount_tds'); + $date_payment=str_to_MysqlDate($this->input->post('date_payment')); + $pay_info=$this->input->post('pay_info'); + $org_id=$this->input->post('org_id'); + + $user = $this->ion_auth->user()->row(); + $user_id = $user->id; + $user_name = $user->first_name.''. $user->last_name.'['.$user_id.']'.date('d-m-Y H:i:s'); + + $this->load->model('Ocasemaster_M'); + + $data= array( + 'pay_date_received' => $date_payment, + 'amount_recived' => $amount_r, + 'amount_deduction' => $amount_d, + 'amount_claim' => $amount_claim, + 'amount_tds' => $amount_tds, + 'amount_payment_info' => $pay_info, + 'status' => '3', + 'amount_update_by' => $user_name + ); + + $this->Ocasemaster_M->update( $data,$org_id); + + $rvar=array( + 'update' =>1, + 'showcontent'=>'Update' + ); + + $encode_data = json_encode($rvar); + echo $encode_data; + } + + + + public function org_payment_request() + { + $sql="select * from org_payment_request "; + $query = $this->db->query($sql); + $data['org_info']= $query->result(); + + $sql="select * from v_ipd_list where org_id='".$data['org_info'][0]->id."' "; + $query = $this->db->query($sql); + $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."' "; + $query = $this->db->query($sql); + $data['person_info']= $query->result(); + + $this->load->view('Invoice/org_case_payment',$data); + } + + public function load_model_box($caseidcode) + { + $sql="select * from organization_case_master where case_id_code='".$caseidcode."' "; + $query = $this->db->query($sql); + $data['org_info']= $query->result(); + + $sql="select * from v_ipd_list where org_id='".$data['org_info'][0]->id."' "; + $query = $this->db->query($sql); + $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."' "; + $query = $this->db->query($sql); + $data['person_info']= $query->result(); + + $this->load->view('Invoice/org_case_payment',$data); + } + + public function payment_request() + { + $input_pay_amount=$this->input->post('input_pay_amount'); + $caseidcode=$this->input->post('caseid'); + $input_remark=$this->input->post('input_remark'); + + $user = $this->ion_auth->user()->row(); + $user_id = $user->id; + $user_name = $user->first_name.''. $user->last_name.'['.$user_id.']'.date('d-m-Y H:i:s'); + + $sql="select * from organization_case_master where id='".$caseidcode."' "; + $query = $this->db->query($sql); + $org_info= $query->result(); + + $sql="select * from org_payment_request where payment_process=0 and org_id='".$caseidcode."' "; + $query = $this->db->query($sql); + $org_payment_request= $query->result(); + + $patient_id=0; + $org_date=date('Y-m-d H:i:s'); + + if(count($org_info)>0) + { + $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."' "; + $query = $this->db->query($sql); + $person_info= $query->result(); + + $org_date=$org_info[0]->insert_datetime; + $patient_name=$person_info[0]->p_fname; + + $org_code=$org_info[0]->case_id_code; + } + + $paydata = array( + 'org_id'=> $caseidcode, + 'org_code'=>$org_code, + 'patient_id'=>$patient_id, + 'org_date'=>$org_date, + 'patient_name'=>$patient_name, + 'payment_amount'=>$input_pay_amount, + 'payment_request_datetime'=>date('Y-m-d H:i:s'), + 'request_by_id'=>$user_id, + 'request_by'=>$user_name, + 'remark'=>$input_remark, + ); + + $this->load->model('Payment_M'); + + if(count($org_payment_request)<1) + { + $insert_id=$this->Payment_M->insert_org_payment($paydata); + }else{ + $this->Payment_M->update_org_payment($paydata,$org_payment_request[0]->id); + $insert_id=$org_payment_request[0]->id; + } + + echo 'Request has been Created : Req. ID -> '.$insert_id; + } + + + public function refund_request() + { + $input_refund_amount=$this->input->post('input_refund_amount'); + $caseidcode=$this->input->post('caseid'); + $input_remark=$this->input->post('input_refund_remark'); + + $user = $this->ion_auth->user()->row(); + $user_id = $user->id; + $user_name = $user->first_name.''. $user->last_name.'['.$user_id.']'.date('d-m-Y H:i:s'); + + $sql="select * from organization_case_master where id='".$caseidcode."' "; + $query = $this->db->query($sql); + $org_info= $query->result(); + + $sql="select * from refund_order where refund_process=0 and refund_type=3 and refund_type_id=$caseidcode"; + $query = $this->db->query($sql); + $refund_order= $query->result(); + + $patient_id=0; + $org_date=date('Y-m-d H:i:s'); + + if(count($org_info)>0) + { + $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."' "; + $query = $this->db->query($sql); + $person_info= $query->result(); + + $org_date=$org_info[0]->insert_datetime; + $patient_name=$person_info[0]->p_fname; + + $org_code=$org_info[0]->case_id_code; + } + + $RefundRequest = array( + 'refund_type' => 3, + 'refund_type_id' => $caseidcode, + 'refund_type_code' => $org_code, + 'refund_type_reason' => $input_remark, + 'approved_by_id' => $user_id, + 'approved_by' => $user_name, + 'refund_amount' => $input_refund_amount, + 'patient_id' => $patient_id, + 'patient_name' =>$patient_name + ); + + $this->load->model('Payment_M'); + + if(count($refund_order)<1) + { + $insert_id=$this->Payment_M->insert_refundorder($RefundRequest); + echo 'Refund Request has been Created : Req. ID -> '.$insert_id; + }else{ + echo 'Refund Request Pending, Please Refund or Cancel Last Refund Request'; + } + + } + + + +} \ No newline at end of file diff --git a/old_code_ci3/controllers/Package.php b/old_code_ci3/controllers/Package.php new file mode 100644 index 0000000..d186a93 --- /dev/null +++ b/old_code_ci3/controllers/Package.php @@ -0,0 +1,342 @@ +db->query($sql); + $data['data'] = $query->result(); + + $this->load->view('IPD_Package/item_type_search_v', $data); + } + + public function search_adv($itype_id = 1) + { + + $sql = "SELECT * FROM package where pakage_group_id=" . $itype_id; + $query = $this->db->query($sql); + $data = $query->result(); + echo ' Print

'; + + echo ' + + + + + + + + '; + if (count($data) > 0) { + for ($i = 0; $i < count($data); ++$i) { + echo ' + + + + '; + } + } + + echo ' + + + + + + + +
Package NameAmount
' . $data[$i]->ipd_pakage_name . '' . $data[$i]->Pakage_Min_Amount . ' + +
Package NameAmount
'; + echo ""; + } + + public function search() + { + $sql = "SELECT * FROM package_group order by pakage_group_name"; + $query = $this->db->query($sql); + $data['package_group'] = $query->result(); + + $sql = "SELECT * FROM package where pakage_group_id=1"; + $query = $this->db->query($sql); + $data['data'] = $query->result(); + + $this->load->view('IPD_Package/item_search_V', $data); + } + + + public function search_ipd() + { + $sql = "SELECT * FROM ipd_item_type order by group_desc"; + $query = $this->db->query($sql); + $data['labitemtype'] = $query->result(); + + $sql = "SELECT * FROM ipd_items where itype=1"; + $query = $this->db->query($sql); + $data['data'] = $query->result(); + + $this->load->view('IPD_Package/item_search_V', $data); + } + + public function search_print($itype_id = 1) + { + + $sql = "SELECT * FROM v_hc_items where itype=" . $itype_id . " order by group_desc"; + $query = $this->db->query($sql); + $data['data'] = $query->result(); + + $this->load->view('IPD_Package/item_item_list', $data); + } + + function itemtype_record($id) + { + $sql = "SELECT *,(case is_ipd_opd when 0 then 'OPD-IPD' when 1 then 'OPD' when 2 then 'IPD' end) as isIPD_OPD + FROM hc_item_type where itype_id='" . $id . "' order by group_desc"; + $query = $this->db->query($sql); + $data['data_item'] = $query->result(); + + $this->load->view('IPD_Package/item_type_profile', $data); + } + + function item_record($id) + { + + $sql = "select * from package where id=" . $id; + $query = $this->db->query($sql); + $data['data_item'] = $query->result(); + + $sql = "select * from v_insurance_package_list where c_item_id=$id"; + $query = $this->db->query($sql); + $data['data_insurance_item'] = $query->result(); + + $sql = "select * from hc_insurance where id>1"; + $query = $this->db->query($sql); + $data['data_insurance'] = $query->result(); + + $this->load->view('IPD_Package/item_profile_V', $data); + } + + public function UpdateRecord() + { + if (!$this->input->is_ajax_request()) { + exit('no valid req.'); + } + + $this->load->model('Package_M'); + + $data = array( + 'ipd_pakage_name' => $this->input->post('input_Package_name'), + 'Pakage_description' => $this->input->post('input_Pakage_description'), + 'Pakage_Min_Amount' => $this->input->post('input_Pakage_Min_Amount'), + 'update_by' => date('Y-m-d H:i:s') + ); + $old_id = $this->input->post('p_id'); + $update = $this->Package_M->update($data, $old_id); + + if ($update > 0) { + $rvar = array( + 'update' => 1, + 'showcontent' => Show_Alert('success', 'Saved', 'Data Saved successfully') + ); + $encode_data = json_encode($rvar); + echo $encode_data; + } + } + + public function AddRecord() + { + $sql = "select * from package_group"; + $query = $this->db->query($sql); + $data['data_item_type'] = $query->result(); + + $this->load->view('IPD_Package/item_create_V', $data); + } + + + public function AddItemTypeRecord() + { + $this->load->view('IPD_Package/item_type_create'); + } + + public function CreateRecord() + { + if (!$this->input->is_ajax_request()) { + exit('no valid req.'); + } + + $this->load->model('Package_M'); + $data = array( + 'pakage_group_id' => $this->input->post('Item_Type'), + 'ipd_pakage_name' => $this->input->post('input_Item_name'), + 'Pakage_Min_Amount' => $this->input->post('input_amount'), + 'update_date' => date('Y-m-d H:i:s'), + + ); + + $inser_id = $this->Package_M->insert($data); + + if ($inser_id > 0) { + + $rvar = array( + 'insertid' => $inser_id + ); + $encode_data = json_encode($rvar); + echo $encode_data; + } + } + + public function AddInsuranceItemRecord() + { + if (!$this->input->is_ajax_request()) { + exit('no valid req.'); + } + + $this->load->model('Package_M'); + $data = array( + 'hc_items_id' => $this->input->post('p_id'), + 'hc_insurance_id' => $this->input->post('ins_company_name'), + 'i_amount' => $this->input->post('input_amount'), + 'code' => $this->input->post('input_item_code') + ); + + $inser_id = $this->Package_M->insert_in_item($data); + + if ($inser_id > 0) { + $sql = "select * from v_insurance_package_list where c_item_id=" . $this->input->post('p_id'); + $query = $this->db->query($sql); + $data_insurance_item = $query->result(); + + echo ' + + + + + + + + + '; + for ($i = 0; $i < count($data_insurance_item); ++$i) { + echo ' + + + + + '; + } + echo '
Company NameAmountCodeAction
' . $data_insurance_item[$i]->ins_company_name . '' . $data_insurance_item[$i]->i_amount . '' . $data_insurance_item[$i]->code . '
'; + } + } + + public function remove_record_item() + { + if (!$this->input->is_ajax_request()) { + exit('no valid req.'); + } + + $this->load->model('Package_M'); + $data = array( + 'isdelete' => $this->input->post('in_remove_id') + ); + + $inser_id = $this->Package_M->delete_in_item($data, $this->input->post('in_remove_id')); + + if ($inser_id > 0) { + $sql = "select * from v_insurance_item_list where c_item_id=" . $this->input->post('p_id'); + $query = $this->db->query($sql); + $data_insurance_item = $query->result(); + + echo ' + + + + + + + + + '; + for ($i = 0; $i < count($data_insurance_item); ++$i) { + echo ' + + + + + '; + } + echo '
Company NameAmountCodeAction
' . $data_insurance_item[$i]->ins_company_name . '' . $data_insurance_item[$i]->i_amount . '' . $data_insurance_item[$i]->code . '
'; + } + } + + + 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 + } + + + public function CreateItemTypeRecord() + { + if (!$this->input->is_ajax_request()) { + exit('no valid req.'); + } + + $this->load->model('Package_M'); + $data = array( + 'is_ipd_opd' => $this->input->post('Item_Type_ipd'), + 'group_desc' => $this->input->post('input_Item_type') + ); + + $inser_id = $this->Package_M->insert_type($data); + + if ($inser_id > 0) { + + $rvar = array( + 'insertid' => $inser_id + ); + $encode_data = json_encode($rvar); + echo $encode_data; + } + } + + public function UpdateItemTypeRecord() + { + if (!$this->input->is_ajax_request()) { + exit('no valid req.'); + } + + $this->load->model('Package_M'); + + $data = array( + 'is_ipd_opd' => $this->input->post('Item_Type_ipd'), + 'group_desc' => $this->input->post('input_Item_type') + ); + + $old_id = $this->input->post('itemtype_id'); + $update = $this->Package_M->update_type($data, $old_id); + + if ($update > 0) { + $rvar = array( + 'update' => 1, + 'showcontent' => Show_Alert('success', 'Saved', 'Data Saved successfully') + ); + $encode_data = json_encode($rvar); + echo $encode_data; + } + } +} diff --git a/old_code_ci3/controllers/PathLab.php b/old_code_ci3/controllers/PathLab.php new file mode 100644 index 0000000..a60011e --- /dev/null +++ b/old_code_ci3/controllers/PathLab.php @@ -0,0 +1,1354 @@ +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'); + $bank_id=$this->input->post('cbo_pay_type'); + + 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_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', + '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.']', + 'pay_bank_id'=>$this->input->post('cbo_pay_type'), + '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/Online', + '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, + IFNULL(GET_AGE_BY_DOB(dob),age) 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, + IFNULL(GET_AGE_BY_DOB(dob),age) 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 '
+ +
'; + + //echo $sql; + + } + + public function update_refer_doc() + { + $invoice_id=$this->input->post('inv_id'); + $doc_id=$this->input->post('doc_id'); + $inv_date=str_to_MysqlDate($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; + } + + + $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/Online' + 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 case_type=0 and 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 case_type=0 and id=".$data['ipd_master'][0]->case_id; + } + } + + $query = $this->db->query($sql); + $data['case_master']= $query->result(); + + + $sql="select s.id,s.pay_type,m.bank_name + From hospital_bank m join hospital_bank_payment_source s on m.id=s.bank_id"; + $query = $this->db->query($sql); + $data['bank_data']= $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, + 'prepared_by'=>$user_name.'['.$user_id.']', + 'prepared_by_id'=>$user_id, + 'confirm_invoice'=>date('Y-m-d H:i:s'), + ); + + $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; + + $dataupdate = array( + 'is_print_out'=>1, + ); + + $this->load->model('Invoice_M'); + $this->Invoice_M->update($dataupdate,$invoice_id); + + 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; + + // $this->m_pdf->pdf->showImageErrors = false; + + // $this->m_pdf->pdf->curlAllowUnsafeSslRequests = true; + $this->m_pdf->pdf->useSubstitutions = false; + //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, + 'prepared_by'=>$user_name.'['.$user_id.']', + 'prepared_by_id'=>$user_id, + 'confirm_invoice'=>date('Y-m-d H:i:s'), + ); + + $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/Patient.php b/old_code_ci3/controllers/Patient.php new file mode 100644 index 0000000..09da2a8 --- /dev/null +++ b/old_code_ci3/controllers/Patient.php @@ -0,0 +1,850 @@ +load->model('Patient_M'); + } + + public function index() + { + $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); + } + + 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_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"; + $query = $this->db->query($sql); + $search_result = $query->result(); + + $data['search_result'] = $search_result; + + + $this->load->view('search_adv_data', $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 , + 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 { + + $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 , + Date_Format(p.last_visit,'%d-%m-%Y') AS Last_Visit + FROM patient_master p + WHERE $search_string + 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); + } + + + public function search_opd() + { + $sql = "SELECT p.*,GET_AGE_1(dob,age,age_in_month,estimate_dob) AS age , + Date_Format(o.apointment_date,'%d-%m-%Y') AS opd_Visit,o.doc_name,o.doc_spec,o.opd_code,i.short_name + FROM (patient_master p join opd_master o on p.id =o.p_id) + Left join hc_insurance i on i.id = o.insurance_id + 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); + + echo $content; + } + + 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; + $query = $this->db->query($sql); + $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; + } + } + } + + if ($required_dob == '' && $estimate_dob == 0) { + $edit = 1; + } + + + $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, + 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 + 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(); + + $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 , + 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; + $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['tag_master'] = $query->result(); + + $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(); + + 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); + } + } + + public function update_1() + { + 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]' + ) + ); + + $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'), + '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; + } + } + + + public function update() + { + 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'); + + + 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, + array( + 'field' => 'datepicker_dob', + 'label' => 'Date of Birth', + 'rules' => 'required|min_length[1]|max_length[10]' + ) + ); + } + + $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; + } + } + + public function update_aadhar() + { + 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' + ); + $encode_data = json_encode($rvar); + echo $encode_data; + } + + public function create() + { + 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[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'); + + + 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, + array( + 'field' => 'datepicker_dob', + 'label' => 'Date of Birth', + 'rules' => 'required|min_length[1]|max_length[10]' + ) + ); + } + + $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' => $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 + ); + + // 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(); + + $user = $this->ion_auth->user()->row(); + $user_name = $user->first_name . '' . $user->last_name . '[Date:' . date('d-m-Y h:i:s') . ']-' . $user->id; + + $log_text = ''; + + 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; + } + } + + 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 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); + } + + public function city() + { + $this->load->model('Patient_M'); + if (isset($_GET['term'])) { + $q = strtolower($_GET['term']); + $this->Patient_M->get_city($q); + } + } + + 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; + } else { + $Patient_id = 0; + $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.'); + } + + $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]' + ) + ); + + $this->form_validation->set_rules($FormRules); + + 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_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; + } + } + + public function show_profile_opd($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 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(); + + //$this->load->view('Person/person_file_show',$data); + + $this->load->view('Person/Person_Profile', $data); + } + + public function show_profile_image($p_id) + { + $data['p_id'] = $p_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=" . $p_id; + $query = $this->db->query($sql); + $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'); + + 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('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 + ); + + 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); + } + + echo $filename; + } + } + + //Patient Tag + + function add_comments($p_id) + { + 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 + ); + } 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'); + + $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 * + 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, + '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); + } + + echo '1'; + } + + + + //AutoList of Person Names + + public function get_name() + { + + if (isset($_GET['term'])) { + $q = strtolower($_GET['term']); + + $sql = "select * from name_list where name like '" . $q . "%' "; + + $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'])); + + $row_set[] = $new_row; //build an array + } + echo json_encode($row_set); //format the array into json data + } + } + } +} diff --git a/old_code_ci3/controllers/Payment.php b/old_code_ci3/controllers/Payment.php new file mode 100644 index 0000000..8b6f46a --- /dev/null +++ b/old_code_ci3/controllers/Payment.php @@ -0,0 +1,313 @@ +load->model('Patient_M'); + + } + + function index() + { + $this->load->view('Invoice/payment_search'); + } + + function payment_record() + { + $sdata=$this->input->post('txtsearch'); + + $rec_no = preg_replace('/[^A-Za-z0-9 _.@\-]/', '', trim($sdata)); + + $sql="select * from payment_history where id='".$rec_no."'"; + $query = $this->db->query($sql); + $data['payment_history']= $query->result(); + + $sql="select * from users where active=1"; + $query = $this->db->query($sql); + $data['all_user_list']= $query->result_array(); + + + $data['invoice_no']=''; + + if(count($data['payment_history'])>0) + { + $charge_type=$data['payment_history'][0]->payof_type; + $payof_id=$data['payment_history'][0]->payof_id; + + + if($charge_type==1) + { + $sql="select * from opd_master where opd_id=".$payof_id; + $query = $this->db->query($sql); + $data['opd_master']= $query->result(); + + $pid=$data['opd_master'][0]->p_id; + + $data['invoice_no']=$data['opd_master'][0]->opd_code; + + $data['inv_Type']='OPD'; + } + + if($charge_type==2) + { + $sql="select * from invoice_master where id=".$payof_id; + $query = $this->db->query($sql); + $data['invoice_master']= $query->result(); + + $pid=$data['invoice_master'][0]->attach_id; + + $data['invoice_no']=$data['invoice_master'][0]->invoice_code; + + $data['inv_Type']='OPD Charge'; + } + + if($charge_type==3) + { + $sql="select * from org_payment_request where id=".$payof_id; + $query = $this->db->query($sql); + $data['org_payment_request']= $query->result(); + + $pid=$data['org_payment_request'][0]->patient_id; + + $data['invoice_no']=$data['org_payment_request'][0]->org_code; + + $data['inv_Type']='ORG Charge'; + } + + if($charge_type==4) + { + $sql="select * from ipd_master where id=".$payof_id; + $query = $this->db->query($sql); + $data['ipd_master']= $query->result(); + + $pid=$data['ipd_master'][0]->p_id; + + $data['invoice_no']=$data['ipd_master'][0]->ipd_code; + + $data['inv_Type']='IPD Payment'; + } + + $sql="select * from patient_master_exten where id=".$pid; + $query = $this->db->query($sql); + $data['patient_master']= $query->result(); + + $data['rec_no']=$rec_no; + + $sql="select s.id,s.pay_type,m.bank_name + From hospital_bank m join hospital_bank_payment_source s on m.id=s.bank_id"; + $query = $this->db->query($sql); + $data['bank_data']= $query->result(); + + $this->load->view('Invoice/payment_edit',$data); + + }else{ + echo 'No Record Found'; + } + } + + public function change_to_bank() + { + 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.']'; + + $pay_id=$this->input->post('pay_id'); + + $sql="select * from payment_history where id=".$pay_id; + $query = $this->db->query($sql); + $payment_history= $query->result(); + + if(count($payment_history)>0) + { + $payof_id=$payment_history[0]->payof_id; + + $paydata = array( + 'payment_mode'=> '2', + 'pay_bank_id'=>$this->input->post('cbo_pay_type'), + 'card_tran_id'=>$this->input->post('input_card_tran'), + 'update_remark'=>'Change To Bank' + ); + + $paydata_log = array( + 'pay_id'=> $pay_id, + 'update_type'=>'1', + 'update_by'=> $user_name, + ); + + $this->load->model('Payment_M'); + + $insert_id=$this->Payment_M->insert_payment_history_log($paydata_log); + $this->Payment_M->update($paydata,$pay_id); + + if($payment_history[0]->payof_type==1) + { + $dataupdate = array( + 'payment_mode'=> '2', + 'payment_mode_desc'=>'BANK', + ); + + $this->load->model('Opd_M'); + $this->Opd_M->update($dataupdate,$payof_id); + + }elseif($payment_history[0]->payof_type==4) + { + $dataupdate = array( + 'payment_mode'=> '2', + 'payment_mode_desc'=>'BANK', + ); + $this->load->model('Ipd_M'); + //$this->Ipd_M->update_payment_ipd($dataupdate,$payof_id); + } + + } + } + + public function change_to_cash() + { + 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.']'; + + $pay_id=$this->input->post('pay_id'); + + $sql="select * from payment_history where id=".$pay_id; + $query = $this->db->query($sql); + $payment_history= $query->result(); + + if(count($payment_history)>0) + { + $payof_id=$payment_history[0]->payof_id; + + $paydata = array( + 'payment_mode'=> '1', + ); + + $paydata_log = array( + 'pay_id'=> $payof_id, + 'update_type'=>'1', + 'update_by'=> $user_name, + 'update_remark'=>'Change To CASH' + ); + + $this->load->model('Payment_M'); + $insert_id=$this->Payment_M->insert_payment_history_log($paydata_log); + $this->Payment_M->update($paydata,$pay_id); + + if($payment_history[0]->payof_type==1) + { + $dataupdate = array( + 'payment_mode'=> '1', + 'payment_mode_desc'=>'CASH', + ); + + $this->load->model('Opd_M'); + $this->Opd_M->update($dataupdate,$payof_id); + + }elseif($payment_history[0]->payof_type==4) + { + $dataupdate = array( + 'payment_mode'=> '1', + 'payment_mode_desc'=>'CASH', + ); + + $this->load->model('Ipd_M'); + //$this->Ipd_M->update_payment_ipd($dataupdate,$payof_id); + } + + } + + + } + + public function change_user() + { + 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.']'; + + $pay_id=$this->input->post('pay_id'); + $user_list=$this->input->post('user_list'); + + $sql="select * from payment_history where id=".$pay_id; + $query = $this->db->query($sql); + $payment_history= $query->result(); + + $sql="select * from users where id=".$user_list; + $query = $this->db->query($sql); + $user_data= $query->result(); + + + if(count($payment_history)>0) + { + $payof_id=$payment_history[0]->payof_id; + + $paydata = array( + 'update_by'=> $user_data[0]->first_name.' '.$user_data[0]->last_name.'['.$payment_history[0]->insert_time.']['.$user_list.']', + 'update_by_id'=> $user_list, + ); + + $paydata_log = array( + 'pay_id'=> $payof_id, + 'update_type'=>'3', + 'update_by'=> $user_name, + 'update_remark'=>'Change Update User From :'.$payment_history[0]->update_by + ); + + $this->load->model('Payment_M'); + $insert_id=$this->Payment_M->insert_payment_history_log($paydata_log); + $this->Payment_M->update($paydata,$pay_id); + + + } + + } + + public function change_amount() + { + 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.']'; + + $pay_id=$this->input->post('pay_id'); + $change_value=$this->input->post('change_value'); + + $sql="select * from payment_history where id=".$pay_id; + $query = $this->db->query($sql); + $payment_history= $query->result(); + + if(count($payment_history)>0) + { + $payof_id=$payment_history[0]->payof_id; + + $paydata = array( + 'amount'=> $change_value, + ); + + $paydata_log = array( + 'pay_id'=> $payof_id, + 'update_type'=>'4', + 'update_by'=> $user_name, + 'update_remark'=>'Change Amount , OLD Amt.'.$payment_history[0]->amount + ); + + $this->load->model('Payment_M'); + $insert_id=$this->Payment_M->insert_payment_history_log($paydata_log); + $this->Payment_M->update($paydata,$pay_id); + + + } + + } +} + diff --git a/old_code_ci3/controllers/Payment_Medical.php b/old_code_ci3/controllers/Payment_Medical.php new file mode 100644 index 0000000..4926e5e --- /dev/null +++ b/old_code_ci3/controllers/Payment_Medical.php @@ -0,0 +1,291 @@ +load->view('Medical/payment_search'); + } + + function payment_record() + { + $sdata=$this->input->post('txtsearch'); + + $rec_no = preg_replace('/[^A-Za-z0-9 _.@\-]/', '', trim($sdata)); + + $sql="select *,if(credit_debit=0,amount,amount*-1) as Amount_str from payment_history_medical where id=".$rec_no; + $query = $this->db->query($sql); + $data['payment_history']= $query->result(); + + $sql="select * from users where active=1"; + $query = $this->db->query($sql); + $data['all_user_list']= $query->result_array(); + + $data['invoice_no']=''; + + if(count($data['payment_history'])>0) + { + $Customerof_type=$data['payment_history'][0]->Customerof_type; + $Customerof_id=$data['payment_history'][0]->Customerof_id; + $Medical_invoice_id=$data['payment_history'][0]->Medical_invoice_id; + $ipd_id=$data['payment_history'][0]->ipd_id; + + if($Customerof_type==1) //OPD Bill + { + $sql="select * from invoice_med_master where id=".$Medical_invoice_id; + $query = $this->db->query($sql); + $data['invoice_med_master']= $query->result(); + + $data['invoice_to_name']=$data['invoice_med_master'][0]->inv_name; + + $data['invoice_no']=$data['invoice_med_master'][0]->inv_med_code; + + $data['inv_Type']='OPD'; + } + + if($Customerof_type==2) // IPD Bill + { + $sql="select * from ipd_master where id=".$ipd_id; + $query = $this->db->query($sql); + $data['ipd_master']= $query->result(); + + $data['invoice_to_name']=$data['ipd_master'][0]->P_name; + + $data['invoice_no']=$data['ipd_master'][0]->ipd_code; + + $data['inv_Type']='IPD Medical Bill'; + } + + if($Customerof_type==3) //CASH BILL + { + $sql="select * from invoice_med_master where id=".$Medical_invoice_id; + $query = $this->db->query($sql); + $data['invoice_med_master']= $query->result(); + + $data['invoice_to_name']=$data['invoice_med_master'][0]->inv_name; + + $data['invoice_no']=$data['invoice_med_master'][0]->inv_med_code; + + $data['inv_Type']='CASH'; + } + + $data['rec_no']=$rec_no; + + $this->load->view('Medical/payment_edit',$data); + + }else{ + echo 'No Record Found'; + } + } + + public function change_to_bank() + { + 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.']'; + + $pay_id=$this->input->post('pay_id'); + + $sql="select * from payment_history_medical where id=".$pay_id; + $query = $this->db->query($sql); + $payment_history= $query->result(); + + if(count($payment_history)>0) + { + + + $paydata = array( + 'amount'=>$payment_history[0]->amount, + 'payment_mode'=> '2', + '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'), + ); + + $paydata_log = array( + 'pay_id'=> $pay_id, + 'update_type'=>'2', + 'update_by'=> $user_name, + ); + + $this->load->model('Medical_M'); + + $insert_id=$this->Medical_M->insert_payment_history_log($paydata_log); + $this->Medical_M->update_payment($paydata,$pay_id); + + } + } + + public function change_to_cash() + { + 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.']'; + + $pay_id=$this->input->post('pay_id'); + + $sql="select * from payment_history_medical where id=".$pay_id; + $query = $this->db->query($sql); + $payment_history= $query->result(); + + if(count($payment_history)>0) + { + + + $paydata = array( + 'payment_mode'=> '1', + 'amount'=>$payment_history[0]->amount, + ); + + $paydata_log = array( + 'pay_id'=> $pay_id, + 'update_type'=>'1', + 'update_by'=> $user_name, + ); + + $this->load->model('Medical_M'); + + $insert_id=$this->Medical_M->insert_payment_history_log($paydata_log); + $this->Medical_M->update_payment($paydata,$pay_id); + + } + + } + + public function update_amount() + { + 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.']'; + + $pay_id=$this->input->post('pay_id'); + $change_value=$this->input->post('change_value'); + + $sql="select * from payment_history_medical where id=".$pay_id; + $query = $this->db->query($sql); + $payment_history= $query->result(); + + if(count($payment_history)>0) + { + $paydata = array( + 'amount'=> $change_value, + ); + + $old_amt=$payment_history[0]->amount; + + $paydata_log = array( + 'pay_id'=> $pay_id, + 'update_type'=>'3', + 'update_by'=> $user_name, + 'update_log'=>'Old Amt. : '.$old_amt, + ); + + $this->load->model('Medical_M'); + + $insert_id=$this->Medical_M->insert_payment_history_log($paydata_log); + $this->Medical_M->update_payment($paydata,$pay_id); + + $customer_type=$payment_history[0]->Customerof_type; + $inv_id=$payment_history[0]->Medical_invoice_id; + $ipd_id=$payment_history[0]->Medical_invoice_id; + + if($customer_type==2){ + $this->Medical_M->update_invoice_group_gst($ipd_id,1); + }else{ + + $this->Medical_M->update_invoice_group($inv_id); + $this->Medical_M->update_invoice_final($inv_id); + } + + } + } + + public function change_user() + { + 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.']'; + + $pay_id=$this->input->post('pay_id'); + $user_list=$this->input->post('user_list'); + + $sql="select * from payment_history_medical where id=".$pay_id; + $query = $this->db->query($sql); + $payment_history= $query->result(); + + $sql="select * from users where id=".$user_list; + $query = $this->db->query($sql); + $user_data= $query->result(); + + + if(count($payment_history)>0) + { + $amount = $payment_history[0]->amount; + + $paydata = array( + 'update_by'=> $user_data[0]->first_name.' '.$user_data[0]->last_name.'['.$payment_history[0]->insert_time.']['.$user_list.']', + 'update_by_id'=> $user_list, + 'amount'=> $amount, + ); + + $paydata_log = array( + 'pay_id'=> $pay_id, + 'update_type'=>'3', + 'update_by'=> $user_name, + 'update_remark'=>'Change Update User From :'.$payment_history[0]->update_by + ); + + $this->load->model('Medical_M'); + $insert_id=$this->Medical_M->insert_payment_history_log($paydata_log); + $this->Medical_M->update_payment($paydata,$pay_id); + + + } + + } + + 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/PhoneHMS.php b/old_code_ci3/controllers/PhoneHMS.php new file mode 100644 index 0000000..1ecabfa --- /dev/null +++ b/old_code_ci3/controllers/PhoneHMS.php @@ -0,0 +1,265 @@ +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'); + + $this->load->model('SMS_M'); + } + + public function Login() + { + $login_id=$this->input->post('login'); + $mobilecode=$this->input->post('mcode'); + + if ($this->ion_auth->login($login_id, $mobilecode, true)) + { + $rvar=array( + 'loginID' => 1, + 'msg' => 'Wrong User Id or Password' + ); + } + else + { + $rvar=array( + 'loginID' => 0, + 'msg' => 'Wrong User Id or Password' + ); + } + + $encode_data = json_encode($rvar); + echo header("Access-Control-Allow-Origin: *"); + echo $encode_data; + } + + public function PhoneGapProcess($reqcode=0) + { + if($reqcode==0) + { + if ($this->ion_auth->logged_in()) + { + $user = $this->ion_auth->user()->row(); + $user_id = $user->id; + $user_name = $user->first_name.''. $user->last_name; + + $rvar=array( + 'loginName' => $user_name, + 'user_id' => $user_id + ); + }else{ + $rvar=array( + 'loginName' => '', + 'user_id' => 0 + ); + } + + $encode_data = json_encode($rvar); + echo header("Access-Control-Allow-Origin: *"); + echo $encode_data; + } + + // Search OPD in Database + + if($reqcode==1) + { + $sdata=$this->input->post('txtsearch'); + + $sdata = preg_replace('/[^A-Za-z0-9_ \-]/', '', $sdata); + + $sql = "select o.opd_id, o.doc_name,o.opd_code,o.P_name,o.p_id,Date_Format(o.apointment_date,'%d-%m-%Y') as App_Date, + p.p_code,p.mphone1,p.email1 ,if(o.insurance_id>1,'Org.','Direct') as Inv_Type, + m.mode_desc as PaymentMode,o.payment_mode + from (opd_master o join patient_master p on o.p_id=p.id ) join payment_mode m on o.payment_mode=m.id + WHERE (opd_code like '%".$sdata."' or p_code like '%".$sdata."' or P_name like '%".$sdata."%' or + mphone1 = '".$sdata."' or email1 = '".$sdata."') and o.apointment_date>Date_Add(curdate(),interval -7 day) order by o.opd_id desc limit 10"; + + + $query = $this->db->query($sql); + $opd_list= $query->result_array(); + + $columns = array( + 0 =>'opd_id', + 1 => 'doc_name', + 2 => 'opd_code', + 3 => 'P_name', + 4=> 'App_Date', + 5=> 'p_code', + 6=> 'mphone1', + 7=> 'Inv_Type' + ); + + $output = array( + "recordsTotal" => intval( count($opd_list) ), // total number of records + "recdata" =>$opd_list, + "url" => substr($_SERVER['PHP_SELF'],0,19) + ); + + $encode_data = json_encode($output); + echo header("Access-Control-Allow-Origin: *"); + echo $encode_data; + + } + + } + + public function SelectOPD($opdid) + { + $sql = "select o.opd_id, o.doc_name,o.opd_code,o.P_name,o.p_id,Date_Format(o.apointment_date,'%d-%m-%Y') as App_Date, + p.p_code,p.mphone1,p.email1 ,if(o.insurance_id>1,'Org.','Direct') as Inv_Type, + m.mode_desc as PaymentMode,o.payment_mode + from (opd_master o join patient_master p on o.p_id=p.id ) join payment_mode m on o.payment_mode=m.id + WHERE o.opd_id=".$opdid; + + $query = $this->db->query($sql); + $opd_data= $query->result_array(); + + $output = array( + "recordsTotal" => intval( count($opd_data) ), // total number of records + "recdata" =>$opd_data + ); + + $encode_data = json_encode($output); + echo header("Access-Control-Allow-Origin: *"); + echo $encode_data; + } + + public function save_image_opd($opdid) + { + $filename = 'OPD-'.$opdid.'-'.time() . '.jpg'; + + $folder_name='uploads/'.date('Ymd'); + + if (!file_exists($folder_name)) { + mkdir($folder_name, 0777, true); + } + + //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('file')) { + $error = array('error' => $this->upload->display_errors()); + echo $error['error']; + }else{ + $data = array('upload_data' => $this->upload->data()); + + $this->load->model('File_M'); + + $file_insert_id=$this->File_M->insert($data['upload_data']); + + $sql="select * from opd_master where opd_id=".$opdid; + $query = $this->db->query($sql); + $opd_master= $query->result(); + + $pid=0; + $ipd_id=0; + $org_id=0; + + if(count($opd_master)>0) + { + $pid=$opd_master[0]->p_id; + $ipd_id=$opd_master[0]->ipd_id; + $org_id=$opd_master[0]->insurance_case_id; + } + + $udata = array( + 'upload_by'=> 'PhoneGap', + 'pid'=>$pid, + 'opd_id'=>$opdid, + 'ipd_id'=>$ipd_id, + 'case_id'=>$org_id, + 'upload_by_id'=>'0' + ); + + 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'); + $user_name ='PhoneGap'; + + $opdstatus=2; + + if($opdstatus=='2') + { + $status_str='Visit Done'; + }elseif($opdstatus=='3') + { + $status_str='Visit Cancel'; + } + + $opd_status_remark=$status_str.' Update By:'.$user_name; + + $dataupdate = array( + 'opd_status' => $opdstatus, + 'opd_status_remark' => $opd_status_remark + ); + + $this->load->model('Opd_M'); + $this->Opd_M->update($dataupdate,$opdid); + } + + $rvar=array( + 'filename' => $filename, + 'upload' => 1 + ); + + $encode_data = json_encode($rvar); + echo header("Access-Control-Allow-Origin: *"); + echo $encode_data; + + } + } + + public function save_sms() + { + echo 'Hello'; + + $data = array( + 'sender' => $this->input->post('sender'), + 'inNumber' => $this->input->post('inNumber'), + 'content' => $this->input->post('content'), + 'keyword' => $this->input->post('keyword'), + 'comments' => trim(str_replace('JC','',$this->input->post('comments'))), + 'msgId' => $this->input->post('msgId'), + 'rcvd' => $this->input->post('rcvd'), + ); + + $insert_id=$this->SMS_M->insert_sms_inbox($data); + + + if(strlen($comments)>0) + { + $data_array=explode(" ",$comments); + + $cmd_ID=''; + + if(isset($data_array[0])) + { + $cmd_ID=$data_array[0]; + } + + } + + + } + + + +} +?> \ No newline at end of file diff --git a/old_code_ci3/controllers/PhoneSMS.php b/old_code_ci3/controllers/PhoneSMS.php new file mode 100644 index 0000000..5d1e072 --- /dev/null +++ b/old_code_ci3/controllers/PhoneSMS.php @@ -0,0 +1,28 @@ +load->model('SMS_M'); + } + + public function show_lab_report($file_id_encrpt) + { + $file_id=decode_dst($file_id_encrpt); + + $sql="select * from file_upload_data where id=".$file_id; + $query = $this->db->query($sql); + $data['lab_file_details']= $query->result(); + + $this->load->view('PhoneSMS/lab_report_show',$data); + } + + + + + +} +?> \ No newline at end of file diff --git a/old_code_ci3/controllers/Product_master.php b/old_code_ci3/controllers/Product_master.php new file mode 100644 index 0000000..4f0614a --- /dev/null +++ b/old_code_ci3/controllers/Product_master.php @@ -0,0 +1,632 @@ +load->view('Medical/Purchase/drug_master_list'); + } + + public function Product_search() + { + $sdata=$this->input->post('txtsearch'); + + $sdata = preg_replace('/[^A-Za-z0-9_ \-]/', '', $sdata); + + if(trim($sdata)=='') + { + $sql="select * from med_product_master order by id desc limit 100"; + }else{ + $sql="select * from med_product_master + where (item_name LIKE '%".$sdata."%' + OR genericname LIKE '%".$sdata."%' + OR id = '".$sdata."')"; + } + + $query = $this->db->query($sql); + $data['product_list']= $query->result(); + + $this->load->view('Medical/Purchase/product_search_result',$data); + } + + public function Product_edit($Product_id) + { + $sql="SELECT m.* ,group_concat(c.med_cat_id) as cat_list + from med_product_master m left join med_product_cat_assign c on m.id=c.med_product_id + where m.id=".$Product_id; + $query = $this->db->query($sql); + $data['product_data']= $query->result(); + + $sql="Select * from med_formulation order by formulation_length"; + $query = $this->db->query($sql); + $data['med_formulation']= $query->result(); + + $sql="Select * from med_company order by company_name"; + $query = $this->db->query($sql); + $data['med_company']= $query->result(); + + $sql="Select * from med_product_cat_master order by med_cat_desc"; + $query = $this->db->query($sql); + $data['med_product_cat_master']= $query->result(); + + + $this->load->view('Medical/Purchase/product_edit',$data); + } + + public function Product_delete($Product_id) + { + $sql="Select count(*) as no_rec from inv_med_item where item_code=".$Product_id; + $query = $this->db->query($sql); + $product_sale_data= $query->result(); + + $sql="Select count(*) as no_rec from purchase_invoice_item where item_code=".$Product_id; + $query = $this->db->query($sql); + $product_purchase_data= $query->result(); + + $is_delete_master=0; + + $data_show=""; + + if($product_sale_data[0]->no_rec>0 || $product_purchase_data[0]->no_rec>0) + { + if($product_sale_data[0]->no_rec>0){ + $data_show.="

This Product in Sale Invoice, So cann't Delete

"; + } + + if($product_purchase_data[0]->no_rec>0){ + $data_show.="

This Product in Purchase Invoice, So cann't Delete

"; + } + + }else{ + + $this->load->model('product_master_M'); + $is_delete_master=$this->product_master_M->delete_master($Product_id); + + if($is_delete_master==0) + { + $data_show.="

Some Error on Delete this product

"; + }else{ + $data_show.="

Deleted

"; + } + + } + + echo $data_show; + + + } + + public function NewProduct() + { + $sql="Select * from med_company order by company_name"; + $query = $this->db->query($sql); + $data['med_company']= $query->result(); + + $sql="Select * from med_formulation order by formulation_length"; + $query = $this->db->query($sql); + $data['med_formulation']= $query->result(); + + $sql="Select * from med_product_cat_master order by med_cat_desc"; + $query = $this->db->query($sql); + $data['med_product_cat_master']= $query->result(); + + + $this->load->view('Medical/Purchase/product_new',$data); + } + + public function get_drug_master(){ + if (isset($_GET['term'])){ + $q = strtolower($_GET['term']); + + $sql="select * from drug_temp + where itemname 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['itemname'])).' | '.htmlentities(stripslashes($row['formulation_length'])).' | '.htmlentities(stripslashes($row['genericname'])); + $new_row['value']=htmlentities(stripslashes($row['itemname'])).' | '.htmlentities(stripslashes($row['formulation_length'])).' | '.htmlentities(stripslashes($row['genericname'])); + + $new_row['l_itemname']=htmlentities(stripslashes($row['itemname'])); + + $new_row['l_genericname']=htmlentities(stripslashes($row['genericname'])); + + $new_row['l_formulation']=htmlentities(stripslashes($row['formulation'])); + + $new_row['l_company_name']=htmlentities(stripslashes($row['company_name'])); + + $row_set[] = $new_row; //build an array + } + echo json_encode($row_set); //format the array into json data + } + }else{ + echo 'No Data'; + } + } + + public function get_formulation_desc(){ + + if (isset($_GET['term'])){ + $q = strtolower($_GET['term']); + + $sql="select * from med_formulation where formulation 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_length'])); + $new_row['value']=htmlentities(stripslashes($row['formulation'])); + $row_set[] = $new_row; //build an array + } + echo json_encode($row_set); //format the array into json data + } + } + } + + public function get_genericname(){ + + if (isset($_GET['term'])){ + $q = strtolower($_GET['term']); + + $where=""; + + if(strlen($q)>3) + { + $where=" or gen_desc like '%".$q."%'"; + } + + $sql="select * from med_genric_name + where gen_desc like '".$q."%'".$where; + $query = $this->db->query($sql); + + if($query->num_rows() > 0){ + foreach ($query->result_array() as $row){ + $new_row['label']=htmlentities(stripslashes($row['gen_desc'])); + $new_row['value']=htmlentities(stripslashes($row['gen_desc'])); + $row_set[] = $new_row; //build an array + } + echo json_encode($row_set); //format the array into json data + } + } + } + + public function get_company_name(){ + + if (isset($_GET['term'])){ + $q = strtolower($_GET['term']); + + $sql="select * from med_company where company_name like '".$q."%'"; + $query = $this->db->query($sql); + + if($query->num_rows() > 0){ + foreach ($query->result_array() as $row){ + $new_row['label']=htmlentities(stripslashes($row['company_name'])); + $new_row['value']=htmlentities(stripslashes($row['company_name'])); + $row_set[] = $new_row; //build an array + } + echo json_encode($row_set); //format the array into json data + } + } + } + + public function product_master_update($product_id=0) + { + if (!$this->input->is_ajax_request()) { exit('no valid req.'); } + + $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'); + + $is_unique = ''; + + if($product_id>0) + { + + $original_value = $this->db->query("SELECT item_name FROM med_product_master WHERE id = ".$product_id)->row()->item_name ; + + if(strtoupper($this->input->post('input_item_name')) != strtoupper($original_value)) { + $is_unique = '|is_unique[med_product_master.item_name]'; + } else { + $is_unique = ''; + } + } + + + + $FormRules = array( + array( + 'field' => 'input_item_name', + 'label' => 'Product Name', + 'rules' => 'required|min_length[3]|max_length[100]'.$is_unique + ), + array( + 'field' => 'input_formulation', + 'label' => 'Formulation', + 'rules' => 'required|min_length[1]|max_length[10]' + ), + array( + 'field' => 'input_packing_type', + 'label' => 'Packing', + 'rules' => 'required|min_length[1]|max_length[10]' + ), + array( + 'field' => 'input_re_order_qty', + 'label' => 'Re-Order Qty', + '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_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) + { + $related_drug_id=$this->input->post('related_drug_id'); + + $ban_flag_id = ($this->input->post('chk_ban_flag_id')=='on'?1:0); + + $narcotic = ($this->input->post('chk_narcotic')=='on'?1:0); + $schedule_h = ($this->input->post('chk_schedule_h')=='on'?1:0); + $schedule_h1 = ($this->input->post('chk_schedule_h1')=='on'?1:0); + $schedule_x = ($this->input->post('chk_schedule_x')=='on'?1:0); + $schedule_g = ($this->input->post('chk_schedule_g')=='on'?1:0); + $high_risk = ($this->input->post('chk_high_risk')=='on'?1:0); + + + $batch_applicable = ($this->input->post('chk_batch_applicable')=='on'?1:0); + $is_continue = ($this->input->post('chk_is_continue')=='on'?1:0); + $exp_date_applicable = ($this->input->post('chk_exp_date_applicable')=='on'?1:0); + + $this->load->model('product_master_M'); + + $Pdata = array( + 'related_drug_id' => $related_drug_id, + 'item_name' => $this->input->post('input_item_name'), + 'formulation' => $this->input->post('input_formulation'), + 'genericname' => $this->input->post('input_genericname'), + 'packing' => $this->input->post('input_packing_type'), + 're_order_qty' => $this->input->post('input_re_order_qty'), + 'CGST_per' => $this->input->post('input_CGST'), + 'SGST_per' => $this->input->post('input_SGST'), + 'HSNCODE' => $this->input->post('input_HSNCODE'), + + 'ban_flag_id' => $ban_flag_id, + 'batch_applicable' => $batch_applicable, + 'is_continue' => $is_continue, + 'exp_date_applicable' => $exp_date_applicable, + + 'rack_no' => $this->input->post('input_rack_no'), + 'shelf_no' => $this->input->post('input_shelf_no'), + 'cold_storage' => $this->input->post('input_cold_storage'), + + 'company_id' => $this->input->post('input_company_name'), + + 'schedule_h' => $schedule_h, + 'schedule_h1' => $schedule_h1, + 'narcotic' => $narcotic, + 'schedule_x' => $schedule_x, + 'schedule_g' => $schedule_g, + 'high_risk' => $high_risk, + ); + + $show_text=''; + + $is_update_stock=0; + + if($product_id<1) + { + $Pdata['insert_by'] = $user_name_info; + $is_update_stock=$this->product_master_M->insert($Pdata); + $product_id_update=$is_update_stock; + }else{ + $Pdata['update_by'] = $user_name_info; + $is_update_stock=$this->product_master_M->update($Pdata,$product_id); + $product_id_update=$product_id; + } + + $cat_id_list=$this->input->post('med_cat_id'); + + if($cat_id_list<>''){ + $cat_id_list_string = implode(',', $cat_id_list); + }else{ + $cat_id_list_string ="0"; + } + + $cat_assingn=$this->product_master_M->insert_update_product_cat_assign($cat_id_list_string,$product_id_update); + + 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, + '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 company_master_list() + { + $sql="Select * from med_company order by company_name"; + $query = $this->db->query($sql); + $data['med_company']= $query->result(); + + $this->load->view('Medical/Purchase/company_list',$data); + } + + public function CompanyListSub() + { + $sql="Select * from med_company order by company_name"; + $query = $this->db->query($sql); + $data['med_company']= $query->result(); + + $this->load->view('Medical/Purchase/company_list_sub',$data); + + } + + public function CompanyEdit($cid=0) + { + $sql="select * from med_company where id=".$cid; + $query = $this->db->query($sql); + $data['med_company']= $query->result(); + + + + $this->load->view('Medical/Purchase/company_edit',$data); + } + + public function CompanyUpdate() + { + if (!$this->input->is_ajax_request()) { exit('no valid req.'); } + + $FormRules = array( + array( + 'field' => 'input_company_name', + 'label' => 'Company Name', + 'rules' => 'required|min_length[3]|max_length[30]' + ), + ); + + $this->form_validation->set_rules($FormRules); + + if ($this->form_validation->run() == TRUE) + { + $cid=$this->input->post('hid_cid'); + $company_name=$this->input->post('input_company_name'); + $contact_person_name=$this->input->post('input_contact_person_name'); + $contact_phone_no=$this->input->post('input_contact_phone_no'); + + $Udata = array( + 'company_name'=> $company_name, + 'contact_person_name'=> $contact_person_name, + 'contact_phone_no'=> $contact_phone_no, + ); + + $this->load->model('Medical_M'); + + if($cid>0) + { + $this->Medical_M->update_company($Udata,$cid); + $inser_id=$cid; + $send_msg="Saved Successfully"; + }else{ + $inser_id=$this->Medical_M->insert_company($Udata); + $send_msg="Added Successfully"; + } + + if($inser_id>0) + { + $show_text=$send_msg; + }else{ + $show_text=$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'=>$send_msg + ); + $encode_data = json_encode($rvar); + echo $encode_data; + } + + } + + public function medicine_category() + { + $sql="Select * from med_product_cat_master order by med_cat_desc"; + $query = $this->db->query($sql); + $data['med_product_cat_master']= $query->result(); + + $this->load->view('Medical/Purchase/med_product_cat_list',$data); + } + + public function medicine_category_edit($cid=0) + { + $sql="select * from med_product_cat_master where id=".$cid; + $query = $this->db->query($sql); + $data['med_product_cat_master']= $query->result(); + + $this->load->view('Medical/Purchase/medicine_category_edit',$data); + } + + public function medicine_category_Sub() + { + $sql="Select * from med_product_cat_master order by med_cat_desc"; + $query = $this->db->query($sql); + $data['med_product_cat_master']= $query->result(); + + $this->load->view('Medical/Purchase/medicine_category_Sub',$data); + + } + + public function medicine_category_Update() + { + if (!$this->input->is_ajax_request()) { exit('no valid req.'); } + + $FormRules = array( + array( + 'field' => 'input_med_cat_desc', + 'label' => 'Medicince Category Name', + 'rules' => 'required|min_length[3]|max_length[100]' + ), + ); + + $this->form_validation->set_rules($FormRules); + + if ($this->form_validation->run() == TRUE) + { + $cid=$this->input->post('hid_cid'); + $med_cat_desc=$this->input->post('input_med_cat_desc'); + + $Udata = array( + 'med_cat_desc'=> $med_cat_desc, + ); + + $this->load->model('Medical_M'); + + if($cid>0) + { + $this->Medical_M->update_med_product_cat_master($Udata,$cid); + $inser_id=$cid; + $send_msg="Saved Successfully"; + }else{ + $inser_id=$this->Medical_M->insert_med_product_cat_master($Udata); + $send_msg="Added Successfully"; + } + + if($inser_id>0) + { + $show_text=$send_msg; + }else{ + $show_text=$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'=>$send_msg + ); + $encode_data = json_encode($rvar); + echo $encode_data; + } + + } + + + + public function get_product_master(){ + if (isset($_GET['term'])){ + $q = strtolower($_GET['term']); + + $sql="select * from med_product_master + where item_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['item_name'])).' | '.htmlentities(stripslashes($row['formulation'])).' | '.htmlentities(stripslashes($row['genericname'])); + $new_row['value']=htmlentities(stripslashes($row['item_name'])).' | '.htmlentities(stripslashes($row['formulation'])); + //$new_row['value']=htmlentities(stripslashes($row['itemname'])); + + $new_row['l_item_code']=htmlentities(stripslashes($row['id'])); + + $new_row['l_itemname']=htmlentities(stripslashes($row['item_name'])); + + $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_genericname']=htmlentities(stripslashes($row['genericname'])); + + $new_row['l_formulation']=htmlentities(stripslashes($row['formulation'])); + + $row_set[] = $new_row; //build an array + } + echo json_encode($row_set); //format the array into json data + } + }else{ + echo 'No Data'; + } + } + + + + +} \ No newline at end of file diff --git a/old_code_ci3/controllers/Product_stock_master.php b/old_code_ci3/controllers/Product_stock_master.php new file mode 100644 index 0000000..74e41a3 --- /dev/null +++ b/old_code_ci3/controllers/Product_stock_master.php @@ -0,0 +1,483 @@ +load->view('Medical/Storestock/drug_master_list'); + } + + public function Product_search() + { + $sdata=$this->input->post('txtsearch'); + + $sdata = preg_replace('/[^A-Za-z0-9_ \-]/', '', $sdata); + + if(trim($sdata)=='') + { + $sql="select * from med_store_product_master order by id desc limit 100"; + }else{ + $sql="select * from med_store_product_master + where (item_name LIKE '%".$sdata."%' + OR genericname LIKE '%".$sdata."%' + OR id = '".$sdata."')"; + } + + $query = $this->db->query($sql); + $data['product_list']= $query->result(); + + $this->load->view('Medical/Storestock/product_search_result',$data); + } + + public function Product_edit($Product_id) + { + $sql="Select * from med_store_product_master where id=".$Product_id; + $query = $this->db->query($sql); + $data['product_data']= $query->result(); + + $this->load->view('Medical/Storestock/product_edit',$data); + } + + public function Product_delete($Product_id) + { + $sql="Select count(*) as no_rec from inv_stock_item where item_code=".$Product_id; + $query = $this->db->query($sql); + $product_sale_data= $query->result(); + + $sql="Select count(*) as no_rec from purchase_invoice_item_stock where item_code=".$Product_id; + $query = $this->db->query($sql); + $product_purchase_data= $query->result(); + + $is_delete_master=0; + + $data_show=""; + + if($product_sale_data[0]->no_rec>0 || $product_purchase_data[0]->no_rec>0) + { + if($product_sale_data[0]->no_rec>0){ + $data_show.="

This Product in Sale Invoice, So cann't Delete

"; + } + + if($product_purchase_data[0]->no_rec>0){ + $data_show.="

This Product in Purchase Invoice, So cann't Delete

"; + } + + }else{ + + $this->load->model('Product_stock_master_M'); + $is_delete_master=$this->Product_stock_master_M->delete_master($Product_id); + + if($is_delete_master==0) + { + $data_show.="

Some Error on Delete this product

"; + }else{ + $data_show.="

Deleted

"; + } + + } + + echo $data_show; + + + } + + public function NewProduct() + { + $sql="Select * from med_company order by company_name"; + $query = $this->db->query($sql); + $data['med_company']= $query->result(); + + $sql="Select * from med_formulation order by formulation_length"; + $query = $this->db->query($sql); + $data['med_formulation']= $query->result(); + + $this->load->view('Medical/Storestock/product_new',$data); + } + + public function get_drug_master(){ + if (isset($_GET['term'])){ + $q = strtolower($_GET['term']); + + $sql="select * from drug_temp + where itemname 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['itemname'])).' | '.htmlentities(stripslashes($row['formulation_length'])).' | '.htmlentities(stripslashes($row['genericname'])); + $new_row['value']=htmlentities(stripslashes($row['itemname'])).' | '.htmlentities(stripslashes($row['formulation_length'])).' | '.htmlentities(stripslashes($row['genericname'])); + + $new_row['l_itemname']=htmlentities(stripslashes($row['itemname'])); + + $new_row['l_genericname']=htmlentities(stripslashes($row['genericname'])); + + $new_row['l_formulation']=htmlentities(stripslashes($row['formulation'])); + + $new_row['l_company_name']=htmlentities(stripslashes($row['company_name'])); + + $row_set[] = $new_row; //build an array + } + echo json_encode($row_set); //format the array into json data + } + }else{ + echo 'No Data'; + } + } + + public function get_formulation_desc(){ + + if (isset($_GET['term'])){ + $q = strtolower($_GET['term']); + + $sql="select * from med_formulation where formulation 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_length'])); + $new_row['value']=htmlentities(stripslashes($row['formulation'])); + $row_set[] = $new_row; //build an array + } + echo json_encode($row_set); //format the array into json data + } + } + } + + public function get_genericname(){ + + if (isset($_GET['term'])){ + $q = strtolower($_GET['term']); + + $where=""; + + if(strlen($q)>3) + { + $where=" or gen_desc like '%".$q."%'"; + } + + $sql="select * from med_genric_name + where gen_desc like '".$q."%'".$where; + $query = $this->db->query($sql); + + if($query->num_rows() > 0){ + foreach ($query->result_array() as $row){ + $new_row['label']=htmlentities(stripslashes($row['gen_desc'])); + $new_row['value']=htmlentities(stripslashes($row['gen_desc'])); + $row_set[] = $new_row; //build an array + } + echo json_encode($row_set); //format the array into json data + } + } + } + + public function get_company_name(){ + + if (isset($_GET['term'])){ + $q = strtolower($_GET['term']); + + $sql="select * from med_company where company_name like '".$q."%'"; + $query = $this->db->query($sql); + + if($query->num_rows() > 0){ + foreach ($query->result_array() as $row){ + $new_row['label']=htmlentities(stripslashes($row['company_name'])); + $new_row['value']=htmlentities(stripslashes($row['company_name'])); + $row_set[] = $new_row; //build an array + } + echo json_encode($row_set); //format the array into json data + } + } + } + + public function product_master_update($product_id=0) + { + if (!$this->input->is_ajax_request()) { exit('no valid req.'); } + + $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'); + + $is_unique = ''; + + if($product_id>0) + { + + $original_value = $this->db->query("SELECT item_name FROM med_store_product_master WHERE id = ".$product_id)->row()->item_name ; + + if(strtoupper($this->input->post('input_item_name')) != strtoupper($original_value)) { + $is_unique = '|is_unique[med_product_master.item_name]'; + } else { + $is_unique = ''; + } + } + + + $FormRules = array( + array( + 'field' => 'input_item_name', + 'label' => 'Product Name', + 'rules' => 'required|min_length[3]|max_length[100]'.$is_unique + ), + array( + 'field' => 'input_packing_type', + 'label' => 'Packing', + 'rules' => 'required|min_length[1]|max_length[10]' + ), + array( + 'field' => 'input_re_order_qty', + 'label' => 'Re-Order Qty', + 'rules' => 'required|min_length[1]|max_length[10]' + ) + ); + + $this->form_validation->set_rules($FormRules); + + if ($this->form_validation->run() == TRUE) + { + $related_drug_id=$this->input->post('related_drug_id'); + + $ban_flag_id = ($this->input->post('chk_ban_flag_id')=='on'?1:0); + + $narcotic = ($this->input->post('chk_narcotic')=='on'?1:0); + $schedule_h = ($this->input->post('chk_schedule_h')=='on'?1:0); + $schedule_h1 = ($this->input->post('chk_schedule_h1')=='on'?1:0); + $schedule_x = ($this->input->post('chk_schedule_x')=='on'?1:0); + $schedule_g = ($this->input->post('chk_schedule_g')=='on'?1:0); + $high_risk = ($this->input->post('chk_high_risk')=='on'?1:0); + + + $batch_applicable = ($this->input->post('chk_batch_applicable')=='on'?1:0); + $is_continue = ($this->input->post('chk_is_continue')=='on'?1:0); + $exp_date_applicable = ($this->input->post('chk_exp_date_applicable')=='on'?1:0); + + $this->load->model('Product_stock_master_M'); + + $Pdata = array( + 'related_drug_id' => $related_drug_id, + 'item_name' => $this->input->post('input_item_name'), + 'formulation' => $this->input->post('input_formulation'), + 'genericname' => $this->input->post('input_genericname'), + 'packing' => $this->input->post('input_packing_type'), + 're_order_qty' => $this->input->post('input_re_order_qty'), + 'CGST_per' => $this->input->post('input_CGST'), + 'SGST_per' => $this->input->post('input_SGST'), + 'HSNCODE' => $this->input->post('input_HSNCODE'), + + 'ban_flag_id' => $ban_flag_id, + 'batch_applicable' => $batch_applicable, + 'is_continue' => $is_continue, + 'exp_date_applicable' => $exp_date_applicable, + + 'rack_no' => $this->input->post('input_rack_no'), + 'shelf_no' => $this->input->post('input_shelf_no'), + 'cold_storage' => $this->input->post('input_cold_storage'), + + 'company_name' => $this->input->post('input_company_name'), + + 'schedule_h' => $schedule_h, + 'schedule_h1' => $schedule_h1, + 'narcotic' => $narcotic, + 'schedule_x' => $schedule_x, + 'schedule_g' => $schedule_g, + 'high_risk' => $high_risk, + ); + + $show_text=''; + + $is_update_stock=0; + + if($product_id<1) + { + $Pdata['insert_by'] = $user_name_info; + $is_update_stock=$this->Product_stock_master_M->insert($Pdata); + }else{ + $Pdata['update_by'] = $user_name_info; + $is_update_stock=$this->Product_stock_master_M->update($Pdata,$product_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, + '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 company_master_list() + { + $sql="Select * from med_company order by company_name"; + $query = $this->db->query($sql); + $data['med_company']= $query->result(); + + $this->load->view('Medical/Purchase/company_list',$data); + } + + public function CompanyListSub() + { + $sql="Select * from med_company order by company_name"; + $query = $this->db->query($sql); + $data['med_company']= $query->result(); + + $this->load->view('Medical/Purchase/company_list_sub',$data); + + } + + public function CompanyEdit($cid=0) + { + $sql="select * from med_company where id=".$cid; + $query = $this->db->query($sql); + $data['med_company']= $query->result(); + + + + $this->load->view('Medical/Purchase/company_edit',$data); + } + + public function CompanyUpdate() + { + if (!$this->input->is_ajax_request()) { exit('no valid req.'); } + + $FormRules = array( + array( + 'field' => 'input_company_name', + 'label' => 'Company Name', + 'rules' => 'required|min_length[3]|max_length[30]' + ), + ); + + $this->form_validation->set_rules($FormRules); + + if ($this->form_validation->run() == TRUE) + { + $cid=$this->input->post('hid_cid'); + $company_name=$this->input->post('input_company_name'); + $contact_person_name=$this->input->post('input_contact_person_name'); + $contact_phone_no=$this->input->post('input_contact_phone_no'); + + $Udata = array( + 'company_name'=> $company_name, + 'contact_person_name'=> $contact_person_name, + 'contact_phone_no'=> $contact_phone_no, + ); + + $this->load->model('Medical_M'); + + if($cid>0) + { + $this->Medical_M->update_company($Udata,$cid); + $inser_id=$cid; + $send_msg="Saved Successfully"; + }else{ + $inser_id=$this->Medical_M->insert_company($Udata); + $send_msg="Added Successfully"; + } + + if($inser_id>0) + { + $show_text=$send_msg; + }else{ + $show_text=$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'=>$send_msg + ); + $encode_data = json_encode($rvar); + echo $encode_data; + } + + } + + + + public function get_product_master(){ + if (isset($_GET['term'])){ + $q = strtolower($_GET['term']); + + $sql="select * from med_store_product_master + where item_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['item_name'])).' | '.htmlentities(stripslashes($row['formulation'])).' | '.htmlentities(stripslashes($row['genericname'])); + $new_row['value']=htmlentities(stripslashes($row['item_name'])).' | '.htmlentities(stripslashes($row['formulation'])); + //$new_row['value']=htmlentities(stripslashes($row['itemname'])); + + $new_row['l_item_code']=htmlentities(stripslashes($row['id'])); + + $new_row['l_itemname']=htmlentities(stripslashes($row['item_name'])); + + $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_genericname']=htmlentities(stripslashes($row['genericname'])); + + $new_row['l_formulation']=htmlentities(stripslashes($row['formulation'])); + + $row_set[] = $new_row; //build an array + } + echo json_encode($row_set); //format the array into json data + } + }else{ + echo 'No Data'; + } + } + + + + +} \ No newline at end of file diff --git a/old_code_ci3/controllers/Reffer.php b/old_code_ci3/controllers/Reffer.php new file mode 100644 index 0000000..1a36bb3 --- /dev/null +++ b/old_code_ci3/controllers/Reffer.php @@ -0,0 +1,164 @@ +load->model('Reffer_M'); + + } + + function index() + { + $sql="select *,date_format(date_of_add,'%d-%m-%Y') as str_dateadd from refer_master order by f_name"; + $query = $this->db->query($sql); + $data['refer_master']= $query->result(); + + $this->load->view('hospital_refer/reffer_index',$data); + } + + function reffer_add() + { + $sql="select * from refer_type "; + $query = $this->db->query($sql); + $data['refer_type']= $query->result(); + + $this->load->view('hospital_refer/reffer_add',$data); + } + + function reffer_edit($refer_id) + { + $sql="select * from refer_master where id=$refer_id"; + $query = $this->db->query($sql); + $data['data']= $query->result(); + + $sql="select * from refer_type "; + $query = $this->db->query($sql); + $data['refer_type']= $query->result(); + + + $this->load->view('hospital_refer/reffer_edit',$data); + } + + function save_new_user() + { + if (!$this->input->is_ajax_request()) { exit('no valid req.'); } + + $cbo_title=$this->input->post('cbo_title'); + $input_name=$this->input->post('input_name'); + $cbo_refer_type=$this->input->post('cbo_refer_type'); + $input_phone_number=$this->input->post('input_phone_number'); + + + + $user = $this->ion_auth->user()->row(); + $user_id = $user->id; + $user_name = $user->first_name.''. $user->last_name.'['.$user_id.']'; + + + $FormRules = array( + array( + 'field' => 'input_name', + 'label' => 'Name of Patient', + 'rules' => 'required|min_length[1]|max_length[30]' + ), + ); + + + $this->form_validation->set_rules($FormRules); + + if ($this->form_validation->run() == TRUE) + { + + $data = array( + 'title' => $cbo_title, + 'f_name' => strtoupper($input_name), + 'refer_type' => $cbo_refer_type, + 'date_of_add' => date('Y-m-d H:i:s'), + 'insert_by' => $user_name, + 'phone_number'=> $input_phone_number, + 'active' => 1, + ); + + + $inser_id=$this->Reffer_M->insert($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; + } + + } + + + function save_user($reffer_id) + { + if (!$this->input->is_ajax_request()) { exit('no valid req.'); } + + $cbo_title=$this->input->post('cbo_title'); + $input_name=$this->input->post('input_name'); + $cbo_refer_type=$this->input->post('cbo_refer_type'); + $input_phone_number=$this->input->post('input_phone_number'); + + $user = $this->ion_auth->user()->row(); + $user_id = $user->id; + $user_name = $user->first_name.''. $user->last_name.'['.$user_id.']'; + + + $FormRules = array( + array( + 'field' => 'input_name', + 'label' => 'Name of Patient', + 'rules' => 'required|min_length[1]|max_length[30]' + ), + ); + + + $this->form_validation->set_rules($FormRules); + + if ($this->form_validation->run() == TRUE) + { + + $data = array( + 'title' => $cbo_title, + 'f_name' => strtoupper($input_name), + 'refer_type' => $cbo_refer_type, + 'date_of_add' => date('Y-m-d H:i:s'), + 'insert_by' => $user_name, + 'phone_number'=> $input_phone_number, + 'active' => 1, + ); + + $this->Reffer_M->update($data,$reffer_id); + $rvar=array( + 'update' =>1 + ); + $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; + } + + } +} \ No newline at end of file diff --git a/old_code_ci3/controllers/Report.php b/old_code_ci3/controllers/Report.php new file mode 100644 index 0000000..a1d4fe9 --- /dev/null +++ b/old_code_ci3/controllers/Report.php @@ -0,0 +1,2395 @@ +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); + + $content=$table_show; + $this->load->library('m_pdf'); + + $file_name="Report-OPD-".date('Ymdhis').".pdf"; + $filepath=$file_name; + $this->m_pdf->pdf->WriteHTML($content); + $this->m_pdf->pdf->Output($filepath,"I"); + + } + + 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,$output=0) + { + $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,IFNULL(GET_AGE_BY_DOB(dob),age) 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 (payment_mode>0 or running_opd=1) "; + + $rangeArray = explode("S",$opd_date_range); + $minRange = $rangeArray[0]; + $maxRange = $rangeArray[1]; + + $data_show=""; + + if (!$this->ion_auth->in_group('ReportOLDREC')) { + $date1=date_create($minRange); + $date2=date_create(date('Y-m-d')); + + $diff=date_diff($date1,$date2); + + //echo $diff->format('%a'); + + $int_diff=$diff->format('%a'); + + if($int_diff>2) + { + date_sub($date2,date_interval_create_from_date_string("1 days")); + // date_format($date2,"Y-m-d"); + $minRange=date_format($date2,"Y-m-d");; + } + } + + $sql_where.=" and Date(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_id = '".$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==0) + { + $sql_order.=' ,o.opd_id'; + } + + 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==0) + { + $sql_order.=' ,o.opd_id'; + } + + if($order_2==1) + { + $sql_order.=' ,o.doc_name'; + } + + if($order_2==2) + { + $sql_order.=' ,o.prepared_by'; + } + + + $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 ".$sql_where." + group by Date(o.apointment_date)"; + + $query = $this->db->query($GroupSQL); + $data['group_rec']= $query->result(); + + $index = 0; + $data_show=""; + + foreach($data['group_rec'] as $row) + { + if($index>0) + { + $data_show.=""; + } + + $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; + + $index++; + } + } + + 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 ".$sql_where." group by o.doc_id"; + + $query = $this->db->query($GroupSQL); + $data['group_rec']= $query->result(); + + $index = 0; + $data_show=""; + foreach($data['group_rec'] as $row) + { + + if($index>0) + { + $data_show.=""; + } + + $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; + + $index++; + + } + } + + 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 ".$sql_where." group by o.prepared_by"; + + $query = $this->db->query($GroupSQL); + $data['group_rec']= $query->result(); + + $index = 0; + $data_show=""; + foreach($data['group_rec'] as $row) + { + + if($index>0) + { + $data_show.=""; + } + + $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; + + $index++; + + } + } + + + 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 + ".$sql_where." group by o.payment_mode"; + + $query = $this->db->query($GroupSQL); + $data['group_rec']= $query->result(); + + $index = 0; + $data_show=""; + + foreach($data['group_rec'] as $row) + { + + if($index>0) + { + $data_show.=""; + } + + $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; + + $index++; + + } + } + + $content=$data_show; + $file_name="Report-OPD".date('Ymdhis').".pdf"; + + + if($output==0) + { + + $this->load->library('m_pdf'); + $filepath=$file_name; + $this->m_pdf->pdf->WriteHTML($content); + $this->m_pdf->pdf->Output($filepath,"I"); + + }else{ + + ExportExcel($content,$file_name); + } + + + + } + + + public function report_charge_app_show($opd_date_range, + $doc_name_id,$emp_name_id,$paymode_id,$order_1,$order_2,$group_by,$output=0) + { + $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]; + + if (!$this->ion_auth->in_group('ReportOLDREC')) { + $date1=date_create($minRange); + $date2=date_create(date('Y-m-d')); + + $diff=date_diff($date1,$date2); + + //echo $diff->format('%a'); + + $int_diff=$diff->format('%a'); + + if($int_diff>2) + { + date_sub($date2,date_interval_create_from_date_string("1 days")); + // date_format($date2,"Y-m-d"); + $minRange=date_format($date2,"Y-m-d");; + } + } + + + + $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'; + } + + + $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(); + + $index = 0; + $data_show=""; + + + foreach($data['group_rec'] as $row) + { + if($index>0) + { + $data_show.=""; + } + + $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; + + + } + } + + 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(); + + $index = 0; + $data_show=""; + + foreach($data['group_rec'] as $row) + { + if($index>0) + { + $data_show.=""; + } + + $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; + + } + } + + 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(); + + $index = 0; + $data_show=""; + + + foreach($data['group_rec'] as $row) + { + if($index>0) + { + $data_show.=""; + } + + $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; + + } + } + + + 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(); + + $index = 0; + $data_show=""; + + foreach($data['group_rec'] as $row) + { + if($index>0) + { + $data_show.=""; + } + + $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; + + + + } + } + + $content=$data_show; + $file_name="Report-OPD-".date('Ymdhis').".pdf"; + + + if($output==0) + { + $this->load->library('m_pdf'); + $filepath=$file_name; + $this->m_pdf->pdf->WriteHTML($content); + $this->m_pdf->pdf->Output($filepath,"I"); + + + }else{ + + ExportExcel($content,$file_name); + } + + + } + + + public function report_ipdpayment_app_show($opd_date_range, + $doc_name_id,$emp_name_id,$paymode_id,$order_1,$order_2,$group_by,$output=0) + { + $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.payment_date,p.id as pay_id, + Date_format(p.payment_date,'%d-%m-%Y') as strPayDate, + if(i.ipd_status=0,'Admit','Discharged') as IPD_Status, + if(p.credit_debit=0,p.amount,0) as C_Amount, + if(p.credit_debit=1,p.amount,0) as D_Amount, + if(p.payment_mode=1,'CASH','BANK') AS payment_mode_desc, + doc.doc_name,doc_list,p.update_by AS prepared_by,p.remark, + if(i.case_id=0,'','INSURED') as insurance_type"; + + $sql_from=" FROM ((payment_history p join ipd_master i on i.id=p.payof_id AND p.payof_type=4) + join patient_master m ON i.p_id=m.id) + 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=doc.ipd_id"; + + $sql_where=" Where 1=1 "; + + $rangeArray = explode("S",$opd_date_range); + $minRange = $rangeArray[0]; + $maxRange = $rangeArray[1]; + + if (!$this->ion_auth->in_group('ReportOLDREC')) { + $date1=date_create($minRange); + $date2=date_create(date('Y-m-d')); + + $diff=date_diff($date1,$date2); + + //echo $diff->format('%a'); + + $int_diff=$diff->format('%a'); + + if($int_diff>2) + { + date_sub($date2,date_interval_create_from_date_string("1 days")); + // date_format($date2,"Y-m-d"); + $minRange=date_format($date2,"Y-m-d");; + } + } + + $sql_where.=" and Date(p.payment_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.update_by_id in (".$emp_name_id.") "; + } + + if($paymode_id>0) + { + $sql_where.=" and p.payment_mode = '".$paymode_id."'"; + } + + $sql_order=" Order by p.payment_date"; + + if($order_1==1) + { + $sql_order.=' ,doc.doc_name'; + } + + if($order_1==2) + { + $sql_order.=' ,p.update_by'; + } + + if($order_1==3) + { + $sql_order.=' ,p.payment_mode'; + } + + if($order_2==1) + { + $sql_order.=' ,doc.doc_name'; + } + + if($order_2==2) + { + $sql_order.=' ,p.update_by'; + } + + + $table_start=''; + $table_end='
'; + + $table_head=''; + $table_head.='Pay ID '; + $table_head.='IPD No '; + $table_head.='Patient Name'; + $table_head.='Pay Date'; + $table_head.='Pay Mode'; + $table_head.='TPA/Direct'; + $table_head.='Amount (Cr.)'; + $table_head.='Amount (Dr.)'; + $table_head.='Remark'; + $table_head.='Dr.Name'; + $table_head.='Employee'; + + $data_show=""; + + if($group_by==-1) + { + $data_show.='Payment Date between: '.$minRange.' and '.$maxRange. '
'; + + + $query = $this->db->query($sql_f_all.$sql_from.$sql_where.' '.$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->pay_id.''; + $table_body.=''.$rowdata->ipd_code.''; + $table_body.=''.$rowdata->p_fname.''; + $table_body.=''.$rowdata->strPayDate.''; + $table_body.=''.$rowdata->payment_mode_desc.''; + $table_body.=''.$rowdata->insurance_type.''; + $table_body.=''.$rowdata->C_Amount.''; + $table_body.=''.$rowdata->D_Amount.''; + $table_body.=''.$rowdata->remark.''; + $table_body.=''.$rowdata->doc_name.''; + $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; + } + + $TOTAL_AMT=$table_total_1-$table_Dr_total_1; + $table_footer=''; + $table_footer.='Net Amt. (Cr-Dr) : '.$TOTAL_AMT.''; + $table_footer.=''.$table_total_1.''; + $table_footer.=''.$table_Dr_total_1.''; + $table_footer.=''; + $table_footer.=''; + $data_show.=$table_start.$table_head.$table_body.$table_footer.$table_end; + + + } + + + + if($group_by==0) + { + + + $GroupSQL="select Date(p.payment_date) as sdate,Date_Format(Date(p.payment_date),'%d-%m-%Y') as strDate + From ((payment_history p join ipd_master i on i.id=p.payof_id AND p.payof_type=4) + join patient_master m ON i.p_id=m.id) + where Date(p.payment_date) between'".$minRange."' and '".$maxRange. "' + group by Date(p.payment_date) "; + + $query = $this->db->query($GroupSQL); + $data['group_rec']= $query->result(); + + $index = 0; + $data_show=""; + + foreach($data['group_rec'] as $row) + { + if($index>0) + { + $data_show.=""; + } + + $data_show.='Payment Date : '.$row->strDate.'
'; + + $gwhere=" and Date(p.payment_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->pay_id.''; + $table_body.=''.$rowdata->ipd_code.''; + $table_body.=''.$rowdata->p_fname.''; + $table_body.=''.$rowdata->strPayDate.''; + $table_body.=''.$rowdata->payment_mode_desc.''; + $table_body.=''.$rowdata->insurance_type.''; + $table_body.=''.$rowdata->C_Amount.''; + $table_body.=''.$rowdata->D_Amount.''; + $table_body.=''.$rowdata->remark.''; + $table_body.=''.$rowdata->doc_name.''; + $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; + + + } + } + + if($group_by==1) + { + + + $GroupSQL="select doc.doc_name + from ((payment_history p join ipd_master i on i.id=p.payof_id AND p.payof_type=4) + join patient_master m ON i.p_id=m.id) + 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=doc.ipd_id + where Date(p.payment_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) + { + $index = 0; + $data_show=""; + + if($index>0) + { + $data_show.=""; + } + + $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->pay_id.''; + $table_body.=''.$rowdata->ipd_code.''; + $table_body.=''.$rowdata->p_fname.''; + $table_body.=''.$rowdata->strPayDate.''; + $table_body.=''.$rowdata->payment_mode_desc.''; + $table_body.=''.$rowdata->insurance_type.''; + $table_body.=''.$rowdata->C_Amount.''; + $table_body.=''.$rowdata->D_Amount.''; + $table_body.=''.$rowdata->remark.''; + $table_body.=''.$rowdata->doc_name.''; + $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; + + + } + } + + if($group_by==2) + { + + $GroupSQL="select p.update_by as prepared_by + from ((payment_history p join ipd_master i on i.id=p.payof_id AND p.payof_type=4) + join patient_master m ON i.p_id=m.id) + Where Date(p.payment_date) between'".$minRange."' and '".$maxRange. "' group by p.prepared_by"; + + $query = $this->db->query($GroupSQL); + $data['group_rec']= $query->result(); + + $index = 0; + $data_show=""; + + foreach($data['group_rec'] as $row) + { + if($index>0) + { + $data_show.=""; + } + + $data_show.='Prepared By : '.$row->prepared_by.'
'; + + $gwhere=" and p.update_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->pay_id.''; + $table_body.=''.$rowdata->ipd_code.''; + $table_body.=''.$rowdata->p_fname.''; + $table_body.=''.$rowdata->strPayDate.''; + $table_body.=''.$rowdata->payment_mode_desc.''; + $table_body.=''.$rowdata->insurance_type.''; + $table_body.=''.$rowdata->C_Amount.''; + $table_body.=''.$rowdata->D_Amount.''; + $table_body.=''.$rowdata->remark.''; + $table_body.=''.$rowdata->doc_name.''; + $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; + + } + } + + + if($group_by==3) + { + + $GroupSQL="select p.payment_mode,p.payment_mode_desc + from ((payment_history p join ipd_master i on i.id=p.payof_id AND p.payof_type=4) + join patient_master m ON i.p_id=m.id) + Where Date(p.payment_date) between'".$minRange."' and '".$maxRange. "' group by p.payment_mode "; + + $query = $this->db->query($GroupSQL); + $data['group_rec']= $query->result(); + + $index = 0; + $data_show=""; + + + foreach($data['group_rec'] as $row) + { + if($index>0) + { + $data_show.=""; + } + + $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->pay_id.''; + $table_body.=''.$rowdata->ipd_code.''; + $table_body.=''.$rowdata->p_fname.''; + $table_body.=''.$rowdata->strPayDate.''; + $table_body.=''.$rowdata->payment_mode_desc.''; + $table_body.=''.$rowdata->insurance_type.''; + $table_body.=''.$rowdata->C_Amount.''; + $table_body.=''.$rowdata->D_Amount.''; + $table_body.=''.$rowdata->remark.''; + $table_body.=''.$rowdata->doc_name.''; + $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; + + } + } + + $content=$data_show; + + + if($output==0) + { + + $this->load->library('m_pdf'); + + // $content; + $file_name="Report-opd-".date('Ymdhis').".pdf"; + $filepath=$file_name; + $this->m_pdf->pdf->WriteHTML($content); + $this->m_pdf->pdf->Output($filepath,"I"); + + }else{ + + ExportExcel($content,'IPD_List_payment'); + } + + } + + 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 3 then 'ORG' 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 (!$this->ion_auth->in_group('ReportOLDREC')) { + $date1=date_create($minRange); + $date2=date_create(date('Y-m-d')); + + $diff=date_diff($date1,$date2); + + //echo $diff->format('%a'); + + $int_diff=$diff->format('%a'); + + if($int_diff>2) + { + date_sub($date2,date_interval_create_from_date_string("1 days")); + // date_format($date2,"Y-m-d"); + $minRange=date_format($date2,"Y-m-d");; + } + } + + 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) + { + $content= $data_show; + + $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($data_show,'Payment'); + } + } + + public function report_charge_type($opd_date_range,$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 (!$this->ion_auth->in_group('ReportOLDREC')) { + $date1=date_create($minRange); + $date2=date_create(date('Y-m-d')); + + $diff=date_diff($date1,$date2); + + //echo $diff->format('%a'); + + $int_diff=$diff->format('%a'); + + if($int_diff>2) + { + date_sub($date2,date_interval_create_from_date_string("1 days")); + // date_format($date2,"Y-m-d"); + $minRange=date_format($date2,"Y-m-d");; + } + } + + + 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'; + + // 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.'

'; + + $content=$data_show; + $this->load->library('m_pdf'); + + + + if($output==0) + { + $file_name="Report-opd-".date('Ymdhis').".pdf"; + $filepath=$file_name; + $this->m_pdf->pdf->WriteHTML($content); + $this->m_pdf->pdf->Output($filepath,"I"); + + }else{ + + ExportExcel($content,'IPD_List_payment'); + } + } + + + 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.payof_type=3,if(p.credit_debit=0,p.amount,0),0)) as ORG_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 (!$this->ion_auth->in_group('ReportOLDREC')) { + $date1=date_create($minRange); + $date2=date_create(date('Y-m-d')); + + $diff=date_diff($date1,$date2); + + //echo $diff->format('%a'); + + $int_diff=$diff->format('%a'); + + if($int_diff>2) + { + date_sub($date2,date_interval_create_from_date_string("1 days")); + // date_format($date2,"Y-m-d"); + $minRange=date_format($date2,"Y-m-d");; + } + } + + 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.='ORG 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_org=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->ORG_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_org=$table_total_org+$rowdata->ORG_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_org.''; + $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) + { + $content=$data_show; + $this->load->library('m_pdf'); + + $file_name="Report-opd-".date('Ymdhis').".pdf"; + $filepath=$file_name; + $this->m_pdf->pdf->WriteHTML($content); + $this->m_pdf->pdf->Output($filepath,"I"); + }else{ + + ExportExcel($data_show,'Payment_Complie'); + } + } + + public function report_emp_total_daywise($opd_date_range,$emp_name_id,$paymode_id,$order_1,$output=0) + { + $sql_f_all = "select p.update_by_id,date_format(p.payment_date,'%d-%m-%Y') as g_payment_date,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.payof_type=3,if(p.credit_debit=0,p.amount,0),0)) as ORG_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 date(p.payment_date), p.update_by_id "; + + $rangeArray = explode("S",$opd_date_range); + $minRange = str_replace('T',' ',$rangeArray[0]); + $maxRange = str_replace('T',' ',$rangeArray[1]); + + if (!$this->ion_auth->in_group('ReportOLDREC')) { + $date1=date_create($minRange); + $date2=date_create(date('Y-m-d')); + + $diff=date_diff($date1,$date2); + + //echo $diff->format('%a'); + + $int_diff=$diff->format('%a'); + + if($int_diff>2) + { + date_sub($date2,date_interval_create_from_date_string("1 days")); + // date_format($date2,"Y-m-d"); + $minRange=date_format($date2,"Y-m-d");; + } + } + + $sql_where.=" and Date(p.payment_date) between Date('".$minRange."') and Date('".$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 date(p.payment_date)"; + + + $table_start=''; + $table_end='
'; + + $table_head=''; + $table_head.='User ID'; + $table_head.='OPD Amount'; + $table_head.='Charge Amount'; + $table_head.='IPD Amount'; + $table_head.='ORG Amount'; + $table_head.='Return Amount'; + $table_head.='Total'; + $table_head.=''; + + $table_footer=''; + + $sql=$sql_f_all.$sql_from.$sql_where.' '.$sql_group_by.' WITH rollup'; + + $query = $this->db->query($sql); + $data['gsub_rec']= $query->result(); + + $table_body=''; + $data_show=''; + + foreach($data['gsub_rec'] as $rowdata) + { + if($rowdata->g_payment_date=='' && $rowdata->update_by_id==''){ + + $table_footer=''; + $table_footer.='Grand Total'; + $table_footer.=''.$rowdata->OPD_Amount.''; + $table_footer.=''.$rowdata->Charge_Amount.''; + $table_footer.=''.$rowdata->IPD_Amount.''; + $table_footer.=''.$rowdata->ORG_Amount.''; + + $table_footer.=''.$rowdata->Return_Amount.''; + $table_footer.=''.$rowdata->total_Amount.''; + $table_footer.=''; + + $data_show.='

Date(YYYY-MM-DD h:m) '.$rowdata->g_payment_date.'

'; + $data_show.=$table_start.$table_head.$table_body.$table_footer.$table_end; + + }else if($rowdata->update_by_id=='') + { + + $table_footer=''; + $table_footer.='Total'; + $table_footer.=''.$rowdata->OPD_Amount.''; + $table_footer.=''.$rowdata->Charge_Amount.''; + $table_footer.=''.$rowdata->IPD_Amount.''; + $table_footer.=''.$rowdata->ORG_Amount.''; + + $table_footer.=''.$rowdata->Return_Amount.''; + $table_footer.=''.$rowdata->total_Amount.''; + $table_footer.=''; + + $data_show.='

Date(YYYY-MM-DD h:m) '.$rowdata->g_payment_date.'

'; + $data_show.=$table_start.$table_head.$table_body.$table_footer.$table_end; + $data_show.=''; + $table_body=''; + $table_footer=''; + + }else{ + $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->ORG_Amount.''; + + $table_body.=''.$rowdata->Return_Amount.''; + $table_body.=''.$rowdata->total_Amount.''; + $table_body.=''; + + } + } + + $content=$data_show; + if($output==0) + { + + $this->load->library('m_pdf'); + + $file_name="Report-opd-".date('Ymdhis').".pdf"; + $filepath=$file_name; + $this->m_pdf->pdf->WriteHTML($content); + $this->m_pdf->pdf->Output($filepath,"I"); + //echo $content; + }else{ + + ExportExcel($content,'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]; + + if (!$this->ion_auth->in_group('ReportOLDREC')) { + $date1=date_create($minRange); + $date2=date_create(date('Y-m-d')); + + $diff=date_diff($date1,$date2); + + //echo $diff->format('%a'); + + $int_diff=$diff->format('%a'); + + if($int_diff>2) + { + date_sub($date2,date_interval_create_from_date_string("1 days")); + // date_format($date2,"Y-m-d"); + $minRange=date_format($date2,"Y-m-d");; + } + } + + $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 + + from opd_master o + where ".$sql_where." and o.payment_status=1 AND o.opd_status IN (1,2) + 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.Net OPDNet Amount
'; + $FooterHead=''; + foreach($opdlist as $row) + { + + 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_opd.''.PHP_EOL; + $line.=''.$row->OPD_Amount.''.PHP_EOL; + + $line.=""; + + $FooterHead.='

Doctor :Dr. '.$row->doc_name.' / Total Net OPD : '.$row->no_opd.' / Total Amount : Rs.'.number_format($row->OPD_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_opd.''.PHP_EOL; + $line.=''.$row->OPD_Amount.''.PHP_EOL; + + $line.=""; + } + } + + $print_data= $tableHead.$line.$tablefooter.'
'.$FooterHead; + $content=$print_data; + + if($output==0) + { + + $this->load->library('m_pdf'); + + $file_name="Report-opd-".date('Ymdhis').".pdf"; + $filepath=$file_name; + $this->m_pdf->pdf->WriteHTML($content); + $this->m_pdf->pdf->Output($filepath,"I"); + }else{ + + ExportExcel($content,'OPDList'); + } + + } + + function report_opd_total() + { + + $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_total',$data); + } + + + function opd_total_data($opd_date_range,$doc_name_id,$emp_name_id,$paymode_id,$output=0) + { + $rangeArray = explode("S",$opd_date_range); + $minRange = $rangeArray[0]; + $maxRange = $rangeArray[1]; + + $sql_where =" 1=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="SELECT o.doc_name, + o.opd_fee_desc,o.opd_fee_amount, + sum(if(o.opd_status IN (1,2),1,0)) AS No_opd, + sum(if(o.opd_status IN (1,2),o.opd_fee_amount,0)) AS T_Amt + FROM opd_master o + where ".$sql_where." + AND o.opd_status IN (1,2) and + o.payment_status=1 AND (payment_mode>0 or running_opd=1) + GROUP BY o.opd_fee_id,o.opd_fee_type,o.opd_fee_amount"; + + //echo $sql; + + $query = $this->db->query($sql); + $OPD_list= $query->result(); + + $sql="SELECT o.doc_name, + o.opd_fee_desc,o.opd_fee_amount, + sum(if(o.opd_status IN (3),1,0)) AS No_opd, + sum(if(o.opd_status IN (3),o.opd_fee_amount,0)) AS T_Amt + FROM opd_master o + where ".$sql_where." + AND o.opd_status IN (3) and + o.payment_status=1 AND (payment_mode>0 or running_opd=1) + GROUP BY o.opd_fee_id,o.opd_fee_type,o.opd_fee_amount"; + + //echo $sql; + + $query = $this->db->query($sql); + $OPD_list_cancel= $query->result(); + + $content=''; + + $content.=' + + + + + + + '; + $sr_no=0; + $total_Payment=0; + $total_opd=0; + + foreach($OPD_list as $row) + { + $sr_no=$sr_no+1; + $content.=' + + + + + + + '; + $total_Payment+= $row->T_Amt; + $total_opd+= $row->No_opd; + } + + $content.=' + + + + + + + '; + + $content.="
#Dr NameOPD TypeOPD FeeNo. of OPDTot.
'.$sr_no.'Dr. '.$row->doc_name.''.$row->opd_fee_desc.''.$row->opd_fee_amount.''.$row->No_opd.''.$row->T_Amt.'
#Total'.$total_opd.''.$total_Payment.'
"; + + //Cancel OPD + + $content_cancel=' +

Cancel OPD

+ '; + + $content_cancel.=' + + + + + + + '; + $sr_no=0; + $total_Payment=0; + $total_opd=0; + + foreach($OPD_list_cancel as $row) + { + $sr_no=$sr_no+1; + $content_cancel.=' + + + + + + + '; + $total_Payment+= $row->T_Amt; + $total_opd+= $row->No_opd; + } + + $content_cancel.=' + + + + + + + '; + + $content_cancel.="
#Dr NameOPD TypeOPD FeeNo. of OPDTot.
'.$sr_no.'Dr. '.$row->doc_name.''.$row->opd_fee_desc.''.$row->opd_fee_amount.''.$row->No_opd.''.$row->T_Amt.'
#Total'.$total_opd.''.$total_Payment.'
"; + + if(count($OPD_list_cancel)>0){ + $content.=$content_cancel; + } + + if($output==0) + { + $this->load->library('m_pdf'); + + $file_name='Report-OPD-'.date('Ymdhis').".pdf"; + $filepath=$file_name; + $this->m_pdf->pdf->WriteHTML($content); + $this->m_pdf->pdf->Output($filepath,"I"); + }else{ + ExportExcel($content,'OPD_List'.date('Yms')); + } + + } + + public function report_totalpayment_bank_app() + { + $sql="select * from users where active=1 order by first_name"; + $query = $this->db->query($sql); + $data['emplist']= $query->result(); + + $sql="SELECT b.id,b.bank_name,a.pay_type,a.id AS ac_id + FROM hospital_bank b JOIN hospital_bank_payment_source a ON b.id=a.bank_id"; + $query = $this->db->query($sql); + $data['hospital_bank_payment_source']= $query->result(); + + $this->load->view('Report/rep_total_bank_payment',$data); + } + + + public function report_total_payment_bank_show($opd_date_range,$emp_name_id,$bank_id,$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 3 then 'ORG' 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, + CONCAT(h.bank_name,':',b.pay_type) AS bank_pay_source"; + + $sql_from=" FROM (payment_history p LEFT JOIN hospital_bank_payment_source b ON p.pay_bank_id=b.id) + JOIN hospital_bank h ON b.bank_id=h.id "; + + $sql_where=" Where 1=1 "; + + $rangeArray = explode("S",$opd_date_range); + $minRange = str_replace('T',' ',$rangeArray[0]); + $maxRange = str_replace('T',' ',$rangeArray[1]); + + if (!$this->ion_auth->in_group('ReportOLDREC')) { + $date1=date_create($minRange); + $date2=date_create(date('Y-m-d')); + + $diff=date_diff($date1,$date2); + + //echo $diff->format('%a'); + + $int_diff=$diff->format('%a'); + + if($int_diff>2) + { + date_sub($date2,date_interval_create_from_date_string("1 days")); + // date_format($date2,"Y-m-d"); + $minRange=date_format($date2,"Y-m-d");; + } + } + + 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($bank_id<1) + { + $sql_where.=" and p.payment_mode =2 "; + }else{ + $sql_where.=" and p.payment_mode =2 and p.pay_bank_id = '".$paymode_id."'"; + } + + $sql_order=" Order by p.id"; + + + $table_start=''; + $table_end='
'; + + $table_head=''; + $table_head.='PayID '; + $table_head.='Date'; + $table_head.='Bank'; + $table_head.='OPD/IPD/In. Code '; + $table_head.='Bank Source'; + $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(); + + $sql= $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->bank_pay_source.''; + $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) + { + $content= $data_show; + + $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($data_show.$sql,'Payment'); + } + } + + + +} + + + +/* 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/Report2.php b/old_code_ci3/controllers/Report2.php new file mode 100644 index 0000000..429fec5 --- /dev/null +++ b/old_code_ci3/controllers/Report2.php @@ -0,0 +1,1151 @@ +db->query($sql); + $data['doclist']= $query->result(); + + $sql="select * from hc_item_type where is_ipd_opd in (0,1)"; + $query = $this->db->query($sql); + $data['item_type_list']= $query->result(); + + $this->load->view('Report/rep_diagnosis',$data); + } + + function report_Diagnosis_CASH() + { + $sql="select * from doctor_master where active=1"; + $query = $this->db->query($sql); + $data['doclist']= $query->result(); + + $sql="select * from hc_item_type where is_ipd_opd in (0,1)"; + $query = $this->db->query($sql); + $data['item_type_list']= $query->result(); + + $this->load->view('Report/rep_diagnosis_cash',$data); + } + + + function report_Diagnosis_EMP() + { + $sql="select * from users where active=1 order by first_name"; + $query = $this->db->query($sql); + $data['emplist']= $query->result(); + + $sql="select * from hc_item_type where is_ipd_opd in (0,1)"; + $query = $this->db->query($sql); + $data['item_type_list']= $query->result(); + + $this->load->view('Report/rep_diagnosis_empwise',$data); + } + + function report_Diagnosis_EMP_2() + { + $sql="select * from users where active=1 order by first_name"; + $query = $this->db->query($sql); + $data['emplist']= $query->result(); + + $sql="select * from hc_item_type where is_ipd_opd in (0,1)"; + $query = $this->db->query($sql); + $data['item_type_list']= $query->result(); + + $this->load->view('Report/rep_diagnosis_empwise_2',$data); + } + + function ipd_invoice_print($ipdno,$print=0) { + + $sql="select * from ipd_master where id=".$ipdno; + $query = $this->db->query($sql); + $ipdmaster= $query->result(); + + $pno=$ipdmaster[0]->p_id; + $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."' "; + + $query = $this->db->query($sql); + $person_info= $query->result(); + + $total_med=0.00; + $total_charges=0.00; + + if($ipdmaster[0]->case_id>0) + { + $sql="select * from organization_case_master where id='".$ipdmaster[0]->case_id."'"; + $query = $this->db->query($sql); + $orgcase= $query->result(); + + $ins_comp_id=$orgcase[0]->insurance_id; + $inc_card_id=$orgcase[0]->insurance_card_id; + + $sql="select * from hc_insurance_card where id='".$inc_card_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 v_ipd_bill_invoice v + where v.ipd_id=".$ipdno." "; + + $query = $this->db->query($sql); + $showinvoice= $query->result(); + + $sql="select sum(net_amount) as tnet_amount from invoice_med_master where payment_status=1 and ipd_id = ".$ipdno; + $query = $this->db->query($sql); + $inv_med_total= $query->result(); + + $total_med=$inv_med_total[0]->tnet_amount; + + $sql="select sum(net_amount) as tnet_amount from invoice_master where payment_status=1 and ipd_id = ".$ipdno; + $query = $this->db->query($sql); + $inv_charge_total= $query->result(); + + $total_charges=$inv_charge_total[0]->tnet_amount; + + $sql="select *,case payment_mode when 1 then 'Cash' when 2 then 'Bank Card' when 3 then 'Return Cash ' when 4 then 'Bank Return' else 'Other' end as pay_mode from ipd_payment where ipd_id='".$ipdno."' "; + $query = $this->db->query($sql); + $ipd_payment= $query->result(); + + $sql="select sum(if(credit_debit=0,amount,amount*-1)) as t_ipd_pay from ipd_payment where ipd_id='".$ipdno."' "; + $query = $this->db->query($sql); + $ipd_payment_total= $query->result(); + + $total_payment=$ipd_payment_total[0]->t_ipd_pay; + + $net_amount=($total_charges+$total_med)-$discount; + + $balance=$total_payment-$net_amount; + + $inv_total=array( + 'total_med' => $total_med, + 'total_charges' => $total_charges, + 'total_payment' => $total_payment, + 'ipd_id' => $ipdno, + 'discount' => $discount, + 'balance' => $balance, + 'net_amount' => $net_amount + ); + + // make string html string + + $htmlcontent=' + + + + + + + '; + + $srno=1; + $headdesc=''; + foreach($showinvoice as $row) + { + if($headdesc!=$row->Charge_type) + { + $htmlcontent.= ''; + $htmlcontent.= ''; + $htmlcontent.= ''; + $htmlcontent.= ''; + $headdesc=$row->Charge_type; + } + $htmlcontent.= ''; + $htmlcontent.= ''; + $htmlcontent.= ''; + $htmlcontent.= ''; + $htmlcontent.= ''; + $htmlcontent.= ''; + $srno=$srno+1; + $htmlcontent.= ''; + } + + + // Total Show + $htmlcontent.=' + + + + + + '; + + if($ipdmaster[0]->Discount>0) { + $htmlcontent.=' + + + + + + '; + } + + $htmlcontent.=' + + + + + + '; + + $htmlcontent.=' + + + + + + '; + + + $htmlcontent.=' + + + + + + '; + + $htmlcontent.='
#DescriptionUnitRateAmount
'.$row->Charge_type.'
'.$srno.''.$row->idesc.''.$row->no_qty.''.$row->item_rate.''.$row->amount.'
#Gross Total'.$inv_total['total_charges'].'
#Discount Remark :
'.$ipdmaster[0]->Discount_Remark.'
Discount '.$ipdmaster[0]->Discount.'
#Net Amount'.$inv_total['net_amount'].'
# + Payment Recd.
'; + + $i=1; + foreach($ipd_payment as $row) + { + $i=$i+1; + $htmlcontent.= '['.$row->id.':'.$row->pay_mode.':'.$row->amount.'] /'; + if($i & 1) + { + $htmlcontent.= '
'; + } + } + + $htmlcontent.='
'.$ipd_payment_total[0]->t_ipd_pay.'
#Balance'.$inv_total['balance'].'
'; + + $content=$htmlcontent; + $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"); + + + } + + public function report_Diagnosis_total($opd_date_range,$doc_id,$Diagnosis_id) + { + $sql_f_all = "select m.refer_by_other,y.group_desc,t.item_name,count(t.id) as No_test, + sum(t.item_qty) as No_qty, + sum(Round(if(m.invoice_status=1,(t.item_amount-(t.item_amount*m.discount_amount/m.total_amount)),0),2)) as Total_Amount, + sum(if(m.invoice_status=1,t.item_amount,0)) as Total_Act_Amount "; + + $sql_from=" from invoice_master m join invoice_item t join hc_item_type y + on m.id=t.inv_master_id and t.item_type=y.itype_id and y.is_ipd_opd in (0,1) + and m.invoice_status=1"; + + $sql_where=" Where 1=1 "; + + $sql_group_by=" group by m.refer_by_id,m.refer_by_other,t.item_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(m.inv_date) between Date('".$minRange."') and Date('".$maxRange. "')"; + }else{ + $sql_where.=" and m.inv_date between '".$minRange."' and '".$maxRange. "'"; + } + + $data_show='

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

'; + + if($doc_id>0) + { + $doc_id=str_replace('S',',',$doc_id); + + $sql_where.=" and m.refer_by_id in (".$doc_id.")"; + } + + if($Diagnosis_id>0) + { + $Diagnosis_id=str_replace('S',',',$Diagnosis_id); + $sql_where.=" and t.item_type in (".$Diagnosis_id.")"; + } + + $sql_order=" Order by m.refer_by_other,y.group_desc,t.item_name"; + + $table_start=''; + $table_end='
'; + + $table_head=''; + $table_head.=''; + $table_head.=''; + $table_head.='Test Name'; + $table_head.='No. of Test'; + $table_head.='Amount'; + $table_head.='Cost Amt'; + $table_head.=''; + + $table_footer=''; + + + + $query = $this->db->query($sql_f_all.$sql_from.$sql_where.' '.$sql_group_by.$sql_order); + $rowdata= $query->result(); + + //echo $sql_f_all.$sql_from.$sql_where.' '.$sql_group_by.$sql_order; + + $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=''; + $Diagnosis_head=''; + + + for( $i = 0; $irefer_by_other<>$doc_name_head) + { + $table_body.=''; + $table_body.='Refer By : '.$rowdata[$i]->refer_by_other.''; + $table_body.=''; + } + + $doc_name_head=$rowdata[$i]->refer_by_other; + + if($rowdata[$i]->group_desc<>$Diagnosis_head) + { + + $table_body.=''; + $table_body.=''; + $table_body.=''.$rowdata[$i]->group_desc.''; + $table_body.=''; + } + + $Diagnosis_head=$rowdata[$i]->group_desc; + + $table_body.=''; + $table_body.=''; + $table_body.=''; + $table_body.=''.$rowdata[$i]->item_name.''; + $table_body.=''.$rowdata[$i]->No_qty.''; + $table_body.=''.$rowdata[$i]->Total_Amount.''; + $table_body.=''.$rowdata[$i]->Total_Act_Amount.''; + $table_body.=''; + + $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) + { + if($igroup_desc<>$Diagnosis_head) + { + $table_body.=''; + $table_body.=''; + $table_body.=''; + $table_body.=''; + $table_body.='Total of '.$Diagnosis_head.''; + $table_body.=''.$table_Diagnosis_Head_Total.''; + $table_body.=''.$table_Diagnosis_act_Head_Total.''; + $table_body.=''; + + $table_Diagnosis_Head_Total=0.00; + $table_Diagnosis_act_Head_Total=0.00; + $table_qty_total=0.00; + } + }else{ + $table_body.=''; + $table_body.=''; + $table_body.=''; + $table_body.=''; + $table_body.='Total of '.$Diagnosis_head.''; + $table_body.=''.$table_Diagnosis_Head_Total.''; + $table_body.=''.$table_Diagnosis_act_Head_Total.''; + $table_body.=''; + + $table_Diagnosis_Head_Total=0.00; + $table_Diagnosis_act_Head_Total=0.00; + $table_qty_total=0.00; + } + + } + + if($irefer_by_other<>$doc_name_head) + { + $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.='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; + } + + } + + $table_footer=''; + $table_footer.='Total'; + $table_footer.=''; + $table_footer.=''; + $table_footer.=''.$table_grand_qty_total.''; + $table_footer.=''.$table_Grand_Total.''; + $table_footer.=''.$table_Grand_act_Total.''; + $table_footer.=''; + + $data_show.=$table_start.$table_head.$table_body.$table_footer.$table_end; + + $content=$data_show; + $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"); + + } + + + public function report_Diagnosis_Emp_total($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,Round(if(m.invoice_status=1,(t.item_amount-(t.item_amount*m.discount_amount/m.total_amount)),0),2) as item_amount, + ph.RPaidAmount,ph.gupdate_by,ph.gupdate_by_id "; + + $sql_from=" from ((invoice_master m join invoice_item t 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 ) + join (select p.payof_type,p.payof_id,p.payof_code,sum(if(p.credit_debit=0,p.amount,p.amount*-1)) as RPaidAmount, + group_concat(distinct p.update_by) as gupdate_by,group_concat(distinct p.update_by_id) as gupdate_by_id + from payment_history p where p.payof_type=2 + group by p.payof_type,p.payof_id) as ph on m.id=ph.payof_id) "; + + $sql_where=" Where 1=1 "; + + $sql_group_by=" "; + + $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(m.inv_date) between Date('".$minRange."') and Date('".$maxRange. "')"; + }else{ + $sql_where.=" and m.inv_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 m.prepared_by_id in (".$emp_name_id.")"; + } + + if($Diagnosis_id>0) + { + $Diagnosis_id=str_replace('S',',',$Diagnosis_id); + + $sql_where.=" and t.item_type in (".$Diagnosis_id.") "; + } + + $sql_order=" Order by ph.gupdate_by,y.group_desc,t.item_name"; + + + $table_start=''; + $table_end='
'; + + $table_head=''; + $table_head.=''; + $table_head.=''; + $table_head.='Patient Code/Name'; + $table_head.='Test Name'; + $table_head.='Amount'; + $table_head.=''; + + $table_footer=''; + + $sql="SELECT m.invoice_code,p.p_code,p.p_fname,y.group_desc,t.item_name,t.item_qty, Round((t.item_amount-(t.item_amount*m.discount_amount/m.total_amount)),2) as item_amount, + m.prepared_by,m.prepared_by_id + FROM ((invoice_master m join invoice_item t ON m.id=t.inv_master_id AND m.invoice_status=1) + join hc_item_type y ON t.item_type=y.itype_id) + JOIN patient_master p ON m.attach_id=p.id + $sql_where + GROUP BY m.prepared_by_id,y.itype_id,t.id + Order By m.prepared_by,y.group_desc,m.invoice_code"; + + $query = $this->db->query($sql); + $rowdata= $query->result(); + + $table_body=''; + $table_emp_Total=0.00; + $table_Diagnosis_Head_Total=0.00; + $table_Grand_Total=0.00; + + //echo $sql_f_all.$sql_from.$sql_where.$gwhere.' '.$sql_order.'

'; + $emp_name_head=''; + $Diagnosis_head=''; + + for( $i = 0; $iprepared_by<>$emp_name_head) + { + $table_body.=''; + $table_body.='Emp.Name : '.$rowdata[$i]->prepared_by.''; + $table_body.=''; + } + + $emp_name_head=$rowdata[$i]->prepared_by; + + if($rowdata[$i]->group_desc<>$Diagnosis_head) + { + $table_body.=''; + $table_body.=''; + $table_body.=''.$rowdata[$i]->group_desc.''; + $table_body.=''; + } + + $Diagnosis_head=$rowdata[$i]->group_desc; + + $table_body.=''; + $table_body.=''; + $table_body.=''.$rowdata[$i]->p_code.'/'.$rowdata[$i]->p_fname.''; + $table_body.=''.$rowdata[$i]->invoice_code.''; + $table_body.=''.$rowdata[$i]->item_name.''; + $table_body.=''.$rowdata[$i]->item_amount.''; + $table_body.=''; + + $table_emp_Total=$table_emp_Total+$rowdata[$i]->item_amount; + $table_Diagnosis_Head_Total=$table_Diagnosis_Head_Total+$rowdata[$i]->item_amount; + $table_Grand_Total=$table_Grand_Total+$rowdata[$i]->item_amount; + + if($Diagnosis_id<1) + { + if($igroup_desc<>$Diagnosis_head) + { + $table_body.=''; + $table_body.=''; + $table_body.=''; + $table_body.=''; + $table_body.='Total of '.$Diagnosis_head.''; + $table_body.=''.$table_Diagnosis_Head_Total.''; + $table_body.=''; + + $table_Diagnosis_Head_Total=0.00; + } + }else{ + $table_body.=''; + $table_body.=''; + $table_body.=''; + $table_body.=''; + $table_body.='Total of '.$Diagnosis_head.''; + $table_body.=''.$table_Diagnosis_Head_Total.''; + $table_body.=''; + + $table_Diagnosis_Head_Total=0.00; + } + + } + + if($iprepared_by<>$emp_name_head) + { + $table_body.=''; + $table_body.=''; + $table_body.=''; + $table_body.=''; + $table_body.='Total Emp Head'; + $table_body.=''.$table_emp_Total.''; + $table_body.=''; + + $table_emp_Total=0.00; + + } + }else{ + $table_body.=''; + $table_body.=''; + $table_body.=''; + $table_body.=''; + $table_body.='Total Emp. Head'; + $table_body.=''.$table_emp_Total.''; + $table_body.=''; + + $table_emp_Total=0.00; + } + + } + + $table_footer=''; + $table_footer.='Total'; + $table_footer.=''; + $table_footer.=''; + $table_footer.=''; + $table_footer.=''.$table_Grand_Total.''; + $table_footer.=''; + + $data_show.=$table_start.$table_head.$table_body.$table_footer.$table_end; + + $sql_where.=" and (m.payment_part_balance>0 or m.discount_amount>0) "; + //Foot Data Describe Discount + $sql_f_all_2="select m.invoice_code,p.p_code,p.p_fname,m.discount_amount,m.discount_desc,m.disc_update_by,m.total_amount, + ph.RPaidAmount,ph.gupdate_by,ph.gupdate_by_id ,m.payment_part_received,m.payment_part_balance"; + + //echo $sql_f_all_2.$sql_from.$sql_where.' group by m.id'.$sql_order; + $query2=$sql_f_all_2.$sql_from.$sql_where.' group by m.id'.$sql_order; + $query = $this->db->query($sql_f_all_2.$sql_from.$sql_where.' group by m.id'.$sql_order); + $rowfootdata= $query->result(); + + if(count($rowfootdata)>0) + { + + $data_show.='


'; + + $table_head=''; + $table_head.='Invoice ID'; + $table_head.='Patient Code/Name'; + $table_head.='T Amount'; + $table_head.='Disc.Amt'; + $table_head.='Disc.By'; + $table_head.='Rec.Amt.'; + $table_head.='Balance'; + $table_head.=''; + + $T_Discount_Amt=0.00; + $T_Balance_Amt=0.00; + + $table_body=""; + + for( $i = 0; $iinvoice_code.''; + $table_body.=''.$rowfootdata[$i]->p_code.'/'.$rowfootdata[$i]->p_fname.''; + $table_body.=''.$rowfootdata[$i]->total_amount.''; + $table_body.=''.$rowfootdata[$i]->discount_amount.''; + $table_body.=''.$rowfootdata[$i]->discount_desc.''; + $table_body.=''.$rowfootdata[$i]->RPaidAmount.''; + $table_body.=''.$rowfootdata[$i]->payment_part_balance.''; + $table_body.=''; + + $T_Discount_Amt=$T_Discount_Amt+$rowfootdata[$i]->discount_amount; + $T_Balance_Amt=$T_Balance_Amt+$rowfootdata[$i]->payment_part_balance; + } + + $table_footer=''; + $table_footer.=''; + $table_footer.=''; + $table_footer.=''; + $table_footer.=''.$T_Discount_Amt.''; + $table_footer.=''; + $table_footer.=''; + $table_footer.=''.$T_Balance_Amt.''; + $table_footer.=''; + + + $data_show.=$table_start.$table_head.$table_body.$table_footer.$table_end; + } + + $content=$data_show; + $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"); + + } + + public function report_Diagnosis_Emp_total_2($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, + Round(if(m.invoice_status=1,(t.item_amount-(t.item_amount*m.discount_amount/m.total_amount)),0),2) as item_amount, + m.invoice_status "; + $sql_from=" from (invoice_master m join invoice_item t 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 + and payment_status=1 and m.invoice_status=1) "; + + $sql_where=" Where 1=1 "; + + $sql_group_by=" "; + + $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(m.inv_date) between Date('".$minRange."') and Date('".$maxRange. "')"; + }else{ + $sql_where.=" and m.inv_date between '".$minRange."' and '".$maxRange. "'"; + } + + $data_show='

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

'; + + if($Diagnosis_id>0) + { + $Diagnosis_id=str_replace('S',',',$Diagnosis_id); + + $sql_where.=" and t.item_type in (".$Diagnosis_id.") "; + } + + $sql_order=" Order by y.group_desc,t.item_name"; + + + $table_start=''; + $table_end='
'; + + $table_head=''; + $table_head.=''; + $table_head.=''; + $table_head.='Patient Code/Name'; + $table_head.='Test Name'; + $table_head.='Amount'; + $table_head.=''; + + $table_footer=''; + + $query1=$sql_f_all.$sql_from.$sql_where.' '.$sql_group_by.$sql_order; + $query = $this->db->query($query1); + $rowdata= $query->result(); + + + $table_body=''; + $table_emp_Total=0.00; + $table_Diagnosis_Head_Total=0.00; + $table_Grand_Total=0.00; + + //echo $sql_f_all.$sql_from.$sql_where.$gwhere.' '.$sql_order.'

'; + $emp_name_head=''; + $Diagnosis_head=''; + + for( $i = 0; $igroup_desc<>$Diagnosis_head) + { + $table_body.=''; + $table_body.=''; + $table_body.=''.$rowdata[$i]->group_desc.''; + $table_body.=''; + } + + $Diagnosis_head=$rowdata[$i]->group_desc; + + $table_body.=''; + $table_body.=''; + $table_body.=''; + $table_body.=''.$rowdata[$i]->p_code.'/'.$rowdata[$i]->p_fname.''; + $table_body.=''.$rowdata[$i]->invoice_code.''; + $table_body.=''.$rowdata[$i]->item_amount.''; + $table_body.=''; + + + $table_Diagnosis_Head_Total=$table_Diagnosis_Head_Total+$rowdata[$i]->item_amount; + $table_Grand_Total=$table_Grand_Total+$rowdata[$i]->item_amount; + + if($Diagnosis_id<1) + { + if($igroup_desc<>$Diagnosis_head) + { + $table_body.=''; + $table_body.=''; + $table_body.=''; + $table_body.=''; + $table_body.='Total of '.$Diagnosis_head.''; + $table_body.=''.$table_Diagnosis_Head_Total.''; + $table_body.=''; + + $table_Diagnosis_Head_Total=0.00; + } + }else{ + $table_body.=''; + $table_body.=''; + $table_body.=''; + $table_body.=''; + $table_body.='Total of '.$Diagnosis_head.''; + $table_body.=''.$table_Diagnosis_Head_Total.''; + $table_body.=''; + + $table_Diagnosis_Head_Total=0.00; + } + + } + + + + } + + $table_footer=''; + $table_footer.='Total'; + $table_footer.=''; + $table_footer.=''; + $table_footer.=''; + $table_footer.=''.$table_Grand_Total.''; + $table_footer.=''; + + $data_show.=$table_start.$table_head.$table_body.$table_footer.$table_end; + + $content=$data_show; + $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"); + + } + + + 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, + if(m.invoice_status=1,t.item_amount,0) as item_amount,m.invoice_status "; + $sql_from=" from (invoice_master m join invoice_item t 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 + and payment_status=1 and m.invoice_status=1) "; + + $sql_where=" Where 1=1 "; + + $sql_group_by=" "; + + $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(m.inv_date) between Date('".$minRange."') and Date('".$maxRange. "')"; + }else{ + $sql_where.=" and m.inv_date between '".$minRange."' and '".$maxRange. "'"; + } + + $data_show='

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

'; + + if($Diagnosis_id>0) + { + $Diagnosis_id=str_replace('S',',',$Diagnosis_id); + + $sql_where.=" and t.item_type in (".$Diagnosis_id.") "; + } + + $sql_order=" Order by y.group_desc,t.item_name"; + + $table_start=''; + $table_end='
'; + + $table_head=''; + $table_head.=''; + $table_head.=''; + $table_head.='Patient Code/Name'; + $table_head.='Test Name'; + $table_head.='Amount'; + $table_head.=''; + + $table_footer=''; + + // Add a page + // This method has several options, check the source code documentation for more information. + + + + $query1=$sql_f_all.$sql_from.$sql_where.' '.$sql_group_by.$sql_order; + $query = $this->db->query($sql_f_all.$sql_from.$sql_where.' '.$sql_group_by.$sql_order); + $rowdata= $query->result(); + + $table_body=''; + $table_emp_Total=0.00; + $table_Diagnosis_Head_Total=0.00; + $table_Grand_Total=0.00; + + //echo $sql_f_all.$sql_from.$sql_where.$gwhere.' '.$sql_order.'

'; + $emp_name_head=''; + $Diagnosis_head=''; + + for( $i = 0; $igroup_desc<>$Diagnosis_head) + { + $table_body.=''; + $table_body.=''; + $table_body.=''.$rowdata[$i]->group_desc.''; + $table_body.=''; + } + + $Diagnosis_head=$rowdata[$i]->group_desc; + + $table_body.=''; + $table_body.=''; + $table_body.=''; + $table_body.=''.$rowdata[$i]->p_code.'/'.$rowdata[$i]->p_fname.''; + $table_body.=''.$rowdata[$i]->invoice_code.''; + $table_body.=''.$rowdata[$i]->item_amount.''; + $table_body.=''; + + + $table_Diagnosis_Head_Total=$table_Diagnosis_Head_Total+$rowdata[$i]->item_amount; + $table_Grand_Total=$table_Grand_Total+$rowdata[$i]->item_amount; + + if($Diagnosis_id<1) + { + if($igroup_desc<>$Diagnosis_head) + { + $table_body.=''; + $table_body.=''; + $table_body.=''; + $table_body.=''; + $table_body.='Total of '.$Diagnosis_head.''; + $table_body.=''.$table_Diagnosis_Head_Total.''; + $table_body.=''; + + $table_Diagnosis_Head_Total=0.00; + } + }else{ + $table_body.=''; + $table_body.=''; + $table_body.=''; + $table_body.=''; + $table_body.='Total of '.$Diagnosis_head.''; + $table_body.=''.$table_Diagnosis_Head_Total.''; + $table_body.=''; + + $table_Diagnosis_Head_Total=0.00; + } + + } + + + + } + + $table_footer=''; + $table_footer.='Total'; + $table_footer.=''; + $table_footer.=''; + $table_footer.=''; + $table_footer.=''.$table_Grand_Total.''; + $table_footer.=''; + + $data_show.=$table_start.$table_head.$table_body.$table_footer.$table_end; + + $content=$data_show; + $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"); + + } + + + + + + public function report_Diagnosis_total_cash($opd_date_range,$doc_id,$Diagnosis_id,$output=0) + { + $sql_f_all = "select m.refer_by_id,d.p_fname,t.item_id,t.item_type,m.refer_by_other, + y.group_desc,t.item_name,count(t.id) as No_test, + sum(t.item_qty) as No_qty,sum(t.item_amount) as Total_Amount, + Round(sum(t.item_amount*m.net_amount/m.total_amount),2) as net_total"; + + $sql_from=" from (invoice_master m join invoice_item t join hc_item_type y + on m.id=t.inv_master_id and t.item_type=y.itype_id and y.is_ipd_opd in (0,1)) + join doctor_master d on m.refer_by_id=d.id"; + + $sql_where=" Where m.payment_mode in (1,2) and m.payment_status=1 and m.invoice_status=1 and refer_by_id>0 "; + + $sql_group_by=" group by m.refer_by_id Asc ,t.item_type Asc,t.item_id Asc with rollup "; + + $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(m.inv_date) between Date('".$minRange."') and Date('".$maxRange. "')"; + }else{ + $sql_where.=" and m.inv_date between '".$minRange."' and '".$maxRange. "'"; + } + + $data_show='

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

'; + + if($doc_id>0) + { + $doc_id=str_replace('S',',',$doc_id); + + $sql_where.=" and m.refer_by_id in (".$doc_id.")"; + } + + if($Diagnosis_id>0) + { + $Diagnosis_id=str_replace('S',',',$Diagnosis_id); + $sql_where.=" and t.item_type in (".$Diagnosis_id.")"; + } + + $sql_order=" "; + + $table_body=''; + + $table_start=''; + $table_end='
'; + + $table_head=''; + $table_head.=''; + $table_head.=''; + $table_head.='Test Name'; + $table_head.='No. of Test'; + $table_head.='Amount (with Discount Amt.)'; + $table_head.=''; + + $table_footer=''; + + $query = $this->db->query($sql_f_all.$sql_from.$sql_where.' '.$sql_group_by.$sql_order); + $rowdata= $query->result(); + + for( $i = 0; $ip_fname.''; + $table_body.=''; + + $table_body.=''; + $table_body.=''; + $table_body.=''.$rowdata[$i]->group_desc.''; + $table_body.=''; + } + + if($rowdata[$i]->item_id==null) + { + if($rowdata[$i]->item_type==null) + { + if($rowdata[$i]->refer_by_id==null) + { + $table_body.=''; + $table_body.='Grand Total of All Doctors'; + $table_body.=''.$rowdata[$i]->net_total.''; + $table_body.=''; + }else{ + $table_body.=''; + $table_body.='Total of : Dr. '.$rowdata[$i]->p_fname.''; + $table_body.=''.$rowdata[$i]->net_total.''; + $table_body.=''; + + if(count($rowdata)>$i && $rowdata[$i+1]->refer_by_id !=null) + { + $table_body.=''; + $table_body.='Dr. '.$rowdata[$i+1]->p_fname.''; + $table_body.=''; + + $table_body.=''; + $table_body.=''; + $table_body.=''.$rowdata[$i+1]->group_desc.''; + $table_body.=''; + } + } + + }else{ + $table_body.=''; + $table_body.=''; + $table_body.='Total of :'.$rowdata[$i]->group_desc.''; + $table_body.=''.$rowdata[$i]->net_total.''; + $table_body.=''; + + if(count($rowdata)>$i && $rowdata[$i+1]->refer_by_id <>null) + { + $table_body.=''; + $table_body.=''; + $table_body.=''.$rowdata[$i+1]->group_desc.''; + $table_body.=''; + } + } + }else{ + $table_body.=''; + $table_body.=''; + $table_body.=''; + $table_body.=''.$rowdata[$i]->item_name.''; + $table_body.=''.$rowdata[$i]->No_qty.''; + $table_body.=''.$rowdata[$i]->net_total.''; + $table_body.=''; + } + } + + $data_show.=$table_start.$table_head.$table_body.$table_footer.$table_end; + + //echo $data_show; + + if($output==0) + { + $content=$data_show; + $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($data_show,'Diagnosis_Qty_cash'.date('Ymd')); + } + } + + + } \ No newline at end of file diff --git a/old_code_ci3/controllers/Report3.php b/old_code_ci3/controllers/Report3.php new file mode 100644 index 0000000..75af2f1 --- /dev/null +++ b/old_code_ci3/controllers/Report3.php @@ -0,0 +1,839 @@ +db->query($sql); + $data['doclist']= $query->result(); + + $sql="select * from h_insurance_group "; + $query = $this->db->query($sql); + $data['ins_group']= $query->result(); + + $sql="select * from hc_insurance order by short_name"; + $query = $this->db->query($sql); + $data['hc_insurance']= $query->result(); + + $this->load->view('Report/Report_IPD',$data); + } + + function ipd_report_2() + { + $sql="select * from doctor_master where active=1 order by p_fname"; + $query = $this->db->query($sql); + $data['doclist']= $query->result(); + + $sql="select * from h_insurance_group "; + $query = $this->db->query($sql); + $data['ins_group']= $query->result(); + + $sql="select * from hc_insurance order by short_name"; + $query = $this->db->query($sql); + $data['hc_insurance']= $query->result(); + + $this->load->view('Report/IPD_Current_List',$data); + } + + function ipd_report_3() + { + $sql="select * from doctor_master where active=1 order by p_fname"; + $query = $this->db->query($sql); + $data['doclist']= $query->result(); + + $sql="select * from h_insurance_group "; + $query = $this->db->query($sql); + $data['ins_group']= $query->result(); + + $this->load->view('Report/Report_medical',$data); + } + + function ipd_discharge($daterange,$doc_name_id,$ipd_type,$ipd_status,$ipd_date,$output=0) + { + $rangeArray = explode("S",$daterange); + $minRange = $rangeArray[0]; + $maxRange = $rangeArray[1]; + + $where =" 1=1 " ; + + $order_by=""; + + if($ipd_status>-1) + { + $where.=" and p.ipd_status=".$ipd_status; + } + + if($ipd_date==0) + { + $where.=" and date(p.register_date) between '".$minRange."' and '".$maxRange."' " ; + $order_by.=" p.id"; + }elseif($ipd_date==1) + { + $where.=" and date(p.discharge_date) between '".$minRange."' and '".$maxRange."' " ; + $order_by.=" p.discharge_date"; + } + + if($doc_name_id<>0) + { + $doc_array=explode("S",$doc_name_id); + $where.="and ( 1<>1 "; + foreach($doc_array as $row) + { + $where.=" OR FIND_IN_SET('".$row."',doc_list) "; + } + + $where.=")"; + } + + if($ipd_type>=1){ + $where.=" and group_ins=".$ipd_type." "; + }else if($ipd_type<0){ + $where.=" and insurance_id=".($ipd_type*-1)." "; + } + + + + $content=""; + + $sql="select p.ipd_code,p.p_fname,Date_Format(p.register_date,'%d-%m-%Y') as str_register_date,p_code, + Date_Format(p.discharge_date,'%d-%m-%Y') as str_discharge_date,p.admit_type,p.doc_name,p.status_desc, + p.charge_amount,p.package_charge_amount,p.med_amount,p.package_med_amount,p.chargeamount_all,p.Discount_all, + (p.charge_amount+p.med_amount+p.chargeamount_all-p.Discount_all) as net_Amount,p.paid_amount + from v_ipd_list p where ".$where." group by p.id order by $order_by"; + + //$content.= $sql; + $query = $this->db->query($sql); + $dischargelist= $query->result(); + + $total_paid_amount=0.00; + $total_net_amount=0.00; + + $content=""; + + $content.=''; + + $content.=' + + + + + + + + + + + + '; + + $sr_no=0; + foreach($dischargelist as $row) + { + $sr_no=$sr_no+1; + $content.=' + + + + + + + + + + '; + + $total_paid_amount+= $row->paid_amount; + $total_net_amount+= $row->net_Amount; + } + + $content.=' + + + + + + + + + + '; + + + $content.="
#IPD / UHID CodePerson NameAdmit /Discharge DateDoc. NameNet AmountPaid Amt.StatusTYPE
'.$sr_no.''.$row->ipd_code.'
'.$row->p_code.'
'.$row->p_fname.''.$row->str_register_date.'
'.$row->str_discharge_date.'
'.$row->doc_name.''.$row->net_Amount.''.$row->paid_amount.''.$row->status_desc.''.$row->admit_type.'
#'.$total_net_amount.''.$total_paid_amount.'
"; + 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,'IPD_List'); + } + + + + + } + + function ipd_discharge_details($daterange,$doc_name_id,$ipd_type,$ipd_status,$ipd_date,$output=0) + { + $rangeArray = explode("S",$daterange); + $minRange = $rangeArray[0]; + $maxRange = $rangeArray[1]; + + $where =" 1=1 " ; + $order_by=""; + + if($ipd_status>-1) + { + $where.=" and p.ipd_status=".$ipd_status; + } + + if($ipd_date==0) + { + $where.=" and p.register_date between '".$minRange."' and '".$maxRange."' " ; + $order_by.=" p.id"; + }elseif($ipd_date==1) + { + $where.=" and p.discharge_date between '".$minRange."' and '".$maxRange."' " ; + $order_by.=" p.discharge_date"; + } + + if($doc_name_id<>0) + { + $doc_array=explode("S",$doc_name_id); + $where.="and ( 1<>1 "; + foreach($doc_array as $row) + { + $where.=" OR FIND_IN_SET('".$row."',doc_list) "; + } + + $where.=")"; + } + + if($ipd_type>=1){ + $where.=" and group_ins=".$ipd_type." "; + }else if($ipd_type<0){ + $where.=" and insurance_id=".($ipd_type*-1)." "; + } + + + $sql="select p.ipd_code,p.P_mobile1,case_id_code,insurance_no,insurance_no_1,insurance_no_2,Org_insurance_comp,xgender,str_age, + p.p_fname,Date_Format(p.register_date,'%d-%m-%Y') as str_register_date,p.reg_time,p_code, + Date_Format(p.discharge_date,'%d-%m-%Y') as str_discharge_date,p.admit_type,p.doc_name,p.Bed_Desc, + p.charge_amount,p.package_charge_amount,p.med_amount,p.package_med_amount,p.chargeamount_all,p.Discount_all, + (p.charge_amount+p.med_amount+p.chargeamount_all-p.Discount_all) as net_Amount,p.paid_amount, + p.amount_recived,amount_deduction,p.org_approved_amount,status_desc + from v_ipd_list p where ".$where." group by p.id order by $order_by"; + + $query = $this->db->query($sql); + $dischargelist= $query->result(); + + $total_paid_amount=0.00; + $total_net_amount=0.00; + + $content=''; + + $content.=' + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + '; + + $sr_no=0; + foreach($dischargelist as $row) + { + $sr_no=$sr_no+1; + $content.=' + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + '; + $total_paid_amount+= $row->paid_amount; + $total_net_amount+= $row->net_Amount; + } + + $content.=' + + + + + + + + + + + + + + + + + + + + + + + + + + + + '; + + + $content.="
#IPD CodeP CodePerson NameGenderAgeCard No.Claim ID/Case IDClaim ID/Case IDAdmit DateAd. TimeDischarge DateDoc. NameCharge Amt.Medicine Amt.Other ChargeDiscountNet AmountPaid Amt.TPACase CodeInsuranceTPA Approved Amt.TPA Amt. Rec.TPA Amt. Ded.Pack. Amt.Pack. Med. Amt.Discharge Status
'.$sr_no.''.$row->ipd_code.''.$row->p_code.''.$row->p_fname.''.$row->xgender.''.$row->str_age.''.$row->insurance_no.''.$row->insurance_no_1.''.$row->insurance_no_2.''.$row->str_register_date.''.$row->reg_time.''.$row->str_discharge_date.''.$row->doc_name.''.$row->charge_amount.''.$row->med_amount.''.$row->chargeamount_all.''.$row->Discount_all.''.$row->net_Amount.''.$row->paid_amount.''.$row->admit_type.''.$row->case_id_code.''.$row->Org_insurance_comp.''.$row->org_approved_amount.''.$row->amount_recived.''.$row->amount_deduction.''.$row->package_charge_amount.''.$row->package_med_amount.''.$row->status_desc.'
#'.$total_net_amount.''.$total_paid_amount.'
"; + + //echo $content; + ExportExcel($content,'IPD_List'); + + } + + function ipd_discharge_medical($daterange,$doc_name_id,$ipd_type,$ipd_status,$ipd_date,$output=0) + { + $rangeArray = explode("S",$daterange); + $minRange = $rangeArray[0]; + $maxRange = $rangeArray[1]; + + $where =" (p.med_amount>0 or p.package_med_amount>0 )" ; + + if($ipd_status>-1) + { + $where.=" and p.ipd_status=".$ipd_status; + } + + if($ipd_date==0) + { + $where.=" and p.register_date between '".$minRange."' and '".$maxRange."' " ; + }elseif($ipd_date==1) + { + $where.=" and p.discharge_date between '".$minRange."' and '".$maxRange."' " ; + } + + if($doc_name_id>0) + { + $where.=" and FIND_IN_SET('".$doc_name_id."',doc_list) "; + } + + if($ipd_type>=1){ + $where.=" and group_ins=".$ipd_type." "; + }else if($ipd_type<0){ + $where.=" and insurance_id=".($ipd_type*-1)." "; + } + + $sql="select p.ipd_code,case_id_code,insurance_no,insurance_no_1,insurance_no_2,Org_insurance_comp, + p.p_fname,Date_Format(p.register_date,'%d-%m-%Y') as str_register_date,p_code, + Date_Format(p.discharge_date,'%d-%m-%Y') as str_discharge_date,p.admit_type,p.doc_name,p.Bed_Desc, + p.charge_amount,p.package_charge_amount,p.med_amount,p.package_med_amount,p.chargeamount_all,p.Discount_all, + (p.charge_amount+p.med_amount+p.chargeamount_all-p.Discount_all) as net_Amount,p.paid_amount, + p.amount_recived,amount_deduction,p.org_approved_amount + from v_ipd_list p where ".$where." group by p.id order by id"; + + $query = $this->db->query($sql); + $dischargelist= $query->result(); + + $total_med_amount=0.00; + $package_med_amount=0.00; + $total_net_amount=0.00; + + $content="

Date(YYYY-MM-DD) between ".$minRange." and ".$maxRange."

"; + + $content.=''; + + $content.=' + + + + + + + + + '; + + $sr_no=0; + foreach($dischargelist as $row) + { + $sr_no=$sr_no+1; + $content.=' + + + + + + + + + '; + $total_med_amount+= $row->med_amount; + $package_med_amount+= $row->package_med_amount; + $total_net_amount+= $row->net_Amount; + } + + $content.=' + + + + + + + + + '; + + $med_cr_amt=$package_med_amount+$total_med_amount; + + $content.=' + + + + + '; + + $content.="
#IPD CodePerson NameTPANet AmountMedicine Amt.Medicine Pack. Amt.Doc. Name
'.$sr_no.''.$row->ipd_code.''.$row->p_fname.''.$row->admit_type.''.$row->net_Amount.''.$row->med_amount.''.$row->package_med_amount.''.$row->doc_name.'
#'.$total_net_amount.''.$total_med_amount.''.$package_med_amount.'
#Total Medical Cr. Amount'.$med_cr_amt.'
"; + + if($output==0) + { + + $this->load->library('m_pdf'); + + $file_name="Report-Medical_".date('Ymdhis').".pdf"; + $filepath=$file_name; + $this->m_pdf->pdf->WriteHTML($content); + $this->m_pdf->pdf->Output($filepath,"I"); + + }else{ + + ExportExcel($content,'IPD_Medical_List'); + } + + } + + + function ipd_current($doc_name_id,$ipd_type,$sortorder,$output=0) + { + + $where =" p.ipd_status=0 " ; + + if($doc_name_id>0) + { + $where.=" and FIND_IN_SET('".$doc_name_id."',doc_list) "; + } + + if($ipd_type>=1){ + $where.=" and group_ins=".$ipd_type." "; + }else if($ipd_type<0){ + $where.=" and insurance_id=".($ipd_type*-1)." "; + } + + $orderby=" Order By "; + + if($sortorder==0) + { + $orderby.=" p.id"; + }elseif($sortorder==1) + { + $orderby.=" p.register_date"; + }elseif($sortorder==2) + { + $orderby.=" p.p_fname"; + }else{ + $orderby.=" p.Bed_Desc"; + } + + $sql="select p.ipd_code,p.p_fname,Date_Format(p.register_date,'%d-%m-%Y') as str_register_date, + Date_Format(p.discharge_date,'%d-%m-%Y') as str_discharge_date,p.admit_type,p.doc_name,p.Bed_Desc, + charge_amount,paid_amount,p.app_status,p.color,p.org_approved_amount,p.net_amount, + p.balance_amount,no_days + from v_ipd_list p where ".$where." group by p.id ".$orderby; + + $query = $this->db->query($sql); + $dischargelist= $query->result(); + + $content=''; + + $content.=' + + + + + + + + + + + + + + '; + + $sr_no=0; + foreach($dischargelist as $row) + { + $sr_no=$sr_no+1; + $content.=' + + + + + + + + + + + + + + '; + } + + $content.="
#IPD CodePerson NameBed NoAdmit DateNo.DaysDoc. NameTYPEOrg. StatusApp. Amt.Bill Amt.Bal. Amt.Paid Amt.
'.$sr_no.''.$row->ipd_code.''.$row->p_fname.''.$row->Bed_Desc.''.$row->str_register_date.'
'.$row->str_discharge_date.'
'.$row->no_days.''.$row->doc_name.''.$row->admit_type.''.$row->app_status.''.$row->org_approved_amount.''.$row->net_amount.''.$row->balance_amount.''.$row->paid_amount.'
"; + + if($output==0) + { + echo $content; + }else{ + + ExportExcel($content,'Current_IPD_List'+date('Ymdhis')); + } + + + } + function report_Diagnosis_Qty_main() + { + $sql="select * from hc_item_type where is_ipd_opd in (0,1)"; + $query = $this->db->query($sql); + $data['item_type_list']= $query->result(); + + $this->load->view('Report3/diagnosis_qty',$data); + } + + + function report_Diagnosis_Qty_total($opd_date_range,$Diagnosis_id,$output=0) + { + $sql_field="select t.item_type,y.group_desc,t.item_name, + sum(t.item_qty) as t_item_qty, + sum(t.item_amount) as item_amount, + sum(Round(t.item_amount*(1-m.discount_amount/m.total_amount))) as item_amount_net + from (invoice_item t join invoice_master m + on m.id=t.inv_master_id) join hc_item_type y on t.item_type=y.itype_id "; + + $sql_where=" where m.invoice_status=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(m.inv_date) between Date('".$minRange."') and Date('".$maxRange. "')"; + }else{ + $sql_where.=" and m.inv_date between '".$minRange."' and '".$maxRange. "'"; + } + + if($Diagnosis_id>0) + { + $Diagnosis_id=str_replace('S',',',$Diagnosis_id); + + $sql_where.=" and t.item_type in (".$Diagnosis_id.") "; + } + + $data_show='

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

'; + + $sql_group=" group by t.item_type,t.item_id order by t.item_type"; + + $sql=$sql_field.$sql_where.$sql_group; + + $query = $this->db->query($sql); + $Diagnosis_Data= $query->result(); + + $content=''; + + $content.=' + + + + + + + '; + + $sr_no=0; + $item_amount=0; + $item_amount_net=0; + + foreach($Diagnosis_Data as $row) + { + $sr_no=$sr_no+1; + $item_amount+=$row->item_amount; + $item_amount_net+=$row->item_amount_net; + $content.=' + + + + + + + '; + } + $content.=' + + + + + + + '; + + $content.="
#Diagnosis GroupDiagnosisQtyAmountNet Amount
'.$sr_no.''.$row->group_desc.''.$row->item_name.''.$row->t_item_qty.''.$row->item_amount.''.$row->item_amount_net.'
#Total'.$item_amount.''.$item_amount_net.'
"; + + 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,'Diagnosis_Qty'.date('Ymd')); + } + + } + + function ipd_item_reports() + { + $sql="select * from doctor_master where active=1 order by p_fname"; + $query = $this->db->query($sql); + $data['doclist']= $query->result(); + + $sql="select * from ipd_item_type order by 'desc'"; + $query = $this->db->query($sql); + $data['item_type_list']= $query->result(); + + $this->load->view('Report/Report_medical',$data); + } + + function ipd_item_reports_data($daterange,$Diagnosis_id,$doc_name_id,$ipd_status,$output=0) + { + $rangeArray = explode("S",$daterange); + $minRange = $rangeArray[0]; + $maxRange = $rangeArray[1]; + + $where =" 1=1 " ; + + $order_by=" i.id"; + + if($ipd_status>-1) + { + $where.=" and i.ipd_status=".$ipd_status; + } + + if($Diagnosis_id>0) + { + $Diagnosis_id=str_replace('S',',',$Diagnosis_id); + + $where.=" and t.item_type in (".$Diagnosis_id.") "; + } + + if($doc_name_id>0) + { + $doc_list=str_replace("S",",",$doc_name_id); + + $where.=" and t.doc_id in ($doc_list)"; + } + + $where.=" and date(i.register_date) between '".$minRange."' and '".$maxRange."' " ; + + $sql="SELECT i.id,i.ipd_code,i.p_fname,date_format(i.register_date,'%d-%m-%Y') AS register_date_str, + DATE_FORMAT(i.discharge_date,'%d-%m-%Y') AS discharge_date_str,i.doc_name as ipd_doc_name, + t.item_name,t.item_rate,t.item_qty,t.item_amount,t.doc_name,t.doc_id, + ROUND(t.item_amount-(t.item_amount*((i.Discount_all)/(i.net_amount+i.Discount_all)))) AS Aft_Amt, + ROUND(((i.Discount_all*100)/(i.net_amount+i.Discount_all)),2) AS Dis_per + FROM v_ipd_list i JOIN ipd_invoice_item t ON i.id=t.ipd_id + Where $where Order By $order_by"; + $query = $this->db->query($sql); + $data['ipd_item_data']= $query->result(); + + + $content=$this->load->view('Report/Report_medical_template',$data,true); + + //echo $content; + + 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,'IPD_List'); + } + + + } + + + function ipd_item_refer_reports() + { + $sql="select * from refer_master where active=1 order by f_name"; + $query = $this->db->query($sql); + $data['refer_master']= $query->result(); + + $sql="select * from ipd_item_type order by 'desc'"; + $query = $this->db->query($sql); + $data['item_type_list']= $query->result(); + + $this->load->view('Report/Report_refer_ipd',$data); + } + + function ipd_item_refer_reports_data($daterange,$refer_id,$ipd_status,$output=0) + { + $rangeArray = explode("S",$daterange); + $minRange = $rangeArray[0]; + $maxRange = $rangeArray[1]; + + $where =" 1=1 " ; + + $order_by=" i.id"; + + if($ipd_status>-1) + { + $where.=" and i.ipd_status=".$ipd_status; + } + + if($refer_id>0) + { + $refer_list=str_replace("S",",",$refer_id); + + $where.=" and r.refer_by in ($refer_list)"; + } + + $where.=" and date(i.register_date) between '".$minRange."' and '".$maxRange."' " ; + + $sql="SELECT i.id,i.ipd_code,i.p_fname,date_format(i.register_date,'%d-%m-%Y') AS register_date_str, + DATE_FORMAT(i.discharge_date,'%d-%m-%Y') AS discharge_date_str, + i.doc_name as ipd_doc_name, i.net_amount,i.balance_amount, m.title,m.f_name,r.refer_type,t.type_desc + FROM ((v_ipd_list i JOIN ipd_refer r ON i.id=r.ipd_id) JOIN refer_type t ON r.refer_type=t.id) + JOIN refer_master m ON r.refer_by=m.id + Where $where Order By $order_by"; + $query = $this->db->query($sql); + $data['ipd_refer_data']= $query->result(); + + + $content=$this->load->view('Report/Report_refer_template',$data,true); + + //echo $content; + + 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,'IPD_List'); + } + + + } + +} diff --git a/old_code_ci3/controllers/Report4.php b/old_code_ci3/controllers/Report4.php new file mode 100644 index 0000000..a307f9b --- /dev/null +++ b/old_code_ci3/controllers/Report4.php @@ -0,0 +1,261 @@ +db->query($sql); + $data['ins_group']= $query->result(); + + $sql="select * from hc_insurance order by short_name "; + $query = $this->db->query($sql); + $data['hc_insurance']= $query->result(); + + $this->load->view('Report3/ECHS_IPD',$data); + } + + function echs_opd_list_main() + { + $sql="select * from h_insurance_group "; + $query = $this->db->query($sql); + $data['ins_group']= $query->result(); + + $sql="select * from hc_insurance order by short_name "; + $query = $this->db->query($sql); + $data['hc_insurance']= $query->result(); + + $this->load->view('Report3/ECHS_OPD',$data); + } + + function echs_ipd_list_data($daterange,$org_status,$ipd_type,$output=0) + { + $rangeArray = explode("S",$daterange); + $minRange = $rangeArray[0]; + $maxRange = $rangeArray[1]; + + $where =" 1=1 " ; + + $where.=" and p.ipd_status=1"; + + if($org_status>=0) + { + $where.=" and p.status=".$org_status; + } + + $where.=" and p.register_date between '".$minRange."' and '".$maxRange."' " ; + + if($ipd_type>0){ + $where.=" and group_ins=".$ipd_type." "; + }elseif($ipd_type<0){ + $where.=" and insurance_id=".($ipd_type*-1)." "; + } + + + $sql="select p.ipd_code,p.p_fname,Date_Format(p.register_date,'%d-%m-%Y') as str_register_date,p_code, + Date_Format(p.discharge_date,'%d-%m-%Y') as str_discharge_date,p.admit_type,p.doc_name,p.Bed_Desc, + charge_amount,paid_amount,p.org_submit_status,p.status, + concat(p.insurance_no,'/',p.insurance_no_1) as case_info, + p.med_amount,p.Discount_all,p.chargeamount_all,p.insurance_id,p.ins_company_name, + p.amount_recived,p.amount_deduction,p.app_status,p.color, + (p.charge_amount+p.med_amount+p.chargeamount_all-p.Discount_all) as net_total + from v_ipd_list p where ".$where." group by p.p_id,p.doc_list order by id"; + + //echo $sql; + + $query = $this->db->query($sql); + $dischargelist= $query->result(); + + $total_Payment=0.00; + + $content=''; + + $content.=' + + + + + + + + + + + + + + '; + $sr_no=0; + foreach($dischargelist as $row) + { + $sr_no=$sr_no+1; + $content.=' + + + + + + + + + + + + + + '; + $total_Payment+= $row->net_total; + } + + $content.=' + + + + + + + + + + + '; + + $content.="
#Case Info.IPD CodeP CodePerson NameOrg. StatusAdmit DateDischarge DateOrg NameDoc. NameNet Amt.Amt ReceivedAmt Deduct
'.$sr_no.''.$row->case_info.''.$row->ipd_code.''.$row->p_code.''.$row->p_fname.''.$row->org_submit_status.''.$row->str_register_date.''.$row->str_discharge_date.''.$row->ins_company_name.''.$row->doc_name.''.$row->net_total.''.$row->amount_recived.''.$row->amount_deduction.'
#Total'.$total_Payment.'
"; + + if($output==0) + { + //echo $content; + //create_report_pdf_landscape($content,'ECHS_IPD_List'.date('Yms')); + $this->load->library('m_pdf'); + + $file_name="Report-ECHS_IPD_List_".date('Ymdhis').".pdf"; + $filepath=$file_name; + $this->m_pdf->pdf->WriteHTML($content); + $this->m_pdf->pdf->Output($filepath,"I"); + + + }else{ + ExportExcel($content,'ECHS_IPD_List'.date('Yms')); + } + + } + + function echs_opd_list_data($daterange,$org_status,$ipd_type,$output=0) + { + $rangeArray = explode("S",$daterange); + $minRange = $rangeArray[0]; + $maxRange = $rangeArray[1]; + + $where =" 1=1 " ; + + if($org_status>=0) + { + $where.=" and o.status=".$org_status; + } + + $where.=" and o.date_registration between '".$minRange."' and '".$maxRange."' " ; + + if($ipd_type>0){ + $where.=" and in_master.id=".$ipd_type." "; + }elseif($ipd_type<0){ + $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, + `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, + o.inv_opd_med_amt as med_net_amount, + o.date_registration,date_format(o.date_registration,'%d-%m-%Y') as str_date_registration + from (organization_case_master o join patient_master p on o.p_id=p.id and o.case_type=0) + join hc_insurance as in_master on in_master.id = o.insurance_id + 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; + + $query = $this->db->query($sql); + $dischargelist= $query->result(); + + $total_Payment=0.00; + $total_Med_Payment=0.00; + + $content=''; + + $content.=' + + + + + + + + + + + '; + + $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.=' + + + + + + + + + + + '; + $total_Payment+= $row->Charge_amount; + $total_Med_Payment+= $row->med_net_amount; + $total_net_amount+= $net_amount; + + } + $content.=' + + + + + + + + + + + '; + + $content.="
#Bill No.Case Info.Org. CodeUHIDPerson NameDateCharge Amt.Med. Amt.Net Amt.
'.$sr_no.''.$row->id.''.$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.''.$total_Med_Payment.''.$total_net_amount.'
"; + + if($output==0) + { + //echo $content; + //create_report_pdf_landscape($content,'ECHS_OPD_List'.date('Yms')); + $this->load->library('m_pdf'); + + $file_name="Report-ECHS_OPD_List_".date('Ymdhis').".pdf"; + $filepath=$file_name; + $this->m_pdf->pdf->WriteHTML($content); + $this->m_pdf->pdf->Output($filepath,"I"); + }else{ + ExportExcel($content,'ECHS_OPD_List'.date('Yms')); + } + + } + + + +} + +/* 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/Report5.php b/old_code_ci3/controllers/Report5.php new file mode 100644 index 0000000..f27d3e9 --- /dev/null +++ b/old_code_ci3/controllers/Report5.php @@ -0,0 +1,393 @@ +db->query($sql); + $data['doclist']= $query->result(); + + $this->load->view('Report5/Report_Document',$data); + } + + function document_list_data($daterange,$dr_id,$output=0) + { + $rangeArray = explode("S",$daterange); + $minRange = $rangeArray[0]; + $maxRange = $rangeArray[1]; + + $where =" 1=1 " ; + + if($dr_id>0) + { + $where.=" and doc.id =".$dr_id; + } + + $where.=" and d.date_issue between '".$minRange."' and '".$maxRange."' " ; + + $sql="SELECT p.id,p.p_fname,p.p_rname,p.p_relative,p.p_code, + d.doc_subject,d.date_issue,date_format(d.date_issue,'%d-%m-%Y') AS str_date_issue, + d.id AS Doc_id,f.doc_name, + doc.p_fname AS dr_name,doc.id AS dr_id + FROM ((patient_master_exten p JOIN patient_doc d ON p.id=d.p_id) + JOIN doctor_master doc ON d.dr_id=doc.id) + Join doc_format_master f ON d.doc_format_id=f.df_id where ".$where." "; + + //echo $sql; + + $query = $this->db->query($sql); + $doclist= $query->result(); + + $content=''; + + $content.=' + + + + + + + + '; + $sr_no=0; + foreach($doclist as $row) + { + $sr_no=$sr_no+1; + $content.=' + + + + + + + + '; + } + + $content.=' + + + + + + + + '; + + $content.="
#Doc. IDPerson Name / Relative NamePCode/UHIDDoctor NameIssue DateDocument Name
'.$sr_no.''.$row->Doc_id.''.$row->p_fname.'{'.$row->p_relative.' '.$row->p_rname.'}'.$row->p_code.''.$row->dr_name.''.$row->str_date_issue.''.$row->doc_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,'document_List'.date('Yms')); + } + + } + + // 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() + { + $this->load->view('Report5/Report_corona_suspected'); + } + + function corona_suspected_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.corona_suspected=1 ".$where." "; + + //echo $sql; + + $query = $this->db->query($sql); + $doclist= $query->result(); + + $content='

'.H_Name.'

'; + $content.='

'.H_address_1.'

'; + + $content.='

Corona Suspected 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,'corona_suspected'.date('Yms')); + } + } + + // 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() + { + $this->load->view('Report5/Report_dengue'); + } + + function dengue_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.dengue=1 ".$where." "; + + //echo $sql; + + $query = $this->db->query($sql); + $doclist= $query->result(); + + $content='

'.H_Name.'

'; + $content.='

'.H_address_1.'

'; + + $content.='

Dengue Patient 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,'dengue_data'.date('Yms')); + } + } + + +} + \ No newline at end of file diff --git a/old_code_ci3/controllers/Report6.php b/old_code_ci3/controllers/Report6.php new file mode 100644 index 0000000..de0b464 --- /dev/null +++ b/old_code_ci3/controllers/Report6.php @@ -0,0 +1,119 @@ +'ULTRASOUND', + '2'=>'MRI', + '3'=>'X-RAY', + '4'=>'CT SCAN', + '5'=>'PATHOLOGY ', + ); + + $this->load->view('Report6/Report_Lab_Log',$data); + } + + + + function lab_log_data($daterange,$lab_type,$output=0) + { + $rangeArray = explode("S",$daterange); + $minRange = $rangeArray[0]; + $maxRange = $rangeArray[1]; + + $where =" 1=1 " ; + + if($lab_type>0) + { + $where.=" and r.lab_type =".$lab_type; + } + + $where.=" and l.log_insert_time between '".$minRange."' and '".$maxRange."' " ; + + $sql="SELECT l.*,r.invoice_code,r.patient_name,r.lab_type + FROM lab_log l JOIN lab_request r ON l.lab_repo_id=r.id + WHERE ".$where." "; + + //echo $sql; + + $query = $this->db->query($sql); + $doclist= $query->result(); + + $lab_type_data=array( + '1'=>'ULTRASOUND', + '2'=>'MRI', + '3'=>'X-RAY', + '4'=>'CT SCAN', + '5'=>'PATHOLOGY ', + ); + $content="Data Between from ".$minRange."' to '".$maxRange."' " ; + + $content.=''; + + $content.=' + + + + + + + + + + '; + $sr_no=0; + foreach($doclist as $row) + { + $sr_no=$sr_no+1; + $content.=' + + + + + + + + + + '; + } + + $content.=' + + + + + + + + + + '; + + $content.="
#LabDate TimeInvoice /Lab No.Person NameLog TypeLog FaultsUpdateByRemark/Comment
'.$sr_no.''.$lab_type_data[$row->lab_type].''.$row->log_insert_time.''.$row->invoice_code.''.$row->patient_name.''.$row->log_type.''.$row->log_Faults.''.$row->log_by.''.$row->comments.'
#LabDate TimeInvoice /Lab No.Person NameLog TypeLog FaultsUpdateByRemark/Comment
"; + + 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,'document_List'.date('Yms')); + } + + } + + + + +} + \ No newline at end of file diff --git a/old_code_ci3/controllers/ReportPanel2.php b/old_code_ci3/controllers/ReportPanel2.php new file mode 100644 index 0000000..58db238 --- /dev/null +++ b/old_code_ci3/controllers/ReportPanel2.php @@ -0,0 +1,1998 @@ +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,IFNULL(GET_AGE_BY_DOB(dob),age) 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'); + + //============================================================+ + // 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.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->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) + { + $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>0) + { + if($paymode_id==1) + { + $sql_where.=" and p.payment_mode in (1,3) "; + }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_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>0) + { + if($paymode_id==1) + { + $sql_where.=" and p.payment_mode in (1,3) "; + }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) + { + $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>0) + { + if($paymode_id==1) + { + $sql_where.=" and p.payment_mode in (1,3) "; + }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'; + } + + //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.='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=''; + + // Add a page + // This method has several options, check the source code documentation for more information. + $pdf->AddPage(); + + //echo $sql_f_all.$sql_from.$sql_where.' '.$sql_group_by.$sql_order; + + + $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; + + //echo $data_show; + + // 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 + //============================================================+ + } + + +} + +/* 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/Room_bed.php b/old_code_ci3/controllers/Room_bed.php new file mode 100644 index 0000000..bc4aa9b --- /dev/null +++ b/old_code_ci3/controllers/Room_bed.php @@ -0,0 +1,57 @@ +load->database(); + } + + public function index() + { + $sql="SELECT b.* ,v.p_fname,v.p_relative,v.p_rname,v.doc_name,v.ipd_code,v.p_code,v.admit_type + From hc_bed_master b left JOIN v_ipd_list v ON b.bed_used_p_id=v.id"; + $query = $this->db->query($sql); + $data['bed_master']= $query->result(); + + $this->load->view('IPD/Bed_panel',$data); + } + + public function ipd_list() + { + $sql="select * from v_ipd_list where ipd_status=0"; + + $query = $this->db->query($sql); + $ipd_bed_list= $query->result(); + + + } + + public function get_admit_ipd_list(){ + + if (isset($_GET['term'])){ + $q = strtolower($_GET['term']); + + $sql="SELECT * + from v_ipd_list + where ipd_status=0 and + (p_fname LIKE '$q%' or p_code like '%$q' or ipd_code like '%$q') + order BY p_fname "; + + $query = $this->db->query($sql); + + if($query->num_rows() > 0){ + foreach ($query->result_array() as $row){ + $new_row['label']=htmlentities(stripslashes($row['ipd_code'])).' | '.htmlentities(stripslashes($row['p_fname'])).' | '.htmlentities(stripslashes($row['str_register_date'])); + $new_row['value']=htmlentities(stripslashes($row['id'])); + + $row_set[] = $new_row; //build an array + } + echo json_encode($row_set); //format the array into json data + } + } + } + +} +?> \ No newline at end of file diff --git a/old_code_ci3/controllers/Setting.php b/old_code_ci3/controllers/Setting.php new file mode 100644 index 0000000..a028125 --- /dev/null +++ b/old_code_ci3/controllers/Setting.php @@ -0,0 +1,16 @@ +load->view('setting/setting_main'); + } + +} diff --git a/old_code_ci3/controllers/Stock.php b/old_code_ci3/controllers/Stock.php new file mode 100644 index 0000000..bd3b07a --- /dev/null +++ b/old_code_ci3/controllers/Stock.php @@ -0,0 +1,1250 @@ +load->view('Medical/Stock/indent_request'); + } + + public function Indent_Request_Search() + { + $sdata=$this->input->post('txtsearch'); + + $sdata = preg_replace('/[^A-Za-z0-9_ \-]/', '', $sdata); + + if(trim($sdata)=='') + { + $sql=" SELECT m.indent_id,m.indent_code,s.store_name, + m.request_status,m.created_date, + GROUP_CONCAT(t.product_name) AS product_list, + i.indent_id AS process_indent_id, + (case m.request_status + when 0 then 'Pending' + when 1 then 'Send To Store' + when 2 then 'Accept and Process' + when 3 then 'Processed and Verification Pending' + when 4 then concat('Send to Counter :',s.store_name) + when 5 then concat('Accept By Counter :',s.store_name) + else 'UnKnown' end) as request_status_str, + (case m.indent_type when 0 then 'Auto' when 1 then 'By Counter Store' when 2 then 'Main Store' else 'UnKnown' end) as indent_request_type_str + FROM (((med_indent_request m Left JOIN med_indent_request_items t ON m.indent_id=t.indent_id) + JOIN med_product_master p ON t.product_id=p.id) + JOIN store_master s ON m.store_id=s.store_id) + LEFT JOIN med_indent_process i ON m.indent_id=i.indent_id + where m.request_status >0 and m.indent_type in (0,1) + GROUP BY m.indent_id order by m.indent_id desc limit 50"; + }else{ + $sql=" SELECT m.indent_id,m.indent_code,s.store_name, + m.request_status,m.created_date, + GROUP_CONCAT(t.product_name) AS product_list, + i.indent_id AS process_indent_id, + (case m.request_status + when 0 then 'Pending' + when 1 then 'Send To Store' + when 2 then 'Accept and Process' + when 3 then 'Processed and Verification Pending' + when 4 then concat('Send to Counter :',s.store_name) + when 5 then concat('Accept By Counter :',s.store_name) + else 'UnKnown' end) as request_status_str, + (case m.indent_type when 0 then 'Auto' when 1 then 'By Counter Store' when 2 then 'Main Store' else 'UnKnown' end) as indent_request_type_str + FROM (((med_indent_request m Left JOIN med_indent_request_items t ON m.indent_id=t.indent_id) + JOIN med_product_master p ON t.product_id=p.id) + JOIN store_master s ON m.store_id=s.store_id) + LEFT JOIN med_indent_process i ON m.indent_id=i.indent_id + WHERE t.product_name LIKE '%".$sdata."%' OR m.indent_code LIKE '%".$sdata."' + and m.request_status >0 and m.indent_type in (0,1) + GROUP BY m.indent_id order by m.indent_id desc limit 50"; + } + + $query = $this->db->query($sql); + $data['indent_req_list']= $query->result(); + + $this->load->view('Medical/Stock/indent_request_search_result',$data); + } + + + public function indent_request_item_store_list_view($indent_id) + { + $sql="SELECT m.*,s.store_name + from med_indent_request m JOIN store_master s ON m.store_id=s.store_id + where m.indent_id=".$indent_id; + $query = $this->db->query($sql); + $data['med_indent_request']= $query->result(); + + $sql="SELECT t.*,p.item_name,p.formulation,p.genericname,p.packing + FROM ((med_indent_request m JOIN med_indent_request_items t ON m.indent_id=t.indent_id) + JOIN med_product_master p ON t.product_id=p.id) + WHERE m.indent_id=".$indent_id; + $query = $this->db->query($sql); + $data['med_indent_request_items']= $query->result(); + + $data['indent_status_cont']=array( + 'Pending','Send to Store','Accept By Store','Processing Items','Send to Counter','Accept By Counter' + ); + + $this->load->view('Medical/Stock/indent_req_view_with_store',$data); + } + + public function indent_issue_items($indent_id) + { + $sql="SELECT m.*,s.store_name + from med_indent_request m JOIN store_master s ON m.store_id=s.store_id + where m.indent_id=".$indent_id; + $query = $this->db->query($sql); + $data['med_indent_request']= $query->result(); + + $sql="select * from med_indent_process where indent_id=".$indent_id; + $query = $this->db->query($sql); + $data['med_indent_process']= $query->result(); + + $sql="SELECT t.*,p.item_name,p.formulation,p.genericname,p.packing + FROM ((med_indent_request m JOIN med_indent_request_items t ON m.indent_id=t.indent_id) + JOIN med_product_master p ON t.product_id=p.id) + WHERE m.indent_id=".$indent_id; + $query = $this->db->query($sql); + $data['med_indent_request_items']= $query->result(); + + $data['indent_status_cont']=array( + 'Pending','Send to Store','Accept By Store','Processing Items','Send to Counter','Accept By Counter' + ); + + $this->load->view('Medical/Stock/indent_issue_items',$data); + + } + + public function indent_issue_items_view($indent_id) + { + $sql="SELECT m.*,s.store_name + from med_indent_request m JOIN store_master s ON m.store_id=s.store_id + where m.indent_id=".$indent_id; + $query = $this->db->query($sql); + $data['med_indent_request']= $query->result(); + + $sql="select * from med_indent_process where indent_id=".$indent_id; + $query = $this->db->query($sql); + $data['med_indent_process']= $query->result(); + + $data['indent_status_cont']=array( + 'Pending','Send to Store','Accept By Store','Processing Items','Send to Counter','Accept By Counter' + ); + + $this->load->view('Medical/Stock/indent_issue_item_view',$data); + + } + + public function indent_issue_items_sub($indent_id,$indent_view=0) + { + $sql="SELECT t.*,p.item_name,p.formulation,p.genericname,p.packing ,SUM(a.qty) AS issued_qty + FROM ((med_indent_request m JOIN med_indent_request_items t ON m.indent_id=t.indent_id) + JOIN med_product_master p ON t.product_id=p.id) + LEFT JOIN med_indent_process_items a ON m.indent_id=a.indent_id AND t.id=a.indent_item_id + WHERE m.indent_id=".$indent_id." GROUP BY m.indent_id,t.id"; + + $query = $this->db->query($sql); + $med_indent_request_items= $query->result(); + + $srno=0; + $content=' + + + + + + + + '; + foreach($med_indent_request_items as $row) + { + $srno=$srno+1; + $content.= ''; + $content.= ''; + if($indent_view==0) + { + $content.= ''; + }else{ + $content.= '';; + } + + $content.= ''; + $content.= ''; + $content.= ''; + $content.= ''; + $content.= ''; + } + + $content.=' + + + + + + + +
#Item NameFormulationQty.Min QtyIssued Qty
'.$srno.''.$row->item_name.''.$row->item_name.''.$row->formulation.''.$row->request_qty.''.$row->min_requirement.''.$row->issued_qty.'
#Item NameFormulationQty.Min QtyIssued Qty
'; + echo $content; + } + + + public function indent_issue_items_stock($product_id,$indent_id,$indent_item_id) + { + $sql="SELECT s.id,s.purchase_id,s.Item_name,s.batch_no,s.expiry_date,s.tqty,i.qty as issue_item,i.store_stock_id + FROM (purchase_invoice_item s JOIN med_product_master p ON s.item_code=p.id) + LEFT JOIN med_indent_process_items i ON i.ssno=s.id + AND i.indent_id=".$indent_id." AND i.indent_item_id=".$indent_item_id." WHERE s.item_code=".$product_id; + + $query = $this->db->query($sql); + $data['stock_list']= $query->result(); + + $data['product_id']=$product_id; + $data['indent_id']=$indent_id; + $data['indent_item_id']=$indent_item_id; + + $this->load->view('Medical/Stock/indent_stock_list',$data); + + } + + public function indent_process_update_Qty() + { + if (!$this->input->is_ajax_request()) { exit('no valid req.'); } + + $this->load->model('product_master_M'); + + + $product_id=$this->input->post('hid_product_id'); + $indent_id=$this->input->post('hid_indent_id'); + $indent_item_id=$this->input->post('hid_indent_item_id'); + + $ssno=$this->input->post('pur_item_id'); + $qty_issue=$this->input->post('qty_issue'); + + $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'); + + $sql="select * from med_indent_process where indent_id=".$indent_id; + $query = $this->db->query($sql); + $med_indent_process= $query->result(); + + if(count($med_indent_process)<1) + { + $Pdata = array( + 'store_accept_time' => date('d-m-Y H:i:s'), + 'store_accept_by' => $user_id, + 'store_accept_by_name' => $user_name_info, + 'indent_id' => $indent_id, + 'indent_process_status' =>0, + 'verify_status'=>0, + ); + $inser_id=$this->product_master_M->insert_med_indent_process($Pdata); + } + + $Pdata = array( + 'indent_id' => $indent_id, + 'indent_item_id' => $indent_item_id, + 'product_id' => $product_id, + 'qty' => $qty_issue, + 'ssno' => $ssno + ); + + $sql="select * from med_indent_process_items + where indent_id=".$indent_id." and + indent_item_id=".$indent_item_id." + and product_id=".$product_id." and ssno=".$ssno; + $query = $this->db->query($sql); + $med_indent_process_items= $query->result(); + + //echo $sql; + + if(count($med_indent_process_items)>0) + { + $indent_process_item_id=$med_indent_process_items[0]->id; + $this->product_master_M->update_med_indent_process_items($Pdata,$indent_process_item_id); + }else{ + $inser_id=$this->product_master_M->insert_med_indent_process_items($Pdata); + } + + $rvar=array( + 'is_update_stock' =>1, + 'show_text'=>'Updated' + ); + + $encode_data = json_encode($rvar); + echo $encode_data; + + } + + function indent_process_items_list($indent_id) + { + $sql="SELECT i.indent_id,i.id AS request_item_id,t.id AS process_item_id,i.product_name,t.ssno,p.batch_no,p.expiry_date,i.request_qty, + SUM(t.qty) AS t_qty + FROM ((med_indent_process m join med_indent_process_items t ON m.indent_id=t.indent_id) + JOIN med_indent_request_items i ON m.indent_id=i.indent_id AND i.id=t.indent_item_id) + JOIN purchase_invoice_item p ON t.ssno=p.id + where i.indent_id=".$indent_id." + GROUP BY i.indent_id,i.id,t.id WITH rollup"; + $query = $this->db->query($sql); + $med_indent_process_items= $query->result(); + + $content='
'; + + $content.="

Issued Items

"; + + $content.=' + + + + + + '; + $srno=0; + $header_name=""; + foreach($med_indent_process_items as $row) + { + if($row->indent_id=='') + { + + }elseif($row->request_item_id==''){ + + }elseif($row->process_item_id==''){ + $content.=' '; + $content.= ''; + $content.= ''; + $content.= ''; + $content.= ''; + }else{ + if($header_name!=$row->product_name) + { + $content.=' '; + $content.= ''; + $content.= ''; + $content.= ''; + } + + $header_name=$row->product_name; + + $srno=$srno+1; + $content.=' '; + $content.= ''; + $content.= ''; + $content.= ''; + $content.= ''; + $content.= ''; + } + } + + $content.= '
#Batch No.Expiry DateIssued Qty.
Item Name : Total Qty of '.$row->product_name.''.$row->t_qty.'
'.$row->product_name.'
'.$srno.''.$row->batch_no.''.$row->expiry_date.''.$row->t_qty.'
'; + + $content.= '
'; + $content.='
'; + $content.='
+ +
'; + $content.= '
'; + echo $content; + + } + + //indent Accept By Store + + function indent_store_accept_items_list($indent_id) + { + $sql="SELECT m.*,s.store_name + from med_indent_request m JOIN store_master s ON m.store_id=s.store_id + where m.indent_id=".$indent_id; + $query = $this->db->query($sql); + $data['med_indent_request']= $query->result(); + + $this->load->view('Medical/Stock/indent_accept_items_list',$data); + } + + + function indent_accept_items_list($indent_id,$item_id=0) + { + $where=" i.indent_id=$indent_id"; + if($item_id>0) + { + $where.=" and i.id =$item_id"; + } + + $sql="SELECT i.indent_id,i.id AS request_item_id,t.id AS process_item_id,i.product_name, + t.ssno,p.batch_no,p.expiry_date,i.request_qty,t.store_stock_id, + SUM(t.qty) AS t_qty,r.request_status + FROM (((med_indent_process m join med_indent_process_items t ON m.indent_id=t.indent_id) + JOIN med_indent_request_items i ON m.indent_id=i.indent_id AND i.id=t.indent_item_id) + JOIN purchase_invoice_item p ON t.ssno=p.id) + JOIN med_indent_request r on i.indent_id=r.indent_id + where $where + GROUP BY i.indent_id,i.id,t.id WITH rollup"; + + $query = $this->db->query($sql); + $med_indent_process_items= $query->result(); + + $content=""; + + $content.=' + + + + + + + '; + $srno=0; + $header_name=""; + foreach($med_indent_process_items as $row) + { + if($row->indent_id=='') + { + + }elseif($row->request_item_id==''){ + + }elseif($row->process_item_id==''){ + $content.=' '; + $content.= ''; + $content.= ''; + $content.= ''; + $content.= ''; + }else{ + if($header_name!=$row->product_name) + { + $content.=' '; + $content.= ''; + $content.= ''; + $content.= ''; + } + + $header_name=$row->product_name; + + $srno=$srno+1; + $content.=' '; + $content.= ''; + $content.= ''; + $content.= ''; + $content.= ''; + if($row->store_stock_id==0 && $row->request_status==4) + { + $content.= ''; + }else{ + $content.= ''; + } + + $content.= ''; + } + } + + $content.= '
#Batch No.Expiry DateIssued Qty.
Total Qty of '.$row->product_name.' : '.$row->t_qty.'
'.$row->product_name.'
'.$srno.''.$row->batch_no.''.$row->expiry_date.''.$row->t_qty.'
'; + + $content.= ''; + + echo $content; + + } + + + + public function indent_process_accept_Qty() + { + if (!$this->input->is_ajax_request()) { exit('no valid req.'); } + + $this->load->model('product_master_M'); + + $indent_id=$this->input->post('indent_id'); + $process_item_id=$this->input->post('process_item_id'); + + $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'); + + $sql="select * from med_indent_request where indent_id=".$indent_id; + $query = $this->db->query($sql); + $med_indent_request= $query->result(); + + $store_id=$med_indent_request[0]->store_id; + + $sql="select * from med_indent_process_items where id=".$process_item_id." and indent_id=".$indent_id; + $query = $this->db->query($sql); + $med_indent_process_items= $query->result(); + + if(count($med_indent_process_items)>0) + { + $sql="select * from purchase_invoice_item where id=".$med_indent_process_items[0]->ssno; + $query = $this->db->query($sql); + $purchase_invoice_item= $query->result(); + + $item_unit_qty=$med_indent_process_items[0]->qty*$purchase_invoice_item[0]->packing; + + $Pdata = array( + 'store_id' => $store_id, + 'ind_proc_item_id' => $process_item_id, + 'product_id' => $med_indent_process_items[0]->product_id, + 'ssno' => $med_indent_process_items[0]->ssno, + 'item_qty' => $med_indent_process_items[0]->qty, + 'item_unit_qty' => $item_unit_qty, + 'insert_date' => date('Y-m-d H:i:s'), + 'accept_by' => $user_id, + 'accept_by_name' => $user_name_info, + 'accept_time' => date('Y-m-d H:i:s'), + ); + + $insert_id=$this->product_master_M->insert_store_stock_items($Pdata); + + if($insert_id>0) + { + $Pdata = array( + 'store_stock_id' => $insert_id, + ); + + $insert_id=$this->product_master_M->update_med_indent_process_items($Pdata,$process_item_id); + } + } + + $rvar=array( + 'is_update_stock' =>1, + 'show_text'=>'Updated' + ); + + $encode_data = json_encode($rvar); + echo $encode_data; + + } + + + public function indent_process_accept_Qty_all($indent_id) + { + if (!$this->input->is_ajax_request()) { exit('no valid req.'); } + + $this->load->model('product_master_M'); + + + $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'); + + $sql="select * from med_indent_request where indent_id=".$indent_id; + $query = $this->db->query($sql); + $med_indent_request= $query->result(); + + $store_id=$med_indent_request[0]->store_id; + + $sql="select * from med_indent_process_items where indent_id=".$indent_id; + $query = $this->db->query($sql); + $med_indent_process_items= $query->result(); + + foreach($med_indent_process_items as $row) + { + $sql="select * from purchase_invoice_item where id=".$row->ssno; + $query = $this->db->query($sql); + $purchase_invoice_item= $query->result(); + + $process_item_id=$row->id; + + $item_unit_qty=$row->qty*$purchase_invoice_item[0]->packing; + + $Pdata = array( + 'store_id' => $store_id, + 'ind_proc_item_id' => $process_item_id, + 'product_id' => $row->product_id, + 'ssno' => $row->ssno, + 'item_qty' => $row->qty, + 'item_unit_qty' => $item_unit_qty, + 'insert_date' => date('Y-m-d H:i:s'), + 'accept_by' => $user_id, + 'accept_by_name' => $user_name_info, + 'accept_time' => date('Y-m-d H:i:s'), + ); + + $insert_id=$this->product_master_M->insert_store_stock_items($Pdata); + + if($insert_id>0) + { + $Pdata = array( + 'store_stock_id' => $insert_id, + ); + + $insert_id=$this->product_master_M->update_med_indent_process_items($Pdata,$process_item_id); + } + } + + $rvar=array( + 'is_update_stock' =>1, + 'show_text'=>'Updated' + ); + + $encode_data = json_encode($rvar); + echo $encode_data; + + } + + + + //Store Indent Transfer Direct + + public function indent_counter_list() + { + $sql="select * from store_master order by store_name"; + $query = $this->db->query($sql); + $data['store_master']= $query->result(); + + $this->load->view('Medical/Stock/indent_counter_list',$data); + } + + public function Indent_counter_Search() + { + $sdata=$this->input->post('txtsearch'); + + $sdata = preg_replace('/[^A-Za-z0-9_ \-]/', '', $sdata); + + if(trim($sdata)=='') + { + $sql=" SELECT m.indent_id,m.indent_code,s.store_name, + m.request_status,m.created_date, + GROUP_CONCAT(t.product_name) AS product_list, + i.indent_id AS process_indent_id, + (case m.request_status + when 0 then 'Pending' + when 1 then 'Send To Store' + when 2 then 'Accept and Process' + when 3 then 'Processed and Verification Pending' + when 4 then concat('Send to Counter :',s.store_name) + when 5 then concat('Accept By Counter :',s.store_name) + else 'UnKnown' end) as request_status_str, + (case m.indent_type when 0 then 'Auto' when 1 then 'By Counter Store' when 2 then 'Main Store' else 'UnKnown' end) as indent_request_type_str + FROM (((med_indent_request m Left JOIN med_indent_request_items t ON m.indent_id=t.indent_id) + JOIN med_product_master p ON t.product_id=p.id) + JOIN store_master s ON m.store_id=s.store_id) + LEFT JOIN med_indent_process i ON m.indent_id=i.indent_id + where m.indent_type = 2 + GROUP BY m.indent_id order by m.indent_id desc limit 50"; + }else{ + $sql=" SELECT m.indent_id,m.indent_code,s.store_name, + m.request_status,m.created_date, + GROUP_CONCAT(t.product_name) AS product_list, + i.indent_id AS process_indent_id, + (case m.request_status + when 0 then 'Pending' + when 1 then 'Send To Store' + when 2 then 'Accept and Process' + when 3 then 'Processed and Verification Pending' + when 4 then concat('Send to Counter :',s.store_name) + when 5 then concat('Accept By Counter :',s.store_name) + else 'UnKnown' end) as request_status_str, + (case m.indent_type when 0 then 'Auto' when 1 then 'By Counter Store' when 2 then 'Main Store' else 'UnKnown' end) as indent_request_type_str + FROM (((med_indent_request m Left JOIN med_indent_request_items t ON m.indent_id=t.indent_id) + JOIN med_product_master p ON t.product_id=p.id) + JOIN store_master s ON m.store_id=s.store_id) + LEFT JOIN med_indent_process i ON m.indent_id=i.indent_id + WHERE t.product_name LIKE '%".$sdata."%' OR m.indent_code LIKE '%".$sdata."' + and m.indent_type = 2 + GROUP BY m.indent_id order by m.indent_id desc limit 50"; + } + + $query = $this->db->query($sql); + $data['indent_req_list']= $query->result(); + + $this->load->view('Medical/Stock/indent_counter_search_result',$data); + } + + public function Create_Indent_counter($store_id=3) + { + if (!$this->input->is_ajax_request()) { exit('no valid req.'); } + + $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'); + + + $sql="SELECT m.indent_id,COUNT(t.id) AS No_item + from med_indent_request m LEFT join med_indent_request_items t ON m.indent_id=t.id + where store_id='".$store_id."' and indent_type <>2 + GROUP BY m.indent_id having COUNT(t.id)=0"; + $query = $this->db->query($sql); + $pending_nil_indent= $query->result(); + + $user_update_log='Indent Create By '.$user_name_info.'.'; + + $Udata = array( + 'store_id'=> $store_id, + 'indent_type'=> '2', + 'created_date'=> date('Y-m-d H:i:s'), + 'request_status'=>'0', + 'request_status_log'=>$user_update_log, + ); + + $this->load->model('product_master_M'); + + if(count($pending_nil_indent)>0) + { + $this->product_master_M->update_med_indent_request($Udata,$pending_nil_indent[0]->indent_id); + $inser_id=$pending_nil_indent[0]->indent_id; + }else{ + $inser_id=$this->product_master_M->insert_med_indent_request($Udata); + } + + $send_msg="Added Successfully"; + + if($inser_id>0) + { + redirect('Stock/Indent_counter_Edit/'.$inser_id); + }else{ + echo $send_msg; + } + + } + + public function Indent_counter_Edit($indent_id) + { + $sql="SELECT m.*,s.store_name + from med_indent_request m Left JOIN store_master s ON m.store_id=s.store_id + where m.indent_id=".$indent_id; + + $query = $this->db->query($sql); + $data['med_indent_request']= $query->result(); + + $sql="SELECT t.*,p.item_name,p.formulation,p.genericname,p.packing + FROM ((med_indent_request m JOIN med_indent_request_items t ON m.indent_id=t.indent_id) + JOIN med_product_master p ON t.product_id=p.id) + WHERE m.indent_id=".$indent_id; + $query = $this->db->query($sql); + $data['med_indent_request_items']= $query->result(); + + $data['indent_status_cont']=array( + 'Pending','Send to Store','Accept By Store','Processing Items','Send to Counter','Accept By Counter' + ); + + $this->load->view('Medical/Stock/indent_counter_edit',$data); + } + + public function get_product_master(){ + if (isset($_GET['term'])){ + $q = strtolower($_GET['term']); + + $where_str=" i.item_name like '".$q."%'"; + + if(strlen($q)>3) + { + $where_str=" or batch_no like '".$q."%'"; + } + + $sql="SELECT i.Item_name,i.tqty,i.id,i.item_code,i.batch_no,date_format(p.date_of_invoice,'%d-%m-%Y') as purchase_date, + date_format(i.expiry_date,'%m-%Y') AS exp_date ,m.formulation,i.mrp,m.packing, + (i.tqty-sum(COALESCE(s.item_qty,0))) as Pending_stock_invoice + FROM ((purchase_invoice_item i JOIN purchase_invoice p ON i.purchase_id=p.id) + left JOIN store_stock s ON i.id=s.ssno ) + JOIN med_product_master m ON i.item_code=m.id + WHERE $where_str + GROUP BY i.item_code,i.id + HAVING (i.tqty-sum(COALESCE(s.item_qty,0)))>0 + ORDER BY i.Item_name,i.id "; + + $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['formulation'])).' | '.htmlentities(stripslashes($row['exp_date'])); + $new_row['value']=htmlentities(stripslashes($row['Item_name'])).' | '.htmlentities(stripslashes($row['formulation'])); + //$new_row['value']=htmlentities(stripslashes($row['itemname'])); + + $new_row['l_item_code']=htmlentities(stripslashes($row['item_code'])); + $new_row['l_item_ssno']=htmlentities(stripslashes($row['id'])); + $new_row['l_item_qty']=htmlentities(stripslashes($row['Pending_stock_invoice'])); + $new_row['l_packing']=htmlentities(stripslashes($row['packing'])); + $new_row['l_itemname']=htmlentities(stripslashes($row['Item_name'])).' | '.htmlentities(stripslashes($row['formulation'])); + + $new_row['l_batch_mrp_exp']=htmlentities(stripslashes($row['batch_no'])).' / '.htmlentities(stripslashes($row['mrp'])).' / '.htmlentities(stripslashes($row['exp_date'])); + + + $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; //build an array + echo json_encode($row_set); + } + + }else{ + echo 'No Data'; + } + } + + public function Indent_product_stock($product_id) + { + $sql="SELECT i.Item_name,i.qty,i.id,i.item_code,i.batch_no,p.date_of_invoice, + date_format(i.expiry_date,'%m-%Y') AS exp_date , + (i.qty-sum(COALESCE(s.item_qty,0))) as Pending_stock_invoice + FROM (purchase_invoice_item i JOIN purchase_invoice p ON i.purchase_id=p.id) + left JOIN store_stock s ON i.id=s.ssno + WHERE i.item_code=$product_id + GROUP BY i.item_code,i.id + HAVING (i.qty-sum(COALESCE(s.item_qty,0)))>0 + ORDER BY i.Item_name,i.id "; + $query = $this->db->query($sql); + $data['product_store']= $query->result(); + + $this->load->view('Medical/Stock/indent_counter_edit_stock_list',$data); + } + + public function indent_request_item_list($indent_id) + { + $sql="SELECT m.*,s.store_name + from med_indent_request m JOIN store_master s ON m.store_id=s.store_id + where m.indent_id=".$indent_id; + $query = $this->db->query($sql); + $data['med_indent_request']= $query->result(); + + $sql="SELECT t.*,p.item_name,p.formulation,p.genericname,p.packing + FROM ((med_indent_request m JOIN med_indent_request_items t ON m.indent_id=t.indent_id) + JOIN med_product_master p ON t.product_id=p.id) + WHERE m.indent_id=".$indent_id; + $query = $this->db->query($sql); + $data['med_indent_request_items']= $query->result(); + + $this->load->view('Medical/Stock/indent_counter_item_list',$data); + + } + + public function indent_update_item($indent_id) + { + if (!$this->input->is_ajax_request()) { exit('no valid req.'); } + + $sql="select * from med_indent_request where indent_id=".$indent_id; + $query = $this->db->query($sql); + $med_indent_request= $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_item_name', + 'label' => 'Product Name', + 'rules' => 'required|min_length[3]|max_length[30]' + ), + + ); + + $this->form_validation->set_rules($FormRules); + + if ($this->form_validation->run() == TRUE) + { + $indent_id=$this->input->post('indent_id'); + $indent_item_id=$this->input->post('med_indent_request_items_id'); + + $this->load->model('product_master_M'); + + $Pdata = array( + 'indent_id' => $indent_id, + 'product_id' => $this->input->post('product_id'), + 'product_name' => $this->input->post('input_item_name'), + 'request_qty' => $this->input->post('input_Qty'), + 'cat' => '1', + 'insert_by' => $user_name_info, + ); + + $show_text=''; + + $is_update_stock=0; + + if($indent_item_id<1) + { + $is_update_stock=$this->product_master_M->insert_med_indent_request_items($Pdata); + }else{ + $is_update_stock=$this->product_master_M->update_med_indent_request_items($Pdata,$indent_item_id); + } + + if($is_update_stock>0) + { + $send_msg="Updated"; + }else{ + $send_msg="Error : Update in Indent Request 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, + '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 Transfer_invoice_to_counter($inv_id,$store_id) { + $this->load->model('product_master_M'); + + $sql="SELECT COUNT(*) AS no_record + FROM (purchase_invoice p JOIN purchase_invoice_item i ON p.id=i.purchase_id) + WHERE p.id=$inv_id"; + $query = $this->db->query($sql); + $sql_result= $query->result(); + + $msg=""; + + $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(count($sql_result)>0) + { + $no_record=$sql_result[0]->no_record; + if($no_record>0) + { + $sql="SELECT (SUM(i.qty+COALESCE(i.qty_free,0))-sum(COALESCE(s.item_qty,0))) as Pending_stock_invoice + FROM (purchase_invoice_item i left JOIN store_stock s ON i.id=s.ssno) + WHERE i.purchase_id=$inv_id + GROUP BY i.purchase_id"; + $query = $this->db->query($sql); + $sql_result= $query->result(); + + if(count($sql_result)>0) + { + $Pending_stock_invoice=$sql_result[0]->Pending_stock_invoice; + + if($Pending_stock_invoice>0) + { + //Check Pending Indent: Create on Direct Purchase Invoice + + /* + $sql="SELECT m.indent_id,COUNT(t.id) AS No_item + from med_indent_request m LEFT join med_indent_request_items t ON m.indent_id=t.id + where store_id='".$store_id."' and indent_type=2 + GROUP BY m.indent_id having COUNT(t.id)=0"; + $query = $this->db->query($sql); + $pending_nil_indent= $query->result(); + + echo $sql; + + */ + + $user_update_log='Indent Create By '.$user_name_info.'.'; + + $Udata = array( + 'store_id'=> $store_id, + 'indent_type'=> '2', + 'created_date'=> date('Y-m-d H:i:s'), + 'request_status'=>'3', + 'request_status_log'=>$user_update_log, + ); + + /* + + if(count($pending_nil_indent)>0) + { + $this->product_master_M->update_med_indent_request($Udata,$pending_nil_indent[0]->indent_id); + $indent_id=$pending_nil_indent[0]->indent_id; + }else{ + $indent_id=$this->product_master_M->insert_med_indent_request($Udata); + } + + */ + + $indent_id=$this->product_master_M->insert_med_indent_request($Udata); + + + //Indent Process Create here + $Pdata = array( + 'store_accept_time' => date('d-m-Y H:i:s'), + 'store_accept_by' => $user_id, + 'store_accept_by_name' => $user_name_info, + 'indent_id' => $indent_id, + 'remark' => $user_update_log, + ); + + $process_indent_id=$this->product_master_M->insert_med_indent_process($Pdata); + + // Get Purchase Invoice List + $sql="SELECT i.Item_name,i.qty,i.id,i.item_code, + sum((i.qty+COALESCE(i.qty_free,0))-sum(COALESCE(s.item_qty,0))) as Pending_stock_invoice + FROM (purchase_invoice_item i left JOIN store_stock s ON i.id=s.ssno) + WHERE i.purchase_id=$inv_id + GROUP BY i.purchase_id,i.item_code"; + $query = $this->db->query($sql); + $sql_result= $query->result(); + + foreach($sql_result as $row) + { + //Entry in indent_request_list + + $Udata = array( + 'indent_id'=> $indent_id, + 'product_id'=> $row->item_code, + 'product_name'=> $row->Item_name, + 'request_qty'=> $row->Pending_stock_invoice, + 'datetime_before'=> date('Y-m-d H:i:s'), + 'insert_by'=> $user_id, + 'update_by'=> $user_id, + ); + $indent_item_id=$this->product_master_M->insert_med_indent_request_items($Udata); + + //Entry in indent_process_items + + $Pdata = array( + 'indent_id' => $indent_id, + 'indent_item_id' => $indent_item_id, + 'product_id' => $row->item_code, + 'qty' =>$row->Pending_stock_invoice, + 'ssno' => $row->id, + ); + + $inser_id=$this->product_master_M->insert_med_indent_process_items($Pdata); + + } + + $msg="Indent Created and Process"; + + /* Code For Indent Verified and Send to Store And Accept By Store . + Remove or Comment , if Indent Verification Step Require + */ + + /* $indent_id Already Define */ + $request_status = '4'; + + $sql="select * from med_indent_request where indent_id=".$indent_id; + $query = $this->db->query($sql); + $med_indent_request= $query->result(); + + // 0 Pending , 1 For Send,2 Accept and Process,3 Processed and Verification Pending,4 Verifired & Send by Main Store,5 Accept By Counter + $indent_status_cont=array( + 'Pending','Send to Store','Accept By Store','Processing Items','Send to Counter','Accept By Counter' + ); + + $request_status_log=""; + + if(count($med_indent_request)>0) + { + $request_status_log.=$med_indent_request[0]->request_status_log; + } + + $request_status_log.='Status Change Direct to Store Wih Verification By '.$indent_status_cont[$request_status].' By '.$user_name_info; + + $Pdata = array( + 'request_status' => $request_status, + 'last_update_time' => date('Y-m-d H:i:s'), + 'request_status_log'=>$request_status_log, + ); + + if(count($med_indent_request)>0){ + $is_update_stock=$this->product_master_M->update_med_indent_request($Pdata,$indent_id); + $msg= $indent_status_cont[$request_status]; + }else{ + $msg= 'Indent Record Not Found'; + } + + /* Indent Accept by Counter Auto */ + + redirect('Stock/indent_process_accept_Qty_all/'.indent_id); + + /* Code End Here */ + + + }else{ + $msg="No Items found in Purchase Item"; + } + + }else{ + $msg="No Items found in Purchase Item"; + } + + }else{ + $msg="No Items found in Purchase Item"; + } + + }else{ + $msg="No Invoice Found"; + } + + echo $msg; + } + + public function indent_request_item_delete($indent_id,$indent_item_id_del) + { + $this->load->model('product_master_M'); + + $sql="SELECT r.id,r.product_name,s.ssno,s.store_id + FROM (med_indent_request_items r JOIN med_indent_process_items p ON r.id=p.indent_item_id) + LEFT JOIN store_stock s ON s.ind_proc_item_id=p.id + WHERE r.id=$indent_item_id_del"; + $query = $this->db->query($sql); + $result = $query->result(); + + $rvar=array( + 'is_delete' =>0, + 'show_text'=>'Nothing Happen', + ); + + if(count($result)>0) + { + $ssno=$result[0]->ssno; + + if($ssno=='') + { + $is_delete=$this->product_master_M->delete_med_indent_request_item($indent_id,$indent_item_id_del); + + $rvar=array( + 'is_delete' =>1, + 'show_text'=>'Removed Successfully', + ); + }else{ + $rvar=array( + 'is_delete' =>0, + 'show_text'=>'After Indent Process, Cannot Delete', + ); + } + }else{ + $rvar=array( + 'is_delete' =>0, + 'show_text'=>'No Record Found', + ); + } + + $encode_data = json_encode($rvar); + echo $encode_data; + } + + public function indent_update_item_direct($indent_id) + { + if (!$this->input->is_ajax_request()) { exit('no valid req.'); } + + $sql="select * from med_indent_request where indent_id=".$indent_id; + $query = $this->db->query($sql); + $med_indent_request= $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_add_qty', + 'label' => 'Product Name', + 'rules' => 'required|numeric|greater_than[0]', + ), + ); + + $this->form_validation->set_rules($FormRules); + + if ($this->form_validation->run() == TRUE) + { + $indent_id=$this->input->post('indent_id'); + $product_id=$this->input->post('product_id'); + $product_name=$this->input->post('product_name'); + $add_qty=$this->input->post('input_add_qty'); + $inv_ssno=$this->input->post('inv_ssno'); + $indent_item_id=$this->input->post('med_indent_request_items_id'); + + $this->load->model('product_master_M'); + + #Check indent Process + $sql="select indent_process_id + from med_indent_process where indent_id=$indent_id"; + $query = $this->db->query($sql); + $sql_result= $query->result(); + + $user_update_log='ADD By :'.$user_name_info; + + if(count($sql_result)==0) + { + $Pdata = array( + 'store_accept_time' => date('d-m-Y H:i:s'), + 'store_accept_by' => $user_id, + 'store_accept_by_name' => $user_name_info, + 'indent_id' => $indent_id, + 'remark' => $user_update_log, + ); + + $process_indent_id=$this->product_master_M->insert_med_indent_process($Pdata); + } + + $Udata = array( + 'indent_id'=> $indent_id, + 'product_id'=> $product_id, + 'product_name'=> $product_name, + 'request_qty'=> $add_qty, + 'datetime_before'=> date('Y-m-d H:i:s'), + 'insert_by'=> $user_id, + 'update_by'=> $user_id, + ); + + if($indent_item_id>0) + { + $this->product_master_M->update_med_indent_request_items($Udata,$indent_item_id); + }else{ + $indent_item_id=$this->product_master_M->insert_med_indent_request_items($Udata); + } + + $Pdata = array( + 'indent_id' => $indent_id, + 'indent_item_id' => $indent_item_id, + 'product_id' => $product_id, + 'qty' =>$add_qty, + 'ssno' => $inv_ssno, + ); + + $sql="select id + from med_indent_process_items + where indent_id=$indent_id and indent_item_id=$indent_item_id and ssno=$inv_ssno"; + $query = $this->db->query($sql); + $sql_result= $query->result(); + + if(count($sql_result)>0) + { + $med_indent_process_items_id=$sql_result[0]->id; + $this->product_master_M->update_med_indent_process_items($Pdata,$med_indent_process_items_id); + }else{ + $med_indent_process_items_id=$this->product_master_M->insert_med_indent_process_items($Pdata); + } + + $show_text='Update Done'; + + $is_update_stock=1; + + $rvar=array( + 'is_update_stock' =>$is_update_stock, + '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; + } + } + + +} \ No newline at end of file diff --git a/old_code_ci3/controllers/Storestock.php b/old_code_ci3/controllers/Storestock.php new file mode 100644 index 0000000..f110ed5 --- /dev/null +++ b/old_code_ci3/controllers/Storestock.php @@ -0,0 +1,2126 @@ +load->model('Stock_M'); + $this->load->model('Master_M'); + + } + + public function index() + { + + $this->load->view('Storestock/Dashboard'); + } + + public function Indent_List() + { + $this->load->view('Storestock/Draft_indent'); + } + + //Product Master + public function Product_search() + { + $sdata=$this->input->post('txtsearch'); + + $sdata = preg_replace('/[^A-Za-z0-9_ \-]/', '', $sdata); + + if(trim($sdata)=='') + { + $sql="select * from med_store_product_master order by id desc limit 100"; + }else{ + $sql="select * from med_store_product_master + where (item_name LIKE '%".$sdata."%' + OR genericname LIKE '%".$sdata."%' + OR id = '".$sdata."')"; + } + + $query = $this->db->query($sql); + $data['product_list']= $query->result(); + + $this->load->view('Medical/Purchase/product_search_result',$data); + } + + public function Product_edit($Product_id) + { + $sql="Select * from med_store_product_master where id=".$Product_id; + $query = $this->db->query($sql); + $data['product_data']= $query->result(); + + $sql="Select * from med_formulation order by formulation_length"; + $query = $this->db->query($sql); + $data['med_formulation']= $query->result(); + + $sql="Select * from med_company order by company_name"; + $query = $this->db->query($sql); + $data['med_company']= $query->result(); + + $this->load->view('Medical/Purchase/product_edit',$data); + } + + public function Product_delete($Product_id) + { + $sql="Select count(*) as no_rec from inv_med_item where item_code=".$Product_id; + $query = $this->db->query($sql); + $product_sale_data= $query->result(); + + $sql="Select count(*) as no_rec from purchase_invoice_item where item_code=".$Product_id; + $query = $this->db->query($sql); + $product_purchase_data= $query->result(); + + $is_delete_master=0; + + $data_show=""; + + if($product_sale_data[0]->no_rec>0 || $product_purchase_data[0]->no_rec>0) + { + if($product_sale_data[0]->no_rec>0){ + $data_show.="

This Product in Sale Invoice, So cann't Delete

"; + } + + if($product_purchase_data[0]->no_rec>0){ + $data_show.="

This Product in Purchase Invoice, So cann't Delete

"; + } + + }else{ + + $this->load->model('product_master_M'); + $is_delete_master=$this->product_master_M->delete_master($Product_id); + + if($is_delete_master==0) + { + $data_show.="

Some Error on Delete this product

"; + }else{ + $data_show.="

Deleted

"; + } + + } + + echo $data_show; + + + } + + public function NewProduct() + { + $sql="Select * from med_company order by company_name"; + $query = $this->db->query($sql); + $data['med_company']= $query->result(); + + $sql="Select * from med_formulation order by formulation_length"; + $query = $this->db->query($sql); + $data['med_formulation']= $query->result(); + + $this->load->view('Medical/Purchase/product_new',$data); + } + + + + + //End Product Master + + public function getIndentTable() + { + //Single Store Remove Store ID feild + + $requestData= $_REQUEST; + + $columns = array( + // datatable column index => database column name + 0 => 'indent_code', + 1 => 'issued_name', + 2=> 'indent_date_str', + 3=> 'id', + ); + + // getting total number records without any search + $sql_f_all = "SELECT m.id,m.indent_code,m.issued_name,m.indent_date,DATE_FORMAT(m.indent_date,'%d-%m-%Y') as indent_date_str "; + + $sql_count="Select count(*) as no_rec "; + + $sql_from=" from invoice_stock_master m"; + + //$total_sql=$sql_count.$sql_from; + $total_sql="Select count(*) as no_rec from invoice_stock_master m"; + + $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']) ){ //indent_code + $sql_where.=" AND indent_code LIKE '%".$requestData['columns'][0]['search']['value']."' "; + $sql_where_flag=1; + } + + if( !empty($requestData['columns'][1]['search']['value']) ){ //issued_name + $stext=$requestData['columns'][1]['search']['value']; + $sql_where.=" AND (issued_name LIKE '%".$stext."' )"; + $sql_where_flag=1; + } + + if( !empty($requestData['columns'][2]['search']['value']) ){ //indent_date + $stext=$requestData['columns'][2]['search']['value']; + $sql_where.=" AND (indent_date = '".$stext."' )"; + $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 new_indent() + { + $sql="select * from location_master "; + $query = $this->db->query($sql); + $data['location_master']= $query->result(); + + $sql="select * from employee_master "; + $query = $this->db->query($sql); + $data['employee_master']= $query->result(); + + $this->load->view('Storestock/new_indent',$data); + } + + public function Indent_create($location_type) + { + + $date_indent=$this->input->post('date_indent'); + $loc_id=$this->input->post('loc_id'); + + $issued_name=""; + + if($location_type==1){ + $sql="select * from location_master where l_id=$loc_id "; + $query = $this->db->query($sql); + $location_master= $query->result(); + + if(count($location_master)>0){ + $issued_name=$location_master[0]->loc_name; + } + + }elseif($location_type==2){ + $sql="select * from employee_master where emp_id=$loc_id "; + $query = $this->db->query($sql); + $employee_master= $query->result(); + + if(count($employee_master)>0){ + $issued_name=$employee_master[0]->emp_name.' ['.$employee_master[0]->emp_code.']'; + } + + } + + $data['invoice_stock_master'] = array( + 'indent_date' => str_to_MysqlDate($date_indent), + 'location_type' => $location_type, + 'location_id' => $loc_id, + 'issued_name' => $issued_name, + ); + + $inser_id=$this->Stock_M->insert_indent($data['invoice_stock_master']); + + redirect('Storestock/Indent_show/'.$inser_id); + + } + + public function Indent_show($indent_id) + { + + $sql="select * from invoice_stock_master where id=$indent_id "; + $query = $this->db->query($sql); + $data['invoice_stock_master']= $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_stock_item i JOIN purchase_invoice_item_stock p ON i.item_code=p.item_code AND p.remove_item=0 ) + where indent_id=".$indent_id." GROUP BY i.id"; + $query = $this->db->query($sql); + $data['inv_stock_item']= $query->result(); + + $sql="select sum(amount) as Gtotal,sum(tamount) as tamt,sum(CGST) as TCGST, + sum(SGST) as TSGST + from inv_stock_item where indent_id=".$indent_id; + $query = $this->db->query($sql); + $data['invoiceGtotal']= $query->result(); + + $data['content']=$this->load->view('Storestock/indent_item_list',$data,true); + + $this->load->view('Storestock/indent_edit',$data); + + } + + public function Indent_Items_list($indent_id) + { + $sql="select * from inv_stock_item where indent_id=$indent_id Order by id"; + $query = $this->db->query($sql); + $data['inv_stock_item']= $query->result(); + + $sql="select sum(amount) as Gtotal,sum(tamount) as tamt,sum(CGST) as TCGST, + sum(SGST) as TSGST + from inv_stock_item where indent_id=".$indent_id; + $query = $this->db->query($sql); + $data['invoiceGtotal']= $query->result(); + + + $content=$this->load->view('Storestock/indent_item_list',$data,true); + + echo $content; + } + + + // Purchase Stock + + public function Purchase() + { + $this->load->view('Storestock/Purchase/supplier_list'); + } + + public function PurchaseMasterEdit($inv_id) + { + $sql="select * from stock_supplier order by name_supplier"; + $query = $this->db->query($sql); + $data['supplier_data']= $query->result(); + + $sql="select p.*,s.name_supplier from purchase_invoice_stock p join stock_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_stock where purchase_id='".$inv_id."' "; + $query = $this->db->query($sql); + $data['purchase_item']= $query->result(); + + $this->load->view('Storestock/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 + ); + + $update_id=$this->Stock_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, + ); + + $update_id=$this->Stock_M->update_purchase($Udata,$purchase_inv_id); + + redirect('Storestock/PurchaseMasterEdit/'.$purchase_inv_id); + + } + + public function PurchaseNew() + { + $sql="select * from stock_supplier where active=1 order by name_supplier"; + $query = $this->db->query($sql); + $data['supplier_data']= $query->result(); + + $this->load->view('Storestock/Purchase/new_purchase_invoice',$data); + } + + public function SupplierList() + { + $sql="select * from stock_supplier"; + $query = $this->db->query($sql); + $data['supplier_data']= $query->result(); + + $this->load->view('Storestock/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_stock p join stock_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_stock p join stock_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('Storestock/Purchase/purchase_supp_list',$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_stock p JOIN purchase_invoice_item_stock 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('Storestock/Purchase/purchase_item_old',$data); + + } + + public function print_purchase($inv_id) + { + $sql="select * from stock_supplier order by name_supplier"; + $query = $this->db->query($sql); + $data['supplier_data']= $query->result(); + + $sql="select p.*,s.name_supplier from purchase_invoice_stock p join stock_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_stock where purchase_id='".$inv_id."' "; + $query = $this->db->query($sql); + $data['purchase_item']= $query->result(); + + $content = $this->load->view('Storestock/Purchase/purchase_invoice_item_print', $data, true); + + //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 = false; + + $file_name='Return_Invoice-'.$inv_id."-".date('Ymdhis').".pdf"; + + $filepath=$file_name; + + //echo $content; + + $this->m_pdf->pdf->debug = true; + + //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 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_stock p join stock_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_stock 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('Storestock/Purchase/purchase_invoice_edit',$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_stock 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->Stock_M->insert_purchase_item($Pdata); + $send_msg="Added"; + }else{ + $sql="select * from purchase_invoice_item_stock 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->Stock_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->Stock_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; + } + } + + public function purchase_invoice_item_list($inv_id) + { + $sql="select *,date_format(expiry_date,'%m/%y') as exp_date_str from purchase_invoice_item_stock where purchase_id='".$inv_id."' "; + $query = $this->db->query($sql); + $data['purchase_item']= $query->result(); + + $sql="select * from purchase_invoice_stock where id='".$inv_id."' "; + $query = $this->db->query($sql); + $data['purchase_invoice']= $query->result(); + + + $this->load->view('Storestock/Purchase/purchase_invoice_item',$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_stock 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 add_item($type,$req=0) + { + + $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_store_product_master p + JOIN purchase_invoice_item_stock 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_stock_item where indent_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( + 'indent_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->Stock_M->add_indentitem( $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_stock_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]->indent_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_store_product_master p + JOIN purchase_invoice_item_stock 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, + 'indent_id' => $inv_id, + ); + + $this->Stock_M->update_indentitem($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{ + $itemid=$this->input->post('itemid'); + + $sql="select * from inv_stock_item where id=".$itemid; + $query = $this->db->query($sql); + $inv_items= $query->row_array(); + + $inv_id=$inv_items['indent_id']; + + $this->Stock_M->delete_indentitem($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_stock_item i JOIN purchase_invoice_item_stock p ON i.item_code=p.item_code AND p.remove_item=0 ) + where indent_id=".$inv_id." GROUP BY i.id"; + $query = $this->db->query($sql); + $data['inv_stock_item']= $query->result(); + + $sql="select item_code + from inv_stock_item where indent_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_stock_item where indent_id=".$inv_id; + $query = $this->db->query($sql); + $data['invoiceGtotal']= $query->result(); + + $sql="select * from invoice_stock_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('Storestock/indent_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() + ); + $encode_data = json_encode($rvar); + echo $encode_data; + } + + public function purchase_invoice_item_delete($inv_id,$inv_item_del) + { + + $sql="select * from purchase_invoice_item_stock 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->Stock_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 final_invoice($inv_id) + { + + $this->Stock_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_stock_master where id=".$inv_id; + $query = $this->db->query($sql); + $data['invoice_stock_master']= $query->result(); + + $sql="select * from inv_stock_item where indent_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_stock_item where indent_id=".$inv_id; + $query = $this->db->query($sql); + $data['invoiceGtotal']= $query->result(); + + + $this->load->view('Storestock/Store_Final_Invoice',$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_store_product_master p + JOIN purchase_invoice_item_stock 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 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_store_product_master m + LEFT JOIN (SELECT * from purchase_invoice_item_stock + WHERE id in (select max(id) from purchase_invoice_item_stock + 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 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_stock p join stock_supplier s on p.sid=s.sid) + JOIN purchase_invoice_item_stock 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('Storestock/Purchase/purchase_challan_list',$data); + } + + public function challan_item_to_purchase($ss_no,$purchase_id) + { + $sql="select * from purchase_invoice_item_stock 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, + ); + + $is_update_stock=$this->Stock_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_stock 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_stock 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, + ); + + + $is_update_stock=$this->Stock_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, + ); + + + $is_update_stock=$this->Stock_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_stock 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{ + + $is_delete=$this->Stock_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 stock_supplier order by name_supplier"; + $query = $this->db->query($sql); + $data['supplier_data']= $query->result(); + + $this->load->view('Storestock/Purchase/supplier_master_sub',$data); + } + + public function SupplierEdit($sid=0) + { + $sql="select * from stock_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('Storestock/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 + ); + + $inser_id=$this->Stock_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[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'); + + $Udata = array( + 'name_supplier'=> $name_supplier, + 'short_name'=> $short_name, + 'contact_no'=> $contact_no, + 'gst_no'=> $gst_no, + 'city'=> $city, + 'state'=> $state + ); + + + if($sid>0) + { + $inser_id=$this->Stock_M->update_supplier($Udata,$sid); + $send_msg="Saved Successfully"; + }else{ + $inser_id=$this->Stock_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('Storestock/Medical_stock_drug'); + } + + // Store Main + public function main_store() + { + $this->load->view('Storestock/Stock/main_store_dashboard'); + } + + + // Location Master + public function location_master_list() + { + $sql="select * from location_master order by loc_name "; + $query = $this->db->query($sql); + $data['location_master']= $query->result(); + + $this->load->view('Storestock/Stock/location_master_list',$data); + } + + function Location_add() + { + $this->load->view('MasterData/location_master_add'); + } + + function Location_edit($l_id) + { + $sql="select * from location_master where l_id= $l_id"; + $query = $this->db->query($sql); + $data['location_master']= $query->result(); + + $this->load->view('MasterData/location_master_edit',$data); + } + + function Location_save() + { + $input_loc_name = $this->input->post('input_loc_name'); + $input_loc_desc = $this->input->post('input_loc_desc'); + $hid_l_id = $this->input->post('hid_location_id'); + + $user = $this->ion_auth->user()->row(); + $user_id = $user->id; + $user_name = $user->first_name.''. $user->last_name.' ['.$user_id.']'; + + $insert_data=array( + 'loc_name'=>$input_loc_name, + 'loc_desc'=>$input_loc_desc, + 'loc_add_by'=>$user_name.' : '.date('Y-m-d H:i:s'), + ); + + if($hid_l_id==0){ + $inser_id=$this->Master_M->insert_location_master($insert_data); + }else{ + $inser_id=$this->Master_M->update_location_master($insert_data,$hid_l_id); + } + + echo $inser_id; + } + + + + // Print Indent + + public function print_single_indent($inv_id,$print_format=0) + { + //$cash 0 for Cash Only,1 for Credit only,2 Package Credit only,3 for All + + $this->Stock_M->update_invoice_final($inv_id); + + $sql="select i.indent_id,i.id,i.item_Name,i.formulation, + i.batch_no,Date_Format(i.expiry,'%m-%y')as expiry, + i.price,i.qty,(i.amount) as amount,i.HSNCODE, + m.indent_code,m.id as m_id, + date_format(m.indent_date,'%d-%m-%Y') as str_inv_date, + (twdisc_amount) as twdisc_amount, + (i.disc_amount+i.disc_whole) as d_amt, + (i.CGST+i.SGST) as gst, + (i.CGST_per+i.SGST_per) as gst_per ,i.sale_return + from inv_stock_item i join invoice_stock_master m + on i.indent_id=m.id + where m.id=$inv_id order by i.sale_return,id"; + $query = $this->db->query($sql); + $data['inv_items']= $query->result(); + + $sql="select *, + date_format(indent_date,'%d-%m-%Y') as str_inv_date, + (discount_amount+item_discount_amount) as inv_disc_total, + (CGST_Tamount+SGST_Tamount) as TGST + from invoice_stock_master + where id=$inv_id"; + $query = $this->db->query($sql); + $data['invoice_stock_master']= $query->result(); + + + //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 = false; + + $file_name='Report-MedicalBill_'.$inv_id.'_'.date('Ymdhis').".pdf"; + + $filepath=$file_name; + + //$this->load->view('Medical/medical_bill_print_format',$data); + + $content=$this->load->view('Storestock/Store_Print',$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"); + + } + + // Store Stock + + public function store_stock() + { + $sql="select * from stock_supplier"; + $query = $this->db->query($sql); + $data['supplier_data']= $query->result(); + + $sql = "select * from med_formulation order by formulation_length"; + $query = $this->db->query($sql); + $data['med_formulation'] = $query->result(); + + $this->load->view('Storestock/store_stock_search', $data); + } + + public function store_Stock_result() + { + $supplier_id = $this->input->post('input_supplier'); + $item_name = $this->input->post('txtsearch'); + $store_id = $this->input->post('input_store_id'); + $chk_reorder = $this->input->post('chk_reorder'); + + $HAVING = ""; + + if ($chk_reorder == "on") { + $HAVING = " HAVING SUM(s.total_unit-s.total_lost_unit-s.total_sale_unit-s.total_return_unit)<=p.re_order_qty"; + } + + $where = " remove_item=0 "; + + if ($supplier_id > 0) { + $where .= " and m.sid = " . $supplier_id; + } + + + if ($item_name <> '') { + $where .= " and p.Item_name like '%" . $item_name . "%' "; + } + + $sql = "SELECT i.Item_name,i.item_code ,sum(distinct i.tqty), + pm.re_order_qty, + sum(i.total_unit) as T_unit, + sum(if(ss.sale_qty is NULL,0,ss.sale_qty)) sal_qty, + GROUP_CONCAT(distinct s.name_supplier) AS supplier_names + FROM (((purchase_invoice_item_stock i join purchase_invoice_stock p on i.purchase_id=p.id ) + join stock_supplier s on s.sid=p.sid) + JOIN med_store_product_master pm ON i.item_code=pm.id AND pm.is_continue=1) + LEFT JOIN + (SELECT item_code,sum(qty) AS sale_qty FROM inv_stock_item GROUP BY item_code ) + AS ss ON i.item_code= ss.item_code + Where " . $where . " group by i.item_code " . $HAVING . " order by i.Item_name"; + + + $sql = "SELECT p.id, p.item_name, + IFNULL(s.item_code,0) AS item_found, + ifnull(s.packing,p.packing) as packing, + SUM(s.total_unit-s.total_sale_unit-s.total_lost_unit-s.total_return_unit) as C_Unit_Stock_Qty, + Concat(TRUNCATE(SUM(s.total_unit-s.total_sale_unit-s.total_lost_unit-s.total_return_unit)/s.packing,0), + ':', + MOD(SUM(s.total_unit-s.total_sale_unit-s.total_lost_unit-s.total_return_unit),s.packing)) as C_Pak_Qty, + sum(s.total_unit) as P_Unit_Qty, + sum(s.total_unit)/s.packing as Pak_qty, + sum(s.total_sale_unit) as sale_unit, + sum(s.total_sale_unit)/s.packing as C_Pak_Sale_Qty, + p.re_order_qty, + s.total_lost_unit + FROM (med_store_product_master p + JOIN purchase_invoice_item_stock s ON p.id=s.item_code AND s.remove_item=0 AND s.item_return=0) + JOIN purchase_invoice_stock m ON s.purchase_id=m.id and p.is_continue=1 + WHERE " . $where . " group by p.id,s.packing " . $HAVING . " order by p.Item_name "; + + $query = $this->db->query($sql); + $data['stock_list'] = $query->result(); + + //echo $sql; + + $this->load->view('Storestock/Stock_search_qty_result', $data); + } + + + public function get_product_stock($product_id, $remove_item = 0) + { + $supplier_id = $this->input->post('input_supplier'); + $date_range = $this->input->post('date_range'); + + $product_pak = $this->input->post('product_pak'); + + $where = "1=1 "; + + if ($date_range <> '0') { + $rangeArray = explode("S", $date_range); + $minRange = $rangeArray[0]; + $maxRange = $rangeArray[1]; + + $where .= " and p.date_of_invoice between '" . $minRange . "' and '" . $maxRange . "'"; + } + + if ($supplier_id > 0) { + $where .= " and m.sid=$supplier_id"; + } + + $where .= " and i.item_code=$product_id and i.packing=$product_pak "; + + $sql = "SELECT i.id,s.name_supplier,s.short_name,i.Item_name, + p.Invoice_no,p.date_of_invoice,i.mrp,i.packing, + i.batch_no,i.expiry_date,i.purchase_price,i.purchase_unit_rate, + i.qty,i.qty_free,i.tqty,i.total_unit,i.total_sale_unit, + i.total_return_unit,i.total_lost_unit, + (i.total_unit-i.total_sale_unit-i.total_lost_unit-i.total_return_unit) as cur_unit + FROM (purchase_invoice_stock p JOIN purchase_invoice_item_stock i ON p.id=i.purchase_id and i.item_return=0) + JOIN med_supplier s ON p.sid=s.sid + WHERE $where and remove_item=$remove_item + Order by p.id"; + + $query = $this->db->query($sql); + $data['product_purchase_detail'] = $query->result(); + + $this->load->view('Storestock/Stock_Item_history', $data); + } + + public function Stock_result_excel($chk_reorder, $item_name = "", $schedule_id = '') + { + $HAVING = ""; + + if ($chk_reorder == "on") { + $HAVING = " HAVING (SUM(TRUNCATE((p.total_unit-p.total_sale_unit-p.total_lost_unit-p.total_return_unit)/p.packing,0)))<=m.re_order_qty"; + } + + $where = " 1=1 "; + + if ($item_name <> '-') { + $where .= " and m.item_name like '%" . urldecode($item_name) . "%' "; + } + + if ($schedule_id == '0') { + } else { + + $schedule_id = explode("S", $schedule_id); + if (count($schedule_id) > 0) { + $where .= " ( "; + } + foreach ($schedule_id as $row) { + if ($row == 1) { + $where .= " or m.schedule_h=1 "; + } + + if ($row == 2) { + $where .= " or m.schedule_h1=1 "; + } + + if ($row == 3) { + $where .= " or m.schedule_x=1 "; + } + + if ($row == 4) { + $where .= " or m.schedule_g=1 "; + } + + if ($row == 5) { + $where .= " or m.narcotic=1 "; + } + } + if (count($schedule_id) > 0) { + $where .= " ) "; + } + } + + + + $where .= " and i.date_of_invoice>date_add(curdate(),interval -24 month) "; + + $sql = "SELECT m.item_name, m.id,m.genericname, + SUM(p.tqty) AS Pak_qty, + SUM(p.total_unit) AS P_Unit_Qty, + m.packing, + SUM(TRUNCATE((p.total_unit-p.total_sale_unit)/p.packing,0)) AS C_Pak_Qty, + SUM(p.total_sale_unit) AS sale_unit, + SUM(TRUNCATE((p.total_sale_unit)/p.packing,0)) AS C_Pak_Sale_Qty, + m.re_order_qty, + SUM(p.total_unit-p.total_sale_unit) AS C_Unit_Stock_Qty, + SUM(TRUNCATE((p.total_unit-p.total_sale_unit-p.total_lost_unit-p.total_return_unit),0))*MAX(p.purchase_unit_rate) AS Stock_Cost, + p.purchase_unit_rate + FROM (med_store_product_master m JOIN purchase_invoice_item_stock p + ON m.id=p.item_code and m.is_continue=1 and p.item_return=0 AND p.remove_item=0) + JOIN purchase_invoice_stock i ON p.purchase_id=i.id + WHERE " . $where . " group by m.id " . $HAVING . " order by m.Item_name"; + $query = $this->db->query($sql); + $stock_list = $query->result(); + + + + $content = ""; + //$content.=$sql; + $content .= ' + + + + + + + + + + + + + + '; + + $total_stock_value = 0; + + foreach ($stock_list as $row) { + + if ($row->C_Pak_Qty <= $row->re_order_qty) { + $tr_color = 'style="background-color: #999999;"'; + } else { + $tr_color = ''; + } + + $content .= ' + + + + + + + + + + '; + $total_stock_value += $row->Stock_Cost; + } + + $content .= ' + + + '; + + $content .= '
Item NameGeneric NameCurrent Pak.Current Unit QtyTotal Sale Pak.Total Sale Unit QtyPackage/Re-Order QtyPurchase Unit RateStock Cost
' . $row->item_name . '' . $row->genericname . '' . $row->C_Pak_Qty . '' . $row->C_Unit_Stock_Qty . '' . $row->C_Pak_Sale_Qty . '' . $row->sale_unit . '' . $row->packing . '' . $row->purchase_unit_rate . '' . $row->Stock_Cost . '
Total Stock Cost' . $total_stock_value . '
'; + + ExportExcel($content, 'Report_Medical_store_stock'); + } + + public function Stock_result_excel_2($supplier_id, $opd_date_range, $item_name, $chk_reorder, $schedule_id = '') + { + + $HAVING = ""; + + if ($chk_reorder == "on") { + $HAVING = " HAVING SUM(s.total_unit-s.total_lost_unit-s.total_sale_unit-s.total_return_unit)<=p.re_order_qty"; + } + + $where = " 1=1 "; + + if ($item_name <> '-') { + $where .= " and p.item_name like '%" . $item_name . "%' "; + } + + if (!($opd_date_range == '' || $opd_date_range <> '0')) { + $rangeArray = explode("S", $opd_date_range); + $minRange = $rangeArray[0]; + $maxRange = $rangeArray[1]; + + $where .= " and s.stock_date between '" . $minRange . "' and '" . $maxRange . "'"; + } + + if ($supplier_id > 0) { + $where .= " and m.sid=$supplier_id"; + } + + if ($schedule_id == '') { + } else { + + $where .= " and (1<>1 "; + $schedule_id = explode("S", $schedule_id); + foreach ($schedule_id as $row) { + if ($row == 1) { + $where .= " or p.schedule_h=1 "; + } + + if ($row == 2) { + $where .= " or p.schedule_h1=1 "; + } + + if ($row == 3) { + $where .= " or p.schedule_x=1 "; + } + + if ($row == 4) { + $where .= " or p.schedule_g=1 "; + } + + if ($row == 5) { + $where .= " or p.narcotic=1 "; + } + } + $where .= ")"; + } + + + $sql = "SELECT p.item_name, p.id,p.genericname, + SUM(s.tqty) AS Pak_qty, + SUM(s.total_unit) AS P_Unit_Qty, + s.packing, + SUM(TRUNCATE((s.total_unit-s.total_sale_unit-s.total_lost_unit-s.total_return_unit)/s.packing,0)) AS C_Pak_Qty, + SUM(s.total_sale_unit) AS sale_unit, + SUM(TRUNCATE((s.total_sale_unit)/s.packing,0)) AS C_Pak_Sale_Qty, + p.re_order_qty, + SUM(s.total_unit-s.total_sale_unit) AS C_Unit_Stock_Qty, + SUM(TRUNCATE((s.total_unit-s.total_sale_unit),0))*MAX(s.purchase_unit_rate) AS Stock_Cost + FROM (med_store_product_master p JOIN purchase_invoice_item_stock s ON p.id=s.item_code and s.item_return=0) + JOIN purchase_invoice_stock m ON s.purchase_id=m.id + WHERE " . $where . " group by p.id,s.packing " . $HAVING . " order by p.Item_name"; + $query = $this->db->query($sql); + $stock_list = $query->result(); + + + $content = ""; + $content .= ' + + + + + + + + + + + '; + + foreach ($stock_list as $row) { + + if ($row->C_Pak_Qty <= $row->re_order_qty) { + $tr_color = 'style="background-color: #999999;"'; + } else { + $tr_color = ''; + } + + $content .= ' + + + + + + + '; + } + + $content .= '
Item NameTotal Unit QtyCurrent Unit QtyTotal Sale Unit QtyPackage/Re-Order QtyStock Cost
' . $row->item_name . '' . $row->P_Unit_Qty . '' . $row->C_Unit_Stock_Qty . '' . $row->sale_unit . '' . $row->packing . '' . $row->Stock_Cost . '
'; + + //echo $content; + ExportExcel($content, 'Report_Medical_store_stock'); + } + + public function Stock_result_excel_3($supplier_id, $opd_date_range, $item_name, $chk_reorder, $schedule_id = "") + { + + $HAVING = ""; + + if ($chk_reorder == "on") { + $HAVING = " HAVING SUM(s.total_unit-s.total_lost_unit-s.total_sale_unit-s.total_return_unit)<=p.re_order_qty"; + } + + $where = " 1=1 "; + + if ($item_name <> '-') { + $where .= " and p.item_name like '%" . $item_name . "%' "; + } + + if (!($opd_date_range == '' || $opd_date_range == '0')) { + $rangeArray = explode("S", $opd_date_range); + $minRange = $rangeArray[0]; + $maxRange = $rangeArray[1]; + + $where .= " and s.stock_date between '" . $minRange . "' and '" . $maxRange . "'"; + } + + if ($supplier_id > 0) { + $where .= " and m.sid=$supplier_id"; + } + + if ($schedule_id == '') { + } else { + + $where .= " and (1<>1 "; + $schedule_id = explode("S", $schedule_id); + foreach ($schedule_id as $row) { + if ($row == 1) { + $where .= " or p.schedule_h=1 "; + } + + if ($row == 2) { + $where .= " or p.schedule_h1=1 "; + } + + if ($row == 3) { + $where .= " or p.schedule_x=1 "; + } + + if ($row == 4) { + $where .= " or p.schedule_g=1 "; + } + + if ($row == 5) { + $where .= " or p.narcotic=1 "; + } + } + $where .= ")"; + } + + $sql = "SELECT p.item_name, p.id,p.genericname, + SUM(s.tqty) AS Pak_qty, + SUM(s.total_unit) AS P_Unit_Qty, + s.packing,s.batch_no,date_format(s.expiry_date,'%m-%Y') as str_exp, + s.mrp, + TRIM(',' FROM Concat(if(p.schedule_h=1,'schedule_h,',''), + if(p.schedule_h1=1,'schedule_h1,',''), + if(p.narcotic=1,'narcotic,',''), + if(p.schedule_x=1,'schedule_x,',''), + if(p.schedule_g=1,'schedule_g,',''))) as shed_x_h, + s.HSNCODE, + SUM(TRUNCATE((s.total_unit-s.total_sale_unit-s.total_lost_unit-s.total_return_unit)/s.packing,0)) AS C_Pak_Qty, + SUM(s.total_sale_unit) AS sale_unit,p.SGST_per, + SUM(TRUNCATE((s.total_sale_unit)/s.packing,0)) AS C_Pak_Sale_Qty, + p.re_order_qty, + SUM(s.total_unit-s.total_sale_unit) AS C_Unit_Stock_Qty,s.purchase_unit_rate, + SUM(TRUNCATE((s.total_unit-s.total_sale_unit-total_lost_unit-s.total_return_unit),0))*MAX(s.purchase_unit_rate) AS Stock_Cost , + v.name_supplier,date_format(date_of_invoice,'%d-%m-%Y') as P_Date + FROM ((med_store_product_master p JOIN purchase_invoice_item_stock s ON p.id=s.item_code) + JOIN purchase_invoice_stock m ON s.purchase_id=m.id ) + JOIN stock_supplier v on v.sid=m.sid + WHERE " . $where . " group by p.id,s.packing " . $HAVING . " order by p.Item_name"; + $query = $this->db->query($sql); + $stock_list = $query->result(); + + + $content = ""; + $content .= ' + + + + + + + + + + + + + + + + + + + + '; + + foreach ($stock_list as $row) { + + if ($row->C_Pak_Qty <= $row->re_order_qty) { + $tr_color = 'style="background-color: #999999;"'; + } else { + $tr_color = ''; + } + + $content .= ' + + + + + + + + + + + + + + + + '; + } + + $content .= '
Item NameCompostion Name (Salt Name)Pur. DateBatch No.ExpiryPurchase Unit QtySale Unit QtyCur. QtyShedule H / XSuppLier NameHSN CodeGST PerStock CostPurchase RateMRP
' . $row->item_name . '' . $row->genericname . '' . $row->P_Date . '' . $row->batch_no . '' . $row->str_exp . '' . $row->P_Unit_Qty . '' . $row->sale_unit . '' . $row->C_Unit_Stock_Qty . '' . $row->shed_x_h . '' . $row->name_supplier . '' . $row->HSNCODE . '' . $row->SGST_per . '' . $row->Stock_Cost . '' . $row->purchase_unit_rate . '' . $row->mrp . '
'; + + //echo $content; + ExportExcel($content, 'Report_Medical_store_stock'); + } + + + + + + + + + +} \ No newline at end of file diff --git a/old_code_ci3/controllers/Testcont.php b/old_code_ci3/controllers/Testcont.php new file mode 100644 index 0000000..16d936d --- /dev/null +++ b/old_code_ci3/controllers/Testcont.php @@ -0,0 +1,137 @@ +load->library("Barcode"); + + $bar_content_bar=rawurldecode($bar_content); + + $barcodeobj = new TCPDFBarcode($bar_content_bar, 'C128'); + $barcode = $barcodeobj->getBarcodePNG(2, 30, array(0,128,0)); + echo $barcode; + + } + + public function bar2($bar_content) { + + $this->load->library("Barcode2"); + + $bar_content_bar=rawurldecode($bar_content); + + $barcodeobj = new TCPDF2DBarcode($bar_content_bar, 'QRCODE,L'); + $barcode = $barcodeobj->getBarcodePNG(); + echo $barcode; + } + + public function test_upload() + { + $this->load->view('testcode/test_1'); + } + + public function save_image($user_id) + { + $filename = $user_id.time() . '.jpg'; + $filepath = '/uploads/'; + + $config['upload_path'] = 'uploads'; + $config['allowed_types'] = 'gif|jpg|png|jpeg'; + + $new_name = time().$_FILES["webcam"]['name']; + $config['file_name'] = $new_name; + + $this->load->library('upload', $config); + if (!$this->upload->do_upload('webcam')) { + $error = array('error' => $this->upload->display_errors()); + echo $error['error']; + } + } + + + public function testdir($file_v_no) + { + $sql="select * from file_opd_rec where v_no=$file_v_no"; + $query = $this->db->query($sql); + $chk_file= $query->result(); + + if(count($chk_file)>0) + { + $full_path=$chk_file[0]->full_path; + $start_no=stripos($full_path,$file_v_no); + $end_no=strlen($full_path); + + $folder_name=substr($full_path,0,$start_no); + + $files_info = get_dir_file_info($folder_name); + + Echo '
';
+			print_r($files_info);
+			Echo '
'; + + foreach($files_info as $key => $value) { + $find_file=number_format(substr_count($value['name'],$file_v_no),0); + if($find_file==1) + { + echo ' File Name :'.$value['name'].' / Find File '.$file_v_no.'
'; + $index_key=str_replace($file_v_no.'_','',$value['name']); + $index_key=str_replace('.webm','',$index_key); + + $file_list[$index_key] = $value['name']; + } + } + + ksort($file_list); + + echo 'No. of Files :'. count($file_list); + + $prev_file=''; + $current_file=''; + foreach($file_list as $key => $value) { + $current_file=$folder_name.'/'.$value; + if(strlen($prev_file)>0) + { + //First File + $objFH = fopen( $prev_file, "rb" ); + $strBuffer1 = fread( $objFH, filesize( $prev_file) ); + fclose( $objFH ); + + //Second File + $objFH = fopen( $current_file, "rb" ); + $strBuffer2 = fread( $objFH, filesize( $current_file) ); + fclose( $objFH ); + + // manipulate buffers here... + $strBuffer3 = $strBuffer1 . $strBuffer2; + + // open for write/binary-safe + $objFH = fopen( $current_file, "wb" ); + fwrite( $objFH, $strBuffer3 ); + fclose( $objFH ); + + //Delete prev File + unlink($prev_file); + } + + $prev_file=$current_file; + } + + Echo '
';
+			print_r($file_list);
+			Echo '
'; + + + } + + } + + public function test_math() + { + Test_exp("2+5*3"); + } + +} \ No newline at end of file diff --git a/old_code_ci3/controllers/User_Authentication.php b/old_code_ci3/controllers/User_Authentication.php new file mode 100644 index 0000000..f97a6c9 --- /dev/null +++ b/old_code_ci3/controllers/User_Authentication.php @@ -0,0 +1,84 @@ +load->helper('form'); + + // Load form validation library + $this->load->library('form_validation'); + + // Load session library + $this->load->library('session'); + + $this->load->helper('security'); +} + +// Show login page +public function index() { + $this->load->view('Mobile_app/login'); +} + +// Check for user login process +public function user_login_process() { + + // Retrieve session data + $session_set_value = $this->session->all_userdata(); + + // Check for remember_me data in retrieved session data + if (isset($session_set_value['remember_me']) && $session_set_value['remember_me'] == "1") { + //$this->load->view('admin_page'); + $data['user'] = 1; + $this->load->view('Mobile_app/index',$data); + } else { + + // Check for validation + $this->form_validation->set_rules('username', 'Username', 'trim|required|xss_clean'); + $this->form_validation->set_rules('password', 'Password', 'trim|required|xss_clean'); + + if ($this->form_validation->run() == FALSE) { + //$this->load->view('login_form'); + $this->load->view('Mobile_app/login'); + } else { + $username = $this->input->post('username'); + $password = $this->input->post('password'); + if ($username == "fugo" && $password == "formget") { + $remember = $this->input->post('remember_me'); + if ($remember) { + // Set remember me value in session + $this->session->set_userdata('remember_me', TRUE); + } + $sess_data = array( + 'username' => $username, + 'password' => $password + ); + + $this->session->set_userdata('logged_in', $sess_data); + //$this->load->view('admin_page'); + + $data['user'] = 1; + $this->load->view('Mobile_app/index',$data); + + } else { + $data = array( + 'error_message' => 'Invalid Username or Password' + ); + $this->load->view('Mobile_app/login', $data); + } + } + } +} + +// Logout from admin page +public function logout() { + + // Destroy session data + $this->session->sess_destroy(); + $data['message_display'] = 'Successfully Logout'; + $this->load->view('Mobile_app/login', $data); +} + +}?> \ No newline at end of file diff --git a/old_code_ci3/controllers/Web_medical.php b/old_code_ci3/controllers/Web_medical.php new file mode 100644 index 0000000..9fb0eb5 --- /dev/null +++ b/old_code_ci3/controllers/Web_medical.php @@ -0,0 +1,9 @@ +load->view('form'); + } + + public function submission() + { + + if (!$this->input->is_ajax_request()) { exit('no valid req.'); } + + $FormRules = array( + array( + 'field' => 'inputEmail3', + 'label' => 'Email Address', + 'rules' => 'required|min_length[5]|max_length[30]|valid_email' + ) + ); + + $this->form_validation->set_rules($FormRules); + + if ($this->form_validation->run() == TRUE) + { + echo '
Your website is submitted
'; + } + else + { + echo '
'.validation_errors().'
'; + } + } + + } diff --git a/old_code_ci3/controllers/Welcome.php b/old_code_ci3/controllers/Welcome.php new file mode 100644 index 0000000..f14df7e --- /dev/null +++ b/old_code_ci3/controllers/Welcome.php @@ -0,0 +1,105 @@ +load->view('welcome_message'); + } + + public function logout() + { + $this->ion_auth->logout(); + redirect('auth_dst/login', 'refresh'); + } + + public function index() + { + if (!$this->ion_auth->logged_in()) + { + redirect('auth_dst/login', 'refresh'); + } + + $d= $this->ion_auth->user()->row(); + + $data['user'] = $d; + + //print_r($d); + + $sql="SELECT count(opd_id) as no_opd_id + FROM opd_master WHERE online_book=1 and apointment_date=date(sysdate())"; + $query = $this->db->query($sql); + $opd_master= $query->result(); + + $data['No_of_online_opd']=$opd_master[0]->no_opd_id; + + $this->load->view('Header',$data); + $this->load->view('LeftSide',$data); + $this->load->view('AdminMain'); + //$this->load->view('ControlSide'); + $this->load->view('Footer'); + } + + public function loademail() + { + $this->load->view('TestForm'); + } + public function loademail2() + { + $this->load->view('TestForm2'); + } + + public function check_login() + { + if (!$this->ion_auth->logged_in()) + { + $rvar=array( + 'login' =>1 + ); + $encode_data = json_encode($rvar); + echo $encode_data; + } + } + + public function Patient() + { + $this->load->view('Patient'); + } + + + function update_online_opd(){ + + $sql="SELECT count(opd_id) as no_opd_id + FROM opd_master + WHERE online_book=1 and apointment_date=date(sysdate())"; + $query = $this->db->query($sql); + $opd_master= $query->result(); + + $No_of_online_opd=$opd_master[0]->no_opd_id; + + $rvar=array( + 'online_opd' =>$No_of_online_opd, + ); + + $encode_data = json_encode($rvar); + echo $encode_data; + + } + + + function opd_online_list() + { + $sql="SELECT o.*,p.p_code,p.p_fname + FROM opd_master o JOIN patient_master p on o.p_id=p.id + WHERE o.online_book=1 and o.apointment_date=date(sysdate())"; + $query = $this->db->query($sql); + $data['opd_online_list']= $query->result(); + + $this->load->view('dashboard/opd_line_list',$data); + + } + + +} diff --git a/old_code_ci3/controllers/Workplace.php b/old_code_ci3/controllers/Workplace.php new file mode 100644 index 0000000..df55ae9 --- /dev/null +++ b/old_code_ci3/controllers/Workplace.php @@ -0,0 +1,14 @@ +load->view('workplace/workpanel'); + } +} \ No newline at end of file diff --git a/old_code_ci3/controllers/index.html b/old_code_ci3/controllers/index.html new file mode 100644 index 0000000..b702fbc --- /dev/null +++ b/old_code_ci3/controllers/index.html @@ -0,0 +1,11 @@ + + + + 403 Forbidden + + + +

Directory access is forbidden.

+ + + diff --git a/old_code_ci3/controllers/php_opd_appointment_online.php b/old_code_ci3/controllers/php_opd_appointment_online.php new file mode 100644 index 0000000..0e8327c --- /dev/null +++ b/old_code_ci3/controllers/php_opd_appointment_online.php @@ -0,0 +1,248 @@ + $apiKey, 'numbers' => $numbers, "sender" => $sender, "message" => $message); + // Send the POST request with cURL + $ch = curl_init('https://api.textlocal.in/send/'); + curl_setopt($ch, CURLOPT_POST, true); + curl_setopt($ch, CURLOPT_POSTFIELDS, $data); + curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); + $response = curl_exec($ch); + curl_close($ch); + +} + +$conn_main=mysqli_connect("localhost","root","Bisht@9720958717","main_website") or die("Unable to connect to Main Server"); + +if (mysqli_connect_errno()) +{ + echo "Failed to connect to MySQL: " . mysqli_connect_error(); +} + +// New Patient Create in HMS + +$sql = "select * from patient_master p where p.p_id=0 order by id limit 1"; + +$result = mysqli_query($conn_main,$sql) or die(mysqli_error($conn_main)); + +$flag=0; + +while($row = mysqli_fetch_array($result)) + { + $hospital_id=$row['hospital_id']; + $p_fname =$row['p_fname']; + $p_relative = $row['p_relative']; + $p_rname= $row['p_rname']; + $gender= $row['gender']; + $dob= $row['dob']; + $mphone1= $row['mphone1']; + + + $sql="select * from hospital_client where hospital_id=".$hospital_id; + $hospital_data = mysqli_query($conn_main,$sql) or die(mysqli_error($conn_main)); + + while($row_hospital = mysqli_fetch_array($hospital_data)) + { + $hospital_name=$row_hospital['hospital_name']; + $online_url=$row_hospital['online_url']; + $webservice_url=$row_hospital['webservice_url']; + $vpn_server_id=$row_hospital['vpn_server_id']; + + $data = array( + 'mphone1' => $mphone1, + 'p_fname' => strtoupper($p_fname), + 'gender' => $gender, + 'p_relative' => $p_relative, + 'p_rname' => strtoupper($p_rname), + 'dob' => $dob, + 'estimate_dob' => 1 + ); + + $data_json = json_encode($data); + + $post_url=$webservice_url.'/Opd_online_api/patient_create'; + echo $post_url; + $ch = curl_init(); + curl_setopt($ch, CURLOPT_URL, $post_url); + curl_setopt($ch, CURLOPT_HEADER, 0); + //curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/json')); + curl_setopt($ch, CURLOPT_POST, 1); + curl_setopt($ch, CURLOPT_POSTFIELDS,$data); + curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); + $response = curl_exec($ch); + curl_close($ch); + + $retrun_data=json_decode(utf8_encode($response)); + + var_dump($retrun_data); + } + + $update_sql="update patient_master + set p_id=".$retrun_data->New_UHID.", + p_code='".$retrun_data->p_code."' + where id=".$row['id']; + + echo $update_sql; + + mysqli_query($conn_main,$update_sql); + + } + +// New Patient Created End + +//Update Patient_Id in OPd_BOOK Table +$update_sql="UPDATE patient_master p JOIN opd_book b ON p.id=b.online_patient_id +SET b.hospital_patient_id=p.p_id +WHERE p.p_id>0 AND b.hospital_patient_id=0"; + +mysqli_query($conn_main,$update_sql); + +//Update Payment Info in OPD_BOOK Table + +$update_sql="UPDATE opd_book b JOIN payments p ON p.product_id=b.id +SET b.pg_id=p.id +WHERE b.pg_id IS null"; + +mysqli_query($conn_main,$update_sql); + +// OPD Registering Process Start here + +$sql="select * from opd_book +where pg_id>0 and (hospital_opd_id=0 or hospital_opd_id is null)"; + +$opd_book_data = mysqli_query($conn_main,$sql) or die(mysqli_error($conn_main)); + +while($row_opd_book = mysqli_fetch_array($opd_book_data)) +{ + $hospital_patient_id=$row_opd_book['hospital_patient_id']; + $hospital_doc_id=$row_opd_book['hospital_doc_id']; + $appointment_date=$row_opd_book['appointment_date']; + $opd_fee=$row_opd_book['opd_fee']; + $hospital_id=$row_opd_book['hospital_id']; + + $sql="select * from hospital_client where hospital_id=".$hospital_id; + $hospital_data = mysqli_query($conn_main,$sql) or die(mysqli_error($conn_main)); + + while($row_hospital = mysqli_fetch_array($hospital_data)) + { + $hospital_name=$row_hospital['hospital_name']; + $online_url=$row_hospital['online_url']; + $webservice_url=$row_hospital['webservice_url']; + $vpn_server_id=$row_hospital['vpn_server_id']; + + $data = array( + 'hospital_patient_id' => $hospital_patient_id, + 'hospital_doc_id' => $hospital_doc_id, + 'appointment_date' => $appointment_date, + 'opd_fee'=> $opd_fee + ); + + $data_json = json_encode($data); + + $post_url=$webservice_url.'/Opd_online_api/opd_register'; + echo $post_url; + $ch = curl_init(); + curl_setopt($ch, CURLOPT_URL, $post_url); + curl_setopt($ch, CURLOPT_HEADER, 0); + //curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/json')); + curl_setopt($ch, CURLOPT_POST, 1); + curl_setopt($ch, CURLOPT_POSTFIELDS,$data); + curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); + $response = curl_exec($ch); + curl_close($ch); + + $retrun_data=json_decode(utf8_encode($response)); + + var_dump($retrun_data); + + $update_sql="update opd_book + set hospital_opd_id=".$retrun_data->OPD_ID." + where id=".$row_opd_book['id']; + + mysqli_query($conn_main,$update_sql); + + //Send SMS + + $sms_template="Your OPD Appointment with Dr. #DrName# has been Booked. +
Booked No : #BookNo#. +
Date: #date# +
Time Between #time# +
Place: #HospitalName# +
Thanks DevSoft Tech"; + + $sql="Select * from opd_slot where slot_id=".$row_opd_book['slot_id']; + $opd_slot = mysqli_query($conn_main,$sql) or die(mysqli_error($conn_main)); + + if($row_opd_slot = mysqli_fetch_array($opd_slot)) + { + $str_time=$row_opd_slot['slot_desc']; + }else{ + $str_time=' '; + } + + $sms_template=str_replace('#DrName#',$retrun_data->DOC_NAME,$sms_template); + $sms_template=str_replace('#BookNo#',$retrun_data->BOOKNO,$sms_template); + $sms_template=str_replace('#date#',$retrun_data->BOOKDATE,$sms_template); + $sms_template=str_replace('#time#',$str_time,$sms_template); + $sms_template=str_replace('#HospitalName#',$hospital_name,$sms_template); + + $mphone1=$retrun_data->PHONENO; + + $sms_send="insert into sms_outbox (hospital_id,phone_number,content) + values ($hospital_id,$mphone1,'$sms_template')"; + + $write_web_sms="insert into web_msg_content (web_content,web_content_key,msg_insert_date,hospital_id,hospital_name,phone_no) + values ('".$data_sms."','Medicine',sysdate(),1,'Krishna Pharmcy','".$sender_number."')"; + + if ($conn_main->query($sms_send) === TRUE) { + $last_id = $conn_main->insert_id; + echo "New record created successfully. Last inserted ID is: " . $last_id; + + $url_link="https://m.dhms.in/msg/show/".$last_id; + $from_hospital=$hospital_name; + + //Send SMS End + + $insert_sms_sql="INSERT INTO sms_fast2sms (hospital_id, sender_id, message, variables_values, route, numbers) + VALUES (".$hospital_id.", 'DSTWEB', 160545, '".$hospital_name."|".$url_link."', 'dlt', '".substr($mphone1,-10)."')"; + + echo $insert_sms_sql; + + mysqli_query($conn_main,$insert_sms_sql); + + } else { + echo "Error: " . $sms_send . "
" . $conn->error; + } + + + + + + + + + + echo $sms_send; + + mysqli_query($conn_main,$sms_send); + } + +} + + +// OPD Registered , Process End Here +mysqli_close($conn_main); +//echo date("l jS \of F Y h:i:s A"); diff --git a/old_code_ci3/helpers/commonfunction_helper.php b/old_code_ci3/helpers/commonfunction_helper.php new file mode 100644 index 0000000..5d066f9 --- /dev/null +++ b/old_code_ci3/helpers/commonfunction_helper.php @@ -0,0 +1,217 @@ +0) + { + return "checked"; + } + else{ + return ""; + } +} + +function Doc_Value($doc_id) +{ + return 'Hello'; +} + +function Show_Alert($alert_type,$Head_title,$Body_content) +{ + $showAlert='
+ + '.$Head_title.' '.$Body_content.'
'; + + return $showAlert; +} + +function number_to_word($number) +{ + $no = round($number); + $point = round($number - $no, 2) * 100; + $hundred = null; + $digits_1 = strlen($no); + $i = 0; + $str = array(); + $words = array('0' => '', '1' => 'one', '2' => 'two', + '3' => 'three', '4' => 'four', '5' => 'five', '6' => 'six', + '7' => 'seven', '8' => 'eight', '9' => 'nine', + '10' => 'ten', '11' => 'eleven', '12' => 'twelve', + '13' => 'thirteen', '14' => 'fourteen', + '15' => 'fifteen', '16' => 'sixteen', '17' => 'seventeen', + '18' => 'eighteen', '19' =>'nineteen', '20' => 'twenty', + '30' => 'thirty', '40' => 'forty', '50' => 'fifty', + '60' => 'sixty', '70' => 'seventy', + '80' => 'eighty', '90' => 'ninety'); + $digits = array('', 'hundred', 'thousand', 'lakh', 'crore'); + while ($i < $digits_1) { + $divider = ($i == 2) ? 10 : 100; + $number = floor($no % $divider); + $no = floor($no / $divider); + $i += ($divider == 10) ? 1 : 2; + if ($number) { + $plural = (($counter = count($str)) && $number > 9) ? 's' : null; + $hundred = ($counter == 1 && $str[0]) ? ' and ' : null; + $str [] = ($number < 21) ? $words[$number] . + " " . $digits[$counter] . $plural . " " . $hundred + : + $words[floor($number / 10) * 10] + . " " . $words[$number % 10] . " " + . $digits[$counter] . $plural . " " . $hundred; + } else $str[] = null; + } + $str = array_reverse($str); + $result = implode('', $str); + $points = ($point) ? + "." . $words[$point / 10] . " " . + $words[$point = $point % 10] : ''; + + + $rvalue="".ucwords($result)." Only"; + return $rvalue; + +} + +function ExportExcel($table,$filename) +{ + + //header("Content-type: application/x-msdownload"); + //header('Content-Disposition: attachment; filename="filename.xls"'); + + // Sending headers to force the user to download the file + header('Content-Type: application/vnd.ms-excel'); + header('Content-Disposition: attachment;filename="'.$filename.'_'.date('dMy').'.xls"'); + header('Cache-Control: max-age=0'); + header("Pragma: no-cache"); + header("Expires: 0"); + + echo $table; +} + +function objectToArray($d) { + if (is_object($d)) { + // Gets the properties of the given object + // with get_object_vars function + $d = get_object_vars($d); + } + + if (is_array($d)) { + /* + * Return array converted to object + * Using __FUNCTION__ (Magic constant) + * for recursive call + */ + return array_map(__FUNCTION__, $d); + } + else { + // Return array + return $d; + } +} + +function compare_arrays($data1,$data2) + { + $data_change=""; + + foreach ($data2 as $key => $value) + { + + if((isset($data1[$key])) && (strtoupper($key)!='LOG')) + { + if($value!=$data1[$key]) + { + $data_change.='Field :'.$key.' Old Value:{'.$data1[$key].'} => New Value:{'.$value.'}'.PHP_EOL; + } + } + + } + + return $data_change; + } + + function cal_exp($exp) + { + //$string = "(11+10)*3"; + $string = $exp; + $result="Not Valid"; + $pattern = '~^[0-9()+\-*\/.]+$~'; + if(preg_match($pattern, $string)){ + $math_string ="return (".$string.");"; + $result = floatval(@eval($math_string)); + } + + if(is_numeric($result)){ + round($result,2); + } + + return $result; + } + + + + + + + + + + + + + + + + + + + + + + + + + + +?> \ No newline at end of file diff --git a/old_code_ci3/helpers/index.html b/old_code_ci3/helpers/index.html new file mode 100644 index 0000000..b702fbc --- /dev/null +++ b/old_code_ci3/helpers/index.html @@ -0,0 +1,11 @@ + + + + 403 Forbidden + + + +

Directory access is forbidden.

+ + + diff --git a/old_code_ci3/models/DbRemote_M.php b/old_code_ci3/models/DbRemote_M.php new file mode 100644 index 0000000..e69de29 diff --git a/old_code_ci3/models/DocFormat_M.php b/old_code_ci3/models/DocFormat_M.php new file mode 100644 index 0000000..ac5e084 --- /dev/null +++ b/old_code_ci3/models/DocFormat_M.php @@ -0,0 +1,93 @@ +db->insert("doc_format_master", $data)) { + $insert_id = $this->db->insert_id(); + return $insert_id; + }else + return 0; + } + + public function insert_sub($data) { + + if ($this->db->insert("doc_format_sub", $data)) { + $insert_id = $this->db->insert_id(); + return $insert_id; + }else + return 0; + } + + public function insert_sub_item($data) { + + if ($this->db->insert("doc_format_sub_item", $data)) { + $insert_id = $this->db->insert_id(); + return $insert_id; + }else + return 0; + } + + public function update_master($data,$old_id_no) { + $this->db->set($data); + $this->db->where("df_id", $old_id_no); + if ($this->db->update("doc_format_master", $data)) { + return 1; + }else + return 0; + } + + public function update_sub($data,$old_id_no) { + $this->db->set($data); + $this->db->where("id", $old_id_no); + if ($this->db->update("doc_format_sub", $data)) { + return 1; + }else + return 0; + } + + public function update_sub_item($data,$old_id_no) { + $this->db->set($data); + $this->db->where("id", $old_id_no); + if ($this->db->update("doc_format_sub_item", $data)) { + return 1; + }else + return 0; + } + + public function insert_patient_doc($data) { + if ($this->db->insert("patient_doc", $data)) { + $insert_id = $this->db->insert_id(); + return $insert_id; + }else + return 0; + } + + public function update_patient_doc($data,$old_id_no) { + $this->db->set($data); + $this->db->where("id", $old_id_no); + if ($this->db->update("patient_doc", $data)) { + return 1; + }else + return 0; + } + + public function insert_patient_doc_raw($data) { + $this->db->insert("patient_doc_raw", $data); + $insert_id = $this->db->insert_id(); + return $insert_id ; + } + + public function update_patient_doc_raw($data,$old_id_no) { + $this->db->set($data); + $this->db->where("id", $old_id_no); + $this->db->update("patient_doc_raw", $data); + } + +} +?> \ No newline at end of file diff --git a/old_code_ci3/models/Doctor_M.php b/old_code_ci3/models/Doctor_M.php new file mode 100644 index 0000000..bc82b9a --- /dev/null +++ b/old_code_ci3/models/Doctor_M.php @@ -0,0 +1,133 @@ +db->query($sql); + $result = $query->result_array(); + //print_r($result); + return $result; + } + + public function insert($data) { + + if ($this->db->insert("doctor_master", $data)) { + $insert_id = $this->db->insert_id(); + return $insert_id; + }else + return 0; + } + + public function insert_spec($data) { + + if ($this->db->insert("doc_spec", $data)) { + $insert_id = $this->db->insert_id(); + return $insert_id; + }else + return 0; + } + + public function insert_fee($data) { + + if ($this->db->insert("doc_opd_fee", $data)) { + $insert_id = $this->db->insert_id(); + return $insert_id; + }else + return 0; + } + + public function update_fee($data,$old_id_no) { + $this->db->set($data); + $this->db->where("id", $old_id_no); + if ($this->db->update("doc_opd_fee", $data)) { + return 1; + }else + return 0; + } + + public function update($data,$old_id_no) { + $this->db->set($data); + $this->db->where("id", $old_id_no); + if ($this->db->update("doctor_master", $data)) { + return 1; + }else + return 0; + } + + + + + public function delete_fee($delete_id_no) { + $this->db->where('id', $delete_id_no); + $q = $this->db->get('doc_opd_fee'); + // if id is unique, we want to return just one row + $data = $q->row_array(); + + $user = $this->ion_auth->user()->row(); + $user_id = $user->id; + $user_name = $user->first_name.''. $user->last_name . '['.date("d-m-Y h:i").']'; + + $data['remove_update_by']=$user_name; + + if ($this->db->insert("doc_opd_fee_update", $data)) { + $this->db->where("id", $delete_id_no); + $this->db->delete("doc_opd_fee"); + return 1; + }else{ + return 0; + } + } + + //opd_prescription_template + + public function insert_opd_prescription_template($data) { + if ($this->db->insert("opd_prescription_template", $data)) { + $insert_id = $this->db->insert_id(); + return $insert_id; + }else + return 0; + } + + //opd_prescription_template -> Sub opd_prescrption_prescribed_template + public function insert_opd_prescrption_prescribed_template($data) { + if ($this->db->insert("opd_prescrption_prescribed_template", $data)) { + $insert_id = $this->db->insert_id(); + return $insert_id; + }else + return 0; + } + + public function remove_p_medical($delid) { + $this->db->where("id", $delid); + $this->db->delete("opd_prescrption_prescribed_template"); + } + + + + public function update_opd_prescription_template($data,$old_id_no) { + $this->db->set($data); + $this->db->where("id", $old_id_no); + if ($this->db->update("opd_prescription_template", $data)) { + return 1; + }else + return 0; + } + + public function update_opd_prescrption_prescribed_template($data,$old_id_no) { + $this->db->set($data); + $this->db->where("id", $old_id_no); + if ($this->db->update("opd_prescrption_prescribed_template", $data)) { + return 1; + }else + return 0; +} + + + +} +?> \ No newline at end of file diff --git a/old_code_ci3/models/DotPrint_M.php b/old_code_ci3/models/DotPrint_M.php new file mode 100644 index 0000000..f00c77c --- /dev/null +++ b/old_code_ci3/models/DotPrint_M.php @@ -0,0 +1,25 @@ +db->insert("dot_printer", $data)) { + $insert_id = $this->db->insert_id(); + return $insert_id; + }else + return 0; + } + + public function update($data,$old_id_no) { + $this->db->set($data); + $this->db->where("id", $old_id_no); + if ($this->db->update("dot_printer", $data)) { + return 1; + }else + return 0; + } +} \ No newline at end of file diff --git a/old_code_ci3/models/ECHS_M.php b/old_code_ci3/models/ECHS_M.php new file mode 100644 index 0000000..8334e9b --- /dev/null +++ b/old_code_ci3/models/ECHS_M.php @@ -0,0 +1,43 @@ +db->insert("echs_master", $data)) { + $insert_id = $this->db->insert_id(); + $pid=1000000+$insert_id; + $pid=date('ym').$pid; + + return $insert_id; + }else + return 0; + } + + public function insert_mem($data) { + + if ($this->db->insert("echs_member", $data)) { + $insert_id = $this->db->insert_id(); + return $insert_id; + }else + return 0; + } + + public function update_mem($data,$old_id_no) { + $this->db->set($data); + $this->db->where("id", $old_id_no); + $this->db->update("echs_member", $data); + } + + public function update($data,$old_id_no) { + $this->db->set($data); + $this->db->where("id", $old_id_no); + $this->db->update("echs_master", $data); + } + + + } +?> \ No newline at end of file diff --git a/old_code_ci3/models/FileMedical_M.php b/old_code_ci3/models/FileMedical_M.php new file mode 100644 index 0000000..4508645 --- /dev/null +++ b/old_code_ci3/models/FileMedical_M.php @@ -0,0 +1,61 @@ +db->insert("purchase_invoice_scan_file", $data)) { + $insert_id = $this->db->insert_id(); + + return $insert_id; + } else { + echo $this->db->_error_message(); + return 0; + } + } + + public function update_purchase_scan($data, $old_id_no) + { + $this->db->set($data); + $this->db->where("id", $old_id_no); + $this->db->update("purchase_invoice_scan_file", $data); + } + + function get_purchase_scan_filedetail($id) + { + return $this->db->get_where('purchase_invoice_scan_file', array('id' => $id))->row_array(); + } + + function get_filedetail_file_url($id) + { + if ($id == '' || $id == 0) { + $file_url = "No File"; + } else { + $file_url = $this->db->get_where('purchase_invoice_scan_file', array('id' => $id))->row()->full_path; + } + + return $file_url; + } + + function delete_purchase_scan_fileupload($id) + { + $this->db->where('id', $id); + $q = $this->db->get('purchase_invoice_scan_file'); + // if id is unique, we want to return just one row + $data = $q->row_array(); + + $user_name = $this->session->userdata('username') . '[' . $this->session->userdata('agent_id') . ']' . date('d-m-Y H:i:s'); + $data['delete_by'] = $user_name; + + if ($this->db->insert("purchase_invoice_scan_file_delete", $data)) { + return $this->db->delete('purchase_invoice_scan_file', array('id' => $id)); + } else { + return 0; + } + } +} diff --git a/old_code_ci3/models/FileOPDRec_M.php b/old_code_ci3/models/FileOPDRec_M.php new file mode 100644 index 0000000..a44f330 --- /dev/null +++ b/old_code_ci3/models/FileOPDRec_M.php @@ -0,0 +1,62 @@ +db->query($sql); + $chk_file= $query->result(); + + if(count($chk_file)>0) + { + $this->db->set($data); + $this->db->where("v_no",$file_v_no); + $this->db->update("file_opd_rec", $data); + }else{ + $data['v_no']=$file_v_no; + if ($this->db->insert("file_opd_rec", $data)) { + $insert_id = $this->db->insert_id(); + return $insert_id; + }else{ + echo $this->db->_error_message(); + return 0; + } + } + } + + public function file_complie($file_v_no) + { + $sql="select * from file_opd_rec where v_no=$file_v_no"; + $query = $this->db->query($sql); + $chk_file= $query->result(); + + if(count($chk_file)>0) + { + $full_path=$chk_file[0]->full_path; + $start_no=stripos($full_path,$file_v_no); + $end_no=strlen($full_path); + + $folder_name=substr($full_path,0,$start_no); + + $files_info = get_dir_file_info($folder_name); + + Echo '
';
+		        print_r($files_info) ;
+		    Echo '
'; + } + + } + + public function update($data,$old_id_no) { + $this->db->set($data); + $this->db->where("id", $old_id_no); + $this->db->update("file_opd_rec", $data); + } + +} +?> \ No newline at end of file diff --git a/old_code_ci3/models/File_M.php b/old_code_ci3/models/File_M.php new file mode 100644 index 0000000..b97fe5a --- /dev/null +++ b/old_code_ci3/models/File_M.php @@ -0,0 +1,63 @@ +db->insert("file_upload_data", $data)) { + $insert_id = $this->db->insert_id(); + + return $insert_id; + }else{ + echo $this->db->_error_message(); + return 0; + } + } + + public function update($data,$old_id_no) { + $this->db->set($data); + $this->db->where("id", $old_id_no); + $this->db->update("file_upload_data", $data); + } + + function get_filedetail($id) + { + return $this->db->get_where('file_upload_data',array('id'=>$id))->row_array(); + } + + function get_filedetail_file_url($id) + { + if($id=='' || $id==0 ) + { + $file_url="No File"; + + }else{ + $file_url=$this->db->get_where('file_upload_data',array('id'=>$id))->row()->full_path; + } + + return $file_url; + } + + function delete_fileupload($id) + { + $this->db->where('id', $id); + $q = $this->db->get('file_upload_data'); + // if id is unique, we want to return just one row + $data = $q->row_array(); + + $user_name=$this->session->userdata('username').'['.$this->session->userdata('agent_id').']'.date('d-m-Y H:i:s'); + $data['delete_by']=$user_name; + + if ($this->db->insert("file_upload_data_delete", $data)) + { + return $this->db->delete('file_upload_data',array('id'=>$id)); + }else{ + return 0; + } + } + +} +?> \ No newline at end of file diff --git a/old_code_ci3/models/Insurance_M.php b/old_code_ci3/models/Insurance_M.php new file mode 100644 index 0000000..bdb8c71 --- /dev/null +++ b/old_code_ci3/models/Insurance_M.php @@ -0,0 +1,29 @@ +db->insert("hc_insurance", $data)) { + $insert_id = $this->db->insert_id(); + + return $insert_id; + }else + return 0; + } + + public function update($data,$old_id_no) { + + $this->db->set($data); + $this->db->where("id", $old_id_no); + if ($this->db->update("hc_insurance", $data)) { + return 1; + }else + return 0; + } +} +?> \ No newline at end of file diff --git a/old_code_ci3/models/Invoice_M.php b/old_code_ci3/models/Invoice_M.php new file mode 100644 index 0000000..6f07fa1 --- /dev/null +++ b/old_code_ci3/models/Invoice_M.php @@ -0,0 +1,95 @@ +db->insert("invoice_master", $data)) { + $insert_id = $this->db->insert_id(); + + $pid=str_pad(substr($insert_id,-7,7),7,0,STR_PAD_LEFT); + + $pid='N'.date('ym').$pid; + $data1 = array( + 'invoice_code' => $pid + ); + + $this->db->set($data1); + $this->db->where("id", $insert_id); + $this->db->update("invoice_master", $data1); + + return $insert_id; + }else + return 0; + } + + public function addinvoiceitem($data) + { + if ($this->db->insert("invoice_item", $data)) { + $insert_id = $this->db->insert_id(); + + $this->db->query("CALL p_cal_invoice_byItem(".$insert_id.")"); + + return $insert_id; + }else + return 0; + } + + public function deleteinvoiceitem($del_id) + { + $this->db->where('id', $del_id); + $q = $this->db->get('invoice_item'); + // if id is unique, we want to return just one row + $data = $q->row_array(); + + $user = $this->ion_auth->user()->row(); + $user_id = $user->id; + $user_name = $user->first_name.''. $user->last_name; + + $data['update_by_id']=$user_id; + $data['update_by']=$user_name; + $data['update_action']='1'; + + if ($this->db->insert("invoice_item_update", $data)) { + $this->db->where("id", $del_id); + $this->db->delete("invoice_item"); + return 1; + }else{ + return 0; + } + + $this->db->query("CALL p_cal_invoice_byItem(".$data['inv_master_id'].")"); + } + + public function update($data,$old_id_no) { + $this->db->set($data); + $this->db->where("id", $old_id_no); + $this->db->update("invoice_master", $data); + + $this->db->query("CALL p_cal_invoice_byItem(".$old_id_no.")"); + } + + public function update_item($data,$old_id_no) { + $this->db->set($data); + $this->db->where("id", $old_id_no); + $this->db->update("invoice_item", $data); + + $this->db->where('id', $old_id_no); + $q = $this->db->get('invoice_item'); + // if id is unique, we want to return just one row + $data = $q->row_array(); + + $this->db->query("CALL p_cal_invoice_byItem(".$data['inv_master_id'].")"); + } + + public function update_invoice_final($inv_id) + { + $this->db->query("CALL p_cal_invoice_byItem(".$inv_id.")"); + + } +} \ No newline at end of file diff --git a/old_code_ci3/models/Ion_auth_model.php b/old_code_ci3/models/Ion_auth_model.php new file mode 100644 index 0000000..e2cbc6e --- /dev/null +++ b/old_code_ci3/models/Ion_auth_model.php @@ -0,0 +1,2249 @@ +load->database(); + $this->load->config('ion_auth', TRUE); + $this->load->helper('cookie'); + $this->load->helper('date'); + $this->lang->load('ion_auth'); + + // initialize db tables data + $this->tables = $this->config->item('tables', 'ion_auth'); + + //initialize data + $this->identity_column = $this->config->item('identity', 'ion_auth'); + $this->store_salt = $this->config->item('store_salt', 'ion_auth'); + $this->salt_length = $this->config->item('salt_length', 'ion_auth'); + $this->join = $this->config->item('join', 'ion_auth'); + + + // initialize hash method options (Bcrypt) + $this->hash_method = $this->config->item('hash_method', 'ion_auth'); + $this->default_rounds = $this->config->item('default_rounds', 'ion_auth'); + $this->random_rounds = $this->config->item('random_rounds', 'ion_auth'); + $this->min_rounds = $this->config->item('min_rounds', 'ion_auth'); + $this->max_rounds = $this->config->item('max_rounds', 'ion_auth'); + + + // initialize messages and error + $this->messages = array(); + $this->errors = array(); + $delimiters_source = $this->config->item('delimiters_source', 'ion_auth'); + + // load the error delimeters either from the config file or use what's been supplied to form validation + if ($delimiters_source === 'form_validation') + { + // load in delimiters from form_validation + // to keep this simple we'll load the value using reflection since these properties are protected + $this->load->library('form_validation'); + $form_validation_class = new ReflectionClass("CI_Form_validation"); + + $error_prefix = $form_validation_class->getProperty("_error_prefix"); + $error_prefix->setAccessible(TRUE); + $this->error_start_delimiter = $error_prefix->getValue($this->form_validation); + $this->message_start_delimiter = $this->error_start_delimiter; + + $error_suffix = $form_validation_class->getProperty("_error_suffix"); + $error_suffix->setAccessible(TRUE); + $this->error_end_delimiter = $error_suffix->getValue($this->form_validation); + $this->message_end_delimiter = $this->error_end_delimiter; + } + else + { + // use delimiters from config + $this->message_start_delimiter = $this->config->item('message_start_delimiter', 'ion_auth'); + $this->message_end_delimiter = $this->config->item('message_end_delimiter', 'ion_auth'); + $this->error_start_delimiter = $this->config->item('error_start_delimiter', 'ion_auth'); + $this->error_end_delimiter = $this->config->item('error_end_delimiter', 'ion_auth'); + } + + + // initialize our hooks object + $this->_ion_hooks = new stdClass; + + // load the bcrypt class if needed + if ($this->hash_method == 'bcrypt') { + if ($this->random_rounds) + { + $rand = rand($this->min_rounds,$this->max_rounds); + $params = array('rounds' => $rand); + } + else + { + $params = array('rounds' => $this->default_rounds); + } + + $params['salt_prefix'] = $this->config->item('salt_prefix', 'ion_auth'); + $this->load->library('bcrypt',$params); + } + + $this->trigger_events('model_constructor'); + } + + /** + * Misc functions + * + * Hash password : Hashes the password to be stored in the database. + * Hash password db : This function takes a password and validates it + * against an entry in the users table. + * Salt : Generates a random salt value. + * + * @author Mathew + */ + + /** + * Hashes the password to be stored in the database. + * + * @return void + * @author Mathew + **/ + public function hash_password($password, $salt=false, $use_sha1_override=FALSE) + { + if (empty($password)) + { + return FALSE; + } + + // bcrypt + if ($use_sha1_override === FALSE && $this->hash_method == 'bcrypt') + { + return $this->bcrypt->hash($password); + } + + + if ($this->store_salt && $salt) + { + return sha1($password . $salt); + } + else + { + $salt = $this->salt(); + return $salt . substr(sha1($salt . $password), 0, -$this->salt_length); + } + } + + /** + * This function takes a password and validates it + * against an entry in the users table. + * + * @return void + * @author Mathew + **/ + public function hash_password_db($id, $password, $use_sha1_override=FALSE) + { + if (empty($id) || empty($password)) + { + return FALSE; + } + + $this->trigger_events('extra_where'); + + $query = $this->db->select('password, salt') + ->where('id', $id) + ->limit(1) + ->order_by('id', 'desc') + ->get($this->tables['users']); + + $hash_password_db = $query->row(); + + if ($query->num_rows() !== 1) + { + return FALSE; + } + + // bcrypt + if ($use_sha1_override === FALSE && $this->hash_method == 'bcrypt') + { + if ($this->bcrypt->verify($password,$hash_password_db->password)) + { + return TRUE; + } + + return FALSE; + } + + // sha1 + if ($this->store_salt) + { + $db_password = sha1($password . $hash_password_db->salt); + } + else + { + $salt = substr($hash_password_db->password, 0, $this->salt_length); + + $db_password = $salt . substr(sha1($salt . $password), 0, -$this->salt_length); + } + + if($db_password == $hash_password_db->password) + { + return TRUE; + } + else + { + return FALSE; + } + } + + /** + * Generates a random salt value for forgotten passwords or any other keys. Uses SHA1. + * + * @return void + * @author Mathew + **/ + public function hash_code($password) + { + return $this->hash_password($password, FALSE, TRUE); + } + + /** + * Generates a random salt value. + * + * Salt generation code taken from https://github.com/ircmaxell/password_compat/blob/master/lib/password.php + * + * @return void + * @author Anthony Ferrera + **/ + public function salt() + { + + $raw_salt_len = 16; + + $buffer = ''; + $buffer_valid = false; + + if (function_exists('mcrypt_create_iv') && !defined('PHALANGER')) { + $buffer = mcrypt_create_iv($raw_salt_len, MCRYPT_DEV_URANDOM); + if ($buffer) { + $buffer_valid = true; + } + } + + if (!$buffer_valid && function_exists('openssl_random_pseudo_bytes')) { + $buffer = openssl_random_pseudo_bytes($raw_salt_len); + if ($buffer) { + $buffer_valid = true; + } + } + + if (!$buffer_valid && @is_readable('/dev/urandom')) { + $f = fopen('/dev/urandom', 'r'); + $read = strlen($buffer); + while ($read < $raw_salt_len) { + $buffer .= fread($f, $raw_salt_len - $read); + $read = strlen($buffer); + } + fclose($f); + if ($read >= $raw_salt_len) { + $buffer_valid = true; + } + } + + if (!$buffer_valid || strlen($buffer) < $raw_salt_len) { + $bl = strlen($buffer); + for ($i = 0; $i < $raw_salt_len; $i++) { + if ($i < $bl) { + $buffer[$i] = $buffer[$i] ^ chr(mt_rand(0, 255)); + } else { + $buffer .= chr(mt_rand(0, 255)); + } + } + } + + $salt = $buffer; + + // encode string with the Base64 variant used by crypt + $base64_digits = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/'; + $bcrypt64_digits = './ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789'; + $base64_string = base64_encode($salt); + $salt = strtr(rtrim($base64_string, '='), $base64_digits, $bcrypt64_digits); + + $salt = substr($salt, 0, $this->salt_length); + + + return $salt; + + } + + /** + * Activation functions + * + * Activate : Validates and removes activation code. + * Deactivate : Updates a users row with an activation code. + * + * @author Mathew + */ + + /** + * activate + * + * @return void + * @author Mathew + **/ + public function activate($id, $code = false) + { + $this->trigger_events('pre_activate'); + + if ($code !== FALSE) + { + $query = $this->db->select($this->identity_column) + ->where('activation_code', $code) + ->where('id', $id) + ->limit(1) + ->order_by('id', 'desc') + ->get($this->tables['users']); + + $result = $query->row(); + + if ($query->num_rows() !== 1) + { + $this->trigger_events(array('post_activate', 'post_activate_unsuccessful')); + $this->set_error('activate_unsuccessful'); + return FALSE; + } + + $data = array( + 'activation_code' => NULL, + 'active' => 1 + ); + + $this->trigger_events('extra_where'); + $this->db->update($this->tables['users'], $data, array('id' => $id)); + } + else + { + $data = array( + 'activation_code' => NULL, + 'active' => 1 + ); + + + $this->trigger_events('extra_where'); + $this->db->update($this->tables['users'], $data, array('id' => $id)); + } + + + $return = $this->db->affected_rows() == 1; + if ($return) + { + $this->trigger_events(array('post_activate', 'post_activate_successful')); + $this->set_message('activate_successful'); + } + else + { + $this->trigger_events(array('post_activate', 'post_activate_unsuccessful')); + $this->set_error('activate_unsuccessful'); + } + + + return $return; + } + + + /** + * Deactivate + * + * @return void + * @author Mathew + **/ + public function deactivate($id = NULL) + { + $this->trigger_events('deactivate'); + + if (!isset($id)) + { + $this->set_error('deactivate_unsuccessful'); + return FALSE; + } + + $activation_code = sha1(md5(microtime())); + $this->activation_code = $activation_code; + + $data = array( + 'activation_code' => $activation_code, + 'active' => 0 + ); + + $this->trigger_events('extra_where'); + $this->db->update($this->tables['users'], $data, array('id' => $id)); + + $return = $this->db->affected_rows() == 1; + if ($return) + $this->set_message('deactivate_successful'); + else + $this->set_error('deactivate_unsuccessful'); + + return $return; + } + + public function clear_forgotten_password_code($code) { + + if (empty($code)) + { + return FALSE; + } + + $this->db->where('forgotten_password_code', $code); + + if ($this->db->count_all_results($this->tables['users']) > 0) + { + $data = array( + 'forgotten_password_code' => NULL, + 'forgotten_password_time' => NULL + ); + + $this->db->update($this->tables['users'], $data, array('forgotten_password_code' => $code)); + + return TRUE; + } + + return FALSE; + } + + /** + * reset password + * + * @return bool + * @author Mathew + **/ + public function reset_password($identity, $new) { + $this->trigger_events('pre_change_password'); + + if (!$this->identity_check($identity)) { + $this->trigger_events(array('post_change_password', 'post_change_password_unsuccessful')); + return FALSE; + } + + $this->trigger_events('extra_where'); + + $query = $this->db->select('id, password, salt') + ->where($this->identity_column, $identity) + ->limit(1) + ->order_by('id', 'desc') + ->get($this->tables['users']); + + if ($query->num_rows() !== 1) + { + $this->trigger_events(array('post_change_password', 'post_change_password_unsuccessful')); + $this->set_error('password_change_unsuccessful'); + return FALSE; + } + + $result = $query->row(); + + $new = $this->hash_password($new, $result->salt); + + // store the new password and reset the remember code so all remembered instances have to re-login + // also clear the forgotten password code + $data = array( + 'password' => $new, + 'remember_code' => NULL, + 'forgotten_password_code' => NULL, + 'forgotten_password_time' => NULL, + ); + + $this->trigger_events('extra_where'); + $this->db->update($this->tables['users'], $data, array($this->identity_column => $identity)); + + $return = $this->db->affected_rows() == 1; + if ($return) + { + $this->trigger_events(array('post_change_password', 'post_change_password_successful')); + $this->set_message('password_change_successful'); + } + else + { + $this->trigger_events(array('post_change_password', 'post_change_password_unsuccessful')); + $this->set_error('password_change_unsuccessful'); + } + + return $return; + } + + /** + * change password + * + * @return bool + * @author Mathew + **/ + public function change_password($identity, $old, $new) + { + $this->trigger_events('pre_change_password'); + + $this->trigger_events('extra_where'); + + $query = $this->db->select('id, password, salt') + ->where($this->identity_column, $identity) + ->limit(1) + ->order_by('id', 'desc') + ->get($this->tables['users']); + + if ($query->num_rows() !== 1) + { + $this->trigger_events(array('post_change_password', 'post_change_password_unsuccessful')); + $this->set_error('password_change_unsuccessful'); + return FALSE; + } + + $user = $query->row(); + + $old_password_matches = $this->hash_password_db($user->id, $old); + + if ($old_password_matches === TRUE) + { + // store the new password and reset the remember code so all remembered instances have to re-login + $hashed_new_password = $this->hash_password($new, $user->salt); + $data = array( + 'password' => $hashed_new_password, + 'remember_code' => NULL, + ); + + $this->trigger_events('extra_where'); + + $successfully_changed_password_in_db = $this->db->update($this->tables['users'], $data, array($this->identity_column => $identity)); + if ($successfully_changed_password_in_db) + { + $this->trigger_events(array('post_change_password', 'post_change_password_successful')); + $this->set_message('password_change_successful'); + } + else + { + $this->trigger_events(array('post_change_password', 'post_change_password_unsuccessful')); + $this->set_error('password_change_unsuccessful'); + } + + return $successfully_changed_password_in_db; + } + + $this->set_error('password_change_unsuccessful'); + return FALSE; + } + + /** + * Checks username + * + * @return bool + * @author Mathew + **/ + public function username_check($username = '') + { + $this->trigger_events('username_check'); + + if (empty($username)) + { + return FALSE; + } + + $this->trigger_events('extra_where'); + + return $this->db->where('username', $username) + ->group_by("id") + ->order_by("id", "ASC") + ->limit(1) + ->count_all_results($this->tables['users']) > 0; + } + + /** + * Checks email + * + * @return bool + * @author Mathew + **/ + public function email_check($email = '') + { + $this->trigger_events('email_check'); + + if (empty($email)) + { + return FALSE; + } + + $this->trigger_events('extra_where'); + + return $this->db->where('email', $email) + ->group_by("id") + ->order_by("id", "ASC") + ->limit(1) + ->count_all_results($this->tables['users']) > 0; + } + + /** + * Identity check + * + * @return bool + * @author Mathew + **/ + public function identity_check($identity = '') + { + $this->trigger_events('identity_check'); + + if (empty($identity)) + { + return FALSE; + } + + return $this->db->where($this->identity_column, $identity) + ->count_all_results($this->tables['users']) > 0; + } + + /** + * Insert a forgotten password key. + * + * @return bool + * @author Mathew + * @updated Ryan + * @updated 52aa456eef8b60ad6754b31fbdcc77bb + **/ + public function forgotten_password($identity) + { + if (empty($identity)) + { + $this->trigger_events(array('post_forgotten_password', 'post_forgotten_password_unsuccessful')); + return FALSE; + } + + // All some more randomness + $activation_code_part = ""; + if(function_exists("openssl_random_pseudo_bytes")) { + $activation_code_part = openssl_random_pseudo_bytes(128); + } + + for($i=0;$i<1024;$i++) { + $activation_code_part = sha1($activation_code_part . mt_rand() . microtime()); + } + + $key = $this->hash_code($activation_code_part.$identity); + + // If enable query strings is set, then we need to replace any unsafe characters so that the code can still work + if ($key != '' && $this->config->item('permitted_uri_chars') != '' && $this->config->item('enable_query_strings') == FALSE) + { + // preg_quote() in PHP 5.3 escapes -, so the str_replace() and addition of - to preg_quote() is to maintain backwards + // compatibility as many are unaware of how characters in the permitted_uri_chars will be parsed as a regex pattern + if ( ! preg_match("|^[".str_replace(array('\\-', '\-'), '-', preg_quote($this->config->item('permitted_uri_chars'), '-'))."]+$|i", $key)) + { + $key = preg_replace("/[^".$this->config->item('permitted_uri_chars')."]+/i", "-", $key); + } + } + + $this->forgotten_password_code = $key; + + $this->trigger_events('extra_where'); + + $update = array( + 'forgotten_password_code' => $key, + 'forgotten_password_time' => time() + ); + + $this->db->update($this->tables['users'], $update, array($this->identity_column => $identity)); + + $return = $this->db->affected_rows() == 1; + + if ($return) + $this->trigger_events(array('post_forgotten_password', 'post_forgotten_password_successful')); + else + $this->trigger_events(array('post_forgotten_password', 'post_forgotten_password_unsuccessful')); + + return $return; + } + + /** + * Forgotten Password Complete + * + * @return string + * @author Mathew + **/ + public function forgotten_password_complete($code, $salt=FALSE) + { + $this->trigger_events('pre_forgotten_password_complete'); + + if (empty($code)) + { + $this->trigger_events(array('post_forgotten_password_complete', 'post_forgotten_password_complete_unsuccessful')); + return FALSE; + } + + $profile = $this->where('forgotten_password_code', $code)->users()->row(); //pass the code to profile + + if ($profile) { + + if ($this->config->item('forgot_password_expiration', 'ion_auth') > 0) { + //Make sure it isn't expired + $expiration = $this->config->item('forgot_password_expiration', 'ion_auth'); + if (time() - $profile->forgotten_password_time > $expiration) { + //it has expired + $this->set_error('forgot_password_expired'); + $this->trigger_events(array('post_forgotten_password_complete', 'post_forgotten_password_complete_unsuccessful')); + return FALSE; + } + } + + $password = $this->salt(); + + $data = array( + 'password' => $this->hash_password($password, $salt), + 'forgotten_password_code' => NULL, + 'active' => 1, + ); + + $this->db->update($this->tables['users'], $data, array('forgotten_password_code' => $code)); + + $this->trigger_events(array('post_forgotten_password_complete', 'post_forgotten_password_complete_successful')); + return $password; + } + + $this->trigger_events(array('post_forgotten_password_complete', 'post_forgotten_password_complete_unsuccessful')); + return FALSE; + } + + /** + * register + * + * @return bool + * @author Mathew + **/ + public function register($identity, $password, $email, $additional_data = array(), $groups = array()) + { + $this->trigger_events('pre_register'); + + $manual_activation = $this->config->item('manual_activation', 'ion_auth'); + + if ($this->identity_check($identity)) + { + $this->set_error('account_creation_duplicate_identity'); + return FALSE; + } + elseif ( !$this->config->item('default_group', 'ion_auth') && empty($groups) ) + { + $this->set_error('account_creation_missing_default_group'); + return FALSE; + } + + // check if the default set in config exists in database + $query = $this->db->get_where($this->tables['groups'],array('name' => $this->config->item('default_group', 'ion_auth')),1)->row(); + if( !isset($query->id) && empty($groups) ) + { + $this->set_error('account_creation_invalid_default_group'); + return FALSE; + } + + // capture default group details + $default_group = $query; + + // IP Address + $ip_address = $this->_prepare_ip($this->input->ip_address()); + $salt = $this->store_salt ? $this->salt() : FALSE; + $password = $this->hash_password($password, $salt); + + // Users table. + $data = array( + $this->identity_column => $identity, + 'password' => $password, + 'email' => $email, + 'ip_address' => $ip_address, + 'created_on' => time(), + 'active' => ($manual_activation === false ? 1 : 0) + ); + + if ($this->store_salt) + { + $data['salt'] = $salt; + } + + // filter out any data passed that doesnt have a matching column in the users table + // and merge the set user data and the additional data + $user_data = array_merge($this->_filter_data($this->tables['users'], $additional_data), $data); + + $this->trigger_events('extra_set'); + + $this->db->insert($this->tables['users'], $user_data); + + $id = $this->db->insert_id(); + + // add in groups array if it doesn't exists and stop adding into default group if default group ids are set + if( isset($default_group->id) && empty($groups) ) + { + $groups[] = $default_group->id; + } + + if (!empty($groups)) + { + // add to groups + foreach ($groups as $group) + { + $this->add_to_group($group, $id); + } + } + + $this->trigger_events('post_register'); + + return (isset($id)) ? $id : FALSE; + } + + /** + * login + * + * @return bool + * @author Mathew + **/ + public function login($identity, $password, $remember=FALSE) + { + $this->trigger_events('pre_login'); + + if (empty($identity) || empty($password)) + { + $this->set_error('login_unsuccessful'); + return FALSE; + } + + $this->trigger_events('extra_where'); + + $query = $this->db->select($this->identity_column . ', email, id, password, active, last_login') + ->where($this->identity_column, $identity) + ->limit(1) + ->order_by('id', 'desc') + ->get($this->tables['users']); + + if($this->is_time_locked_out($identity)) + { + // Hash something anyway, just to take up time + $this->hash_password($password); + + $this->trigger_events('post_login_unsuccessful'); + $this->set_error('login_timeout'); + + return FALSE; + } + + if ($query->num_rows() === 1) + { + $user = $query->row(); + + $password = $this->hash_password_db($user->id, $password); + + if ($password === TRUE) + { + if ($user->active == 0) + { + $this->trigger_events('post_login_unsuccessful'); + $this->set_error('login_unsuccessful_not_active'); + + return FALSE; + } + + $this->set_session($user); + + $this->update_last_login($user->id); + + $this->clear_login_attempts($identity); + + if ($remember && $this->config->item('remember_users', 'ion_auth')) + { + $this->remember_user($user->id); + } + + $this->trigger_events(array('post_login', 'post_login_successful')); + $this->set_message('login_successful'); + + return TRUE; + } + } + + // Hash something anyway, just to take up time + $this->hash_password($password); + + $this->increase_login_attempts($identity); + + $this->trigger_events('post_login_unsuccessful'); + $this->set_error('login_unsuccessful'); + + return FALSE; + } + + /** + * is_max_login_attempts_exceeded + * Based on code from Tank Auth, by Ilya Konyukhov (https://github.com/ilkon/Tank-Auth) + * + * @param string $identity + * @return boolean + **/ + public function is_max_login_attempts_exceeded($identity) { + if ($this->config->item('track_login_attempts', 'ion_auth')) { + $max_attempts = $this->config->item('maximum_login_attempts', 'ion_auth'); + if ($max_attempts > 0) { + $attempts = $this->get_attempts_num($identity); + return $attempts >= $max_attempts; + } + } + return FALSE; + } + + /** + * Get number of attempts to login occured from given IP-address or identity + * Based on code from Tank Auth, by Ilya Konyukhov (https://github.com/ilkon/Tank-Auth) + * + * @param string $identity + * @return int + */ + public function get_attempts_num($identity) + { + if ($this->config->item('track_login_attempts', 'ion_auth')) { + $ip_address = $this->_prepare_ip($this->input->ip_address()); + $this->db->select('1', FALSE); + if ($this->config->item('track_login_ip_address', 'ion_auth')) { + $this->db->where('ip_address', $ip_address); + $this->db->where('login', $identity); + } else if (strlen($identity) > 0) $this->db->or_where('login', $identity); + $qres = $this->db->get($this->tables['login_attempts']); + return $qres->num_rows(); + } + return 0; + } + + /** + * Get a boolean to determine if an account should be locked out due to + * exceeded login attempts within a given period + * + * @return boolean + */ + public function is_time_locked_out($identity) { + + return $this->is_max_login_attempts_exceeded($identity) && $this->get_last_attempt_time($identity) > time() - $this->config->item('lockout_time', 'ion_auth'); + } + + /** + * Get the time of the last time a login attempt occured from given IP-address or identity + * + * @param string $identity + * @return int + */ + public function get_last_attempt_time($identity) { + if ($this->config->item('track_login_attempts', 'ion_auth')) { + $ip_address = $this->_prepare_ip($this->input->ip_address()); + + $this->db->select('time'); + if ($this->config->item('track_login_ip_address', 'ion_auth')) $this->db->where('ip_address', $ip_address); + else if (strlen($identity) > 0) $this->db->or_where('login', $identity); + $this->db->order_by('id', 'desc'); + $qres = $this->db->get($this->tables['login_attempts'], 1); + + if($qres->num_rows() > 0) { + return $qres->row()->time; + } + } + + return 0; + } + + /** + * increase_login_attempts + * Based on code from Tank Auth, by Ilya Konyukhov (https://github.com/ilkon/Tank-Auth) + * + * @param string $identity + **/ + public function increase_login_attempts($identity) { + if ($this->config->item('track_login_attempts', 'ion_auth')) { + $ip_address = $this->_prepare_ip($this->input->ip_address()); + return $this->db->insert($this->tables['login_attempts'], array('ip_address' => $ip_address, 'login' => $identity, 'time' => time())); + } + return FALSE; + } + + /** + * clear_login_attempts + * Based on code from Tank Auth, by Ilya Konyukhov (https://github.com/ilkon/Tank-Auth) + * + * @param string $identity + **/ + public function clear_login_attempts($identity, $expire_period = 86400) { + if ($this->config->item('track_login_attempts', 'ion_auth')) { + $ip_address = $this->_prepare_ip($this->input->ip_address()); + + $this->db->where(array('ip_address' => $ip_address, 'login' => $identity)); + // Purge obsolete login attempts + $this->db->or_where('time <', time() - $expire_period, FALSE); + + return $this->db->delete($this->tables['login_attempts']); + } + return FALSE; + } + + public function limit($limit) + { + $this->trigger_events('limit'); + $this->_ion_limit = $limit; + + return $this; + } + + public function offset($offset) + { + $this->trigger_events('offset'); + $this->_ion_offset = $offset; + + return $this; + } + + public function where($where, $value = NULL) + { + $this->trigger_events('where'); + + if (!is_array($where)) + { + $where = array($where => $value); + } + + array_push($this->_ion_where, $where); + + return $this; + } + + public function like($like, $value = NULL, $position = 'both') + { + $this->trigger_events('like'); + + if (!is_array($like)) + { + $like = array($like => array( + 'value' => $value, + 'position' => $position, + )); + } + + array_push($this->_ion_like, $like); + + return $this; + } + + public function select($select) + { + $this->trigger_events('select'); + + $this->_ion_select[] = $select; + + return $this; + } + + public function order_by($by, $order='desc') + { + $this->trigger_events('order_by'); + + $this->_ion_order_by = $by; + $this->_ion_order = $order; + + return $this; + } + + public function row() + { + $this->trigger_events('row'); + + $row = $this->response->row(); + + return $row; + } + + public function row_array() + { + $this->trigger_events(array('row', 'row_array')); + + $row = $this->response->row_array(); + + return $row; + } + + public function result() + { + $this->trigger_events('result'); + + $result = $this->response->result(); + + return $result; + } + + public function result_array() + { + $this->trigger_events(array('result', 'result_array')); + + $result = $this->response->result_array(); + + return $result; + } + + public function num_rows() + { + $this->trigger_events(array('num_rows')); + + $result = $this->response->num_rows(); + + return $result; + } + + /** + * users + * + * @return object Users + * @author Ben Edmunds + **/ + public function users($groups = NULL) + { + $this->trigger_events('users'); + + if (isset($this->_ion_select) && !empty($this->_ion_select)) + { + foreach ($this->_ion_select as $select) + { + $this->db->select($select); + } + + $this->_ion_select = array(); + } + else + { + //default selects + $this->db->select(array( + $this->tables['users'].'.*', + $this->tables['users'].'.id as id', + $this->tables['users'].'.id as user_id' + )); + } + + // filter by group id(s) if passed + if (isset($groups)) + { + // build an array if only one group was passed + if (!is_array($groups)) + { + $groups = Array($groups); + } + + // join and then run a where_in against the group ids + if (isset($groups) && !empty($groups)) + { + $this->db->distinct(); + $this->db->join( + $this->tables['users_groups'], + $this->tables['users_groups'].'.'.$this->join['users'].'='.$this->tables['users'].'.id', + 'inner' + ); + } + + // verify if group name or group id was used and create and put elements in different arrays + $group_ids = array(); + $group_names = array(); + foreach($groups as $group) + { + if(is_numeric($group)) $group_ids[] = $group; + else $group_names[] = $group; + } + $or_where_in = (!empty($group_ids) && !empty($group_names)) ? 'or_where_in' : 'where_in'; + // if group name was used we do one more join with groups + if(!empty($group_names)) + { + $this->db->join($this->tables['groups'], $this->tables['users_groups'] . '.' . $this->join['groups'] . ' = ' . $this->tables['groups'] . '.id', 'inner'); + $this->db->where_in($this->tables['groups'] . '.name', $group_names); + } + if(!empty($group_ids)) + { + $this->db->{$or_where_in}($this->tables['users_groups'].'.'.$this->join['groups'], $group_ids); + } + } + + $this->trigger_events('extra_where'); + + // run each where that was passed + if (isset($this->_ion_where) && !empty($this->_ion_where)) + { + foreach ($this->_ion_where as $where) + { + $this->db->where($where); + } + + $this->_ion_where = array(); + } + + if (isset($this->_ion_like) && !empty($this->_ion_like)) + { + foreach ($this->_ion_like as $like) + { + $this->db->or_like($like); + } + + $this->_ion_like = array(); + } + + if (isset($this->_ion_limit) && isset($this->_ion_offset)) + { + $this->db->limit($this->_ion_limit, $this->_ion_offset); + + $this->_ion_limit = NULL; + $this->_ion_offset = NULL; + } + else if (isset($this->_ion_limit)) + { + $this->db->limit($this->_ion_limit); + + $this->_ion_limit = NULL; + } + + // set the order + if (isset($this->_ion_order_by) && isset($this->_ion_order)) + { + $this->db->order_by($this->_ion_order_by, $this->_ion_order); + + $this->_ion_order = NULL; + $this->_ion_order_by = NULL; + } + + $this->response = $this->db->get($this->tables['users']); + + return $this; + } + + /** + * user + * + * @return object + * @author Ben Edmunds + **/ + public function user($id = NULL) + { + $this->trigger_events('user'); + + // if no id was passed use the current users id + $id = isset($id) ? $id : $this->session->userdata('user_id'); + + $this->limit(1); + $this->order_by($this->tables['users'].'.id', 'desc'); + $this->where($this->tables['users'].'.id', $id); + + $this->users(); + + return $this; + } + + /** + * get_users_groups + * + * @return array + * @author Ben Edmunds + **/ + public function get_users_groups($id=FALSE) + { + $this->trigger_events('get_users_group'); + + // if no id was passed use the current users id + $id || $id = $this->session->userdata('user_id'); + + return $this->db->select($this->tables['users_groups'].'.'.$this->join['groups'].' as id, '.$this->tables['groups'].'.name, '.$this->tables['groups'].'.description') + ->where($this->tables['users_groups'].'.'.$this->join['users'], $id) + ->join($this->tables['groups'], $this->tables['users_groups'].'.'.$this->join['groups'].'='.$this->tables['groups'].'.id') + ->get($this->tables['users_groups']); + } + + /** + * add_to_group + * + * @return bool + * @author Ben Edmunds + **/ + public function add_to_group($group_ids, $user_id=false) + { + $this->trigger_events('add_to_group'); + + // if no id was passed use the current users id + $user_id || $user_id = $this->session->userdata('user_id'); + + if(!is_array($group_ids)) + { + $group_ids = array($group_ids); + } + + $return = 0; + + // Then insert each into the database + foreach ($group_ids as $group_id) + { + if ($this->db->insert($this->tables['users_groups'], array( $this->join['groups'] => (float)$group_id, $this->join['users'] => (float)$user_id))) + { + if (isset($this->_cache_groups[$group_id])) { + $group_name = $this->_cache_groups[$group_id]; + } + else { + $group = $this->group($group_id)->result(); + $group_name = $group[0]->name; + $this->_cache_groups[$group_id] = $group_name; + } + $this->_cache_user_in_group[$user_id][$group_id] = $group_name; + + // Return the number of groups added + $return += 1; + } + } + + return $return; + } + + /** + * remove_from_group + * + * @return bool + * @author Ben Edmunds + **/ + public function remove_from_group($group_ids=false, $user_id=false) + { + $this->trigger_events('remove_from_group'); + + // user id is required + if(empty($user_id)) + { + return FALSE; + } + + // if group id(s) are passed remove user from the group(s) + if( ! empty($group_ids)) + { + if(!is_array($group_ids)) + { + $group_ids = array($group_ids); + } + + foreach($group_ids as $group_id) + { + $this->db->delete($this->tables['users_groups'], array($this->join['groups'] => (float)$group_id, $this->join['users'] => (float)$user_id)); + if (isset($this->_cache_user_in_group[$user_id]) && isset($this->_cache_user_in_group[$user_id][$group_id])) + { + unset($this->_cache_user_in_group[$user_id][$group_id]); + } + } + + $return = TRUE; + } + // otherwise remove user from all groups + else + { + if ($return = $this->db->delete($this->tables['users_groups'], array($this->join['users'] => (float)$user_id))) { + $this->_cache_user_in_group[$user_id] = array(); + } + } + return $return; + } + + /** + * groups + * + * @return object + * @author Ben Edmunds + **/ + public function groups() + { + $this->trigger_events('groups'); + + // run each where that was passed + if (isset($this->_ion_where) && !empty($this->_ion_where)) + { + foreach ($this->_ion_where as $where) + { + $this->db->where($where); + } + $this->_ion_where = array(); + } + + if (isset($this->_ion_limit) && isset($this->_ion_offset)) + { + $this->db->limit($this->_ion_limit, $this->_ion_offset); + + $this->_ion_limit = NULL; + $this->_ion_offset = NULL; + } + else if (isset($this->_ion_limit)) + { + $this->db->limit($this->_ion_limit); + + $this->_ion_limit = NULL; + } + + // set the order + if (isset($this->_ion_order_by) && isset($this->_ion_order)) + { + $this->db->order_by($this->_ion_order_by, $this->_ion_order); + } + + $this->response = $this->db->get($this->tables['groups']); + + return $this; + } + + /** + * group + * + * @return object + * @author Ben Edmunds + **/ + public function group($id = NULL) + { + $this->trigger_events('group'); + + if (isset($id)) + { + $this->where($this->tables['groups'].'.id', $id); + } + + $this->limit(1); + $this->order_by('id', 'desc'); + + return $this->groups(); + } + + /** + * update + * + * @return bool + * @author Phil Sturgeon + **/ + public function update($id, array $data) + { + $this->trigger_events('pre_update_user'); + + $user = $this->user($id)->row(); + + $this->db->trans_begin(); + + if (array_key_exists($this->identity_column, $data) && $this->identity_check($data[$this->identity_column]) && $user->{$this->identity_column} !== $data[$this->identity_column]) + { + $this->db->trans_rollback(); + $this->set_error('account_creation_duplicate_identity'); + + $this->trigger_events(array('post_update_user', 'post_update_user_unsuccessful')); + $this->set_error('update_unsuccessful'); + + return FALSE; + } + + // Filter the data passed + $data = $this->_filter_data($this->tables['users'], $data); + + if (array_key_exists($this->identity_column, $data) || array_key_exists('password', $data) || array_key_exists('email', $data)) + { + if (array_key_exists('password', $data)) + { + if( ! empty($data['password'])) + { + $data['password'] = $this->hash_password($data['password'], $user->salt); + } + else + { + // unset password so it doesn't effect database entry if no password passed + unset($data['password']); + } + } + } + + $this->trigger_events('extra_where'); + $this->db->update($this->tables['users'], $data, array('id' => $user->id)); + + if ($this->db->trans_status() === FALSE) + { + $this->db->trans_rollback(); + + $this->trigger_events(array('post_update_user', 'post_update_user_unsuccessful')); + $this->set_error('update_unsuccessful'); + return FALSE; + } + + $this->db->trans_commit(); + + $this->trigger_events(array('post_update_user', 'post_update_user_successful')); + $this->set_message('update_successful'); + return TRUE; + } + + /** + * delete_user + * + * @return bool + * @author Phil Sturgeon + **/ + public function delete_user($id) + { + $this->trigger_events('pre_delete_user'); + + $this->db->trans_begin(); + + // remove user from groups + $this->remove_from_group(NULL, $id); + + // delete user from users table should be placed after remove from group + $this->db->delete($this->tables['users'], array('id' => $id)); + + // if user does not exist in database then it returns FALSE else removes the user from groups + if ($this->db->affected_rows() <= 0) + { + return FALSE; + } + + if ($this->db->trans_status() === FALSE) + { + $this->db->trans_rollback(); + $this->trigger_events(array('post_delete_user', 'post_delete_user_unsuccessful')); + $this->set_error('delete_unsuccessful'); + return FALSE; + } + + $this->db->trans_commit(); + + $this->trigger_events(array('post_delete_user', 'post_delete_user_successful')); + $this->set_message('delete_successful'); + return TRUE; + } + + /** + * update_last_login + * + * @return bool + * @author Ben Edmunds + **/ + public function update_last_login($id) + { + $this->trigger_events('update_last_login'); + + $this->load->helper('date'); + + $this->trigger_events('extra_where'); + + $this->db->update($this->tables['users'], array('last_login' => time()), array('id' => $id)); + + return $this->db->affected_rows() == 1; + } + + /** + * set_lang + * + * @return bool + * @author Ben Edmunds + **/ + public function set_lang($lang = 'en') + { + $this->trigger_events('set_lang'); + + // if the user_expire is set to zero we'll set the expiration two years from now. + if($this->config->item('user_expire', 'ion_auth') === 0) + { + $expire = (60*60*24*365*2); + } + // otherwise use what is set + else + { + $expire = $this->config->item('user_expire', 'ion_auth'); + } + + set_cookie(array( + 'name' => 'lang_code', + 'value' => $lang, + 'expire' => $expire + )); + + return TRUE; + } + + /** + * set_session + * + * @return bool + * @author jrmadsen67 + **/ + public function set_session($user) + { + + $this->trigger_events('pre_set_session'); + + $session_data = array( + 'identity' => $user->{$this->identity_column}, + $this->identity_column => $user->{$this->identity_column}, + 'email' => $user->email, + 'user_id' => $user->id, //everyone likes to overwrite id so we'll use user_id + 'old_last_login' => $user->last_login + ); + + $this->session->set_userdata($session_data); + + $this->trigger_events('post_set_session'); + + return TRUE; + } + + /** + * remember_user + * + * @return bool + * @author Ben Edmunds + **/ + public function remember_user($id) + { + $this->trigger_events('pre_remember_user'); + + if (!$id) + { + return FALSE; + } + + $user = $this->user($id)->row(); + + $salt = $this->salt(); + + $this->db->update($this->tables['users'], array('remember_code' => $salt), array('id' => $id)); + + if ($this->db->affected_rows() > -1) + { + // if the user_expire is set to zero we'll set the expiration two years from now. + if($this->config->item('user_expire', 'ion_auth') === 0) + { + $expire = (60*60*24*365*2); + } + // otherwise use what is set + else + { + $expire = $this->config->item('user_expire', 'ion_auth'); + } + + set_cookie(array( + 'name' => $this->config->item('identity_cookie_name', 'ion_auth'), + 'value' => $user->{$this->identity_column}, + 'expire' => $expire + )); + + set_cookie(array( + 'name' => $this->config->item('remember_cookie_name', 'ion_auth'), + 'value' => $salt, + 'expire' => $expire + )); + + $this->trigger_events(array('post_remember_user', 'remember_user_successful')); + return TRUE; + } + + $this->trigger_events(array('post_remember_user', 'remember_user_unsuccessful')); + return FALSE; + } + + /** + * login_remembed_user + * + * @return bool + * @author Ben Edmunds + **/ + public function login_remembered_user() + { + $this->trigger_events('pre_login_remembered_user'); + + // check for valid data + if (!get_cookie($this->config->item('identity_cookie_name', 'ion_auth')) + || !get_cookie($this->config->item('remember_cookie_name', 'ion_auth')) + || !$this->identity_check(get_cookie($this->config->item('identity_cookie_name', 'ion_auth')))) + { + $this->trigger_events(array('post_login_remembered_user', 'post_login_remembered_user_unsuccessful')); + return FALSE; + } + + // get the user + $this->trigger_events('extra_where'); + $query = $this->db->select($this->identity_column.', id, email, last_login') + ->where($this->identity_column, get_cookie($this->config->item('identity_cookie_name', 'ion_auth'))) + ->where('remember_code', get_cookie($this->config->item('remember_cookie_name', 'ion_auth'))) + ->limit(1) + ->order_by('id', 'desc') + ->get($this->tables['users']); + + // if the user was found, sign them in + if ($query->num_rows() == 1) + { + $user = $query->row(); + + $this->update_last_login($user->id); + + $this->set_session($user); + + // extend the users cookies if the option is enabled + if ($this->config->item('user_extend_on_login', 'ion_auth')) + { + $this->remember_user($user->id); + } + + $this->trigger_events(array('post_login_remembered_user', 'post_login_remembered_user_successful')); + return TRUE; + } + + $this->trigger_events(array('post_login_remembered_user', 'post_login_remembered_user_unsuccessful')); + return FALSE; + } + + + /** + * create_group + * + * @author aditya menon + */ + public function create_group($group_name = FALSE, $group_description = '', $additional_data = array()) + { + // bail if the group name was not passed + if(!$group_name) + { + $this->set_error('group_name_required'); + return FALSE; + } + + // bail if the group name already exists + $existing_group = $this->db->get_where($this->tables['groups'], array('name' => $group_name))->num_rows(); + if($existing_group !== 0) + { + $this->set_error('group_already_exists'); + return FALSE; + } + + $data = array('name'=>$group_name,'description'=>$group_description); + + // filter out any data passed that doesnt have a matching column in the groups table + // and merge the set group data and the additional data + if (!empty($additional_data)) $data = array_merge($this->_filter_data($this->tables['groups'], $additional_data), $data); + + $this->trigger_events('extra_group_set'); + + // insert the new group + $this->db->insert($this->tables['groups'], $data); + $group_id = $this->db->insert_id(); + + // report success + $this->set_message('group_creation_successful'); + // return the brand new group id + return $group_id; + } + + /** + * update_group + * + * @return bool + * @author aditya menon + **/ + public function update_group($group_id = FALSE, $group_name = FALSE, $additional_data = array()) + { + if (empty($group_id)) return FALSE; + + $data = array(); + + if (!empty($group_name)) + { + // we are changing the name, so do some checks + + // bail if the group name already exists + $existing_group = $this->db->get_where($this->tables['groups'], array('name' => $group_name))->row(); + if(isset($existing_group->id) && $existing_group->id != $group_id) + { + $this->set_error('group_already_exists'); + return FALSE; + } + + $data['name'] = $group_name; + } + + // restrict change of name of the admin group + $group = $this->db->get_where($this->tables['groups'], array('id' => $group_id))->row(); + if($this->config->item('admin_group', 'ion_auth') === $group->name && $group_name !== $group->name) + { + $this->set_error('group_name_admin_not_alter'); + return FALSE; + } + + + // IMPORTANT!! Third parameter was string type $description; this following code is to maintain backward compatibility + // New projects should work with 3rd param as array + if (is_string($additional_data)) $additional_data = array('description' => $additional_data); + + + // filter out any data passed that doesnt have a matching column in the groups table + // and merge the set group data and the additional data + if (!empty($additional_data)) $data = array_merge($this->_filter_data($this->tables['groups'], $additional_data), $data); + + + $this->db->update($this->tables['groups'], $data, array('id' => $group_id)); + + $this->set_message('group_update_successful'); + + return TRUE; + } + + /** + * delete_group + * + * @return bool + * @author aditya menon + **/ + public function delete_group($group_id = FALSE) + { + // bail if mandatory param not set + if(!$group_id || empty($group_id)) + { + return FALSE; + } + $group = $this->group($group_id)->row(); + if($group->name == $this->config->item('admin_group', 'ion_auth')) + { + $this->trigger_events(array('post_delete_group', 'post_delete_group_notallowed')); + $this->set_error('group_delete_notallowed'); + return FALSE; + } + + $this->trigger_events('pre_delete_group'); + + $this->db->trans_begin(); + + // remove all users from this group + $this->db->delete($this->tables['users_groups'], array($this->join['groups'] => $group_id)); + // remove the group itself + $this->db->delete($this->tables['groups'], array('id' => $group_id)); + + if ($this->db->trans_status() === FALSE) + { + $this->db->trans_rollback(); + $this->trigger_events(array('post_delete_group', 'post_delete_group_unsuccessful')); + $this->set_error('group_delete_unsuccessful'); + return FALSE; + } + + $this->db->trans_commit(); + + $this->trigger_events(array('post_delete_group', 'post_delete_group_successful')); + $this->set_message('group_delete_successful'); + return TRUE; + } + + public function set_hook($event, $name, $class, $method, $arguments) + { + $this->_ion_hooks->{$event}[$name] = new stdClass; + $this->_ion_hooks->{$event}[$name]->class = $class; + $this->_ion_hooks->{$event}[$name]->method = $method; + $this->_ion_hooks->{$event}[$name]->arguments = $arguments; + } + + public function remove_hook($event, $name) + { + if (isset($this->_ion_hooks->{$event}[$name])) + { + unset($this->_ion_hooks->{$event}[$name]); + } + } + + public function remove_hooks($event) + { + if (isset($this->_ion_hooks->$event)) + { + unset($this->_ion_hooks->$event); + } + } + + protected function _call_hook($event, $name) + { + if (isset($this->_ion_hooks->{$event}[$name]) && method_exists($this->_ion_hooks->{$event}[$name]->class, $this->_ion_hooks->{$event}[$name]->method)) + { + $hook = $this->_ion_hooks->{$event}[$name]; + + return call_user_func_array(array($hook->class, $hook->method), $hook->arguments); + } + + return FALSE; + } + + public function trigger_events($events) + { + if (is_array($events) && !empty($events)) + { + foreach ($events as $event) + { + $this->trigger_events($event); + } + } + else + { + if (isset($this->_ion_hooks->$events) && !empty($this->_ion_hooks->$events)) + { + foreach ($this->_ion_hooks->$events as $name => $hook) + { + $this->_call_hook($events, $name); + } + } + } + } + + /** + * set_message_delimiters + * + * Set the message delimiters + * + * @return void + * @author Ben Edmunds + **/ + public function set_message_delimiters($start_delimiter, $end_delimiter) + { + $this->message_start_delimiter = $start_delimiter; + $this->message_end_delimiter = $end_delimiter; + + return TRUE; + } + + /** + * set_error_delimiters + * + * Set the error delimiters + * + * @return void + * @author Ben Edmunds + **/ + public function set_error_delimiters($start_delimiter, $end_delimiter) + { + $this->error_start_delimiter = $start_delimiter; + $this->error_end_delimiter = $end_delimiter; + + return TRUE; + } + + /** + * set_message + * + * Set a message + * + * @return void + * @author Ben Edmunds + **/ + public function set_message($message) + { + $this->messages[] = $message; + + return $message; + } + + + + /** + * messages + * + * Get the messages + * + * @return void + * @author Ben Edmunds + **/ + public function messages() + { + $_output = ''; + foreach ($this->messages as $message) + { + $messageLang = $this->lang->line($message) ? $this->lang->line($message) : '##' . $message . '##'; + $_output .= $this->message_start_delimiter . $messageLang . $this->message_end_delimiter; + } + + return $_output; + } + + /** + * messages as array + * + * Get the messages as an array + * + * @return array + * @author Raul Baldner Junior + **/ + public function messages_array($langify = TRUE) + { + if ($langify) + { + $_output = array(); + foreach ($this->messages as $message) + { + $messageLang = $this->lang->line($message) ? $this->lang->line($message) : '##' . $message . '##'; + $_output[] = $this->message_start_delimiter . $messageLang . $this->message_end_delimiter; + } + return $_output; + } + else + { + return $this->messages; + } + } + + + /** + * clear_messages + * + * Clear messages + * + * @return void + * @author Ben Edmunds + **/ + public function clear_messages() + { + $this->messages = array(); + + return TRUE; + } + + + /** + * set_error + * + * Set an error message + * + * @return void + * @author Ben Edmunds + **/ + public function set_error($error) + { + $this->errors[] = $error; + + return $error; + } + + /** + * errors + * + * Get the error message + * + * @return void + * @author Ben Edmunds + **/ + public function errors() + { + $_output = ''; + foreach ($this->errors as $error) + { + $errorLang = $this->lang->line($error) ? $this->lang->line($error) : '##' . $error . '##'; + $_output .= $this->error_start_delimiter . $errorLang . $this->error_end_delimiter; + } + + return $_output; + } + + /** + * errors as array + * + * Get the error messages as an array + * + * @return array + * @author Raul Baldner Junior + **/ + public function errors_array($langify = TRUE) + { + if ($langify) + { + $_output = array(); + foreach ($this->errors as $error) + { + $errorLang = $this->lang->line($error) ? $this->lang->line($error) : '##' . $error . '##'; + $_output[] = $this->error_start_delimiter . $errorLang . $this->error_end_delimiter; + } + return $_output; + } + else + { + return $this->errors; + } + } + + + /** + * clear_errors + * + * Clear Errors + * + * @return void + * @author Ben Edmunds + **/ + public function clear_errors() + { + $this->errors = array(); + + return TRUE; + } + + + + protected function _filter_data($table, $data) + { + $filtered_data = array(); + $columns = $this->db->list_fields($table); + + if (is_array($data)) + { + foreach ($columns as $column) + { + if (array_key_exists($column, $data)) + $filtered_data[$column] = $data[$column]; + } + } + + return $filtered_data; + } + + protected function _prepare_ip($ip_address) { + // just return the string IP address now for better compatibility + return $ip_address; + } +} diff --git a/old_code_ci3/models/IpdDischarge_M.php b/old_code_ci3/models/IpdDischarge_M.php new file mode 100644 index 0000000..5776420 --- /dev/null +++ b/old_code_ci3/models/IpdDischarge_M.php @@ -0,0 +1,416 @@ +db->insert("ipd_discharge", $data)) { + $insert_id = $this->db->insert_id(); + return $insert_id; + }else + return 0; + } + + public function update_ipdDischarge($data,$old_id_no) { + $this->db->set($data); + $this->db->where("id", $old_id_no); + $this->db->update("ipd_discharge", $data); + } + + + public function insert_ipd_discharge_1_a($data) { + + if ($this->db->insert("ipd_discharge_1_a", $data)) { + $insert_id = $this->db->insert_id(); + return $insert_id; + }else + return 0; + } + + public function update_ipd_discharge_1_a($data,$old_id_no) { + $this->db->set($data); + $this->db->where("id", $old_id_no); + $this->db->update("ipd_discharge_1_a", $data); + } + + + public function update_insert_ipd_discharge_1_b($data,$ipd_id,$gen_exam_id) { + $sql="select id from ipd_discharge_1_b where ipd_d_id=".$ipd_id." and col_id=".$gen_exam_id; + $query = $this->db->query($sql); + $discharge_general_exam= $query->result(); + + if(count($discharge_general_exam)>0) + { + $this->db->set($data); + $this->db->where("id", $discharge_general_exam[0]->id); + $this->db->update("ipd_discharge_1_b", $data); + + return $discharge_general_exam[0]->id; + }else{ + if ($this->db->insert("ipd_discharge_1_b", $data)) { + $insert_id = $this->db->insert_id(); + return $insert_id; + }else + return 0; + } + } + + public function update_insert_ipd_discharge_1_d($data,$ipd_id,$gen_exam_id) { + $sql="select id from ipd_discharge_1_d where ipd_d_id=".$ipd_id." and col_id=".$gen_exam_id; + $query = $this->db->query($sql); + $discharge_general_exam= $query->result(); + + if(count($discharge_general_exam)>0) + { + $this->db->set($data); + $this->db->where("id", $discharge_general_exam[0]->id); + $this->db->update("ipd_discharge_1_d", $data); + + return $discharge_general_exam[0]->id; + }else{ + if ($this->db->insert("ipd_discharge_1_d", $data)) { + $insert_id = $this->db->insert_id(); + return $insert_id; + }else + return 0; + } + } + + public function update_insert_ipd_discharge_1_e($data,$ipd_id,$gen_exam_id) { + $sql="select id from ipd_discharge_1_e where ipd_d_id=".$ipd_id." and col_id=".$gen_exam_id; + $query = $this->db->query($sql); + $discharge_general_exam= $query->result(); + + if(count($discharge_general_exam)>0) + { + $this->db->set($data); + $this->db->where("id", $discharge_general_exam[0]->id); + $this->db->update("ipd_discharge_1_e", $data); + + return $discharge_general_exam[0]->id; + }else{ + if ($this->db->insert("ipd_discharge_1_e", $data)) { + $insert_id = $this->db->insert_id(); + return $insert_id; + }else + return 0; + } + } + + + + public function update_insert_ipd_discharge_1_b_final($data,$ipd_id,$gen_exam_id) { + $sql="select id from ipd_discharge_1_b_final where ipd_d_id=".$ipd_id." and col_id=".$gen_exam_id; + $query = $this->db->query($sql); + $discharge_general_exam= $query->result(); + + if(count($discharge_general_exam)>0) + { + $this->db->set($data); + $this->db->where("id", $discharge_general_exam[0]->id); + $this->db->update("ipd_discharge_1_b_final", $data); + + return $discharge_general_exam[0]->id; + }else{ + if ($this->db->insert("ipd_discharge_1_b_final", $data)) { + $insert_id = $this->db->insert_id(); + return $insert_id; + }else + return 0; + } + } + + public function update_insert_ipd_discharge_2($data,$ipd_id) { + $sql="select id from ipd_discharge_2 where ipd_d_id=".$ipd_id.""; + $query = $this->db->query($sql); + $discharge_general_exam= $query->result(); + + if(count($discharge_general_exam)>0) + { + $this->db->set($data); + $this->db->where("id", $discharge_general_exam[0]->id); + $this->db->update("ipd_discharge_2", $data); + + return $discharge_general_exam[0]->id; + }else{ + if ($this->db->insert("ipd_discharge_2", $data)) { + $insert_id = $this->db->insert_id(); + return $insert_id; + }else + return 0; + } + } + + //ipd_discharge_drug_food_interaction + + public function update_insert_ipd_discharge_drug_food_interaction($data,$ipd_id) { + $sql="select id from ipd_discharge_drug_food_interaction where ipd_id=".$ipd_id.""; + $query = $this->db->query($sql); + $ipd_discharge_drug_food_interaction= $query->result(); + + if(count($ipd_discharge_drug_food_interaction)>0) + { + $this->db->set($data); + $this->db->where("id", $ipd_discharge_drug_food_interaction[0]->id); + $this->db->update("ipd_discharge_drug_food_interaction", $data); + + return $ipd_discharge_drug_food_interaction[0]->id; + }else{ + if ($this->db->insert("ipd_discharge_drug_food_interaction", $data)) { + $insert_id = $this->db->insert_id(); + return $insert_id; + }else + return 0; + } + } + + // Surgery Table + + + public function insert_p_surgery($data) { + if ($this->db->insert("ipd_discharge_surgery", $data)) { + $insert_id = $this->db->insert_id(); + return $insert_id; + }else + return 0; + } + + public function update_p_surgery($data,$old_id_no) { + $this->db->set($data); + $this->db->where("id", $old_id_no); + $this->db->update("ipd_discharge_surgery", $data); + } + + public function remove_p_surgery($delid) { + $this->db->where("id", $delid); + $this->db->delete("ipd_discharge_surgery"); + } + + // Prosedure Table + + + public function insert_p_procedure($data) { + if ($this->db->insert("ipd_discharge_procedure", $data)) { + $insert_id = $this->db->insert_id(); + return $insert_id; + }else + return 0; + } + + public function update_p_procedure($data,$old_id_no) { + $this->db->set($data); + $this->db->where("id", $old_id_no); + $this->db->update("ipd_discharge_procedure", $data); + } + + public function remove_p_procedure($delid) { + $this->db->where("id", $delid); + $this->db->delete("ipd_discharge_procedure"); + } + + + + // Prescription Complaint + + public function insert_p_complaint($data) { + if ($this->db->insert("ipd_discharge_complaint", $data)) { + $insert_id = $this->db->insert_id(); + return $insert_id; + }else + return 0; + } + + public function update_p_complaint($data,$old_id_no) { + $this->db->set($data); + $this->db->where("id", $old_id_no); + $this->db->update("ipd_discharge_complaint", $data); + } + + public function remove_p_complaint($delid) { + $this->db->where("id", $delid); + $this->db->delete("ipd_discharge_complaint"); + } + + public function update_insert_ipd_discharge_complaint_remark($data,$ipd_id) { + $sql="select id from ipd_discharge_complaint_remark where ipd_id=".$ipd_id.""; + $query = $this->db->query($sql); + $data_rec= $query->result(); + + if(count($data_rec)>0) + { + $this->db->set($data); + $this->db->where("id", $data_rec[0]->id); + $this->db->update("ipd_discharge_complaint_remark", $data); + + return $data_rec[0]->id; + }else{ + if ($this->db->insert("ipd_discharge_complaint_remark", $data)) { + $insert_id = $this->db->insert_id(); + return $insert_id; + }else + return 0; + } + } + + + // Diagnosis + + public function insert_p_diagnosis($data) { + if ($this->db->insert("ipd_discharge_diagnosis", $data)) { + $insert_id = $this->db->insert_id(); + return $insert_id; + }else + return 0; + } + + public function update_p_diagnosis($data,$old_id_no) { + $this->db->set($data); + $this->db->where("id", $old_id_no); + $this->db->update("ipd_discharge_diagnosis", $data); + } + + public function remove_p_diagnosis($delid) { + $this->db->where("id", $delid); + $this->db->delete("ipd_discharge_diagnosis"); + } + + public function update_insert_ipd_discharge_diagnosis_remark($data,$ipd_id) { + $sql="select id from ipd_discharge_diagnosis_remark where ipd_id=".$ipd_id.""; + $query = $this->db->query($sql); + $data_rec= $query->result(); + + if(count($data_rec)>0) + { + $this->db->set($data); + $this->db->where("id", $data_rec[0]->id); + $this->db->update("ipd_discharge_diagnosis_remark", $data); + + return $data_rec[0]->id; + }else{ + if ($this->db->insert("ipd_discharge_diagnosis_remark", $data)) { + $insert_id = $this->db->insert_id(); + return $insert_id; + }else + return 0; + } + } + + //Investigtions + + public function update_insert_ipd_discharge_investigtions_inhos($data,$ipd_id) { + $sql="select id from ipd_discharge_investigtions_inhos where ipd_id=".$ipd_id.""; + $query = $this->db->query($sql); + $data_rec= $query->result(); + + if(count($data_rec)>0) + { + $this->db->set($data); + $this->db->where("id", $data_rec[0]->id); + $this->db->update("ipd_discharge_investigtions_inhos", $data); + + return $data_rec[0]->id; + }else{ + if ($this->db->insert("ipd_discharge_investigtions_inhos", $data)) { + $insert_id = $this->db->insert_id(); + return $insert_id; + }else + return 0; + } + } + + //Course in the hospital + + + + public function insert_p_course($data) { + if ($this->db->insert("ipd_discharge_course", $data)) { + $insert_id = $this->db->insert_id(); + return $insert_id; + }else + return 0; + } + + public function update_p_course($data,$old_id_no) { + $this->db->set($data); + $this->db->where("id", $old_id_no); + $this->db->update("ipd_discharge_course", $data); + } + + public function remove_p_course($delid) { + $this->db->where("id", $delid); + $this->db->delete("ipd_discharge_course"); + } + + + public function update_insert_ipd_discharge_course_remark($data,$ipd_id) { + $sql="select id from ipd_discharge_course_remark where ipd_id=".$ipd_id.""; + $query = $this->db->query($sql); + $data_rec= $query->result(); + + if(count($data_rec)>0) + { + $this->db->set($data); + $this->db->where("id", $data_rec[0]->id); + $this->db->update("ipd_discharge_course_remark", $data); + + return $data_rec[0]->id; + }else{ + if ($this->db->insert("ipd_discharge_course_remark", $data)) { + $insert_id = $this->db->insert_id(); + return $insert_id; + }else + return 0; + } + } + + //Discharge Instructions + + public function update_insert_ipd_discharge_instructions($data,$ipd_id) { + $sql="select id from ipd_discharge_instructions where ipd_id=".$ipd_id.""; + $query = $this->db->query($sql); + $data_rec= $query->result(); + + if(count($data_rec)>0) + { + $this->db->set($data); + $this->db->where("id", $data_rec[0]->id); + $this->db->update("ipd_discharge_instructions", $data); + + return $data_rec[0]->id; + }else{ + if ($this->db->insert("ipd_discharge_instructions", $data)) { + $insert_id = $this->db->insert_id(); + return $insert_id; + }else + return 0; + } + } + + //Discharge Drugs + + public function insert_p_drug($data) { + if ($this->db->insert("ipd_discharge_prescrption_prescribed", $data)) { + $insert_id = $this->db->insert_id(); + return $insert_id; + }else + return 0; + } + + public function update_p_drug($data,$old_id_no) { + $this->db->set($data); + $this->db->where("id", $old_id_no); + $this->db->update("ipd_discharge_prescrption_prescribed", $data); + } + + public function remove_p_drug($delid) { + $this->db->where("id", $delid); + $this->db->delete("ipd_discharge_prescrption_prescribed"); + } + + +} +?> \ No newline at end of file diff --git a/old_code_ci3/models/Ipd_M.php b/old_code_ci3/models/Ipd_M.php new file mode 100644 index 0000000..03d0ba8 --- /dev/null +++ b/old_code_ci3/models/Ipd_M.php @@ -0,0 +1,285 @@ +db->query($sql); + $result = $query->result_array(); + //print_r($result); + return $result; + } + + public function insert($data) { + + $sql = "SELECT * FROM ipd_master where ipd_status=0 and p_id=".$data['master']['p_id']; + $query = $this->db->query($sql); + $ipd_info= $query->result(); + + $user = $this->ion_auth->user()->row(); + $user_id = $user->id; + $user_name = $user->first_name.''. $user->last_name.' ['.date('d-m-Y H:i:s'); + + if(count($ipd_info)<1) + { + if ($this->db->insert("ipd_master", $data['master'])) { + $insert_id = $this->db->insert_id(); + + $sql="SELECT count(*) as xtimes from ipd_master where id<=".$insert_id." and p_id=".$data['master']['p_id']; + $query = $this->db->query($sql); + $ipd_times= $query->result(); + + $pid=str_pad(substr($insert_id,-7,7),7,0,STR_PAD_LEFT); + $pid='A'.date('ym').$pid; + $udata = array( + 'ipd_code' => $pid, + 'ipd_times' => $ipd_times[0]->xtimes, + ); + + $this->db->set($udata); + $this->db->where("id", $insert_id); + $this->db->update("ipd_master", $udata); + + foreach ($data['doc_list'] as $doc_id) + { + $doc_data=array( + 'doc_id' => $doc_id, + 'ipd_id' => $insert_id, + 'log'=>'Insert By :'.$user_name + ); + $this->db->insert("ipd_master_doc_list", $doc_data); + } + + return $insert_id; + }else + return 0; + }else{ + return $ipd_info[0]->id; + } + + } + + public function add_ipd_doc($doc_data) + { + $insert_id=0; + if($this->db->insert("ipd_master_doc_list", $doc_data)) + { + $insert_id = $this->db->insert_id(); + } + return $insert_id; + } + + + public function remove_ipd_doc($ipd_doc_id) + { + $this->db->where('id', $del_id); + $q = $this->db->get('ipd_master_doc_list'); + $data = $q->row_array(); + + $user = $this->ion_auth->user()->row(); + $user_id = $user->id; + $user_name = $user->first_name.''. $user->last_name; + + $data['update_by_id']=$user_id; + $data['update_by']=$user_name.'['.date('Y-m-d H:i:s').']'; + + if ($this->db->insert("ipd_master_doc_list_delete", $data)) { + //$this->db->where("id", $del_id); + $this->db->delete("ipd_master_doc_list","id=".$del_id); + return 1; + }else{ + return 0; + } + } + + public function bedassign($data) { + if ($this->db->insert("ipd_bed_assign", $data)) { + $insert_id = $this->db->insert_id(); + + $datau = array( + 'bed_used_p_id' => 0 + ); + + $this->db->set($datau); + $this->db->where("bed_used_p_id",$data['ipd_id']); + $this->db->update("hc_bed_master", $datau); + + $datau = array( + 'bed_used_p_id' => $data['ipd_id'] + ); + + $this->db->set($datau); + $this->db->where("id", $data['bed_id']); + $this->db->update("hc_bed_master", $datau); + + return $insert_id; + }else + return 0; + } + + public function calculate_IPD($IPD_NO) + { + $this->db->query("CALL p_cal_ipd_master($IPD_NO)"); + } + + public function update($data,$old_id_no) { + + $user = $this->ion_auth->user()->row(); + $user_id = $user->id; + $user_name = $user->first_name.''. $user->last_name; + + $sql="select * from ipd_master where id=".$old_id_no; + $query = $this->db->query($sql); + $data1=$query->result_array(); + + if(count($data1)>0) + { + $update_emp_name=$user_id.'['.$user_name.']'.date('Y-m-d H:i:s'); + $Old_Update_data=($data1[0]['log']==''?' ':$data1[0]['log']).PHP_EOL; + + $change_data=compare_arrays($data1[0],$data); + if(strlen($change_data)>0) + { + $data['log']=$Old_Update_data.$change_data.'Update By :'.$update_emp_name; + } + + } + + $this->db->where("id", $old_id_no); + $this->db->update("ipd_master", $data); + } + + public function insert_ipd_item($data) { + + if ($this->db->insert("ipd_invoice_item", $data)) { + $insert_id = $this->db->insert_id(); + return $insert_id; + }else + return 0; + } + + public function update_ipd_item($data,$old_id_no) { + $user = $this->ion_auth->user()->row(); + $user_id = $user->id; + $user_name = $user->first_name.''. $user->last_name; + + $sql="select * from ipd_invoice_item where id=".$old_id_no; + $query = $this->db->query($sql); + $data1=$query->result_array(); + + if(count($data1)>0) + { + $update_emp_name=$user_id.'['.$user_name.']'.date('Y-m-d H:i:s'); + $Old_Update_data=($data1[0]['log']==''?' ':$data1[0]['log']).PHP_EOL; + + $change_data=compare_arrays($data1[0],$data); + if(strlen($change_data)>0) + { + $data['log']=$Old_Update_data.$change_data.'Update By :'.$update_emp_name; + } + } + + $this->db->where("id", $old_id_no); + $this->db->update("ipd_invoice_item", $data); + + } + + public function deleteIpdinvoiceitem($del_id) + { + $this->db->where('id', $del_id); + $q = $this->db->get('ipd_invoice_item'); + $data = $q->row_array(); + + $user = $this->ion_auth->user()->row(); + $user_id = $user->id; + $user_name = $user->first_name.''. $user->last_name; + + $data['update_by_id']=$user_id; + $data['update_by']=$user_name; + $data['update_action']='1'; + + if ($this->db->insert("ipd_invoice_item_update", $data)) { + //$this->db->where("id", $del_id); + $this->db->delete("ipd_invoice_item","id=".$del_id); + return 1; + }else{ + return 0; + } + } + + public function insert_package($data) { + + if ($this->db->insert("ipd_package", $data)) { + $insert_id = $this->db->insert_id(); + return $insert_id; + }else + return 0; + } + + public function update_package($data,$old_id_no) { + $this->db->set($data); + $this->db->where("id", $old_id_no); + $this->db->update("ipd_package", $data); + } + + public function deletepackage($del_id) + { + $this->db->where('id', $del_id); + $q = $this->db->get('ipd_package'); + $data = $q->row_array(); + + $user = $this->ion_auth->user()->row(); + $user_id = $user->id; + $user_name = $user->first_name.''. $user->last_name.' D:'.date('d-m-Y h:i:s'); + + $data['update_by_id']=$user_id; + $data['update_by_action']=$user_name; + $data['update_action']='1'; + + if ($this->db->insert("ipd_package_update", $data)) { + //$this->db->where("id", $del_id); + $this->db->delete("ipd_package","id=".$del_id); + return 1; + }else{ + return 0; + } + } + + + public function insert_refer_ipd($data) { + if ($this->db->insert("ipd_refer", $data)) { + $insert_id = $this->db->insert_id(); + return $insert_id; + }else + return 0; + } + + public function remove_refer_ipd($del_id) + { + $this->db->where('id', $del_id); + $q = $this->db->get('ipd_refer'); + $data = $q->row_array(); + + $user = $this->ion_auth->user()->row(); + $user_id = $user->id; + $user_name = $user->first_name.''. $user->last_name.' D:'.date('d-m-Y h:i:s'); + + $data['update_by_id']=$user_id; + $data['update_by_action']=$user_name; + $data['update_action']='1'; + + if ($this->db->insert("ipd_refer_update", $data)) { + //$this->db->where("id", $del_id); + $this->db->delete("ipd_refer","id=".$del_id); + return 1; + }else{ + return 0; + } + } + +} +?> \ No newline at end of file diff --git a/old_code_ci3/models/Item_M.php b/old_code_ci3/models/Item_M.php new file mode 100644 index 0000000..ec746a4 --- /dev/null +++ b/old_code_ci3/models/Item_M.php @@ -0,0 +1,109 @@ +db->insert("hc_items", $data)) { + $insert_id = $this->db->insert_id(); + + return $insert_id; + }else + return 0; + } + + public function insert_type($data) { + + if ($this->db->insert("hc_item_type", $data)) { + $insert_id = $this->db->insert_id(); + + return $insert_id; + }else + return 0; + } + + public function update_type($data,$old_id_no) { + + $this->db->set($data); + $this->db->where("itype_id", $old_id_no); + if ($this->db->update("hc_item_type", $data)) { + return 1; + }else + return 0; + } + + public function insert_in_item($data) { + + if ($this->db->insert("hc_items_insurance", $data)) { + $insert_id = $this->db->insert_id(); + + return $insert_id; + }else + return 0; + } + + public function update_in_item($data,$old_id_no) { + + $user = $this->ion_auth->user()->row(); + $user_id = $user->id; + $user_name = $user->first_name.''. $user->last_name.'['.$user_id.']'; + + $sql="select *,2 as action,'".$user_name."' as action_by from hc_items_insurance where id=".$old_id_no; + $query = $this->db->query($sql); + $insertdata= $query->result(); + + if(count($insertdata)>0){ + $this->db->insert("hc_items_insurance_update", $insertdata[0]); + } + + $this->db->set($data); + $this->db->where("id", $old_id_no); + if ($this->db->update("hc_items_insurance", $data)) { + return 1; + }else + return 0; + } + + public function delete_in_item($data,$old_id_no) { + $user = $this->ion_auth->user()->row(); + $user_id = $user->id; + $user_name = $user->first_name.''. $user->last_name.'['.$user_id.']'; + + $sql="select *,2 as action,'".$user_name."' as action_by from hc_items_insurance where id=".$old_id_no; + $query = $this->db->query($sql); + $insertdata= $query->result(); + + if(count($insertdata)>0){ + $this->db->insert("hc_items_insurance_update", $insertdata[0]); + $this->db->delete("hc_items_insurance", "id=".$old_id_no); + } + + return 0; + } + + public function update($data,$old_id_no) { + $user = $this->ion_auth->user()->row(); + $user_id = $user->id; + $user_name = $user->first_name.''. $user->last_name.'['.$user_id.']'; + + $sql="select *,1 as action,'".$user_name."' as action_by from hc_items where id=".$old_id_no; + $query = $this->db->query($sql); + $insertdata= $query->result(); + + if(count($insertdata)>0){ + $this->db->insert("hc_items_update", $insertdata[0]); + } + + $this->db->set($data); + $this->db->where("id", $old_id_no); + if ($this->db->update("hc_items", $data)) { + return 1; + }else + return 0; + } +} +?> \ No newline at end of file diff --git a/old_code_ci3/models/Item_ipd_M.php b/old_code_ci3/models/Item_ipd_M.php new file mode 100644 index 0000000..baf6b7a --- /dev/null +++ b/old_code_ci3/models/Item_ipd_M.php @@ -0,0 +1,109 @@ +db->insert("ipd_items", $data)) { + $insert_id = $this->db->insert_id(); + + return $insert_id; + }else + return 0; + } + + public function insert_type($data) { + + if ($this->db->insert("ipd_item_type", $data)) { + $insert_id = $this->db->insert_id(); + + return $insert_id; + }else + return 0; + } + + public function update_type($data,$old_id_no) { + + $this->db->set($data); + $this->db->where("itype_id", $old_id_no); + if ($this->db->update("ipd_item_type", $data)) { + return 1; + }else + return 0; + } + + public function insert_in_item($data) { + if ($this->db->insert("ipd_items_insurance", $data)) { + $insert_id = $this->db->insert_id(); + + return $insert_id; + }else + return 0; + } + + public function update_in_item($data,$old_id_no) { + + $user = $this->ion_auth->user()->row(); + $user_id = $user->id; + $user_name = $user->first_name.''. $user->last_name.'['.$user_id.']'; + + $sql="select *,2 as action,'".$user_name."' as action_by from ipd_items_insurance where id=".$old_id_no; + $query = $this->db->query($sql); + $insertdata= $query->result(); + + if(count($insertdata)>0){ + $this->db->insert("ipd_items_insurance_update", $insertdata[0]); + } + + $this->db->set($data); + $this->db->where("id", $old_id_no); + if ($this->db->update("ipd_items_insurance", $data)) { + return 1; + }else + return 0; + } + + public function delete_in_item($data,$old_id_no) { + $user = $this->ion_auth->user()->row(); + $user_id = $user->id; + $user_name = $user->first_name.''. $user->last_name.'['.$user_id.']'; + + $sql="select *,2 as action,'".$user_name."' as action_by from ipd_items_insurance where id=".$old_id_no; + $query = $this->db->query($sql); + $insertdata= $query->result(); + + if(count($insertdata)>0){ + $this->db->insert("ipd_items_insurance_update", $insertdata[0]); + $this->db->delete("ipd_items_insurance", "id=".$old_id_no); + } + + return 0; + } + + public function update($data,$old_id_no) { + $user = $this->ion_auth->user()->row(); + $user_id = $user->id; + $user_name = $user->first_name.''. $user->last_name.'['.$user_id.']'; + + $sql="select *,1 as action,'".$user_name."' as action_by + from ipd_items where id=".$old_id_no; + $query = $this->db->query($sql); + $insertdata= $query->result(); + + if(count($insertdata)>0){ + $this->db->insert("ipd_items_update", $insertdata[0]); + } + + $this->db->set($data); + $this->db->where("id", $old_id_no); + if ($this->db->update("ipd_items", $data)) { + return 1; + }else + return 0; + } +} +?> \ No newline at end of file diff --git a/old_code_ci3/models/Master_M.php b/old_code_ci3/models/Master_M.php new file mode 100644 index 0000000..5476573 --- /dev/null +++ b/old_code_ci3/models/Master_M.php @@ -0,0 +1,66 @@ +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; + } +//Location Master + public function insert_location_master($data) { + + if ($this->db->insert("location_master", $data)) { + $insert_id = $this->db->insert_id(); + + return $insert_id; + }else + return 0; + } + + public function update_location_master($data,$old_id_no) { + $this->db->set($data); + $this->db->where("l_id", $old_id_no); + if ($this->db->update("location_master", $data)) { + return 1; + }else + return 0; + } + + //Employee Master + public function insert_employee_master($data) { + + if ($this->db->insert("employee_master", $data)) { + $insert_id = $this->db->insert_id(); + + return $insert_id; + }else + return 0; + } + + public function update_employee_master($data,$old_id_no) { + $this->db->set($data); + $this->db->where("emp_id", $old_id_no); + if ($this->db->update("employee_master", $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 new file mode 100644 index 0000000..054b491 --- /dev/null +++ b/old_code_ci3/models/Medical_M.php @@ -0,0 +1,610 @@ +db->insert("drug_temp", $data)) { + $insert_id = $this->db->insert_id(); + return $insert_id; + }else + return 0; + } + + public function update_drug($data,$old_id_no) { + + $this->db->set($data); + $this->db->where("item_id", $old_id_no); + + if($this->db->update("drug_temp", $data)) + { + return 1; + }else{ + return 0; + } + } + + public function insert_stock_add($data) { + + if ($this->db->insert("stock_addition", $data)) { + $insert_id = $this->db->insert_id(); + return $insert_id; + }else + return 0; + } + + public function update_stock_upd($data,$old_id_no) { + $this->db->set($data); + $this->db->where("ss_no", $old_id_no); + if($this->db->update("stock_addition", $data)) + { + return 1; + } else{ + return 0; + } + } + + public function add_invoice($data) + { + if ($this->db->insert("invoice_med_master", $data)) { + $insert_id = $this->db->insert_id(); + + $pid=str_pad(substr($insert_id,-7,7),7,0,STR_PAD_LEFT); + + $pid='M'.date('ym').$pid; + $data1 = array( + 'inv_med_code' => $pid + ); + + $this->db->set($data1); + $this->db->where("id", $insert_id); + $this->db->update("invoice_med_master", $data1); + + return $insert_id; + }else + return 0; + } + + public function add_invoiceitem($data) + { + if ($this->db->insert("inv_med_item", $data)) { + $insert_id = $this->db->insert_id(); + $store_stock_id=$data['store_stock_id']; + $this->db->query("CALL p_stock_update_purchase_id(".$store_stock_id.")"); + $this->db->query("CALL p_update_med_GST(".$data['inv_med_id'].")"); + return $insert_id; + }else + return 0; + } + + + public function update_invoiceitem($data,$old_id_no) + { + $this->db->set($data); + $this->db->where("id", $old_id_no); + + if($this->db->update("inv_med_item", $data)) + { + $store_stock_id=$data['store_stock_id']; + $this->db->query("CALL p_stock_update_purchase_id(".$store_stock_id.")"); + $this->db->query("CALL p_update_med_GST(".$data['inv_med_id'].")"); + return 1; + } else{ + return 0; + } + } + + public function delete_invoiceitem($itemid,$inv_items) + { + $this->db->delete("inv_med_item", "id=".$itemid); + + $update_emp_name=$this->session->userdata('username').'['.$this->session->userdata('agent_id').']'.date('Y-m-d H:i:s'); + + $add_data=array( + 'delete_by' => $update_emp_name, + ); + + $data=array_merge($inv_items,$add_data); + + $store_stock_id=$data['store_stock_id']; + + //echo "Purchase Id :".$store_stock_id; + + $this->db->insert("inv_med_item_delete", $data); + $this->db->query("CALL p_update_med_GST(".$data['inv_med_id'].")"); + + $this->db->query("CALL p_stock_update_purchase_id(".$store_stock_id.")"); + } + + public function update_in_upv_item($data,$old_id_no) { + $sql="select * from invoice_med_master where id=".$old_id_no; + $query = $this->db->query($sql); + $data1=$query->result_array(); + + if(count($data1)>0) + { + $update_emp_name=$this->session->userdata('username').'['.$this->session->userdata('agent_id').']'.date('Y-m-d H:i:s'); + $log=compare_arrays($data1[0],$data).PHP_EOL.'Update By :'.$update_emp_name; + $old_log=$data1[0]['log']; + if($old_log=='' || $old_log==null) + { + $old_log=''; + } + + $ulog=$old_log.PHP_EOL.$log; + + $this->db->set($data); + $this->db->set('log',$ulog,true); + $this->db->where("id", $old_id_no); + $this->db->update("invoice_med_master"); + } + } + + //Start Medical Company + + public function insert_company($data) { + if ($this->db->insert("med_company", $data)) { + $insert_id = $this->db->insert_id(); + return $insert_id; + }else + return 0; + } + + public function update_company($data,$old_id_no) { + + $this->db->set($data); + $this->db->where("id", $old_id_no); + $this->db->update("med_company", $data); + } + + + //Start Medical Company + + public function insert_med_product_cat_master($data) { + if ($this->db->insert("med_product_cat_master", $data)) { + $insert_id = $this->db->insert_id(); + return $insert_id; + }else + return 0; + } + + public function update_med_product_cat_master($data,$old_id_no) { + + $this->db->set($data); + $this->db->where("id", $old_id_no); + $this->db->update("med_product_cat_master", $data); + } + + + //Start Medical Payment History + + public function insert_payment($data) { + $data['amount_1']=$data['amount']; + + if ($this->db->insert("payment_history_medical", $data)) { + $insert_id = $this->db->insert_id(); + return $insert_id; + }else + return 0; + } + + public function update_payment($data,$old_id_no) { + $data['amount_1']=$data['amount']; + $this->db->set($data); + $this->db->where("id", $old_id_no); + $this->db->update("payment_history_medical", $data); + } + + public function insert_payment_history_log($data) { + if ($this->db->insert("paymentmedical_history_log", $data)) { + $insert_id = $this->db->insert_id(); + return $insert_id; + }else + return 0; + } + + //End Medical Histoy + + public function update_group_invoice($data,$old_id_no) { + $this->db->set($data); + $this->db->where("med_group_id", $old_id_no); + $this->db->update("inv_med_group", $data); + } + + public function update_invoice_final($inv_id) + { + $this->db->query("CALL p_update_med_GST(".$inv_id.")"); + } + + public function update_invoice_group($inv_id) + { + $this->db->query("CALL p_update_med_group(".$inv_id.")"); + } + + public function update_invoice_group_gst($ipd,$bill_type=1) + { + $this->db->query("CALL p_update_med_group_GST(".$ipd.",".$bill_type.")"); + } + + public function update_invoice_rate_final($inv_id) + { + $this->db->query("CALL med_rate_update(".$inv_id.")"); + } + + public function transfer_ssno($from_ssno,$to_ssno,$tqty) + { + $this->db->query("CALL p_sale_transfer_ssno(".$from_ssno.",".$to_ssno.",".$tqty.")"); + } + + public function merge_product($from_prod_id,$to_prod_id) + { + $this->db->query("CALL p_combine_product_master(".$from_prod_id.",".$to_prod_id.")"); + } + + public function insert_supplier($data) { + + if ($this->db->insert("med_supplier", $data)) { + $insert_id = $this->db->insert_id(); + return $insert_id; + }else + return 0; + } + + public function update_supplier($data,$old_id_no) { + $this->db->set($data); + $this->db->where("sid", $old_id_no); + if($this->db->update("med_supplier", $data)) + { + return $old_id_no; + } else{ + return 0; + } + } + + public function insert_purchase($data) { + + $this->db->db_debug = false; + + if($this->db->insert("purchase_invoice", $data)) { + $insert_id = $this->db->insert_id(); + return $insert_id; + }else + return 0; + } + + public function update_purchase($data,$old_id_no) { + $this->db->set($data); + $this->db->where("id", $old_id_no); + if($this->db->update("purchase_invoice", $data)) + { + $this->db->query("CALL p_purchase_invoice(".$old_id_no.")"); + return 1; + } else{ + return 0; + } + } + + public function delete_purchase($inv_id) { + + $this->db->where("id", $inv_id); + $this->db->delete("purchase_invoice"); + + return 1; + } + + public function insert_purchase_item($data) { + if ($this->db->insert("purchase_invoice_item", $data)) { + $insert_id = $this->db->insert_id(); + $this->db->query("CALL f_update_purchase_invoice(".$insert_id.")"); + return $insert_id; + }else + return 0; + } + + public function update_purchase_item($data,$old_id_no) { + $this->db->set($data); + $this->db->where("id", $old_id_no); + if($this->db->update("purchase_invoice_item", $data)) + { + $this->db->query("CALL f_update_purchase_invoice(".$old_id_no.")"); + return 1; + } else{ + return 0; + } + } + + public function delete_purchase_item($inv_id,$del_inv_item_id) { + + $this->db->where("id", $del_inv_item_id); + $this->db->delete("purchase_invoice_item"); + + $this->db->query("CALL p_purchase_invoice(".$inv_id.")"); + + return 1; + + /* + $sql="select count(*) as no_rec from inv_med_item where ss_no=".$del_inv_item_id; + $query = $this->db->query($sql); + $result = $query->result(); + + $sale_qty=$result[0]->no_rec; + + if($sale_qty>0) + { + return 0; + + }else{ + $this->db->where("id", $del_inv_item_id); + $this->db->delete("purchase_invoice_item"); + + $this->db->query("CALL f_update_purchase_invoice(".$inv_id.")"); + + return 1; + } + */ + } + + public function update_purchase_item_stock_adjust($data_stock_adjuct,$item_id) { + $sql="select sum(qty) as total_adjust + from purchase_item_stock_adjust + where item_id=".$item_id; + $query = $this->db->query($sql); + $result = $query->result(); + + $sql="select *,(total_unit-total_lost_unit-total_sale_unit) as Cur_unit_qty + from purchase_invoice_item where id=".$item_id; + $query = $this->db->query($sql); + $result_item_master = $query->result(); + + $total_adjust=0; + $total_lost_unit=0; + $current_qty=0; + + $insert_flag=0; + + $qty=$data_stock_adjuct['qty']; + + if(count($result_item_master)>0) + { + $total_lost_unit=$result_item_master[0]->total_lost_unit; + $current_qty=$result_item_master[0]->Cur_unit_qty ; + + } + + if(count($result)>0) + { + $total_adjust=$result[0]->total_adjust; + } + + if($qty>0) + { + if($current_qty>=$qty) + { + $insert_flag=1; + } + }elseif($qty<0){ + if($total_adjust>=$qty*-1) + { + $insert_flag=1; + } + } + + if($insert_flag==1) + { + $total_adjust=$total_adjust+$qty; + + if ($this->db->insert("purchase_item_stock_adjust", $data_stock_adjuct)) { + $insert_id = $this->db->insert_id(); + + $data = array( + 'total_lost_unit' => $total_adjust + ); + + $this->db->set($data); + $this->db->where("id", $item_id); + $this->db->update("purchase_invoice_item", $data); + + return "Done : Re-Search Again for Update Records"; + }else{ return "Not Insert in Stock Adjust"; } + + }else{ + return "Qty Not Correct: either Its greater then stock Qty or 0"; + } + + } + + public function update_remove_status_item($data_stock_adjuct,$item_id) { + + $sql="select sum(qty) as total_adjust + from purchase_item_stock_adjust where item_id=".$item_id; + $query = $this->db->query($sql); + $result = $query->result(); + + $sql="select *,(total_unit-total_lost_unit-total_sale_unit) as Cur_unit_qty + from purchase_invoice_item where item_return=0 and id=".$item_id; + $query = $this->db->query($sql); + $result_item_master = $query->result(); + + $total_adjust=0; + $total_lost_unit=0; + $current_qty=0; + + $insert_flag=0; + + if(count($result_item_master)>0) + { + $total_lost_unit=$result_item_master[0]->total_lost_unit; + $current_qty=$result_item_master[0]->Cur_unit_qty ; + } + + if(count($result)>0) + { + $total_adjust=$result[0]->total_adjust; + } + + $total_adjust=$total_adjust+$current_qty; + + $data_stock_adjuct['qty']=$current_qty; + + if ($this->db->insert("purchase_item_stock_adjust", $data_stock_adjuct)) { + $insert_id = $this->db->insert_id(); + + $data = array( + 'total_lost_unit' => $total_adjust, + 'remove_item' => '1' + ); + + $this->db->set($data); + $this->db->where("id", $item_id); + $this->db->update("purchase_invoice_item", $data); + + return "Done : Remove ".$current_qty." Qty : Re-Search for Update Records"; + }else{ return "Not Insert in Stock Adjust"; } + } + + public function add_removed_item($data_stock_adjuct,$item_id) + { + if ($this->db->insert("purchase_item_stock_adjust", $data_stock_adjuct)) { + $insert_id = $this->db->insert_id(); + + $data = array( + 'remove_item' => '0' + ); + + $this->db->set($data); + $this->db->where("id", $item_id); + $this->db->update("purchase_invoice_item", $data); + + return "Add Item in Stock "; + }else{ + return "Something Wrong "; + } + } + + + public function insert_inv_med_item_return_add($data) { + + if ($this->db->insert("inv_med_item_return", $data)) { + $insert_id = $this->db->insert_id(); + return $insert_id; + }else + return 0; + } + + public function delete_return_item($inv_item_id) { + $this->db->where("inv_item_id", $inv_item_id); + $this->db->where("return_status", '0'); + $this->db->delete("inv_med_item_return"); + } + + public function update_return_item($data,$old_id_no) { + + $this->db->set($data); + $this->db->where("id", $old_id_no); + + if($this->db->update("inv_med_item_return", $data)) + { + return 1; + }else{ + return 0; + } + + } + + public function insert_med_supplier_ledger($data) { + + if($this->db->insert("med_supplier_ledger", $data)) { + $insert_id = $this->db->insert_id(); + return $insert_id; + }else + return 0; + } + + public function update_med_supplier_ledger($data,$old_id_no) { + + $this->db->set($data); + $this->db->where("id", $old_id_no); + + if($this->db->update("med_supplier_ledger", $data)) + { + return 1; + }else{ + return 0; + } + + } + + //Insert Update Table purchase_return_invoice / purchase_return_invoice_item + + public function add_purchase_return_invoice($data) + { + if ($this->db->insert("purchase_return_invoice", $data)) { + $insert_id = $this->db->insert_id(); + + $pid=str_pad(substr($insert_id,-3,3),3,0,STR_PAD_LEFT); + + $pid='PR'.date('ym').$pid; + $data1 = array( + 'p_r_invoice_no' => $pid + ); + + $this->db->set($data1); + $this->db->where("id", $insert_id); + $this->db->update("purchase_return_invoice", $data1); + + return $insert_id; + }else + return 0; + } + + public function add_purchase_return_invoiceitem($data) + { + if ($this->db->insert("purchase_return_invoice_item", $data)) { + $insert_id = $this->db->insert_id(); + + $this->db->query("CALL p_stock_purchase_return(".$insert_id.",0)"); + return $insert_id; + }else + return 0; + } + + public function update_purchase_return_invoiceitem($data,$old_id_no) + { + $this->db->set($data); + $this->db->where("id", $old_id_no); + + if($this->db->update("purchase_return_invoice_item", $data)) + { + $store_stock_id=$data['store_stock_id']; + //$this->db->query("CALL p_stock_update_purchase_id(".$store_stock_id.")"); + return 1; + } else{ + return 0; + } + } + + public function opd_reset($inv_id) + { + //$this->db->query("CALL p_cash_opd_pre_data(".$inv_id.")"); + } + + public function delete_purchase_return_invoiceitem($itemid) + { + $this->db->query("CALL p_stock_purchase_return(".$itemid.",1)"); + + $this->db->delete("purchase_return_invoice_item", "id=".$itemid); + + $update_emp_name=$this->session->userdata('username').'['.$this->session->userdata('agent_id').']'.date('Y-m-d H:i:s'); + + $add_data=array( + 'delete_by' => $update_emp_name, + ); + + } + + + + } +?> \ No newline at end of file diff --git a/old_code_ci3/models/Medical_M_03062021.php b/old_code_ci3/models/Medical_M_03062021.php new file mode 100644 index 0000000..9c4e451 --- /dev/null +++ b/old_code_ci3/models/Medical_M_03062021.php @@ -0,0 +1,491 @@ +db->insert("drug_temp", $data)) { + $insert_id = $this->db->insert_id(); + return $insert_id; + }else + return 0; + } + + public function update_drug($data,$old_id_no) { + + $this->db->set($data); + $this->db->where("item_id", $old_id_no); + + if($this->db->update("drug_temp", $data)) + { + return 1; + }else{ + return 0; + } + + } + + public function insert_stock_add($data) { + + if ($this->db->insert("stock_addition", $data)) { + $insert_id = $this->db->insert_id(); + return $insert_id; + }else + return 0; + } + + public function update_stock_upd($data,$old_id_no) { + $this->db->set($data); + $this->db->where("ss_no", $old_id_no); + if($this->db->update("stock_addition", $data)) + { + return 1; + } else{ + return 0; + } + } + + public function add_invoice($data) + { + if ($this->db->insert("invoice_med_master", $data)) { + $insert_id = $this->db->insert_id(); + + $pid=str_pad(substr($insert_id,-7,7),7,0,STR_PAD_LEFT); + + $pid='M'.date('ym').$pid; + $data1 = array( + 'inv_med_code' => $pid + ); + + $this->db->set($data1); + $this->db->where("id", $insert_id); + $this->db->update("invoice_med_master", $data1); + + return $insert_id; + }else + return 0; + } + + public function add_invoiceitem($data) + { + if ($this->db->insert("inv_med_item", $data)) { + $insert_id = $this->db->insert_id(); + + if($insert_id>0) + { + $this->db->set("total_sale_unit","total_sale_unit+".$data["qty"],false); + $this->db->where("id", $data["store_stock_id"]); + $this->db->update("purchase_invoice_item"); + } + + return $insert_id; + }else + return 0; + } + + public function update_invoiceitem($data,$old_id_no) + { + $sql="select * from inv_med_item where id=".$old_id_no; + $query = $this->db->query($sql); + $result = $query->result(); + + $old_qty=$result[0]->qty; + $diff_qty=$data["qty"]-$old_qty; + $store_stock_id=$result[0]->store_stock_id; + + $this->db->set($data); + $this->db->where("id", $old_id_no); + + if($this->db->update("inv_med_item", $data)) + { + $this->db->set("total_sale_unit","total_sale_unit+".$diff_qty,false); + $this->db->where("id", $store_stock_id); + $this->db->update("purchase_invoice_item"); + } + } + + public function delete_invoiceitem($itemid) + { + $sql="select * from inv_med_item where id=".$itemid; + $query = $this->db->query($sql); + $result = $query->result(); + + $old_qty=$result[0]->qty; + $store_stock_id=$result[0]->store_stock_id; + + if($this->db->delete("inv_med_item", "id=".$itemid)) + { + $this->db->set("total_sale_unit","total_sale_unit-".$old_qty,false); + $this->db->where("id", $store_stock_id); + $this->db->update("purchase_invoice_item"); + } + } + + public function update_in_upv_item($data,$old_id_no) { + $sql="select * from invoice_med_master where id=".$old_id_no; + $query = $this->db->query($sql); + $data1=$query->result_array(); + + if(count($data1)>0) + { + $update_emp_name=$this->session->userdata('username').'['.$this->session->userdata('agent_id').']'.date('Y-m-d H:i:s'); + $log=compare_arrays($data1[0],$data).PHP_EOL.'Update By :'.$update_emp_name; + $old_log=$data1[0]['log']; + if($old_log=='' || $old_log==null) + { + $old_log=''; + } + + $ulog=$old_log.PHP_EOL.$log; + + $this->db->set($data); + $this->db->set('log',$ulog,true); + $this->db->where("id", $old_id_no); + $this->db->update("invoice_med_master"); + } + } + + //Start Medical Company + + public function insert_company($data) { + if ($this->db->insert("med_company", $data)) { + $insert_id = $this->db->insert_id(); + return $insert_id; + }else + return 0; + } + + public function update_company($data,$old_id_no) { + + $this->db->set($data); + $this->db->where("id", $old_id_no); + $this->db->update("med_company", $data); + } + + //Start Medical Payment History + + public function insert_payment($data) { + if ($this->db->insert("payment_history_medical", $data)) { + $insert_id = $this->db->insert_id(); + return $insert_id; + }else + return 0; + } + + public function update_payment($data,$old_id_no) { + + $this->db->set($data); + $this->db->where("id", $old_id_no); + $this->db->update("payment_history_medical", $data); + } + + public function insert_payment_history_log($data) { + if ($this->db->insert("paymentmedical_history_log", $data)) { + $insert_id = $this->db->insert_id(); + return $insert_id; + }else + return 0; + } + + //End Medical Histoy + + public function update_group_invoice($data,$old_id_no) { + $this->db->set($data); + $this->db->where("med_group_id", $old_id_no); + $this->db->update("inv_med_group", $data); + } + + public function update_invoice_final($inv_id) + { + $this->db->query("CALL p_update_med_GST(".$inv_id.")"); + } + + public function update_invoice_group($inv_id) + { + $this->db->query("CALL p_update_med_group(".$inv_id.")"); + } + + public function update_invoice_group_gst($ipd,$bill_type=1) + { + $this->db->query("CALL p_update_med_group_GST(".$ipd.",".$bill_type.")"); + } + + public function update_invoice_rate_final($inv_id) + { + $this->db->query("CALL med_rate_update(".$inv_id.")"); + } + + public function insert_supplier($data) { + + if ($this->db->insert("med_supplier", $data)) { + $insert_id = $this->db->insert_id(); + return $insert_id; + }else + return 0; + } + + public function update_supplier($data,$old_id_no) { + $this->db->set($data); + $this->db->where("sid", $old_id_no); + if($this->db->update("med_supplier", $data)) + { + return 1; + } else{ + return 0; + } + } + + public function insert_purchase($data) { + + $this->db->db_debug = false; + + if($this->db->insert("purchase_invoice", $data)) { + $insert_id = $this->db->insert_id(); + return $insert_id; + }else + return 0; + } + + public function update_purchase($data,$old_id_no) { + $this->db->set($data); + $this->db->where("id", $old_id_no); + if($this->db->update("purchase_invoice", $data)) + { + $this->db->query("CALL p_purchase_invoice(".$old_id_no.")"); + return 1; + } else{ + return 0; + } + } + + public function delete_purchase($inv_id) { + + $this->db->where("id", $inv_id); + $this->db->delete("purchase_invoice"); + + return 1; + } + + public function insert_purchase_item($data) { + if ($this->db->insert("purchase_invoice_item", $data)) { + $insert_id = $this->db->insert_id(); + $this->db->query("CALL f_update_purchase_invoice(".$insert_id.")"); + return $insert_id; + }else + return 0; + } + + public function update_purchase_item($data,$old_id_no) { + $this->db->set($data); + $this->db->where("id", $old_id_no); + if($this->db->update("purchase_invoice_item", $data)) + { + $this->db->query("CALL f_update_purchase_invoice(".$old_id_no.")"); + return 1; + } else{ + return 0; + } + } + + public function delete_purchase_item($inv_id,$del_inv_item_id) { + + $this->db->where("id", $del_inv_item_id); + $this->db->delete("purchase_invoice_item"); + + $this->db->query("CALL p_purchase_invoice(".$inv_id.")"); + + return 1; + + /* + $sql="select count(*) as no_rec from inv_med_item where ss_no=".$del_inv_item_id; + $query = $this->db->query($sql); + $result = $query->result(); + + $sale_qty=$result[0]->no_rec; + + if($sale_qty>0) + { + return 0; + + }else{ + $this->db->where("id", $del_inv_item_id); + $this->db->delete("purchase_invoice_item"); + + $this->db->query("CALL f_update_purchase_invoice(".$inv_id.")"); + + return 1; + } + */ + } + + public function update_purchase_item_stock_adjust($data_stock_adjuct,$item_id) { + $sql="select sum(qty) as total_adjust from purchase_item_stock_adjust where item_id=".$item_id; + $query = $this->db->query($sql); + $result = $query->result(); + + $sql="select *,(total_unit-total_return_unit-total_lost_unit-total_sale_unit) as Cur_unit_qty + from purchase_invoice_item where item_return=0 and id=".$item_id; + $query = $this->db->query($sql); + $result_item_master = $query->result(); + + $total_adjust=0; + $total_lost_unit=0; + $current_qty=0; + + $insert_flag=0; + + $qty=$data_stock_adjuct['qty']; + + if(count($result_item_master)>0) + { + $total_lost_unit=$result_item_master[0]->total_lost_unit; + $current_qty=$result_item_master[0]->Cur_unit_qty ; + + } + + if(count($result)>0) + { + $total_adjust=$result[0]->total_adjust; + } + + if($qty>0) + { + if($current_qty>=$qty) + { + $insert_flag=1; + } + }elseif($qty<0){ + if($total_adjust>=$qty*-1) + { + $insert_flag=1; + } + } + + if($insert_flag==1) + { + $total_adjust=$total_adjust+$qty; + + if ($this->db->insert("purchase_item_stock_adjust", $data_stock_adjuct)) { + $insert_id = $this->db->insert_id(); + + $data = array( + 'total_lost_unit' => $total_adjust + ); + + $this->db->set($data); + $this->db->where("id", $item_id); + $this->db->update("purchase_invoice_item", $data); + + return "Done : Re-Search Again for Update Records"; + }else{ return "Not Insert in Stock Adjust"; } + + }else{ + return "Qty Not Correct: either Its greater then stock Qty or 0"; + } + + } + + public function update_remove_status_item($data_stock_adjuct,$item_id) { + + $sql="select sum(qty) as total_adjust from purchase_item_stock_adjust where item_id=".$item_id; + $query = $this->db->query($sql); + $result = $query->result(); + + $sql="select *,(total_unit-total_return_unit-total_lost_unit-total_sale_unit) as Cur_unit_qty + from purchase_invoice_item where item_return=0 and id=".$item_id; + $query = $this->db->query($sql); + $result_item_master = $query->result(); + + $total_adjust=0; + $total_lost_unit=0; + $current_qty=0; + + $insert_flag=0; + + if(count($result_item_master)>0) + { + $total_lost_unit=$result_item_master[0]->total_lost_unit; + $current_qty=$result_item_master[0]->Cur_unit_qty ; + } + + if(count($result)>0) + { + $total_adjust=$result[0]->total_adjust; + } + + $total_adjust=$total_adjust+$current_qty; + + $data_stock_adjuct['qty']=$current_qty; + + if ($this->db->insert("purchase_item_stock_adjust", $data_stock_adjuct)) { + $insert_id = $this->db->insert_id(); + + $data = array( + 'total_lost_unit' => $total_adjust, + 'remove_item' => '1' + ); + + $this->db->set($data); + $this->db->where("id", $item_id); + $this->db->update("purchase_invoice_item", $data); + + return "Done : Remove ".$current_qty." Qty : Re-Search for Update Records"; + }else{ return "Not Insert in Stock Adjust"; } + } + + public function insert_inv_med_item_return_add($data) { + + if ($this->db->insert("inv_med_item_return", $data)) { + $insert_id = $this->db->insert_id(); + return $insert_id; + }else + return 0; + } + + public function delete_return_item($inv_item_id) { + $this->db->where("inv_item_id", $inv_item_id); + $this->db->where("return_status", '0'); + $this->db->delete("inv_med_item_return"); + } + + public function update_return_item($data,$old_id_no) { + + $this->db->set($data); + $this->db->where("id", $old_id_no); + + if($this->db->update("inv_med_item_return", $data)) + { + return 1; + }else{ + return 0; + } + + } + + public function insert_med_supplier_ledger($data) { + + if($this->db->insert("med_supplier_ledger", $data)) { + $insert_id = $this->db->insert_id(); + return $insert_id; + }else + return 0; + } + + public function update_med_supplier_ledger($data,$old_id_no) { + + $this->db->set($data); + $this->db->where("id", $old_id_no); + + if($this->db->update("med_supplier_ledger", $data)) + { + return 1; + }else{ + return 0; + } + + } + + } +?> \ No newline at end of file diff --git a/old_code_ci3/models/Ocasemaster_M.php b/old_code_ci3/models/Ocasemaster_M.php new file mode 100644 index 0000000..40e151d --- /dev/null +++ b/old_code_ci3/models/Ocasemaster_M.php @@ -0,0 +1,53 @@ +db->insert("organization_case_master", $data)) { + $insert_id = $this->db->insert_id(); + + $pid=str_pad(substr($insert_id,-7,7),7, '0', STR_PAD_LEFT); + $pid='C'.date('ym').$pid; + $data1 = array( + 'case_id_code' => $pid + ); + + $this->db->set($data1); + $this->db->where("id", $insert_id); + $this->db->update("organization_case_master", $data1); + + return $insert_id; + }else + return 0; + } + + public function update($data,$old_id_no) { + $this->db->set($data); + $this->db->where("id", $old_id_no); + $this->db->update("organization_case_master", $data); + + + } + + + public function insert_org_pack($data) { + if ($this->db->insert("org_packing", $data)) { + $insert_id = $this->db->insert_id(); + return $insert_id; + }else + return 0; + } + + public function update_org_pack($data,$old_id_no) { + $this->db->set($data); + $this->db->where("id", $old_id_no); + $this->db->update("org_packing", $data); + return $old_id_no; + } +} +?> \ No newline at end of file diff --git a/old_code_ci3/models/Opd_M.php b/old_code_ci3/models/Opd_M.php new file mode 100644 index 0000000..5e02a24 --- /dev/null +++ b/old_code_ci3/models/Opd_M.php @@ -0,0 +1,279 @@ +db->query($sql); + $result = $query->result_array(); + //print_r($result); + return $result; + } + + public function insert($data) { + + $p_id=$data['p_id']; + $opd_dt=$data['apointment_date']; + $doc_id=$data['doc_id']; + + $sql="select * from opd_master + where apointment_date=curdate() and (payment_status=0 or opd_status=1 ) and p_id=$p_id and doc_id=$doc_id"; + $query = $this->db->query($sql); + $no_duplicate= $query->result(); + + $insert_id=0; + + if(count($no_duplicate)==0) + { + if($this->db->insert("opd_master", $data)) + { + $insert_id = $this->db->insert_id(); + + $sql="SELECT count(*) as xtimes from opd_master where opd_id<=".$insert_id." and p_id=".$p_id; + $query = $this->db->query($sql); + $opd_times= $query->result(); + + $sql="select count(*) as no_max from opd_master where apointment_date=curdate() and doc_id=".$doc_id; + $query = $this->db->query($sql); + $opd_no_data= $query->result(); + + $opd_no=1; + if(count($opd_no_data)>0) + { + $opd_no=$opd_no_data[0]->no_max; + } + //$opd_no=$opd_no+1; + + $pid=str_pad(substr($insert_id,-7,7),7,0,STR_PAD_LEFT); + $doc_id=str_pad(substr($insert_id,-3,3),3,0,STR_PAD_LEFT); + + $Oid='D'.date('ym').$pid; + + $running_opd=0; + $last_opd_id=0; + + if($data['opd_fee_type']==3) + { + $running_opd = 1; + + $sql="select max(opd_id) as last_opd_id from opd_master + where apointment_date between date_add(curdate(),interval -4 day) and curdate() + and running_opd=0 and doc_id=".$doc_id. " and p_id=".$p_id; + $query = $this->db->query($sql); + $opd_no_data= $query->result(); + + if(count($opd_no_data)>0) + { + if($opd_no_data[0]->last_opd_id=='' || $opd_no_data[0]->last_opd_id=='0') + { + $last_opd_id=0; + }else{ + $last_opd_id=$opd_no_data[0]->last_opd_id; + } + } + } + + $dataupadate = array( + 'opd_code' => $Oid, + 'no_visit' => $opd_times[0]->xtimes, + 'running_opd' => $running_opd, + 'running_opd_id' => $last_opd_id, + 'opd_no'=>$opd_no, + ); + + $this->db->set($dataupadate); + $this->db->where("opd_id", $insert_id); + $this->db->update("opd_master", $dataupadate); + + + } + } + + return $insert_id; + } + + + public function insert_bak($data) { + + $p_id=$data['p_id']; + $opd_dt=$data['apointment_date']; + $doc_id=$data['doc_id']; + + $insert_id=0; + + if($data['opd_fee_type']==3) + { + $sql="SELECT * from opd_master where p_id=".$p_id." and doc_id=".$doc_id." + and apointment_date > date_add(sysdate(),interval -5 day) + order by apointment_date desc "; + $query = $this->db->query($sql); + $opd_running= $query->result(); + + if(count($opd_running)>0) + { + $insert_id=$opd_running[0]->opd_id; + $revisit_opd_id=$opd_running[0]->revisit_opd_id; + + $data_visit = array( + 'revisit_opd_id' => $revisit_opd_id+1, + ); + + $this->db->set($data_visit); + $this->db->where("opd_id", $insert_id); + $this->db->update("opd_master", $data_visit); + + } + }else{ + if($this->db->insert("opd_master", $data)) + { + $insert_id = $this->db->insert_id(); + + $sql="SELECT count(*) as xtimes from opd_master where opd_id<=".$insert_id." and p_id=".$p_id; + $query = $this->db->query($sql); + $opd_times= $query->result(); + + $pid=str_pad(substr($insert_id,-7,7),7,0,STR_PAD_LEFT); + + $pid='D'.date('ym').$pid; + + $dataupadate = array( + 'opd_code' => $pid, + 'revisit' => $opd_times[0]->xtimes, + ); + + $this->db->set($dataupadate); + $this->db->where("opd_id", $insert_id); + $this->db->update("opd_master", $dataupadate); + } + } + + $sql="SELECT * from opd_visit_list where date_opd=".$opd_dt." and p_id=".$p_id; + $query = $this->db->query($sql); + $opd_visit= $query->result(); + + if(count($opd_visit)>0) + { + $data_visit = array( + 'p_name' => $data['P_name'], + 'opd_id' => $data['opd_id'], + 'opd_type' => $data['opd_fee_type'], + 'opd_status' => '1', + ); + + $this->db->set($data_visit); + $this->db->where("id", $opd_visit[0]->id); + $this->db->update("opd_visit_list", $data_visit); + + }else{ + $data_visit = array( + 'p_id' => $p_id, + 'p_name' => $data['P_name'], + 'opd_id' => $insert_id, + 'opd_type' => $data['opd_fee_type'], + 'date_opd' => $data['apointment_date'], + 'opd_no' => '0', + 'update_by' => $data['prepared_by'], + 'opd_status' => '1', + ); + + $this->db->insert("opd_visit_list", $data_visit); + } + + return $insert_id; + } + + public function update($data,$old_id_no) { + + /* Auto Que */ + $user = $this->ion_auth->user()->row(); + + if(isset($user->id)) + { + $user_id = $user->id; + $user_name = $user->first_name.''. $user->last_name.'['.$user_id.']'; + }else{ + $user_id = '0'; + $user_name = 'Mobile User'; + } + + + + $this->db->set($data); + $this->db->where("opd_id", $old_id_no); + $this->db->update("opd_master", $data); + + $this->db->where('opd_id', $old_id_no); + $q = $this->db->get('opd_master'); + // if id is unique, we want to return just one row + $data = $q->row_array(); + + $pno=$data['p_id']; + $doc_id=$data['doc_id']; + $opd_date=$data['apointment_date']; + $opd_status=$data['opd_status']; + + $sql="select max(queue_no) as max_queue from opd_prescription + where date_opd_visit=curdate() and doc_id='".$doc_id."'"; + $query = $this->db->query($sql); + $max_queue= $query->result(); + + if(count($max_queue)>0) + { + $max_queue_no=$max_queue[0]->max_queue; + }else{ + $max_queue_no=0; + } + + $max_queue_no=$max_queue_no+1; + + $sql="select * from opd_prescription where visit_status=0 and opd_id=".$old_id_no; + $query = $this->db->query($sql); + $opd_prescription= $query->result(); + + if(count($opd_prescription)==0 ) + { + + if($opd_status==1) + { + $datainsert = array( + 'opd_id' => $old_id_no, + 'p_id' => $pno, + 'revisit'=>'0', + 'queue_no'=>$max_queue_no, + 'doc_id'=>$doc_id, + 'date_opd_visit'=>date('Y-m-d'), + 'update_by'=>$user_name + ); + + $this->load->model('Prescription_M'); + $this->Prescription_M->insert_opd_prescription($datainsert); + + $msg_send="OPD in Queue Now"; + }else{ + $msg_send="OPD Already Done, Create Revisit"; + } + + } + } + + public function update_opd_queue_no($opd_session_id,$doc_id,$date_opd_visit) { + $result = "update opd_prescription + SET current_queue_no=0 + where doc_id='".$doc_id."' and date_opd_visit='".$date_opd_visit."'"; + $qyt = $this->db->query($result); + + $result = "update opd_prescription + SET current_queue_no=1 + where id='".$opd_session_id."'"; + $qyt = $this->db->query($result); + + return 0; + } + + +} +?> \ No newline at end of file diff --git a/old_code_ci3/models/Package_M.php b/old_code_ci3/models/Package_M.php new file mode 100644 index 0000000..ce61e17 --- /dev/null +++ b/old_code_ci3/models/Package_M.php @@ -0,0 +1,109 @@ +db->insert("package", $data)) { + $insert_id = $this->db->insert_id(); + + return $insert_id; + }else + return 0; + } + + public function insert_type($data) { + + if ($this->db->insert("package", $data)) { + $insert_id = $this->db->insert_id(); + + return $insert_id; + }else + return 0; + } + + public function update_type($data,$old_id_no) { + + $this->db->set($data); + $this->db->where("itype_id", $old_id_no); + if ($this->db->update("package", $data)) { + return 1; + }else + return 0; + } + + public function insert_in_item($data) { + + if ($this->db->insert("package_insurance", $data)) { + $insert_id = $this->db->insert_id(); + + return $insert_id; + }else + return 0; + } + + public function update_in_item($data,$old_id_no) { + + $user = $this->ion_auth->user()->row(); + $user_id = $user->id; + $user_name = $user->first_name.''. $user->last_name.'['.$user_id.']'; + + $sql="select *,2 as action,'".$user_name."' as action_by from package_insurance where id=".$old_id_no; + $query = $this->db->query($sql); + $insertdata= $query->result(); + + if(count($insertdata)>0){ + $this->db->insert("package_insurance_update", $insertdata[0]); + } + + $this->db->set($data); + $this->db->where("id", $old_id_no); + if ($this->db->update("package_insurance", $data)) { + return 1; + }else + return 0; + } + + public function delete_in_item($data,$old_id_no) { + $user = $this->ion_auth->user()->row(); + $user_id = $user->id; + $user_name = $user->first_name.''. $user->last_name.'['.$user_id.']'; + + $sql="select *,2 as action,'".$user_name."' as action_by from package_insurance where id=".$old_id_no; + $query = $this->db->query($sql); + $insertdata= $query->result(); + + if(count($insertdata)>0){ + $this->db->insert("package_insurance_update", $insertdata[0]); + $this->db->delete("package_insurance", "id=".$old_id_no); + } + + return 0; + } + + public function update($data,$old_id_no) { + $user = $this->ion_auth->user()->row(); + $user_id = $user->id; + $user_name = $user->first_name.''. $user->last_name.'['.$user_id.']'; + + $sql="select *,1 as action,'".$user_name."' as action_by from package where id=".$old_id_no; + $query = $this->db->query($sql); + $insertdata= $query->result(); + + if(count($insertdata)>0){ + $this->db->insert("package_update", $insertdata[0]); + } + + $this->db->set($data); + $this->db->where("id", $old_id_no); + if ($this->db->update("package", $data)) { + return 1; + }else + return 0; + } +} +?> \ No newline at end of file diff --git a/old_code_ci3/models/PathLab_M.php b/old_code_ci3/models/PathLab_M.php new file mode 100644 index 0000000..680c5e7 --- /dev/null +++ b/old_code_ci3/models/PathLab_M.php @@ -0,0 +1,144 @@ +db->set($data); + $this->db->where("mstRepoKey", $old_id_no); + $this->db->update("lab_repo", $data); + } + + public function insert_report($data) + { + $this->db->insert("lab_repo", $data); + $insert_id = $this->db->insert_id(); + return $insert_id ; + } + + public function update_ultrasound_report($data,$old_id_no) { + $this->db->set($data); + $this->db->where("id", $old_id_no); + $this->db->update("radiology_ultrasound_template", $data); + } + + public function insert_ultrasound_report($data) + { + $this->db->insert("radiology_ultrasound_template", $data); + $insert_id = $this->db->insert_id(); + return $insert_id ; + } + + public function update_item_parameter($data,$old_id_no) { + $this->db->set($data); + $this->db->where("mstTestKey", $old_id_no); + $this->db->update("lab_tests", $data); + } + + public function insert_item_parameter($data) + { + $this->db->insert("lab_tests", $data); + $insert_id = $this->db->insert_id(); + return $insert_id ; + } + + public function update_item_parameter_option($data,$old_id_no) { + $this->db->set($data); + $this->db->where("id", $old_id_no); + $this->db->update("lab_tests_option", $data); + } + + public function insert_item_parameter_option($data) + { + $this->db->insert("lab_tests_option", $data); + $insert_id = $this->db->insert_id(); + return $insert_id ; + } + + public function insert_item_sortorder($data) { + $this->db->insert("lab_repotests", $data); + $insert_id = $this->db->insert_id(); + return $insert_id ; + } + + public function update_item_sortorder($data,$old_id_no) { + $this->db->set($data); + $this->db->where("id", $old_id_no); + $this->db->update("lab_repotests", $data); + } + + public function insert_test_request($data) { + $this->db->insert("lab_request", $data); + $insert_id = $this->db->insert_id(); + return $insert_id ; + } + + public function update_test_request($data,$old_id_no) { + $this->db->set($data); + $this->db->where("id", $old_id_no); + $this->db->update("lab_request", $data); + } + + public function insert_test_entry($data) { + $this->db->insert("lab_request_item", $data); + $insert_id = $this->db->insert_id(); + return $insert_id ; + } + + public function update_test_entry($data,$old_id_no) { + $this->db->set($data); + $this->db->where("id", $old_id_no); + $this->db->update("lab_request_item", $data); + } + + public function delete_request_entry($delete_id_no) { + $this->db->where('id', $delete_id_no); + + $q = $this->db->get('lab_request'); + // if id is unique, we want to return just one row + $data = $q->row_array(); + + $user = $this->ion_auth->user()->row(); + $user_id = $user->id; + $user_name = $user->first_name.''. $user->last_name . '['.date("d-m-Y h:i").']'; + + $data['remove_update_by']=$user_name; + + if ($this->db->insert("lab_request_delete", $data)) { + $this->db->where("id", $delete_id_no); + $this->db->delete("lab_request"); + return 1; + }else{ + return 0; + } + } + + public function insert_invoice_report($data) { + $this->db->insert("lab_invoice_request", $data); + $insert_id = $this->db->insert_id(); + return $insert_id ; + } + + public function update_invoice_report($data,$old_id_no) { + $this->db->set($data); + $this->db->where("id", $old_id_no); + $this->db->update("lab_invoice_request", $data); + } + + public function insert_lab_log($data) { + $this->db->insert("lab_log", $data); + $insert_id = $this->db->insert_id(); + return $insert_id ; + } + + public function update_lab_log($data,$old_id_no) { + $this->db->set($data); + $this->db->where("id", $old_id_no); + $this->db->update("lab_log", $data); + } +} +?> diff --git a/old_code_ci3/models/Patient_M.php b/old_code_ci3/models/Patient_M.php new file mode 100644 index 0000000..0adfe7e --- /dev/null +++ b/old_code_ci3/models/Patient_M.php @@ -0,0 +1,136 @@ +db->insert("patient_master", $data)) { + $insert_id = $this->db->insert_id(); + $pid=1000000+$insert_id; + + $pid='P'.date('ym').$pid; + $data = array( + 'p_code' => $pid + ); + + $this->db->set($data); + $this->db->where("id", $insert_id); + $this->db->update("patient_master", $data); + + return $insert_id; + }else + return 0; + } + + public function update($data,$old_id_no) { + $user = $this->ion_auth->user()->row(); + $user_id = $user->id; + $user_name = $user->first_name.''. $user->last_name; + + $sql="select * from patient_master where id=".$old_id_no; + $query = $this->db->query($sql); + $data1=$query->result_array(); + + if(count($data1)>0) + { + $update_emp_name=$user_id.'['.$user_name.']'.date('Y-m-d H:i:s'); + $Old_Update_data=($data1[0]['log']==''?' ':$data1[0]['log']).PHP_EOL; + + $change_data=compare_arrays($data1[0],$data); + if(strlen($change_data)>0) + { + $data['log']=$Old_Update_data.$change_data.'Update By :'.$update_emp_name; + $data['last_update']=date('Y-m-d H:i:s'); + } + + } + + $this->db->set($data); + $this->db->where("id", $old_id_no); + $this->db->update("patient_master", $data); + } + + public function update_online($data,$old_id_no) { + + $user_id = 0; + $user_name = "online OPD"; + + $sql="select * from patient_master where id=".$old_id_no; + $query = $this->db->query($sql); + $data1=$query->result_array(); + + if(count($data1)>0) + { + $update_emp_name=$user_id.'['.$user_name.']'.date('Y-m-d H:i:s'); + $Old_Update_data=($data1[0]['log']==''?' ':$data1[0]['log']).PHP_EOL; + + $change_data=compare_arrays($data1[0],$data); + if(strlen($change_data)>0) + { + $data['log']=$Old_Update_data.$change_data.'Update By :'.$update_emp_name; + $data['last_update']=date('Y-m-d H:i:s'); + } + + } + + $this->db->set($data); + $this->db->where("id", $old_id_no); + $this->db->update("patient_master", $data); + } + + public function insert_card($data) { + + if ($this->db->insert("hc_insurance_card", $data)) { + $insert_id = $this->db->insert_id(); + return $insert_id; + }else + return 0; + } + + public function insert_log_patient_multiple($data) { + + if ($this->db->insert("log_patient_multiple", $data)) { + $insert_id = $this->db->insert_id(); + return $insert_id; + }else + return 0; + } + + public function update_card($data,$old_id_no) { + $this->db->set($data); + $this->db->where("id", $old_id_no); + $this->db->update("hc_insurance_card", $data); + } + + function get_city($q){ + $this->db->select('*'); + $this->db->like('city', $q); + $query = $this->db->get('city_auto_u'); + if($query->num_rows() > 0){ + foreach ($query->result_array() as $row){ + $new_row['label']=htmlentities(stripslashes($row['city'])).' | '.htmlentities(stripslashes($row['district'])).' | '.htmlentities(stripslashes($row['state'])); + $new_row['value']=htmlentities(stripslashes($row['city'])); + $new_row['l_city']=htmlentities(stripslashes($row['city'])); + $new_row['l_district']=htmlentities(stripslashes($row['district'])); + $new_row['l_state']=htmlentities(stripslashes($row['state'])); + $row_set[] = $new_row; //build an array + } + echo json_encode($row_set); //format the array into json data + } + } + + + public function insert_remark($data) { + + if ($this->db->insert("patient_remark", $data)) { + $insert_id = $this->db->insert_id(); + return $insert_id; + }else + return 0; + } + +} +?> \ No newline at end of file diff --git a/old_code_ci3/models/Patienttag_M.php b/old_code_ci3/models/Patienttag_M.php new file mode 100644 index 0000000..2401ea9 --- /dev/null +++ b/old_code_ci3/models/Patienttag_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/Payment_M.php b/old_code_ci3/models/Payment_M.php new file mode 100644 index 0000000..c842abc --- /dev/null +++ b/old_code_ci3/models/Payment_M.php @@ -0,0 +1,140 @@ +db->insert("payment_history", $data)) { + $insert_id = $this->db->insert_id(); + return $insert_id; + }else + return 0; + } + + public function update($data,$old_id_no) { + + $this->db->set($data); + $this->db->where("id", $old_id_no); + $this->db->update("payment_history", $data); + } + + public function insert_payment_history_log($data) { + + if ($this->db->insert("payment_history_log", $data)) { + $insert_id = $this->db->insert_id(); + + return $insert_id; + }else + return 0; + } + + public function insert_refundorder($data) { + + if ($this->db->insert("refund_order", $data)) { + $insert_id = $this->db->insert_id(); + + return $insert_id; + }else + return 0; + } + + + public function update_ipd_payment_to_admin($Payment_data,$ipd_master) { + + $ipd_no=$Payment_data['ipd_id']; + $group_id=$Payment_data['Med_Group_id']; + $amount=$Payment_data['amount']; + + $sql="Select * from inv_med_group where med_group_id=$group_id"; + $query = $this->db->query($sql); + $inv_med_group= $query->result(); + + $net_amount=0; + $payment_received=0; + if($Payment_data['cr_dr']==0){ + $last_payment=$amount; + }else{ + $last_payment=$amount*-1; + } + $pay_datetime=$Payment_data['payment_date']; + $pharmacy_name="'".M_store."'"; + $admin_phone_no="'".M_Admin_PhoneNo."'"; + $recevied_user=$Payment_data['update_by']; + + + if(count($inv_med_group)>0){ + $net_amount=$inv_med_group[0]->net_amount; + $payment_received=$inv_med_group[0]->payment_received; + } + + $web_msg='Payment Received from IPD No. :'.$ipd_no.'
'; + $web_msg.='Patient Name :'.$ipd_master[0]->P_name.'
'; + $web_msg.='Total Billed amt. :'.$net_amount.'
'; + $web_msg.='Total Paid amt. :'.$payment_received.'
'; + $web_msg.='Last Paid amt. :'.$last_payment.'
'; + $web_msg.='Pay Date Time :'.$pay_datetime.'
'; + $web_msg.='Recevied By :'.$recevied_user.'
'; + $web_msg.='Pharmacy Name :'.$pharmacy_name.'
'; + + $data = array( + 'to_number'=> $admin_phone_no, + 'message'=>$web_msg, + ); + + if ($this->db->insert("sms_outbox", $data)) { + $insert_id = $this->db->insert_id(); + + return $insert_id; + }else + return 0; + } + + public function update_refundorder($data,$rid) { + $this->db->set($data); + $this->db->where("id", $rid); + $this->db->update("refund_order", $data); + } + + public function insert_org_payment($data) { + + if ($this->db->insert("org_payment_request", $data)) { + $insert_id = $this->db->insert_id(); + + return $insert_id; + }else + return 0; + } + + public function update_org_payment($data,$rid) { + + $this->db->set($data); + $this->db->where("id", $rid); + $this->db->update("org_payment_request", $data); + } + + public function cancel_in_payment_history($old_id_no) { + $user = $this->ion_auth->user()->row(); + $user_id = $user->id; + $user_name = $user->first_name.''. $user->last_name.'['.$user_id.']'; + + $sql="select *,2 as action,'".$user_name."' as cancel_by,,'".$user_id."' as cancel_by_id + from payment_history where id=".$old_id_no; + $query = $this->db->query($sql); + $insertdata= $query->result(); + + if(count($insertdata)>0){ + $this->db->insert("payment_history_cancel", $insertdata[0]); + $this->db->delete("payment_history", "id=".$old_id_no); + } + + return 0; + } + + + +} +?> \ No newline at end of file diff --git a/old_code_ci3/models/Prescription_M.php b/old_code_ci3/models/Prescription_M.php new file mode 100644 index 0000000..c6471ce --- /dev/null +++ b/old_code_ci3/models/Prescription_M.php @@ -0,0 +1,240 @@ +db->insert("opd_prescription", $data)) { + $insert_id = $this->db->insert_id(); + return $insert_id; + }else + return 0; + } + + public function update_opd_prescription($data,$old_id_no) { + $this->db->set($data); + $this->db->where("id", $old_id_no); + $this->db->update("opd_prescription", $data); + } + + + + public function insert_p_investigation($data) { + if ($this->db->insert("opd_prescription_investigation", $data)) { + $insert_id = $this->db->insert_id(); + return $insert_id; + }else + return 0; + } + + public function remove_p_investigation($delid) { + $this->db->where("id", $delid); + $this->db->delete("opd_prescription_investigation"); + } + + + // Prescription Surgery + + public function insert_p_surgery($data) { + if ($this->db->insert("opd_prescription_procedures", $data)) { + $insert_id = $this->db->insert_id(); + return $insert_id; + }else + return 0; + } + + public function update_p_surgery($data,$old_id_no) { + $this->db->set($data); + $this->db->where("id", $old_id_no); + $this->db->update("opd_prescription_procedures", $data); + } + + public function remove_p_surgery($delid) { + $this->db->where("id", $delid); + $this->db->delete("opd_prescription_procedures"); + } + + // Prescription Complaint + + public function insert_p_complaint($data) { + if ($this->db->insert("opd_prescription_complaint", $data)) { + $insert_id = $this->db->insert_id(); + return $insert_id; + }else + return 0; + } + + public function update_p_complaint($data,$old_id_no) { + $this->db->set($data); + $this->db->where("id", $old_id_no); + $this->db->update("opd_prescription_complaint", $data); + } + + public function remove_p_complaint($delid) { + $this->db->where("id", $delid); + $this->db->delete("opd_prescription_complaint"); + } + + + // Prescription Diagnosis + + public function insert_p_diagnosis($data) { + if ($this->db->insert("opd_prescription_diagnosis", $data)) { + $insert_id = $this->db->insert_id(); + return $insert_id; + }else + return 0; + } + + public function update_p_diagnosis($data,$old_id_no) { + $this->db->set($data); + $this->db->where("id", $old_id_no); + $this->db->update("opd_prescription_diagnosis", $data); + } + + public function remove_p_diagnosis($delid) { + $this->db->where("id", $delid); + $this->db->delete("opd_prescription_diagnosis"); + } + + // Prescription Medical + + public function insert_p_medical($data) { + if ($this->db->insert("opd_prescrption_prescribed", $data)) { + $insert_id = $this->db->insert_id(); + return $insert_id; + }else + return 0; + } + + public function update_p_medical($data,$old_id_no) { + $this->db->set($data); + $this->db->where("id", $old_id_no); + $this->db->update("opd_prescrption_prescribed", $data); + } + + public function remove_p_medical($delid) { + $this->db->where("id", $delid); + $this->db->delete("opd_prescrption_prescribed"); + } + + //OPD Med Master + + public function insert_med_master($data) { + if ($this->db->insert("opd_med_master", $data)) { + $insert_id = $this->db->insert_id(); + return $insert_id; + }else + return 0; + } + + public function update_med_master($data,$old_id_no) { + $this->db->set($data); + $this->db->where("id", $old_id_no); + if ($this->db->update("opd_med_master", $data)) { + return 1; + }else + return 0; + } + + public function remove_med_master($delid) { + $this->db->where("id", $delid); + $this->db->delete("opd_med_master"); + } + + // opd advice + + public function insert_opd_patient_advice($data) { + if ($this->db->insert("opd_prescription_advice", $data)) { + $insert_id = $this->db->insert_id(); + return $insert_id; + }else + return 0; + } + + public function update_opd_patient_advice($data,$old_id_no) { + $this->db->set($data); + $this->db->where("id", $old_id_no); + $this->db->update("opd_prescription_advice", $data); + } + + public function remove_opd_patient_advice($delid) { + $this->db->where("id", $delid); + $this->db->delete("opd_prescription_advice"); + } + + public function insert_patient_glucose_chart($data) { + if ($this->db->insert("patient_glucose_chart", $data)) { + $insert_id = $this->db->insert_id(); + return $insert_id; + }else + return 0; + } + + public function update_patient_glucose_chart($data,$old_id_no) { + $this->db->set($data); + $this->db->where("id", $old_id_no); + $this->db->update("patient_glucose_chart", $data); + } + + public function remove_patient_glucose_chart($delid) { + $this->db->where("id", $delid); + $this->db->delete("patient_glucose_chart"); + } + + + public function insert_patient_investigation($data) { + if ($this->db->insert("patient_investigation", $data)) { + $insert_id = $this->db->insert_id(); + return $insert_id; + }else + return 0; + } + + public function update_patient_investigation($data,$old_id_no) { + $this->db->set($data); + $this->db->where("id", $old_id_no); + $this->db->update("patient_investigation", $data); + } + + public function remove_patient_investigation($delid) { + $this->db->where("id", $delid); + $this->db->delete("patient_investigation"); + } + + // Update + public function update_patient_morbidities($p_id,$morbidities,$remove=0) { + $sql="SELECT * FROM patient_morbidities WHERE p_id = $p_id and morbidities = $morbidities"; + $query = $this->db->query($sql); + $result = $query->result(); + + $count = count($result); + + $m_id=0; + + if($count>0){ + $m_id=$result[0]->id; + } + + $data=array( + 'p_id' => $p_id, + 'morbidities'=> $morbidities, + 'update_date'=> date('Y-m-d h:m:i'), + ); + + if($remove==0){ + if ($m_id==0) { + $m_id=$this->db->insert('patient_morbidities', $data); + } + }elseif($remove==1){ + $this->db->where("id", $m_id); + $this->db->delete("patient_morbidities"); + } + + return $m_id; + + } +} +?> \ No newline at end of file diff --git a/old_code_ci3/models/Product_master_M.php b/old_code_ci3/models/Product_master_M.php new file mode 100644 index 0000000..1895737 --- /dev/null +++ b/old_code_ci3/models/Product_master_M.php @@ -0,0 +1,205 @@ +db->insert("med_product_master", $data)) { + $insert_id = $this->db->insert_id(); + return $insert_id; + }else + return 0; + } + + + + public function update($data,$old_id_no) { + $user = $this->ion_auth->user()->row(); + $user_id = $user->id; + $user_name = $user->first_name.''. $user->last_name.'['.$user_id.']'; + + $sql="select *,'".$user_id."' as update_by_id,'".$user_name."' as update_by + from med_product_master where id=".$old_id_no; + $query = $this->db->query($sql); + $insertdata= $query->result(); + + if(count($insertdata)>0){ + $this->db->insert("med_product_master_update", $insertdata[0]); + } + + $this->db->set($data); + $this->db->where("id", $old_id_no); + if ($this->db->update("med_product_master", $data)) { + return 1; + }else + return 0; + } + + public function delete_master($old_id_no) { + $user = $this->ion_auth->user()->row(); + $user_id = $user->id; + $user_name = $user->first_name.''. $user->last_name.'['.$user_id.']'; + + $sql="select *,'".$user_id."' as update_by_id,'".$user_name."' as update_by + from med_product_master where id=".$old_id_no; + $query = $this->db->query($sql); + $insertdata= $query->result(); + + if(count($insertdata)>0){ + $this->db->insert("med_product_master_update", $insertdata[0]); + $this->db->where("id", $old_id_no); + if ($this->db->delete("med_product_master")) { + return 1; + }else + return 0; + }else{ + return 0; + } + + } + + + public function insert_update_product_cat_assign($data,$med_id) { + + $sql="select m.id,m.med_cat_desc,a.med_cat_id AS a_id,t.id AS t_id , if(a.id=t.id,0,if(a.id IS NULL AND t.id=m.id,1,if(a.med_cat_id=m.id AND t.id IS NULL,2,0))) AS ins_del_action,a.id AS rec_id + FROM (med_product_cat_master m Left join med_product_cat_assign a on m.id=a.med_cat_id and a.med_product_id=$med_id ) + LEFT JOIN med_product_cat_master t ON m.id=t.id and t.id in ($data)"; + $query = $this->db->query($sql); + $insertdata= $query->result(); + + + + foreach($insertdata as $row) + { + if ($row->ins_del_action==1) { + $data_ins['med_product_id']=$med_id; + $data_ins['med_cat_id']=$row->id; + + $this->db->insert("med_product_cat_assign", $data_ins); + }elseif($row->ins_del_action==2){ + $this->db->where("id", $row->rec_id); + $this->db->delete("med_product_cat_assign"); + } + } + + return 1; + } + + + public function insert_med_indent_request($data) { + if ($this->db->insert("med_indent_request", $data)) { + $insert_id = $this->db->insert_id(); + + $Ind_code=str_pad(substr($insert_id,-5,5),5,0,STR_PAD_LEFT); + + $Ind_code='R'.date('ymd').$Ind_code; + + $data = array( + 'indent_code' => $Ind_code, + ); + + $this->db->set($data); + $this->db->where("indent_id", $insert_id); + $this->db->update("med_indent_request", $data); + + return $insert_id; + }else + return 0; + } + + public function update_med_indent_request($data,$old_id_no) { + $this->db->set($data); + $this->db->where("indent_id", $old_id_no); + $this->db->update("med_indent_request", $data); + + } + + public function insert_med_indent_request_items($data) { + if ($this->db->insert("med_indent_request_items", $data)) { + $insert_id = $this->db->insert_id(); + return $insert_id; + }else + return 0; + } + + public function update_med_indent_request_items($data,$old_id_no) { + $this->db->set($data); + $this->db->where("id", $old_id_no); + $this->db->update("med_indent_request_items", $data); + } + + public function delete_med_indent_request_item($indent_id,$del_indent_item_id) { + + $this->db->where("id", $del_indent_item_id); + $this->db->delete("med_indent_request_items"); + + $this->db->where("indent_item_id", $del_indent_item_id); + $this->db->delete("med_indent_process_items"); + + return 1; + } + + //For Med_indent_process + public function insert_med_indent_process($data) { + if ($this->db->insert("med_indent_process", $data)) { + return 1; + }else + return 0; + } + + public function update_med_indent_process($data,$old_id_no) { + $this->db->set($data); + $this->db->where("indent_id", $old_id_no); + $this->db->update("med_indent_process", $data); + } + + // Med_indent_process Items + + public function insert_med_indent_process_items($data) { + if ($this->db->insert("med_indent_process_items", $data)) { + $insert_id = $this->db->insert_id(); + return $insert_id; + }else + return 0; + } + + public function update_med_indent_process_items($data,$old_id_no) { + $this->db->set($data); + $this->db->where("id", $old_id_no); + $this->db->update("med_indent_process_items", $data); + } + + public function delete_med_indent_process_item($indent_id,$del_indent_item_id) { + $this->db->where("id", $del_indent_item_id); + $this->db->delete("med_indent_process_items"); + return 1; + + } + + // Med_indent_accept Items Table : store_stock + + public function insert_store_stock_items($data) { + if ($this->db->insert("store_stock", $data)) { + $insert_id = $this->db->insert_id(); + return $insert_id; + }else + return 0; + } + + public function update_store_stock_items($data,$old_id_no) { + $this->db->set($data); + $this->db->where("id", $old_id_no); + $this->db->update("store_stock", $data); + } + + public function delete_store_stock_item($id) { + $this->db->where("id", $id); + $this->db->delete("store_stock"); + return 1; + + } +} +?> \ No newline at end of file diff --git a/old_code_ci3/models/Product_stock_master_M.php b/old_code_ci3/models/Product_stock_master_M.php new file mode 100644 index 0000000..656d9a6 --- /dev/null +++ b/old_code_ci3/models/Product_stock_master_M.php @@ -0,0 +1,175 @@ +db->insert("med_store_product_master", $data)) { + $insert_id = $this->db->insert_id(); + return $insert_id; + }else + return 0; + } + + public function update($data,$old_id_no) { + $user = $this->ion_auth->user()->row(); + $user_id = $user->id; + $user_name = $user->first_name.''. $user->last_name.'['.$user_id.']'; + + $sql="select *,'".$user_id."' as update_by_id,'".$user_name."' as update_by + from med_store_product_master where id=".$old_id_no; + $query = $this->db->query($sql); + $insertdata= $query->result(); + + if(count($insertdata)>0){ + $this->db->insert("med_store_product_master_update", $insertdata[0]); + } + + $this->db->set($data); + $this->db->where("id", $old_id_no); + if ($this->db->update("med_store_product_master", $data)) { + return 1; + }else + return 0; + } + + public function delete_master($old_id_no) { + $user = $this->ion_auth->user()->row(); + $user_id = $user->id; + $user_name = $user->first_name.''. $user->last_name.'['.$user_id.']'; + + $sql="select *,'".$user_id."' as update_by_id,'".$user_name."' as update_by + from med_store_product_master where id=".$old_id_no; + $query = $this->db->query($sql); + $insertdata= $query->result(); + + if(count($insertdata)>0){ + $this->db->insert("med_store_product_master_update", $insertdata[0]); + $this->db->where("id", $old_id_no); + if ($this->db->delete("med_store_product_master")) { + return 1; + }else + return 0; + }else{ + return 0; + } + + } + + public function insert_med_indent_request($data) { + if ($this->db->insert("med_indent_request", $data)) { + $insert_id = $this->db->insert_id(); + + $Ind_code=str_pad(substr($insert_id,-5,5),5,0,STR_PAD_LEFT); + + $Ind_code='R'.date('ymd').$Ind_code; + + $data = array( + 'indent_code' => $Ind_code, + ); + + $this->db->set($data); + $this->db->where("indent_id", $insert_id); + $this->db->update("med_indent_request", $data); + + return $insert_id; + }else + return 0; + } + + public function update_med_indent_request($data,$old_id_no) { + $this->db->set($data); + $this->db->where("indent_id", $old_id_no); + $this->db->update("med_indent_request", $data); + + } + + public function insert_med_indent_request_items($data) { + if ($this->db->insert("med_indent_request_items", $data)) { + $insert_id = $this->db->insert_id(); + return $insert_id; + }else + return 0; + } + + public function update_med_indent_request_items($data,$old_id_no) { + $this->db->set($data); + $this->db->where("id", $old_id_no); + $this->db->update("med_indent_request_items", $data); + } + + public function delete_med_indent_request_item($indent_id,$del_indent_item_id) { + + $this->db->where("id", $del_indent_item_id); + $this->db->delete("med_indent_request_items"); + + $this->db->where("indent_item_id", $del_indent_item_id); + $this->db->delete("med_indent_process_items"); + + return 1; + } + + //For Med_indent_process + public function insert_med_indent_process($data) { + if ($this->db->insert("med_indent_process", $data)) { + return 1; + }else + return 0; + } + + public function update_med_indent_process($data,$old_id_no) { + $this->db->set($data); + $this->db->where("indent_id", $old_id_no); + $this->db->update("med_indent_process", $data); + } + + // Med_indent_process Items + + public function insert_med_indent_process_items($data) { + if ($this->db->insert("med_indent_process_items", $data)) { + $insert_id = $this->db->insert_id(); + return $insert_id; + }else + return 0; + } + + public function update_med_indent_process_items($data,$old_id_no) { + $this->db->set($data); + $this->db->where("id", $old_id_no); + $this->db->update("med_indent_process_items", $data); + } + + public function delete_med_indent_process_item($indent_id,$del_indent_item_id) { + $this->db->where("id", $del_indent_item_id); + $this->db->delete("med_indent_process_items"); + return 1; + + } + + // Med_indent_accept Items Table : store_stock + + public function insert_store_stock_items($data) { + if ($this->db->insert("store_stock", $data)) { + $insert_id = $this->db->insert_id(); + return $insert_id; + }else + return 0; + } + + public function update_store_stock_items($data,$old_id_no) { + $this->db->set($data); + $this->db->where("id", $old_id_no); + $this->db->update("store_stock", $data); + } + + public function delete_store_stock_item($id) { + $this->db->where("id", $id); + $this->db->delete("store_stock"); + return 1; + + } +} +?> \ No newline at end of file diff --git a/old_code_ci3/models/Reffer_M.php b/old_code_ci3/models/Reffer_M.php new file mode 100644 index 0000000..2c699dd --- /dev/null +++ b/old_code_ci3/models/Reffer_M.php @@ -0,0 +1,27 @@ +db->insert("refer_master", $data)) { + $insert_id = $this->db->insert_id(); + + return $insert_id; + }else + return 0; + } + + public function update($data,$old_id_no) { + $this->db->set($data); + $this->db->where("id", $old_id_no); + if ($this->db->update("refer_master", $data)) { + return 1; + }else + return 0; + } +} \ No newline at end of file diff --git a/old_code_ci3/models/SMS_M.php b/old_code_ci3/models/SMS_M.php new file mode 100644 index 0000000..de7792c --- /dev/null +++ b/old_code_ci3/models/SMS_M.php @@ -0,0 +1,45 @@ +db->insert("sms_inbox", $data)) { + $insert_id = $this->db->insert_id(); + return $insert_id; + }else + return 0; + } + + public function update_sms_inbox($data,$old_id_no) { + $this->db->set($data); + $this->db->where("id", $old_id_no); + if ($this->db->update("sms_inbox", $data)) { + return 1; + }else + return 0; + } + + public function insert_sms_outbox($data) { + if ($this->db->insert("sms_outbox", $data)) { + $insert_id = $this->db->insert_id(); + return $insert_id; + }else + return 0; + } + + public function update_sms_outbox($data,$old_id_no) { + $this->db->set($data); + $this->db->where("id", $old_id_no); + if ($this->db->update("sms_outbox", $data)) { + return 1; + }else + return 0; + } +} +?> \ No newline at end of file diff --git a/old_code_ci3/models/Stock_M.php b/old_code_ci3/models/Stock_M.php new file mode 100644 index 0000000..9274e75 --- /dev/null +++ b/old_code_ci3/models/Stock_M.php @@ -0,0 +1,204 @@ +db->insert("invoice_stock_master", $data)) { + $insert_id = $this->db->insert_id(); + $pid = str_pad(substr($insert_id, -7, 7), 7, 0, STR_PAD_LEFT); + + $pid = 'S' . date('ym') . $pid; + + $data1 = array( + 'indent_code' => $pid + ); + + $this->db->set($data1); + $this->db->where("id", $insert_id); + $this->db->update("invoice_stock_master", $data1); + return $insert_id; + } else + return 0; + } + + + public function add_indentitem($data) + { + if ($this->db->insert("inv_stock_item", $data)) { + $insert_id = $this->db->insert_id(); + $store_stock_id = $data['store_stock_id']; + $this->db->query("CALL p_stock_update_purchase_id_store(" . $store_stock_id . ")"); + $this->db->query("CALL p_update_med_GST_store(" . $data['indent_id'] . ")"); + return $insert_id; + } else + return 0; + } + + public function update_indentitem($data, $old_id_no) + { + $this->db->set($data); + $this->db->where("id", $old_id_no); + + if ($this->db->update("inv_stock_item", $data)) { + $store_stock_id = $data['store_stock_id']; + $this->db->query("CALL p_stock_update_purchase_id_store(" . $store_stock_id . ")"); + $this->db->query("CALL p_update_med_GST_store(" . $data['indent_id'] . ")"); + return 1; + } else { + return 0; + } + } + + public function delete_indentitem($itemid, $inv_items) + { + $this->db->delete("inv_stock_item", "id=" . $itemid); + + $update_emp_name = $this->session->userdata('username') . '[' . $this->session->userdata('agent_id') . ']' . date('Y-m-d H:i:s'); + + $add_data = array( + 'delete_by' => $update_emp_name, + ); + + $data = array_merge($inv_items, $add_data); + + $store_stock_id = $data['store_stock_id']; + + //echo "Purchase Id :".$store_stock_id; + + $this->db->insert("inv_stock_item_delete", $data); + $this->db->query("CALL p_update_med_GST_store(" . $data['indent_id'] . ")"); + + $this->db->query("CALL p_stock_update_purchase_id_store(" . $store_stock_id . ")"); + } + + public function update_invoice_final($inv_id) + { + $this->db->query("CALL p_update_med_GST_store(" . $inv_id . ")"); + } + + + + //Purchase Table + public function insert_purchase($data) + { + + $this->db->db_debug = false; + + if ($this->db->insert("purchase_invoice_stock", $data)) { + $insert_id = $this->db->insert_id(); + return $insert_id; + } else + return 0; + } + + public function update_purchase($data, $old_id_no) + { + $this->db->set($data); + $this->db->where("id", $old_id_no); + if ($this->db->update("purchase_invoice_stock", $data)) { + //$this->db->query("CALL p_purchase_invoice(".$old_id_no.")"); + return 1; + } else { + return 0; + } + } + + public function delete_purchase($inv_id) + { + + $this->db->where("id", $inv_id); + $this->db->delete("purchase_invoice_stock"); + + return 1; + } + + //Purchase Item + + public function insert_purchase_item($data) + { + if ($this->db->insert("purchase_invoice_item_stock", $data)) { + $insert_id = $this->db->insert_id(); + $this->db->query("CALL f_update_purchase_invoice_stock(" . $insert_id . ")"); + return $insert_id; + } else + return 0; + } + + public function update_purchase_item($data, $old_id_no) + { + $this->db->set($data); + $this->db->where("id", $old_id_no); + if ($this->db->update("purchase_invoice_item_stock", $data)) { + $this->db->query("CALL f_update_purchase_invoice_stock(" . $old_id_no . ")"); + return 1; + } else { + return 0; + } + } + + public function delete_purchase_item($inv_id, $del_inv_item_id) + { + + $this->db->where("id", $del_inv_item_id); + if ($this->db->delete("purchase_invoice_item_stock")) { + + $this->db->query("CALL p_purchase_invoice_stock(" . $inv_id . ")"); + + return 1; + } else { + return 0; + } + } + + public function insert_drug_add($data) + { + if ($this->db->insert("drug_temp", $data)) { + $insert_id = $this->db->insert_id(); + return $insert_id; + } else + return 0; + } + + public function update_drug($data, $old_id_no) + { + + $this->db->set($data); + $this->db->where("item_id", $old_id_no); + + if ($this->db->update("drug_temp", $data)) { + return 1; + } else { + return 0; + } + } + + // Store Supplier + + public function insert_supplier($data) + { + + if ($this->db->insert("stock_supplier", $data)) { + $insert_id = $this->db->insert_id(); + return $insert_id; + } else + return 0; + } + + public function update_supplier($data, $old_id_no) + { + $this->db->set($data); + $this->db->where("sid", $old_id_no); + if ($this->db->update("stock_supplier", $data)) { + return $old_id_no; + } else { + return 0; + } + } +} diff --git a/old_code_ci3/models/Store_M.php b/old_code_ci3/models/Store_M.php new file mode 100644 index 0000000..ac688e0 --- /dev/null +++ b/old_code_ci3/models/Store_M.php @@ -0,0 +1,11 @@ + + + + 403 Forbidden + + + +

Directory access is forbidden.

+ + + diff --git a/old_code_ci3/views/AdminMain.php b/old_code_ci3/views/AdminMain.php new file mode 100644 index 0000000..e856e6b --- /dev/null +++ b/old_code_ci3/views/AdminMain.php @@ -0,0 +1,8 @@ + +
+
+
+
+ + + \ No newline at end of file diff --git a/old_code_ci3/views/ControlSide.php b/old_code_ci3/views/ControlSide.php new file mode 100644 index 0000000..1ec7264 --- /dev/null +++ b/old_code_ci3/views/ControlSide.php @@ -0,0 +1,193 @@ + + + + +
diff --git a/old_code_ci3/views/DocAdmin/doc_input_list.php b/old_code_ci3/views/DocAdmin/doc_input_list.php new file mode 100644 index 0000000..4c3435a --- /dev/null +++ b/old_code_ci3/views/DocAdmin/doc_input_list.php @@ -0,0 +1,103 @@ +'form','class'=>'form1')); ?> +
+
+

Input List

+
+
+ +
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + +
#Input NameInput CodeAction
input_name ?>input_code ?> +
+ + + item_id; + $sort_current=$doc_Item_List[$i]->short_order; + + if($i+1 < count($doc_Item_List)) + { + $option_next=$doc_Item_List[$i+1]->item_id; + $sort_next=$doc_Item_List[$i+1]->short_order; + + echo ''; + } + if($i>0) + { + $option_prev=$doc_Item_List[$i-1]->item_id; + $sort_prev=$doc_Item_List[$i-1]->short_order; + + echo ''; + + } + ?> +
+
#Input NameInput CodeAction
+
+ +
+ + \ No newline at end of file diff --git a/old_code_ci3/views/DocAdmin/doc_item_edit.php b/old_code_ci3/views/DocAdmin/doc_item_edit.php new file mode 100644 index 0000000..764724f --- /dev/null +++ b/old_code_ci3/views/DocAdmin/doc_item_edit.php @@ -0,0 +1,139 @@ +0) + { + $input_id=$input_parameter[0]->id; + $input_name=$input_parameter[0]->input_name; + $input_code=$input_parameter[0]->input_code; + $input_type=$input_parameter[0]->input_type; + $input_default_value=$input_parameter[0]->input_default_value; + } +?> +'form','class'=>'form1')); ?> +
+
+

Input Parameter

+
+ +
+
+
+
+ + + + +
+
+
+
+ + +
+
+
+
+
+
+ + +
+
+
+
+ + +
+
+
+
+
+
+ + +
+
+
+
+ + +
+
+
+
+ +
+
+
+
+
+
+ +
+ + diff --git a/old_code_ci3/views/DocAdmin/doc_letterhead_print.php b/old_code_ci3/views/DocAdmin/doc_letterhead_print.php new file mode 100644 index 0000000..a09044f --- /dev/null +++ b/old_code_ci3/views/DocAdmin/doc_letterhead_print.php @@ -0,0 +1,51 @@ + + + + + + + + + + +
+ + +

+

, Uttarakhand
+ +

+ +
+ +
+ + + + + + +
Page : {PAGENO}/{nbpg}
+
+ + \ No newline at end of file diff --git a/old_code_ci3/views/DocAdmin/doc_list.php b/old_code_ci3/views/DocAdmin/doc_list.php new file mode 100644 index 0000000..5be4200 --- /dev/null +++ b/old_code_ci3/views/DocAdmin/doc_list.php @@ -0,0 +1,59 @@ +
+

+ Document Template List +

+
+
+
+
+
+
+ +

Template List

+
+
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + +
TitleDescriptionAction
doc_name ?>doc_desc ?> + + +
Report TitleGroupAction
+ +
+ +
+
+
+ +
+
+ +
+ \ No newline at end of file diff --git a/old_code_ci3/views/DocAdmin/doc_master_edit.php b/old_code_ci3/views/DocAdmin/doc_master_edit.php new file mode 100644 index 0000000..7abd366 --- /dev/null +++ b/old_code_ci3/views/DocAdmin/doc_master_edit.php @@ -0,0 +1,157 @@ +'form','class'=>'form1')); ?> +
+
+

Report Edit

+
+ +
+
+ +
+
+
+
+ + 0) + { + $doc_name=$doc_master[0]->doc_name; + $df_id=$doc_master[0]->df_id; + $doc_desc=$doc_master[0]->doc_desc; + $HTMLData=$doc_master[0]->doc_raw_format; + } + ?> + + +
+
+
+
+ + +
+
+
+
+
+ + +
+
+
+
+
+ + +
+
+
+ +
+
+
+
+

Document Parameter

+
+ +
+
+ +
+
+
+ Pre-Define +
+
+
+
+ id)%50]->code_code_2.';">'.$doc_pre_input[$i]->input_name.'['.$doc_pre_input[$i]->input_code.']
'; + } + ?> +
+
+
+
+
+
+
+ Custom Define Input Parameter +
+
+
+
+ item_id)%50]->code_code_2.';">'.$doc_Item_List[$i]->input_name.'['.$doc_Item_List[$i]->input_code.']
'; + } + ?> +
+
+
+
+ +
+
+ + + + \ No newline at end of file diff --git a/old_code_ci3/views/Doctor_Profile/Doctor_Search_V.php b/old_code_ci3/views/Doctor_Profile/Doctor_Search_V.php new file mode 100644 index 0000000..813527b --- /dev/null +++ b/old_code_ci3/views/Doctor_Profile/Doctor_Search_V.php @@ -0,0 +1,59 @@ +
+

+ Doctor + List +

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

Result

+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + +
NamePhone NumberEMailAction
p_title ?> p_fname ?>mphone1 ?>email1 ?>
NamePhone NumberEMailAction
+
+ +
+
+
\ No newline at end of file diff --git a/old_code_ci3/views/Doctor_Profile/Doctor_V.php b/old_code_ci3/views/Doctor_Profile/Doctor_V.php new file mode 100644 index 0000000..bb23567 --- /dev/null +++ b/old_code_ci3/views/Doctor_Profile/Doctor_V.php @@ -0,0 +1,105 @@ +
+

+ Doctor + Add New +

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

+ Doctor + Dr. p_fname; ?> +

+ +
+ +
+
+
+
+ 'form','class'=>'form1')); ?> + +
+
+
+ + +
+
+
+
+ + +
+
+
+
+ + +
+
+
+
+
+
+ +
+ + +
+
+
+
+
+ + +
+
+
+
+ +
+
+ +
+ +
+
+
+
+
+
+
+ + +
+
+
+
+
+
+
+ +
+
+
+
+
+
+
+
+
+ +
+ '; + echo ' '; + echo ' '; + echo ' '; + echo '
'; + } + ?> +
+
+
+ + + + + +
+
+
+
+
+
+
+
+
+
+
+ ''); + $this->table->set_template($table_property); + $this->table->set_heading('Fee Type', 'Description', 'Amount'); + foreach($doc_fee_list as $row) + { + if($row->id=='') + { + $button_code=' Not Define'; + }else{ + $button_code='Remove'; + } + + $this->table->add_row($row->fee_type, $row->doc_fee_desc, $row->amount,$button_code); + } + echo $this->table->generate(); + + ?> + + + + +
+ + +
+ + + + + + + + + + + \ No newline at end of file diff --git a/old_code_ci3/views/Doctor_Search_V.php b/old_code_ci3/views/Doctor_Search_V.php new file mode 100644 index 0000000..fc59066 --- /dev/null +++ b/old_code_ci3/views/Doctor_Search_V.php @@ -0,0 +1,59 @@ +
+

+ Doctor + List +

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

Result

+
+ +
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
NamePhone NumberEMailAction
p_title ?> p_fname ?>mphone1 ?>email1 ?>
NamePhone NumberEMailAction
+
+ +
+
+
\ No newline at end of file diff --git a/old_code_ci3/views/Doctor_V.php b/old_code_ci3/views/Doctor_V.php new file mode 100644 index 0000000..d2e9ed5 --- /dev/null +++ b/old_code_ci3/views/Doctor_V.php @@ -0,0 +1,108 @@ +
+

+ Doctor + Add New +

+ +
+ +
+
+
+
+ 'myform','role'=>'form','class'=>'form1'); + echo form_open('Doctor/AddNew',$attributes); ?> +
+
+
+ + +
+
+
+
+ + +
+
+
+
+ + +
+
+
+
+
+
+
+ + +
+
+
+
+
+ + +
+
+
+
+ +
+
+ +
+ +
+
+
+
+
+ + +
+
+ + +
+ + + +
+
+ + +
+ + \ No newline at end of file diff --git a/old_code_ci3/views/Doctor_profile_V.php b/old_code_ci3/views/Doctor_profile_V.php new file mode 100644 index 0000000..2b5463b --- /dev/null +++ b/old_code_ci3/views/Doctor_profile_V.php @@ -0,0 +1,313 @@ +
+

+ Doctor + Dr. p_fname; ?> +

+ +
+ +
+
+
+
+ 'form','class'=>'form1')); ?> + +
+
+
+ + +
+
+
+
+ + +
+
+
+
+ + +
+
+
+
+
+
+ +
+ + +
+
+
+
+
+ + +
+
+
+
+ +
+
+ +
+ +
+
+
+
+
+
+
+ + +
+
+
+
+
+
+
+ +
+
+
+
+
+
+
+
+
+ +
+ '; + echo ' '; + echo ' '; + echo ' '; + echo '
'; + } + ?> +
+
+
+ + + + + +
+
+
+
+
+
+
+
+
+
+
+ ''); + $this->table->set_template($table_property); + $this->table->set_heading('Fee Type', 'Description', 'Amount'); + foreach($doc_fee_list as $row) + { + if($row->id=='') + { + $button_code=' Not Define'; + }else{ + $button_code='Remove'; + } + + $this->table->add_row($row->fee_type, $row->doc_fee_desc, $row->amount,$button_code); + } + echo $this->table->generate(); + + ?> + + + + +
+ + +
+ + + + + + + + + + + \ No newline at end of file diff --git a/old_code_ci3/views/DocumentPatient/Doc_update_pre_value.php b/old_code_ci3/views/DocumentPatient/Doc_update_pre_value.php new file mode 100644 index 0000000..f35ff54 --- /dev/null +++ b/old_code_ci3/views/DocumentPatient/Doc_update_pre_value.php @@ -0,0 +1,134 @@ +
+

+ Document Data + +

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

Patient Name :p_fname ?>

+ / +
+ +
+ 0) { + for ($i = 0; $i < count($doc_format_sub); ++$i) { ?> +
+
+ +
+
+ +
+ input_type ==1) + { + echo ' +
+
+ + +
+
"; + }elseif($doc_format_sub[$i]->input_type ==2){ + echo ' +
+
+ +
+
+ +
+ +
+
+
'; + }elseif($doc_format_sub[$i]->input_type ==3){ + echo ' +
+
+ + +
+
'; + }else{ + echo ' +
+
+ + +
+
'; + } + ?> +
+ +
+
+ +
+
+ + +
+
+
+ +
+ +
+ \ No newline at end of file diff --git a/old_code_ci3/views/DocumentPatient/Patient_Doc_Edit.php b/old_code_ci3/views/DocumentPatient/Patient_Doc_Edit.php new file mode 100644 index 0000000..9d3ccd9 --- /dev/null +++ b/old_code_ci3/views/DocumentPatient/Patient_Doc_Edit.php @@ -0,0 +1,104 @@ +
+

+ Document Data + +

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

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

+ + +
+
+
+
+
+
+ + +
+
+
+ +
+ +
+ +
+ + \ No newline at end of file diff --git a/old_code_ci3/views/DocumentPatient/Patient_Doc_master.php b/old_code_ci3/views/DocumentPatient/Patient_Doc_master.php new file mode 100644 index 0000000..7504c07 --- /dev/null +++ b/old_code_ci3/views/DocumentPatient/Patient_Doc_master.php @@ -0,0 +1,139 @@ +
+

+ Document Data + +

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

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

+ +
+
+
+
+
+
+ + +
+
+
+
+ + +
+
+
+
+ +
+
+ +
+ +
+
+
+
+
+ +
+
+
+
+
+
+
+ + + + + + + '; + echo ''; + echo ''; + echo ''; + if($row->update_pre_value==0) + { + echo ''; + + }else{ + echo ''; + } + + echo ''; + $srno=$srno+1; + } + ?> + +
#Issue DateDocument Name
'.$srno.''.$row->str_date_issue.''.$row->doc_name.' + +
+
+
+
+
+ +
+ + \ No newline at end of file diff --git a/old_code_ci3/views/Footer.php b/old_code_ci3/views/Footer.php new file mode 100644 index 0000000..88fa063 --- /dev/null +++ b/old_code_ci3/views/Footer.php @@ -0,0 +1,345 @@ + +
+ + Copyright © 2014- DevSoft Tech. All + rights + reserved. +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/old_code_ci3/views/Header.php b/old_code_ci3/views/Header.php new file mode 100644 index 0000000..1cc6509 --- /dev/null +++ b/old_code_ci3/views/Header.php @@ -0,0 +1,219 @@ + + + + + + + + <?=H_Name?> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+
+ + + + +
+ \ No newline at end of file diff --git a/old_code_ci3/views/IPD/Bed_panel.php b/old_code_ci3/views/IPD/Bed_panel.php new file mode 100644 index 0000000..0c8ed1c --- /dev/null +++ b/old_code_ci3/views/IPD/Bed_panel.php @@ -0,0 +1,127 @@ +
+
+

Room & Bed Assign List

+
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
RoomBEDUHID IDPatient NameTPA
room_name?>bed_no?>ipd_code?>
p_code?>
p_fname?>
p_relative?>
p_rname?>
admit_type?>
RoomBEDUHID/IPD IDPatient NameTPA
+ +
+ + + + + \ No newline at end of file diff --git a/old_code_ci3/views/IPD/IPDList_V.php b/old_code_ci3/views/IPD/IPDList_V.php new file mode 100644 index 0000000..b28e2ec --- /dev/null +++ b/old_code_ci3/views/IPD/IPDList_V.php @@ -0,0 +1,63 @@ +
+

+ IPD List + +

+ +
+
+
+
+

Result

+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
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 ?>
C:charge_amount ?>/M:med_amount ?>/P:paid_amount?>/B:balance?>
IPD CodeName/Patient CodeRegister DateAdmit TypeAmount
+ +
+ +
+
\ No newline at end of file diff --git a/old_code_ci3/views/IPD/IPD_Medical_Invoice_Panel.php b/old_code_ci3/views/IPD/IPD_Medical_Invoice_Panel.php new file mode 100644 index 0000000..f559124 --- /dev/null +++ b/old_code_ci3/views/IPD/IPD_Medical_Invoice_Panel.php @@ -0,0 +1,87 @@ +
+
+ +
+
+
+
+
+
+

IPD Credit [Include in Bill]

+ Print IPD Credit +
+
+ + + + + + + + + + + '; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + $check=''; + if ($row->ipd_credit_type>0) + { + $check='Checked'; + } + echo ''; + echo ''; + $srno=$srno+1; + echo ''; + } + echo ''; + ?> + + + + + + + + + + + + +
#Invoice ID.PatientInv.DateAmountInc.Invoice
'.$srno.''.$row->inv_med_code.''.$row->inv_name.''.$row->inv_date.''.$row->net_amount.'
#
+ +
+
+
+
+ +
+
+ + \ No newline at end of file diff --git a/old_code_ci3/views/IPD/IPD_View.php b/old_code_ci3/views/IPD/IPD_View.php new file mode 100644 index 0000000..ff7c7c2 --- /dev/null +++ b/old_code_ci3/views/IPD/IPD_View.php @@ -0,0 +1,271 @@ + +
+
+
+
+

General Information : IPD No. ipd_code?>

+
+ +
+ Name + +

+ p_fname?> +
+ Phone Number : mphone1?> +

+
+ + Relative Name + +

+ contact_person_Name?>
+ Phone Number : P_mobile1?> , P_mobile2?> +

+ +
+ Address + +

+ add1?>,
+ add2?>,
+ city?>,
+ state?>,
+

+ +
+ + Admit Date +

+ Admit Date : register_date) ?> Time : reg_time ?> +

+ ipd_status>0) { ?> +

+ Discharge Date : discharge_date) ?> discharge_time ?>
+

+ +
+ Associated Doctors +

+ p_fname.' '; + if ($this->ion_auth->in_group('IPDAdmit')) { + echo ' Remove'; + } + echo '
'; + $srno=$srno+1; + } + ?> +

+
+ Notes +

+ remark?> +

+
+ +
+
+
+
+
+

Update Information

+
+ +
+
+

Charges Bill :

+

Medical Bill :

+

Credit IPD :

+

Cash : /

+

Paid Amount :

+

Discount Amount :

+

Charge Amount :

+

Balance Amount :

+

+ Print Bill +

+
+
+
+
+
+

Medical IPD Credit

+
+
+ + + + + + + + + + + '; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + $check='Package'; + if ($row->ipd_credit_type>0) + { + $check='Cash'; + } + echo ''; + echo ''; + $srno=$srno+1; + echo ''; + } + echo ''; + ?> + + + + + + + + + + + + +
#Invoice ID.PatientInv.DateAmountInc.Invoice
'.$srno.''.$row->inv_med_code.''.$row->inv_name.''.$row->inv_date.''.$row->net_amount.''.$check.' Print +
#
+
+
+
+ ion_auth->in_group('IPDPayment')) { ?> +
+
+
+ +
+
+
+
+ +
+
+
+
+
+ + + + + + + + + '; + echo ''; + echo ''; + echo ''; + echo ''; + $srno=$srno+1; + echo ''; + } + echo ''; + ?> + + + + + + + + + +
#ID.Payment DateAmountMode
'.$srno.''.$row->id.''; + echo ''.$row->pay_date.''.$row->amount.''.$row->pay_mode.'
#
+ +
+
+ +
+ + +
+
+ + + + + + diff --git a/old_code_ci3/views/IPD/Ipd_Registration_V.php b/old_code_ci3/views/IPD/Ipd_Registration_V.php new file mode 100644 index 0000000..675a98e --- /dev/null +++ b/old_code_ci3/views/IPD/Ipd_Registration_V.php @@ -0,0 +1,244 @@ +
+

+ IPD + Registration +

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

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

+ + +
+
+ +
+
+
+
+
+ + +
+
+
+
+ + +
+
+
+
+
+
+ +
+
+ +
+ +
+
+
+
+
+ +
+
+ +
+ +
+
+
+
+ +
+
+
+ +
+
+ +
+ /> +
+
+
+
+
+
+ +
+ +
+ +
+
+ +
+
+
+
+
+
+
+
+ + +
+
+
+
+ 0) { ?> +
+
+
+
+ + +
+
+
+
+ '; + } ?> + +
+
+
+ +
+ '; + echo ' '; + echo $row->p_fname.' ['.$row->SpecName.']'; + echo '
'; + } + ?> +
+
+
+
+
+
+
+ + +
+
+ +
+
+
+
+
+ + +
+
+
+
+
+
+
+

Remarks + Write some about the problem +

+ +
+ + +
+ +
+ +
+ + + +
+
+
+
+ +
+
+
+ +
+
+
+
+ +
+ + \ No newline at end of file diff --git a/old_code_ci3/views/IPD/Ipd_invoice_V.php b/old_code_ci3/views/IPD/Ipd_invoice_V.php new file mode 100644 index 0000000..6800590 --- /dev/null +++ b/old_code_ci3/views/IPD/Ipd_invoice_V.php @@ -0,0 +1,206 @@ +
+

+ IPD Invoice + IPD ID: ipd_code?> +

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

+ Name :p_fname?> + / Age :age?> + / Gender :xgender?> + / P Code :p_code?> + case_id>0) { ?> + / Ins. Comp. :ins_company_name?> + +

+ + case_id>0) { ?> + + +
+
+
+ + + + + + + + + + Charge_type) + { + echo ''; + echo ''; + echo ''; + echo ''; + $headdesc=$showinvoice[$i]->Charge_type; + $headTotal=0.00; + } + + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + $srno=$srno+1; + $headTotal += $showinvoice[$i]->amount; + echo ''; + + if($headdesc!=@$showinvoice[$i+1]->Charge_type) + { + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + } + } + + if(count($inv_med_list)>0) + { + echo ''; + echo ''; + echo ''; + echo ''; + + $med_total=0.00; + + foreach($inv_med_list as $row) + { + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + $srno=$srno+1; + $med_total +=$row->net_amount; + echo ''; + } + + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + } + ?> + + + + + + + + + + + Discount>0) { ?> + + + + + + + + + + Discount2>0) { ?> + + + + + + + + + + Discount3>0) { ?> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
#DescriptionOrg.CodeUnitRateAmount
'.$showinvoice[$i]->Charge_type.'
'.$srno.''.$showinvoice[$i]->idesc.''.$showinvoice[$i]->orgcode.''.$showinvoice[$i]->no_qty.''.$showinvoice[$i]->item_rate.''.$showinvoice[$i]->amount.'
Sub Total'.number_format($headTotal,2).'
Medicine
'.$srno.''.$row->inv_med_code.''.$row->net_amount.'
Med. Total '.number_format($med_total,2).'
#Gross Total
#Remark :
Discount_Remark ?>
Deduction Discount ?>
#Remark :
Discount_Remark2 ?>
Deduction Discount2 ?>
#Remark :
Discount_Remark3 ?>
Deduction Discount3 ?>
#Net Amount
# + Payment Recd.
+ id.':'.$row->pay_mode.':'.$row->pay_date_str.':'.$row->amount.'] /'; + if($i%3==0) + { + echo '
'; + } + } + ?> +
t_ipd_pay?>
#Balance
+
+ +
+ + + +
+ diff --git a/old_code_ci3/views/IPD/Ipd_invoice_print_V.php b/old_code_ci3/views/IPD/Ipd_invoice_print_V.php new file mode 100644 index 0000000..26a29c8 --- /dev/null +++ b/old_code_ci3/views/IPD/Ipd_invoice_print_V.php @@ -0,0 +1,280 @@ + + + + + + <?=H_Name?> | Invoice + + + + + + + + + + + + + + + + + + + + +
+ +
+
+ +
+
+

+ +

+
,
+ Phone: / Email:
+ +
+
+
+ +
+
+

+ ipd_status>0) { ?> + Bill No. : id ?>
+ Provisional Bill
'; } ?> +

+
+ +
+ +
+
+ case_id>0) { ?> + Organisation Invoice #case_id_code?>
+ Organisation :ins_company_name?>
+ Insurance Company Name :Org_insurance_comp?>
+ Card No : insurance_no ?>
+ insurance_id==2) + { + echo ' Service No. :'.$orgcase[0]->insurance_no_2.'
'; + } + ?> + Claim ID/No : insurance_no_1 ?>
+ + +
+
+ IPD ID : 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 Name : doc_name ?>
+
+
+
+ Patient Name : p_fname ?>
+ p_relative ?> : p_rname ?>
+ Gender : xgender ?>
+ Age : age ?>
+ Phone No : mphone1 ?>
+ Patient ID : p_code ?>
+ Address :add1 ?> , add2 ?>
+ city ?> ,district ?> , state ?> - zip ?> +
+ +
+
+ + + +
+
+ + + + + + + + + + Charge_type) + { + echo ''; + echo ''; + echo ''; + echo ''; + $headdesc=$showinvoice[$i]->Charge_type; + $headTotal=0.00; + } + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + $srno=$srno+1; + $headTotal += $showinvoice[$i]->amount; + + echo ''; + + } + + if(count($inv_med_list)>0) + { + echo ''; + echo ''; + echo ''; + echo ''; + $med_total=0.00; + foreach($inv_med_list as $row) + { + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + $srno=$srno+1; + $med_total +=$row->net_amount; + echo ''; + } + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + } + ?> + + + + + + + + + chargeamount1>0) { ?> + + + + + + + + + chargeamount2>0) { ?> + + + + + + + + + Discount>0) { ?> + + + + + + + + + Discount2>0) { ?> + + + + + + + + + Discount3>0) { ?> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
#DescriptionOrg.CodeUnitRateAmount
'.$showinvoice[$i]->Charge_type.'
'.$srno.''.$showinvoice[$i]->idesc.''.$showinvoice[$i]->orgcode.''.$showinvoice[$i]->no_qty.''.$showinvoice[$i]->item_rate.''.$showinvoice[$i]->amount.'
Medicine
'.$srno.''.$row->inv_med_code.''.$row->net_amount.'
Med. Total '.number_format($med_total,2).'
#Gross Total
#Charge:
charge1 ?>
( + ) chargeamount1 ?>
#Charge:
charge2 ?>
( + ) chargeamount2 ?>
#Deduction:
Discount_Remark ?>
( - ) Discount ?>
#Deduction:
Discount_Remark2 ?>
( - ) Discount2 ?>
#Deduction:
Discount_Remark3 ?>
( - ) Discount3 ?>
#Net Amount
# + Payment Recd.
+ pay_id.':'.$row->pay_mode.':'.$row->pay_date_str.':'.$row->amount.'] /'; + if($i%3==0) + { + echo '
'; + } + } + ?> +
t_ipd_pay?>
#Balance



Patient / Relative Signature



Authorized Signatory
+
+
+
+
+ + + + diff --git a/old_code_ci3/views/IPD/Ipd_invoice_short_all.php b/old_code_ci3/views/IPD/Ipd_invoice_short_all.php new file mode 100644 index 0000000..cae2f39 --- /dev/null +++ b/old_code_ci3/views/IPD/Ipd_invoice_short_all.php @@ -0,0 +1,77 @@ +
+

+ IPD Invoice + IPD ID: ipd_code?> +

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

+ Name :p_fname?> + / Age :age?> + / Gender :xgender?> + / P Code :p_code?> + case_id>0) { ?> + / Ins. Comp. :ins_company_name?> + +

+ + case_id>0) { ?> + + +
+
+
+ + + + + + + + + + + + '; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + } + + ?> + + + + + + + + + + +
#DateCharges TypeDescriptionOrg. CodeSub Invoice CodeAmount
'.$srno.''.$row->str_date.''.$row->Charge_type.''.$row->Description.''.$row->orgcode.''.$row->Code.''.$row->Amount.'
#Gross TotalGTotal?>
+
+ +
+ + + +
+ diff --git a/old_code_ci3/views/IPD/Ipdpanel_V.php b/old_code_ci3/views/IPD/Ipdpanel_V.php new file mode 100644 index 0000000..424c2c7 --- /dev/null +++ b/old_code_ci3/views/IPD/Ipdpanel_V.php @@ -0,0 +1,233 @@ +
+

+ IPD + +

+ +
+ +
+
+
+

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

+

Admit Date :str_register_date?> + / Discharge Date :str_discharge_date?> +

+ + + +
+
+
+
+
+

Charges Bill

+

Rs.

+
+
+
+
+

Medical Bill

+

Credit IPD : Rs.

+

Cash : Rs. /

+
+
+
+
+

Paid Amount

+

Rs.

+ +
+
+
+
+

Discount Amount

+

Rs.

+

Charge Amount

+

Rs.

+
+
+
+
+

Balance Amount

+

Rs.

+
+
+
+
+
+
+ +
+
+
+
+ +
+
+
+
+
+ +
+ + + + + + + + \ No newline at end of file diff --git a/old_code_ci3/views/IPD/ipd_account_panel.php b/old_code_ci3/views/IPD/ipd_account_panel.php new file mode 100644 index 0000000..47746cc --- /dev/null +++ b/old_code_ci3/views/IPD/ipd_account_panel.php @@ -0,0 +1,48 @@ +
+
+

Charges Bill

+

Rs.

+
+
+
+
+

Medical Bill

+

Credit IPD : Rs.

+

Cash : Rs. /

+
+
+
+
+

Paid Amount

+

Rs.

+ +
+
+
+
+

Discount Amount

+

Rs.

+

Extra Charge Amount

+

Rs.

+
+
+
+
+

Balance Amount

+

Rs.

+
+
+
+
+
+
+ +
+
+
+
+ +
+
+
+
\ No newline at end of file diff --git a/old_code_ci3/views/IPD/ipd_all_list.php b/old_code_ci3/views/IPD/ipd_all_list.php new file mode 100644 index 0000000..ebe3389 --- /dev/null +++ b/old_code_ci3/views/IPD/ipd_all_list.php @@ -0,0 +1,173 @@ +
+

IPD List

+
+
+
+
+
+
+ + + +
+   + +
+
+
+
+ +
+ +
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
IPD CodePatient CodeNamePhone NumberDoctorStatusRegistrationDischarge
+
+ +
+
+ + \ No newline at end of file diff --git a/old_code_ci3/views/IPD/ipd_bed_assign.php b/old_code_ci3/views/IPD/ipd_bed_assign.php new file mode 100644 index 0000000..5fd554e --- /dev/null +++ b/old_code_ci3/views/IPD/ipd_bed_assign.php @@ -0,0 +1,103 @@ +
+
+ + + + + + + + + + + + + + + + + + + +
Bed No.DescriptionDateVacant Date
bed_no ?>room_name ?>Fdate ?>TDate ?>
+
+ +
+
+ + + \ No newline at end of file diff --git a/old_code_ci3/views/IPD/ipd_bed_status.php b/old_code_ci3/views/IPD/ipd_bed_status.php new file mode 100644 index 0000000..145f84a --- /dev/null +++ b/old_code_ci3/views/IPD/ipd_bed_status.php @@ -0,0 +1,58 @@ +
+

+ Bed Status + +

+ +
+
+
+
+

Result

+
+ +
+ + + + + + + + + + + + + + + + + + + + Total_Bed; + $total_free_bed=$total_free_bed+$roomdata[$i]->FreeBed; + } ?> + + + + + + + + + + + +
#DescNo. of BedFree BedRoom Rent
room_name ?>Total_Bed ?>FreeBed ?>room_rent ?>
#Total
+
+ +
+
\ No newline at end of file diff --git a/old_code_ci3/views/IPD/ipd_dashboard.php b/old_code_ci3/views/IPD/ipd_dashboard.php new file mode 100644 index 0000000..2e154e8 --- /dev/null +++ b/old_code_ci3/views/IPD/ipd_dashboard.php @@ -0,0 +1,38 @@ +
+

+ IPD + Inpatient Department +

+
+ +
+ +
+ +
+
+ \ No newline at end of file diff --git a/old_code_ci3/views/IPD/ipd_discharge.php b/old_code_ci3/views/IPD/ipd_discharge.php new file mode 100644 index 0000000..217dd3e --- /dev/null +++ b/old_code_ci3/views/IPD/ipd_discharge.php @@ -0,0 +1,306 @@ +
+
+

Discharge Process

+
+
+ +
+
+
+ + +
+
+
+
+ + +
+
+
+
+ + +
+
+
+
+
+
+ + +
+
+
+
+ + +
+
+
+
+ + +
+
+
+
+
+
+ + +
+
+
+
+ + +
+
+
+
+ + +
+
+
+
+
+
+
+ + +
+
+
+
+ + +
+
+
+
+ + +
+
+
+ +
+
+
+ + +
+
+
+
+ + +
+
+
+
+ + +
+
+
+
+
+
+
+ +
+
+ +
+ /> +
+
+
+
+
+ +
+ +
+ +
+
+ +
+
+
+
+ + +
+
+
+ +
+
+
+ + +
+
+
+
+ + +
+
+
+
+ + + ion_auth->in_group('IPDDischarge')){ + if($ipd_info[0]->lock_medical==0) { ?> + + + Discharge Button Not Enable due to medical bill pending. Please contact Medical Store + +
+
+
+
+ \ No newline at end of file diff --git a/old_code_ci3/views/IPD/ipd_discharged_status.php b/old_code_ci3/views/IPD/ipd_discharged_status.php new file mode 100644 index 0000000..87ba3ec --- /dev/null +++ b/old_code_ci3/views/IPD/ipd_discharged_status.php @@ -0,0 +1,90 @@ +
+
+

Discharge Process

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

Remarks + +

+
+ +
+ discharge_remark ?> +
+
+
+
+
+
+
+ + +
+
+
+
+ + +
+
+ ion_auth->in_group('IPDReAdmit')) { ?> +
+
+ + + + +
+
+
+ +
+ \ No newline at end of file diff --git a/old_code_ci3/views/IPD/ipd_invoice_error_v.php b/old_code_ci3/views/IPD/ipd_invoice_error_v.php new file mode 100644 index 0000000..59fb4c7 --- /dev/null +++ b/old_code_ci3/views/IPD/ipd_invoice_error_v.php @@ -0,0 +1,3 @@ +

+Discount Should not be greater then 10%

+

Please Contact Admin Department

\ No newline at end of file diff --git a/old_code_ci3/views/IPD/ipd_invoice_items.php b/old_code_ci3/views/IPD/ipd_invoice_items.php new file mode 100644 index 0000000..a427b62 --- /dev/null +++ b/old_code_ci3/views/IPD/ipd_invoice_items.php @@ -0,0 +1,696 @@ +
+

+ IPD Charges + +

+
+
+'form','class'=>'form1')); ?> +
+
+
+ IPD Charges +
+
+
+ +
+ +
+ +
+ + \ No newline at end of file diff --git a/old_code_ci3/views/IPD/ipd_invoice_print_wo_payment.php b/old_code_ci3/views/IPD/ipd_invoice_print_wo_payment.php new file mode 100644 index 0000000..9c6b314 --- /dev/null +++ b/old_code_ci3/views/IPD/ipd_invoice_print_wo_payment.php @@ -0,0 +1,260 @@ + + + + + + <?=H_Name?> | Invoice + + + + + + + + + + + + + + + + + + + + + +
+ +
+
+ +
+
+

+ +

+
,
+ Phone: / Email: +
+
+
+ +
+
+

+ ipd_status>0) { ?> + Bill No. : id ?>
+ Provisional Bill
'; } ?> +

+
+ +
+ +
+
+ case_id>0) { ?> + Organisation Invoice #case_id_code?>
+ Organisation :ins_company_name?>
+ Insurance Company Name :Org_insurance_comp?>
+ Card No : insurance_no ?>
+ insurance_id==2) + { + echo ' Service No. :'.$orgcase[0]->insurance_no_2.'
'; + } + ?> + Claim ID/No : insurance_no_1 ?>
+ + +
+
+ IPD ID : 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 Name : doc_name ?>
+
+
+
+ Patient Name : p_fname ?>
+ p_relative ?> : p_rname ?>
+ Gender : xgender ?>
+ Age : age ?>
+ Phone No : mphone1 ?>
+ Patient ID : p_code ?>
+ Address :add1 ?> , add2 ?>
+ city ?> ,district ?> , state ?> - zip ?> +
+ +
+
+ + + +
+
+ + + + + + + + + + Charge_type) + { + echo ''; + echo ''; + echo ''; + echo ''; + $headdesc=$showinvoice[$i]->Charge_type; + $headTotal=0.00; + } + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + $srno=$srno+1; + $headTotal += $showinvoice[$i]->amount; + + echo ''; + + + + } + + if(count($inv_med_list)>0) + { + echo ''; + echo ''; + echo ''; + echo ''; + $med_total=0.00; + foreach($inv_med_list as $row) + { + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + $srno=$srno+1; + $med_total +=$row->net_amount; + echo ''; + } + + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + + + + } + ?> + + + + + + + + + chargeamount1>0) { ?> + + + + + + + + + chargeamount2>0) { ?> + + + + + + + + + Discount>0) { ?> + + + + + + + + + Discount2>0) { ?> + + + + + + + + + Discount3>0) { ?> + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
#DescriptionOrg.CodeUnitRateAmount
'.$showinvoice[$i]->Charge_type.'
'.$srno.''.$showinvoice[$i]->idesc.''.$showinvoice[$i]->orgcode.''.$showinvoice[$i]->no_qty.''.$showinvoice[$i]->item_rate.''.$showinvoice[$i]->amount.'
Medicine
'.$srno.''.$row->inv_med_code.''.$row->net_amount.'
Med. Total '.number_format($med_total,2).'
#Gross Total
#Charge:
charge1 ?>
( + ) chargeamount1 ?>
#Charge:
charge2 ?>
( + ) chargeamount2 ?>
#Deduction:
Discount_Remark ?>
( - ) Discount ?>
#Deduction:
Discount_Remark2 ?>
( - ) Discount2 ?>
#Deduction:
Discount_Remark3 ?>
( - ) Discount3 ?>
#Net Amount



Patient / Relative Signature



Authorized Signatory
+
+
+
+
+ + + + diff --git a/old_code_ci3/views/IPD/ipd_main_panel.php b/old_code_ci3/views/IPD/ipd_main_panel.php new file mode 100644 index 0000000..dd82811 --- /dev/null +++ b/old_code_ci3/views/IPD/ipd_main_panel.php @@ -0,0 +1,407 @@ +
+
+
+
+

General Information

+
+ +
+ Name + +

+ p_fname?> +
+ Phone Number : mphone1?> +

+
+ + Relative Name + +

+ contact_person_Name?>
+ Phone Number : P_mobile1?> , P_mobile2?> +

+ +
+ Address + +

+ add1?>,
+ add2?>,
+ city?>,
+ state?>,
+

+ +
+ + Admit Date +

+ +

+

+ ion_auth->in_group('IPDAdmit')) { ?> +

+
+
+ +
+
+ +
+ +
+
+
+
+
+
+ +
+ +
+ +
+
+ +
+
+
+
+
+ +
+
+
+ + + + + Admit Date : register_date) ?> Time : reg_time ?> + +

+
+ Associated Doctors +

+ p_fname.' '; + if ($this->ion_auth->in_group('IPDAdmit')) { + echo ' Remove'; + } + echo '
'; + $srno=$srno+1; + } + ?> +

+ + ion_auth->in_group('IPDAdmit')) { ?> +
+
+ +
+ +
+ +
+ Notes +

+ remark?> +

+
+ +
+
+
+
+
+

Update Information

+
+ +
+ + 0) { ?> +
+
+
+ + + + + +
+
+
+ case_id<1) { ?> + + +
+
+
+ +
+
+
+
+ +
+
+
+
+
+
+
+
+
+
+
+ + +
+
+
+
+ + +
+
+
+
+ +
+
+
+
+
+
+
+
+
+
+
+ +
+
+
+
+ +
+ + + + +
+
+
+
+
+
+
+
+
+
+
+
+ +
+ + + + +
+
+
+
+
+ +
+ + + + +
+
+
+
+ + + + +
+
+
+ +
+
+
+ +
+ +
+
+
+ \ No newline at end of file diff --git a/old_code_ci3/views/IPD/ipd_medical_invoice_short.php b/old_code_ci3/views/IPD/ipd_medical_invoice_short.php new file mode 100644 index 0000000..46d1d57 --- /dev/null +++ b/old_code_ci3/views/IPD/ipd_medical_invoice_short.php @@ -0,0 +1,43 @@ +
+
+

Invoice ID : inv_med_code ?>

+ Print + + +
+
+ + + + + + + + + '; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + $srno=$srno+1; + echo ''; + } + echo ''; + ?> + + + + + + + + +
#Item NameQty.PriceAmount
'.$srno.''.$row->item_Name.'['.$row->formulation.']'.$row->qty.''.$row->price.''.$row->tamount.'
#Totalnet_amount ?>
+ +
+
\ No newline at end of file diff --git a/old_code_ci3/views/IPD/ipd_model_payment_box.php b/old_code_ci3/views/IPD/ipd_model_payment_box.php new file mode 100644 index 0000000..20b5090 --- /dev/null +++ b/old_code_ci3/views/IPD/ipd_model_payment_box.php @@ -0,0 +1,307 @@ +
+
+
+
+

Name :p_fname?> {p_rname?>} + / Age :str_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/IPD/ipd_package.php b/old_code_ci3/views/IPD/ipd_package.php new file mode 100644 index 0000000..40e9619 --- /dev/null +++ b/old_code_ci3/views/IPD/ipd_package.php @@ -0,0 +1,194 @@ +
+

+ IPD Billing Panel + +

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

Amount :

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

+ + Cash +

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

Amount :

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

+ + Cash +

+
+
+
+
+
+ + +
+
+ +
+
+
+
+ +
+
+
+
+ + +
+
+ +
+
+ + +
+
+
+
+ + +
+
+
+
+ + +
+
+
+
+ +
+
+ +
+ +
+
+
+
+
+ + +
+
+ +
+
+
+ +
+
+ \ No newline at end of file diff --git a/old_code_ci3/views/IPD/ipd_payment.php b/old_code_ci3/views/IPD/ipd_payment.php new file mode 100644 index 0000000..0e2bdb6 --- /dev/null +++ b/old_code_ci3/views/IPD/ipd_payment.php @@ -0,0 +1,169 @@ +
+
+ +
+
+
+
+
+
+

Charges

+
+
+ + + + + + + + + + + '; + echo ''; + $check=''; + if ($row->ipd_include>0) + { + $check='Checked'; + } + echo ''; + + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + if ($this->ion_auth->in_group('admin')) { + echo ''; + }else{ + echo ''; + } + $srno=$srno+1; + echo ''; + } + echo ''; + ?> + + + + + + + + + +
#Invoice ID.Ref.Inv.DateCharge TypeAmount
'.$srno.''.$row->invoice_code.''.$row->refer_by_other.''.$row->str_date.''.$row->charge_list.''.$row->amount.' IPD Invoice Edit
# +
+
+
+
+
+
+
+
+
+

Payments Details

+
+
+ + + + + + + + + + '; + echo ''; + echo ''; + echo ''; + echo ''; + $srno=$srno+1; + echo ''; + } + echo ''; + ?> + + + + + + + + + +
#ID.Payment DateAmountMode
'.$srno.''.$row->id.''; + echo ''.$row->pay_date.''.$row->amount.''.$row->pay_mode.'
#
+
+
+
+
+
+
+

Medicine

+
+
+
+ + + + + + + + '; + echo ''; + echo ''; + echo ''; + echo ''; + $srno=$srno+1; + echo ''; + } + echo ''; + ?> + + + + + + + + +
#Invoice ID.Inv.DateAmount
'.$srno.''.$row->inv_med_code.''.$row->inv_date.''.$row->net_amount.'
#
+
+
+
+
+
+
+
+ \ No newline at end of file diff --git a/old_code_ci3/views/IPD/ipd_payment_receipt_print.php b/old_code_ci3/views/IPD/ipd_payment_receipt_print.php new file mode 100644 index 0000000..4d3abc7 --- /dev/null +++ b/old_code_ci3/views/IPD/ipd_payment_receipt_print.php @@ -0,0 +1,109 @@ + + + + + + <?=H_Name?> | Invoice + + + + + + + + + + + + + + + + + + + + +
+
+ +
+
+ +
+ +
+ +
+
+ + +
+
+
+ From +
+
+
+
+
+
+ +
+ To +
+ p_fname ?>
+ Patient Code : p_code ?>
+ Phone No : P_mobile1 ?>
+ Payment Receipt No #payment_id ?>
+ Date : pay_date ?>
+ IPD Code : ipd_code ?>
+
+
+ + +
+
+
+ + Payment Receipt No #payment_id ?>
+

+ Mode of Payment : payment_mode_desc ?> +

+

+ IPD Payment Amount : amount ?> (In Words : amount) ?> ) +

+

+ Remark : +

+ remark ?> +
+
+
+ Prepared By : prepared_by ?> +
+
+ +
+
+ Signature +
+
+
+
+
+ This is computer generated invoice , Signature and stamp not required +
+
+ + +
+ +
+ + diff --git a/old_code_ci3/views/IPD/ipd_room.php b/old_code_ci3/views/IPD/ipd_room.php new file mode 100644 index 0000000..1202503 --- /dev/null +++ b/old_code_ci3/views/IPD/ipd_room.php @@ -0,0 +1,5 @@ +
+
+

Room

+
+
\ No newline at end of file diff --git a/old_code_ci3/views/IPD/print_ipd_form1.php b/old_code_ci3/views/IPD/print_ipd_form1.php new file mode 100644 index 0000000..d3e7ac0 --- /dev/null +++ b/old_code_ci3/views/IPD/print_ipd_form1.php @@ -0,0 +1,138 @@ + + + + + + + + +
+

+

,

+ +

+

+ Patient Info :
+ Patient Name : p_fname?>
+ p_relative?> p_rname?>
+ Age : age ?>
+ Gender : xgender ?>
+

+
+

Face Sheet

+
+ + + '; + $Insurance=''; + if(count($case_master)>0){ + $Insurance= '
Insurance : '.$case_master[0]->insurance_company_name; + } + + echo ''; + + echo ''; + + $srno=1; + $ipd_doc_list_show='';; + foreach($ipd_doc_list as $row) + { + $ipd_doc_list_show.= ' Dr. '.$row->p_fname.' / '; + $srno=$srno+1; + } + + + echo ''; + + echo ''; + ?> +
Patient Information :
+ Patient Name :'.$person_info[0]->p_fname.'
+ '.$person_info[0]->p_relative.''.$person_info[0]->p_rname.'
+ Age : '.$person_info[0]->age .'
+ Gender : '.$person_info[0]->xgender.'
+ UHID/Patient Code : '.$person_info[0]->p_code.'
+ IPD Code : '.$ipd_info[0]->ipd_code.'
+ Phone No : '.$person_info[0]->mphone1.$Insurance.' +
+ Contact Person Name : '.$ipd_info[0]->contact_person_Name.'
+ Relation : '.$ipd_info[0]->relation.'
+ Relative Phone No : '.$ipd_info[0]->P_mobile1.'
+ Patient Address
+ '.$person_info[0]->add1.'
, + '.$person_info[0]->add2.'
, + '.$person_info[0]->city.'
, + '.$person_info[0]->state.' +
+ Date of Admission : '.$ipd_info[0]->str_register_date.'
+ Admission Time : '.$ipd_info[0]->reg_time.'
+ Date of Discharge : '.$ipd_info[0]->discharge_date.'
+ Time of Discharge : '.$ipd_info[0]->discharge_time.'
+ Case Type : '.$ipd_info[0]->case_type_s.'
+ Doctors : : '.$ipd_doc_list_show.' +
+

सहमति पत्र

+

+ मैं ईलाज कराने का/की इक्छुक हूँ | मैं () के चिकित्सक और उनके सहायको को अपना उपचार , परीक्षण, परामर्श, जाँच, औषधि देने , चिकित्सा दवा लगवाने की स्वीकृति देता हूँ | + मुझे मेरी /मेरे मरीज की बीमारी के बारे मे उसके खतरों से जटिलताओं (complications ) से अवगत करा दिया गया है | मुझे ईलाज मे होने वाले खर्च की जानकारी दे दी गई है | मैंने अपनी सभी शंकाओं का निवारण कर लिया है । इस स्वीक्रति पत्र को मैंने ठीक प्रकार से पड़कर स्वयं समझकर हस्ताक्षर के द्वारा अपनी सहमति प्रदान करता / करती हूँ । +

+

+

+

+

+

+

+ + + + + + + + +
+
Prepared By : first_name.' '.$user->last_name.'['.$user->id.']' ?> +
+ + हस्ताक्षर / अंगूठा निशान +
+
+
+ नाम : _______________________________________________ +
+
+
+ मरीज / मरीज से संबंध : _____________________________ +
+
+
+ पता : _______________________________________________ +
+
+
+
+ फ़ोन नंबर : _________________________________________ +
+ \ No newline at end of file diff --git a/old_code_ci3/views/IPD/print_payment_receipt_ipd.php b/old_code_ci3/views/IPD/print_payment_receipt_ipd.php new file mode 100644 index 0000000..ed31ce6 --- /dev/null +++ b/old_code_ci3/views/IPD/print_payment_receipt_ipd.php @@ -0,0 +1,73 @@ +
+ +
+
+ +
+ +
+ +
+
+ + +
+ + +
+
+ From +
+
+
+
+ +
+
+ +
+ To +
+ p_fname ?>
+ Phone No : P_mobile1 ?>
+ Payment Reciept No #payment_id ?>
+ Date : pay_date ?>
+ IPD Code : ipd_code ?>
+
+
+ + +
+
+ IPD Credit Amount : amount ?> +
+ Remark : +
+ remark ?> +
+
+ + Mode of Payment : payment_mode_desc ?> +
+
+
+ Prepared By : prepared_by ?> +
+
+ Print +
+
+ Signature +
+
+
+
+ This is computer generated invoice , Signature and stamp not required +
+ + +
+ \ No newline at end of file diff --git a/old_code_ci3/views/IPD/test.php b/old_code_ci3/views/IPD/test.php new file mode 100644 index 0000000..a6c75a3 --- /dev/null +++ b/old_code_ci3/views/IPD/test.php @@ -0,0 +1,173 @@ +@extends('app') + +@section('content') +{!! header('Access-Control-Allow-Origin: *'); !!} +{!! header("content-type: Access-Control-Allow-Methods: GET");!!} +
+
+
+
+ Project - {!! $project_title !!} +
+
+
Enter Flat/Room Booking Details
+
+ {!! Form::open(array('route' => 'client.store', 'method' => 'post', 'files' => 'true')) !!} + {!! Form::hidden('user_id', Auth::user()->id) !!} + {!! Form::hidden('flat_id', $flat_id )!!} + {!! Form::hidden('booking_status', $booking_status )!!} +
Fields with * asteric sign are required
+
+
+ {!! $errors->first('cust_type',':message') !!} +
+ + {!! Form::radio('cust_type', 'new', Input::old('cust_type'), array('id'=>'cust_new' )) !!} +
+
+ + {!! Form::radio('cust_type', 'old', Input::old('cust_type'), array('id'=>'cust_old')) !!} +
+ +
+
+ +
+
+ + {!! Form::text('franchise', Auth::user()->name, array('id'=>'franchise','class' => 'form-control', 'readonly'=>'true', 'placeholder'=> Auth::user()->name ,'value'=>Auth::user()->name)) !!} +
+
+
+ + {!! Form::text('agent', Input::old('agent'), array('id'=>'agent','class' => 'form-control')) !!} + +
+ + +
+
+ + {!! Form::text('project_name', $project_title, array('id'=>'project_name','class' => 'form-control', 'placeholder' => $project_title, 'readonly'=>'true', )) !!} +
+
+
+
+ + {!! Form::text('area', Input::old('area'), array('id'=>'area','class' => 'form-control', 'placeholder' => 'Enter Area')) !!} + {!! $errors->first('area',':message') !!} +
+
+ +
+
+ + {!! Form::text('estimated_date', Input::old('estimated_date'), array('id'=>'estimated_date','class' => 'form-control', 'placeholder' => 'Select Date')) !!} + +
+
+ +
+
+
+ + {!! Form::text('cust_code', Input::old('cust_code'), array('id'=>'cust_code','class' => 'form-control', 'placeholder' => 'Enter Customer Code')) !!} + +
+
+
+ + {!! Form::text('cust_status', Input::old('cust_status'), array('id'=>'cust_status','class' => 'form-control', 'readonly')) !!} + +
+
+
+ +
+ + {!! Form::text('customers_name', Input::old('customers_name'), array('id'=>'customers_name','class' => 'form-control', 'placeholder' => 'Enter Customer Name')) !!} + {!! $errors->first('customers_name',':message') !!} +
+ + +
+ +
+
+ + {!! Form::text('phone', Input::old('phone'), array('id'=>'phone','class' => 'form-control', 'placeholder' => 'Enter Phone Number')) !!} + {!! $errors->first('phone',':message') !!} +
+
+
+
+ + {!! Form::text('email', Input::old('email'), array('id'=>'email','class' => 'form-control', 'placeholder' => 'Enter Email Address')) !!} + {!! $errors->first('email',':message') !!} +
+
+
+
+ + {!! Form::textarea('address', Input::old('address'),array('id'=>'address','class' => 'form-control','rows'=>'5','placeholder'=>'Address')) !!} + {!! $errors->first('address',':message') !!} + +
+
+ + +
+
+ + {!! Form::textarea('description', Input::old('description'),array('class' => 'form-control','rows'=>'5')) !!} + +
+
+
+
+ + {!! $errors->first('terms_conditions',':message') !!} +
+
+
+ + Cancel +
+ {!! Form::close() !!} +
+
+
+
+
+ + + +@endsection \ No newline at end of file diff --git a/old_code_ci3/views/IPD2/IPDList_V.php b/old_code_ci3/views/IPD2/IPDList_V.php new file mode 100644 index 0000000..7b3a0b4 --- /dev/null +++ b/old_code_ci3/views/IPD2/IPDList_V.php @@ -0,0 +1,63 @@ +
+

+ IPD List + +

+ +
+
+
+
+

Result

+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
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 ?>
insurance_no_1 ?>
C:charge_amount ?>/M:med_amount ?>/P:paid_amount?>/B:balance?>
IPD CodeName/Patient CodeRegister DateAdmit TypeAmount
+ +
+ +
+
\ No newline at end of file diff --git a/old_code_ci3/views/IPD2/IPD_Medical_Invoice_Panel.php b/old_code_ci3/views/IPD2/IPD_Medical_Invoice_Panel.php new file mode 100644 index 0000000..8ac6875 --- /dev/null +++ b/old_code_ci3/views/IPD2/IPD_Medical_Invoice_Panel.php @@ -0,0 +1,90 @@ +
+
+ +
+
+
+
+
+
+

IPD Credit [Include in Bill]

+ Print All IPD Credit Bill + Print Medicine List +
+
+ + + + + + + + + + + '; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + $check=''; + if ($row->ipd_credit_type>0) + { + $check='Checked'; + } + echo ''; + echo ''; + $srno=$srno+1; + echo ''; + } + echo ''; + ?> + + + + + + + + + + + + +
#Invoice ID.PatientInv.DateAmountInc.Invoice
'.$srno.''.$row->inv_med_code.''.$row->inv_name.''.$row->inv_date.''.$row->net_amount.'
#
+ +
+
+
+
+ +
+
+ + \ No newline at end of file diff --git a/old_code_ci3/views/IPD2/IPD_View.php b/old_code_ci3/views/IPD2/IPD_View.php new file mode 100644 index 0000000..b6461bd --- /dev/null +++ b/old_code_ci3/views/IPD2/IPD_View.php @@ -0,0 +1,197 @@ + +
+
+
+
+

General Information : IPD No. ipd_code?>

+
+ +
+ Name +

+ p_fname?> +
+ Phone Number : mphone1?> +

+ Relative Name + +

+ contact_person_Name?>
+ Phone Number : P_mobile1?> , P_mobile2?> +

+ Address + +

+ add1?>,
+ add2?>,
+ city?>,
+ state?>,
+

+ Admit Date +

+ Admit Date : register_date) ?> Time : reg_time ?> +

+ + ipd_status>0) { ?> +

+ Discharge Date : discharge_date) ?> discharge_time ?>
+

+ + Associated Doctors +

+ p_fname.' '; + if ($this->ion_auth->in_group('IPDAdmit')) { + echo ' Remove'; + } + echo '
'; + $srno=$srno+1; + } + ?> +

+ Notes + +
+ +
+
+
+
+
+
+

Update Information

+
+
+ Charges :charge_amount?>
+ Pharmacy Cr. IPD :med_amount?>
+ Net Amount :net_amount?>
+ Total Paid :total_paid_amount?>
+ Balance :balance_amount?>
+ Pharmacy Bill :cash_med_amount?>
+ Paid Amount :med_paid?> +

+ Print Bill +

+
+
+
+ + ion_auth->in_group('IPDPayment')) { ?> +
+
+
+ +
+
+
+
+ +
+
+
+
+
+ + + + + + + + + '; + echo ''; + echo ''; + echo ''; + echo ''; + $srno=$srno+1; + echo ''; + } + echo ''; + ?> + + + + + + + + +
#ID.Payment DateAmountMode
'.$srno.''.$row->id.''; + echo ''.$row->pay_date_str.''.$row->amount.''.$row->pay_mode.'
#
+
+
+ +
+
+ +
+ +
+ + + + \ No newline at end of file diff --git a/old_code_ci3/views/Medical/Medical_Invoice_Return_print.php b/old_code_ci3/views/Medical/Medical_Invoice_Return_print.php new file mode 100644 index 0000000..74fea91 --- /dev/null +++ b/old_code_ci3/views/Medical/Medical_Invoice_Return_print.php @@ -0,0 +1,142 @@ + + + + + + <?=M_store?> | 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/Medical_Invoice_V copy.php b/old_code_ci3/views/Medical/Medical_Invoice_V copy.php new file mode 100644 index 0000000..b7bfd32 --- /dev/null +++ b/old_code_ci3/views/Medical/Medical_Invoice_V copy.php @@ -0,0 +1,567 @@ +
+

+ 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_no_title="/IPD:".$invoiceMaster[0]->ipd_id; + ?> + + 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/Medical_Invoice_V.php b/old_code_ci3/views/Medical/Medical_Invoice_V.php new file mode 100644 index 0000000..f690f50 --- /dev/null +++ b/old_code_ci3/views/Medical/Medical_Invoice_V.php @@ -0,0 +1,627 @@ +
+

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

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

Name : + inv_name?> + / P Code :patient_code?> + / Invoice No. :inv_med_code?> + / Date : inv_date)?> + ipd_id > 0) { + $ipd_no_title="/IPD:".$invoiceMaster[0]->ipd_id; + ?> + + 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: + +
+ + + +

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

+ + + + + + + + +

+
+
+
+
+
+ + +
+
+
+
+ + + +
+
+
+
+ + ipd_id > 0){ + $readonly="Readonly"; + }else{ + $readonly="Readonly"; + } + ?> + /> +
+
+
+
+ +
+
+
+ +
+
+ +
+
+
+ ipd_id == 0){ ?> +
+
+ +

Sale Medicine

+
+ + +
+ +
+ + +
+ +
+ + + +
+ + +
+ + +
+ + \ No newline at end of file diff --git a/old_code_ci3/views/Medical/Medical_invoice_list.php b/old_code_ci3/views/Medical/Medical_invoice_list.php new file mode 100644 index 0000000..67541b5 --- /dev/null +++ b/old_code_ci3/views/Medical/Medical_invoice_list.php @@ -0,0 +1,353 @@ +
+
+ '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 || $this->ion_auth->in_group('admin')) + { + echo ''; + if($row->group_invoice_id==0 && $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 ?> + + +
+
+
+
+
+ + ipd_status==0 or $ipd_master[0]->insurance_id<2){ + ?> + + + + + + + + 0) { ?> + + + + + +
+ + + + +
+ + + + discount_group_2>0) { + ?> + + + +
+ + + + +
+
+ + + + + + + + + + + +
+ Print Cash + + Print Cash With Return + + Print IPD Credit + + Print IPD Package + + Print Consolidated Medicine List + + Print Medicine List Datewise + + Print Page Wise + + Print Return List +
+
+
+
+
+ +
+
+ \ No newline at end of file diff --git a/old_code_ci3/views/Medical/Medical_invoice_print.php b/old_code_ci3/views/Medical/Medical_invoice_print.php new file mode 100644 index 0000000..3d089c9 --- /dev/null +++ b/old_code_ci3/views/Medical/Medical_invoice_print.php @@ -0,0 +1,174 @@ + + + + + + <?=M_store?> | 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/Medical_invoice_print_1.php b/old_code_ci3/views/Medical/Medical_invoice_print_1.php new file mode 100644 index 0000000..7724788 --- /dev/null +++ b/old_code_ci3/views/Medical/Medical_invoice_print_1.php @@ -0,0 +1,176 @@ + + + + + + <?=M_store?> | 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/Medical_invoice_print_2.php b/old_code_ci3/views/Medical/Medical_invoice_print_2.php new file mode 100644 index 0000000..034fc02 --- /dev/null +++ b/old_code_ci3/views/Medical/Medical_invoice_print_2.php @@ -0,0 +1,172 @@ + + + + + + <?=M_store?> | 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/Medical_invoice_print_all.php b/old_code_ci3/views/Medical/Medical_invoice_print_all.php new file mode 100644 index 0000000..46a1b60 --- /dev/null +++ b/old_code_ci3/views/Medical/Medical_invoice_print_all.php @@ -0,0 +1,191 @@ + + + + + + <?=M_store?> | 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/Medical_invoice_print_all_provisional.php b/old_code_ci3/views/Medical/Medical_invoice_print_all_provisional.php new file mode 100644 index 0000000..507dc10 --- /dev/null +++ b/old_code_ci3/views/Medical/Medical_invoice_print_all_provisional.php @@ -0,0 +1,173 @@ + + + + + + <?=M_store?> | 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/Medical_ipd_org_list.php b/old_code_ci3/views/Medical/Medical_ipd_org_list.php new file mode 100644 index 0000000..65d0f8a --- /dev/null +++ b/old_code_ci3/views/Medical/Medical_ipd_org_list.php @@ -0,0 +1,65 @@ +
+
+
+

IPD List

+ + 0) + { + echo 'High Balance '; + } + ?> + +
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
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/Medical_org_invoicelist.php b/old_code_ci3/views/Medical/Medical_org_invoicelist.php new file mode 100644 index 0000000..2832d44 --- /dev/null +++ b/old_code_ci3/views/Medical/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/Medical_org_list.php b/old_code_ci3/views/Medical/Medical_org_list.php new file mode 100644 index 0000000..22059a3 --- /dev/null +++ b/old_code_ci3/views/Medical/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/Medical_stock_drug.php b/old_code_ci3/views/Medical/Medical_stock_drug.php new file mode 100644 index 0000000..3c8afae --- /dev/null +++ b/old_code_ci3/views/Medical/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/Patient_Search_Result.php b/old_code_ci3/views/Medical/Patient_Search_Result.php new file mode 100644 index 0000000..e4617e2 --- /dev/null +++ b/old_code_ci3/views/Medical/Patient_Search_Result.php @@ -0,0 +1,48 @@ +

+
+
+

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/Print/Medical_return_medicine.php b/old_code_ci3/views/Medical/Print/Medical_return_medicine.php new file mode 100644 index 0000000..59f8404 --- /dev/null +++ b/old_code_ci3/views/Medical/Print/Medical_return_medicine.php @@ -0,0 +1,128 @@ + + + + + + + + +
+

+


+ +

+

+ p_fname ?>
+ Patient ID : p_code ?>
+ +

+
+

Return Medicine

+
+ + + + $row->str_ret_date) + { + if($date_str<>"") + { + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + } + + $dAmount=0; + + echo ' + '; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + } + + $srno=$srno+1; + + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + $tAmount=$tAmount+$row->amount; + $dAmount=$dAmount+$row->amount; + $date_str=$row->str_ret_date; + + if($total_rec==$srno) + { + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + } + } + + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + + ?> +
#Day Total : '.$date_str.''.number_format(round($dAmount),2).'#


Return Date : '.$row->str_ret_date.'
Sr.No.Invoice DateInv.Code.Item NameRateOld Qty.Return Qty.AmountUpdate By
'.$srno.''.$row->str_inv_date.''.$row->inv_med_code.''.$row->item_Name.''.$row->price.''.$row->qty.''.$row->r_qty.''.$row->amount.''.$row->update_remark.'
#Day Total'.number_format(round($dAmount),2).'#


#Grand Total'.number_format(round($tAmount),2).'#
+ diff --git a/old_code_ci3/views/Medical/Print/Medicine_List.php b/old_code_ci3/views/Medical/Print/Medicine_List.php new file mode 100644 index 0000000..89c52d0 --- /dev/null +++ b/old_code_ci3/views/Medical/Print/Medicine_List.php @@ -0,0 +1,84 @@ + + + + + + + + + + + +
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 % 2)==0 && $srno<>1){ + echo ''; + } + $srno=1; + echo ' + + '; + echo ''; + } + + if(($srno % 2)==1) + { + echo ''; + } + + echo ''; + + if(($srno % 2)==0){ + echo ''; + } + + $inv_date=$row->str_inv_date; + } + + + + ?> +
..

Dated : '.$row->str_inv_date.'

'.$srno.' : ' + . $row->formulation . ' ' . $row->item_Name . '
(' . $row->genericname . ') /Qty :' + .$row->tot_qty.'
+

+ +

diff --git a/old_code_ci3/views/Medical/Print/Medicine_consolidated_List.php b/old_code_ci3/views/Medical/Print/Medicine_consolidated_List.php new file mode 100644 index 0000000..7970ccf --- /dev/null +++ b/old_code_ci3/views/Medical/Print/Medicine_consolidated_List.php @@ -0,0 +1,101 @@ + + + + + + + + + + + +
Page : {PAGENO}/{nbpg}IPD-ID:ipd_code ?> / UHID:p_code ?> /Name : p_fname ?>
+
+ +

Consolidated Summary of Medicine, Disposal & Sundries Used

+
+ + + + + + + + + +
+ Patient Info. + + Treating Consultant / Authorized Team Doctor +
+ p_fname ?>
UHID ID : p_code ?>
IPD Code : ipd_code ?> +
+ +
+ +
+

Medicine Name

+ + + + + + + + + + '; + echo ''; + echo ''; + echo ''; + echo ''; + } + ?> + +
Sr.No.Medicine NameQty
' . $srno . '' . $row->formulation . ' ' . $row->item_Name . '
(' . $row->genericname . ')
', $row->i_qty_total, '
+
+

Disposal & Sundries

+ + + + + + + + + + + '; + echo ''; + echo ''; + echo ''; + echo ''; + } + ?> + +
Sr.No.Disposal & SundriesQty
' . $srno . '' . $row->formulation . ' ' . $row->item_Name . '', $row->i_qty_total, '
+ + diff --git a/old_code_ci3/views/Medical/Print/medical_bill_print_a5.php b/old_code_ci3/views/Medical/Print/medical_bill_print_a5.php new file mode 100644 index 0000000..c0fcbef --- /dev/null +++ b/old_code_ci3/views/Medical/Print/medical_bill_print_a5.php @@ -0,0 +1,220 @@ + + + + + + + + + + + +
+

+


+ +

+

+ Invoice To : + inv_name ?>
+ customer_type == 0) { ?> + Phone No. : inv_phone_number ?>
+ doc_name != '') { ?> + Refer By : 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 ?>
+ +

+
+
+
+ +
+ + + + + +
Page : {PAGENO}/{nbpg}Invoice No.:inv_med_code ?> / Name : inv_name ?>
+
+ + + + + + + + +
+ GST: ' . H_Med_GST . ''; + } + + if (M_LIC != '') { + echo '
L.No: ' . M_LIC; + } + ?> +
+ Invoice ID : inv_med_code ?>
+ Date : str_inv_date ?> +
+ + Bill of Supply + + Invoice +
+ (composition taxable person, not eligible to collect tax on supplies) +
+ + '; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + } + + $srno = $srno + 1; + $head_start = $head_start + 1; + + if($row->sale_return==1){ + echo ''; + echo ''; + echo ''; + } + + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + } + + for($i=0;$i<$no_of_rec;$i++) + { + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + } + + if (count($invoice_med_master) > 0) { + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + } + ?> +
#Item NamePackBatch NoExp.Qty.RateGross Amt
Sale Return
' . $srno . '' . $row->item_Name . '' . $row->formulation . '' . $row->batch_no . '' . $row->expiry . '' . $row->qty . '' . $row->price . '' . number_format(round($row->amount),2) . '
.
#Total'.$invoice_med_master[0]->gross_amount.'
+ + 0) { ?> + + + + + + + payment_balance >= 0) { ?> + + + + + + + + + + payment_balance >= 0) { ?> + + + + +
#GrossDiscountNet AmountAmount receivedBalance Amount
#gross_amount),2) ?>discount_amount + $invoice_med_master[0]->item_discount_amount),2) ?>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 +
\ No newline at end of file diff --git a/old_code_ci3/views/Medical/Print/medical_bill_print_a5_discount.php b/old_code_ci3/views/Medical/Print/medical_bill_print_a5_discount.php new file mode 100644 index 0000000..c966395 --- /dev/null +++ b/old_code_ci3/views/Medical/Print/medical_bill_print_a5_discount.php @@ -0,0 +1,228 @@ + + + + + + + + + + + +
+

+


+ +

+

+ Invoice To : + inv_name ?>
+ customer_type == 0) { ?> + Phone No. : inv_phone_number ?>
+ doc_name != '') { ?> + Refer By : 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 ?>
+ +

+
+
+
+ +
+ + + + + +
Page : {PAGENO}/{nbpg}Invoice No.:inv_med_code ?> / Name : inv_name ?>
+
+ + + + + + + + +
+ GST: ' . H_Med_GST . ''; + } + + if (M_LIC != '') { + echo '
L.No: ' . M_LIC; + } + ?> +
+ Invoice ID : inv_med_code ?>
+ Date : str_inv_date ?> +
+ + Bill of Supply + + Invoice +
+ (composition taxable person, not eligible to collect tax on supplies) +
+ + '; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + } + + $srno = $srno + 1; + $head_start = $head_start + 1; + + if($row->sale_return==1){ + echo ''; + echo ''; + echo ''; + } + + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + } + + for($i=0;$i<$no_of_rec;$i++) + { + 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 ''; + } + ?> +
#Item NamePackBatch NoExp.Qty.RateGross AmtDisc.Net Amt
Sale Return
' . $srno . '' . $row->item_Name . '' . $row->formulation . '' . $row->batch_no . '' . $row->expiry . '' . $row->qty . '' . $row->price . '' . number_format(round($row->amount),2) . '' . number_format(round($row->d_amt),2) . '' . number_format(round($row->twdisc_amount),2) . '
.
#Total'.number_format(round($invoice_med_master[0]->gross_amount),2).''.number_format(round($invoice_med_master[0]->inv_disc_total),2).''.number_format(round($invoice_med_master[0]->net_amount),2).'
+ + 0) { ?> + + + + + + + payment_balance >= 0) { ?> + + + + + + + + + + payment_balance >= 0) { ?> + + + + +
#GrossDiscountNet AmountAmount receivedBalance Amount
#gross_amount),2) ?>discount_amount + $invoice_med_master[0]->item_discount_amount),2) ?>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 +
\ No newline at end of file diff --git a/old_code_ci3/views/Medical/Print/medical_bill_print_a5_old.php b/old_code_ci3/views/Medical/Print/medical_bill_print_a5_old.php new file mode 100644 index 0000000..c0a0c7d --- /dev/null +++ b/old_code_ci3/views/Medical/Print/medical_bill_print_a5_old.php @@ -0,0 +1,209 @@ + + + + + + + + + + + +
+

+


+ +

+

+ Invoice To : + inv_name ?>
+ customer_type == 0) { ?> + Phone No. : inv_phone_number ?>
+ doc_name != '') { ?> + Refer By : 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 ?>
+ +

+
+
+
+ +
+ + + + + +
Page : {PAGENO}/{nbpg}Invoice No.:inv_med_code ?> / Name : inv_name ?>
+
+ + + + + + + + +
+ GST Invoice +
+ GST: ' . H_Med_GST . ''; + } + + if (M_LIC != '') { + echo '
L.No: ' . M_LIC; + } + ?> +
+ Invoice ID : inv_med_code ?>
+ Date : str_inv_date ?> +
+ + '; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + if (H_Med_GST != '') { + echo ''; + echo ''; + } + echo ''; + echo ''; + } + + $srno = $srno + 1; + $head_start = $head_start + 1; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + if (H_Med_GST != '') { + echo ''; + echo ''; + } + echo ''; + echo ''; + } + + if (count($invoice_med_master) > 0) { + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + if (H_Med_GST != '') { + echo ''; + echo ''; + } + echo ''; + echo ''; + } + ?> +
#Item NamePackBatch NoExp.RateQty.Gross AmtDisc.HSNCODE/GSTGSTAmt
' . $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) { ?> + + + + +
#GrossDiscountNet AmountAmount receivedBalance Amount
#gross_amount ?>discount_amount + $invoice_med_master[0]->item_discount_amount) ?>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 +
\ No newline at end of file diff --git a/old_code_ci3/views/Medical/Print/medical_bill_print_a6.php b/old_code_ci3/views/Medical/Print/medical_bill_print_a6.php new file mode 100644 index 0000000..aa83b74 --- /dev/null +++ b/old_code_ci3/views/Medical/Print/medical_bill_print_a6.php @@ -0,0 +1,211 @@ + + + + + + + + + + + +

+


+ '; + + 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?>
+ Refer By :
+ + customer_type==1 && count($patient_master)>0) { ?> + Patient Info. as per Hospital Records
+ UHID ID : p_code ?>
+ Refer By :
+ + 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 ?>
+ +

+
+

+ + GST Invoice + + 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; + + if($row->sale_return==1){ + echo ''; + echo ''; + echo ''; + } + + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + if($row->sale_return==0){ + echo ''; + }else{ + 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
Sale Return
'.$srno.''.$row->item_Name.' '.$row->formulation.''.$row->batch_no.''.$row->expiry.''.$row->price.''.$row->qty.''.$row->amount.''.$row->d_amt.''.$row->twdisc_amount.'(-'.$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/Print/medical_bill_print_format.php b/old_code_ci3/views/Medical/Print/medical_bill_print_format.php new file mode 100644 index 0000000..1ff9114 --- /dev/null +++ b/old_code_ci3/views/Medical/Print/medical_bill_print_format.php @@ -0,0 +1,206 @@ + + + + + + + + +
+

+


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

+

+ Invoice To : + p_fname ?>
p_relative ?> p_rname ?>
+ 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+$inv_med_group[0]->item_discount_amount ?>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 +
\ No newline at end of file diff --git a/old_code_ci3/views/Medical/Print/medical_bill_print_format_newpage.php b/old_code_ci3/views/Medical/Print/medical_bill_print_format_newpage.php new file mode 100644 index 0000000..5f8b7e9 --- /dev/null +++ b/old_code_ci3/views/Medical/Print/medical_bill_print_format_newpage.php @@ -0,0 +1,150 @@ + + + + + + + + +
+

+


+ '; + + 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 '


'; + echo '

For '.M_store.'

'; + echo ''; + + $srno=0; + + $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 '

Invoice No : '.$row->inv_med_code.' / Date : '.$row->str_inv_date.'

'; + 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/Print/medical_bill_print_format_single.php b/old_code_ci3/views/Medical/Print/medical_bill_print_format_single.php new file mode 100644 index 0000000..d557e39 --- /dev/null +++ b/old_code_ci3/views/Medical/Print/medical_bill_print_format_single.php @@ -0,0 +1,208 @@ + + + +

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.'
+ + + + +
+

+


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

+

+ Invoice To : + inv_name?>
+ customer_type==0) { ?> + Phone No. : inv_phone_number?>
+ Refer By :
+ + customer_type==1 && count($patient_master)>0) { ?> + Patient Info. as per Hospital Records
+ UHID ID : p_code ?>
+ + customer_type==1 && $invoice_med_master[0]->ipd_id==0 ) { ?> + Refer By :
+ + 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 ?>
+ +

+
+

+ + GST Invoice + + Invoice + +

+ + + + + + + +
Page : {PAGENO}/{nbpg}Invoice No.:inv_med_code ?> / Name : inv_name ?>
+
+ + '; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + if(H_Med_GST!=''){ + echo ''; + echo ''; + echo ''; + } + echo ''; + echo ''; + } + + $srno=$srno+1; + $head_start=$head_start+1; + + if($row->sale_return==1){ + echo ''; + echo ''; + echo ''; + } + + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + if(H_Med_GST!=''){ + echo ''; + echo ''; + echo ''; + } + echo ''; + echo ''; + } + + if(count($invoice_med_master)>0) { + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + if(H_Med_GST!=''){ + echo ''; + echo ''; + echo ''; + } + echo ''; + echo ''; + } + ?> +
Invoice ID : '.$row->inv_med_code.' [Dated : '.$row->str_inv_date.']
#Item NameBatch NoExp.RateQty.Gross AmtDisc.TaxableAmtHSNCODE/GSTGSTNet Amt
Sale Return
'.$srno.''.$row->item_Name.' '.$row->formulation.''.$row->batch_no.''.$row->expiry.''.$row->price.''.$row->qty.''.$row->amount.''.$row->d_amt.''.$row->TaxableAmount.''.$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]->TaxableAmount.''.$invoice_med_master[0]->TGST.''.number_format(round($invoice_med_master[0]->net_amount),2).'
+ +0) { ?> +
+ + + + if(H_Med_GST!=''){ + + + + } + + payment_balance>=0 ){ ?> + + + + + + + if(H_Med_GST!=''){ + + + + } + + 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/Print/medical_bill_print_format_with_return.php b/old_code_ci3/views/Medical/Print/medical_bill_print_format_with_return.php new file mode 100644 index 0000000..7076657 --- /dev/null +++ b/old_code_ci3/views/Medical/Print/medical_bill_print_format_with_return.php @@ -0,0 +1,280 @@ + + + + + + + + +
+

+


+ '; + + 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 ''; + + $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 ''; + + $invoice_total=0; + } + + $srno=$srno+1; + $head_start=$head_start+1; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + + $Grand_sale_total+=$row->amount; + $invoice_total+=$row->amount; + + } + } + ?> +
#Invoice Total :'.$row->inv_med_code.''.$invoice_total.'

#Grand Sale Total'.$Grand_sale_total.'


Invoice ID : '.$row->inv_med_code.' [Dated : '.$row->str_inv_date.' ]
#Item NameBatch NoExp.RateQty.Amount
'.$srno.''.$row->item_Name.' '.$row->formulation.''.$row->batch_no.''.$row->expiry.''.$row->price.''.$row->qty.''.$row->amount.'
+ +

Return Items

+ + 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 ''; + $invoice_total=0; + } + + $srno=$srno+1; + $head_start=$head_start+1; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + $Grand_return_total+=$row->amount; + $invoice_total+=$row->amount; + + } + } + ?> +
#Invoice Total :'.$row->inv_med_code.''.$invoice_total.'

#Grand Return Total'.$Grand_return_total.'


Invoice ID : '.$row->inv_med_code.' [Dated : '.$row->str_inv_date.' ]
#Item NameBatch NoExp.RateQty.Amount
'.$srno.''.$row->item_Name.' '.$row->formulation.''.$row->batch_no.''.$row->expiry.''.$row->price.''.$row->qty.''.$row->amount.'
+ +0) { + $Gross_amt=$Grand_sale_total-$Grand_return_total; + + + ?> +
+ + + + + + + + + payment_balance>=0 ){ ?> + + + + + + + + + + + + payment_balance>=0 ){ ?> + + + + +
#Sale [A]Sale Return [B]Gross Amt. [G] =([A] - [B])Discount [D]Net Amount [N] =([G]-[D])Amount receivedBalance Amount
#discount_group?>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/Print/medical_cash_received_bill.php b/old_code_ci3/views/Medical/Print/medical_cash_received_bill.php new file mode 100644 index 0000000..c381d9b --- /dev/null +++ b/old_code_ci3/views/Medical/Print/medical_cash_received_bill.php @@ -0,0 +1,84 @@ + + + + + + + + +
+

+


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

+ amount . ':PT' . date('dmYhis'); + ?> + +
+

Payment Amount_str ?> Receipt No.:

+
+ + + + + + +
Page : {PAGENO}/{nbpg}IPD No.:ipd_code ?> / UHID:p_code ?> /Name : p_fname) ?>
+
+ + + + + +
Patient Info.
+ UHID : p_code ?>
+ Name : title ?> p_fname) ?>
+ p_relative ?> p_rname) ?>
+ Sex : xgender ?> age ?> P.No. :mphone1 ?> +
+ IPD No. : ipd_code ?>
+ Date : payment_date_str ?> +
+
+

+ Amount : Rs. amount ?>
+ Amount in Words : Rs.amount) ?> +

+

+ Prepared By :update_by ?>
+ +

+

+ Signature +

\ No newline at end of file diff --git a/old_code_ci3/views/Medical/Purchase/company_Edit.php b/old_code_ci3/views/Medical/Purchase/company_Edit.php new file mode 100644 index 0000000..89cdbf2 --- /dev/null +++ b/old_code_ci3/views/Medical/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/Purchase/company_list.php b/old_code_ci3/views/Medical/Purchase/company_list.php new file mode 100644 index 0000000..877d442 --- /dev/null +++ b/old_code_ci3/views/Medical/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/Purchase/company_list_sub.php b/old_code_ci3/views/Medical/Purchase/company_list_sub.php new file mode 100644 index 0000000..1deb7e1 --- /dev/null +++ b/old_code_ci3/views/Medical/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/Purchase/drug_master_list.php b/old_code_ci3/views/Medical/Purchase/drug_master_list.php new file mode 100644 index 0000000..f5c2c85 --- /dev/null +++ b/old_code_ci3/views/Medical/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/Purchase/indent_req_list.php b/old_code_ci3/views/Medical/Purchase/indent_req_list.php new file mode 100644 index 0000000..5fefe5e --- /dev/null +++ b/old_code_ci3/views/Medical/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/Purchase/indent_req_list_search.php b/old_code_ci3/views/Medical/Purchase/indent_req_list_search.php new file mode 100644 index 0000000..e970c0a --- /dev/null +++ b/old_code_ci3/views/Medical/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/Purchase/indent_request_edit.php b/old_code_ci3/views/Medical/Purchase/indent_request_edit.php new file mode 100644 index 0000000..0f64ee9 --- /dev/null +++ b/old_code_ci3/views/Medical/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/Purchase/indent_request_item_list.php b/old_code_ci3/views/Medical/Purchase/indent_request_item_list.php new file mode 100644 index 0000000..4ee64b2 --- /dev/null +++ b/old_code_ci3/views/Medical/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/Purchase/indent_request_view.php b/old_code_ci3/views/Medical/Purchase/indent_request_view.php new file mode 100644 index 0000000..291e9b3 --- /dev/null +++ b/old_code_ci3/views/Medical/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/Purchase/ledger_add_entry.php b/old_code_ci3/views/Medical/Purchase/ledger_add_entry.php new file mode 100644 index 0000000..8e3efe7 --- /dev/null +++ b/old_code_ci3/views/Medical/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/Purchase/ledger_data.php b/old_code_ci3/views/Medical/Purchase/ledger_data.php new file mode 100644 index 0000000..3121dd4 --- /dev/null +++ b/old_code_ci3/views/Medical/Purchase/ledger_data.php @@ -0,0 +1,61 @@ +
+
+
+
+

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

+ +
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
IDDate TranDescriptionCreditDebitActions
tran_date); ?>mode_desc.' '.$c->tran_desc; ?>credit_debit==0?$c->amount:''); ?>credit_debit==1?$c->amount:''); ?> + +
IDDate TranDescriptionCreditDebitActions
+ +
+
+
+
diff --git a/old_code_ci3/views/Medical/Purchase/ledger_data_print.php b/old_code_ci3/views/Medical/Purchase/ledger_data_print.php new file mode 100644 index 0000000..8bc8d22 --- /dev/null +++ b/old_code_ci3/views/Medical/Purchase/ledger_data_print.php @@ -0,0 +1,114 @@ + + + + + + + + +
+

+

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

+

+ Statement of Supplier : + name_supplier ?>
+

+
+

Statement between

+
+ + + + + + +
Page : {PAGENO}/{nbpg}Supplier:name_supplier ?>
+
+

Opening Balance : / Total Cr. : / Total Dr. : + / Closing Balance :

+ + + + + + + + + + + + + + + + + + + + + + credit_debit == 0 ? $c->amount : $c->amount * -1; + $balance += $amt; + ?> + + + + + + + + + + + + + + + + + + + + +
Sr.NoDate TranDescriptionCreditDebitBalance
Opening Balance : Last Date of Tran
tran_date); ?>mode_desc . ' ' . $c->tran_desc; ?>credit_debit == 0 ? $c->amount : ''); ?>credit_debit == 1 ? $c->amount : ''); ?>
#
\ No newline at end of file diff --git a/old_code_ci3/views/Medical/Purchase/ledger_edit_entry.php b/old_code_ci3/views/Medical/Purchase/ledger_edit_entry.php new file mode 100644 index 0000000..98bd68b --- /dev/null +++ b/old_code_ci3/views/Medical/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/Purchase/ledger_payment_data_print.php b/old_code_ci3/views/Medical/Purchase/ledger_payment_data_print.php new file mode 100644 index 0000000..74de1a8 --- /dev/null +++ b/old_code_ci3/views/Medical/Purchase/ledger_payment_data_print.php @@ -0,0 +1,103 @@ + + + +

+

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

Statement between

+
+ + Page : {PAGENO}/{nbpg} + +

Opening Balance : / Total Cr. : / Total Dr. : + / Closing Balance :

+ + + + + + + + + + + + + + + + + + + + + + credit_debit == 0 ? $c->amount : $c->amount * -1; + $balance += $amt; + ?> + + + + + + + + + + + + + + + + + + + + +
Sr.NoDate TranDescriptionCreditDebitBalance
Opening Balance
tran_date); ?>name_supplier.' / '.$c->mode_desc . ' ' . $c->tran_desc; ?>credit_debit == 0 ? $c->amount : ''); ?>credit_debit == 1 ? $c->amount : ''); ?>
#
\ No newline at end of file diff --git a/old_code_ci3/views/Medical/Purchase/ledger_payment_data_show.php b/old_code_ci3/views/Medical/Purchase/ledger_payment_data_show.php new file mode 100644 index 0000000..31d5837 --- /dev/null +++ b/old_code_ci3/views/Medical/Purchase/ledger_payment_data_show.php @@ -0,0 +1,57 @@ +

Opening Balance : / Total Cr. : / Total Dr. : + / Closing Balance : + Print Statement

+ + + + + + + + + + + + + + + + + + + + + + credit_debit == 0 ? $c->amount : $c->amount * -1; + $balance += $amt; + ?> + + + + + + + + + + + + + + + + + + + + +
Sr.NoDate TranDescriptionCreditDebitBalance
Opening Balance
tran_date); ?>mode_desc . ' ' . $c->tran_desc; ?>credit_debit == 0 ? $c->amount : ''); ?>credit_debit == 1 ? $c->amount : ''); ?>
#
\ No newline at end of file diff --git a/old_code_ci3/views/Medical/Purchase/med_product_cat_list.php b/old_code_ci3/views/Medical/Purchase/med_product_cat_list.php new file mode 100644 index 0000000..10f6c4f --- /dev/null +++ b/old_code_ci3/views/Medical/Purchase/med_product_cat_list.php @@ -0,0 +1,57 @@ +
+

+ Medicine Category +

+
+
+
+
+
+
+ +

Medicine Category List

+
+
+
+ +
+ +
+ + + + + + + + + + + + + + + + + + + + + +
Category NameAction
med_cat_desc ?> + +
Company NameAction
+ +
+ +
+
+
+ +
+
+
+ + \ No newline at end of file diff --git a/old_code_ci3/views/Medical/Purchase/medicine_category_Sub.php b/old_code_ci3/views/Medical/Purchase/medicine_category_Sub.php new file mode 100644 index 0000000..51263e7 --- /dev/null +++ b/old_code_ci3/views/Medical/Purchase/medicine_category_Sub.php @@ -0,0 +1,25 @@ +
+ + + + + + + + + + + + + + + + + + + + + +
Category NameAction
med_cat_desc ?> + +
Company NameAction
\ No newline at end of file diff --git a/old_code_ci3/views/Medical/Purchase/medicine_category_edit.php b/old_code_ci3/views/Medical/Purchase/medicine_category_edit.php new file mode 100644 index 0000000..a51f2e7 --- /dev/null +++ b/old_code_ci3/views/Medical/Purchase/medicine_category_edit.php @@ -0,0 +1,59 @@ +
+
+

Supplier

+
+
+ 'form','class'=>'form1')); ?> + 0) + { + $cid=$med_product_cat_master[0]->id; + $med_cat_desc=$med_product_cat_master[0]->med_cat_desc; + } + + ?> + +
+
+
+ + +
+
+
+
+
+
+ + +
+
+
+ +
+
+ \ No newline at end of file diff --git a/old_code_ci3/views/Medical/Purchase/new_indent_request.php b/old_code_ci3/views/Medical/Purchase/new_indent_request.php new file mode 100644 index 0000000..e75aff1 --- /dev/null +++ b/old_code_ci3/views/Medical/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/Purchase/new_purchase_invoice.php b/old_code_ci3/views/Medical/Purchase/new_purchase_invoice.php new file mode 100644 index 0000000..6bf9567 --- /dev/null +++ b/old_code_ci3/views/Medical/Purchase/new_purchase_invoice.php @@ -0,0 +1,78 @@ +
+
+
+
+
+
+

New Purchase Invoice

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

Product

+ item_name?> +
+
+ + +
+
+
+
+ + ion_auth->in_group('MedicalStoreAdmin'))?'':'readonly'; ?>> +
+
+
+
+ +
+ +
+
+
+
+
+ + +
+
+
+
+ +
+ +
+
+
+
+ + +
+
+
+
+ + +
+
+ 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=""; + } + + $chk_schedule_x=$product_data[0]->schedule_x; + if($chk_schedule_x==1) + { + $chk_schedule_x_checkbox_checked="checked"; + }else{ + $chk_schedule_x_checkbox_checked=""; + } + + + $chk_schedule_g=$product_data[0]->schedule_g; + if($chk_schedule_g==1) + { + $chk_schedule_g_checkbox_checked="checked"; + }else{ + $chk_schedule_g_checkbox_checked=""; + } + + $chk_high_risk=$product_data[0]->high_risk; + if($chk_high_risk==1) + { + $chk_high_risk_checkbox_checked="checked"; + }else{ + $chk_high_risk_checkbox_checked=""; + } + + ?> +
+
+ +
+
+
+
+ + +
+
+
+
+ + +
+
+ +
+
+ + +
+
+
+
+ + +
+
+
+
+ + +
+
+
+
+ + +
+
+
+ +
+ +
+
+
+
+ +
+ +
+
+ + \ No newline at end of file diff --git a/old_code_ci3/views/Medical/Purchase/product_new.php b/old_code_ci3/views/Medical/Purchase/product_new.php new file mode 100644 index 0000000..5f42aff --- /dev/null +++ b/old_code_ci3/views/Medical/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/Purchase/product_search_result.php b/old_code_ci3/views/Medical/Purchase/product_search_result.php new file mode 100644 index 0000000..9612094 --- /dev/null +++ b/old_code_ci3/views/Medical/Purchase/product_search_result.php @@ -0,0 +1,51 @@ +
+
+
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Prod. IDNameFormulationGeneric NamePacking Type
id ?>item_name ?>formulation ?>genericname ?>packing ?> + + +
Prod. IDNameFormulationGeneric NamePacking Type
+ +
+
+
+ + \ No newline at end of file diff --git a/old_code_ci3/views/Medical/Purchase/purchase_challan_list.php b/old_code_ci3/views/Medical/Purchase/purchase_challan_list.php new file mode 100644 index 0000000..41b09dd --- /dev/null +++ b/old_code_ci3/views/Medical/Purchase/purchase_challan_list.php @@ -0,0 +1,37 @@ +
+
+ + $row->id) + { + echo ''; + echo ' '; + echo ''; + + echo ''; + echo ' '; + echo ' '; + echo ' '; + echo ' '; + echo ''; + } + + echo ''; + echo ' '; + echo ' '; + echo ' '; + echo ' '; + echo ''; + + $purchase_id=$row->id; + + } + ?> +
Challan No :'.$row->Invoice_no.' / Date : '.$row->str_date_of_invoice.' /Net Amount :'.$row->tamount.'
Item NameQty + FreeMRPAdd
'.$row->Item_name.''.$row->qty.' + '.$row->qty_free.''.$row->mrp.'Add
+
+
+ + \ No newline at end of file diff --git a/old_code_ci3/views/Medical/Purchase/purchase_file_show.php b/old_code_ci3/views/Medical/Purchase/purchase_file_show.php new file mode 100644 index 0000000..317cfd5 --- /dev/null +++ b/old_code_ci3/views/Medical/Purchase/purchase_file_show.php @@ -0,0 +1,70 @@ +
+
+ +
\ No newline at end of file diff --git a/old_code_ci3/views/Medical/Purchase/purchase_invoice_edit.php b/old_code_ci3/views/Medical/Purchase/purchase_invoice_edit.php new file mode 100644 index 0000000..056dbec --- /dev/null +++ b/old_code_ci3/views/Medical/Purchase/purchase_invoice_edit.php @@ -0,0 +1,533 @@ +
+
+
+
+
+

Purchase Invoice Information

+ Supplier: | name_supplier ?> + ischallan == 1) { ?> + | Challan No.: Invoice_no ?> + + 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/Purchase/purchase_invoice_item.php b/old_code_ci3/views/Medical/Purchase/purchase_invoice_item.php new file mode 100644 index 0000000..11f4f55 --- /dev/null +++ b/old_code_ci3/views/Medical/Purchase/purchase_invoice_item.php @@ -0,0 +1,79 @@ + + + + + + + + + + + + + + + + + + + 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 ''; + } + echo ''; + ?> + + + + + + + + + + + + + + + + + + + +
#RecNoItem NameBatch NoExp.MRPQty.RateAmountDisc.Tax AmountCGSTSGSTNet Amount
'.$srno.''.$row->id.''.$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 ' + '; + if($row->old_purchase_id>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/Purchase/purchase_invoice_master_edit.php b/old_code_ci3/views/Medical/Purchase/purchase_invoice_master_edit.php new file mode 100644 index 0000000..bcc3768 --- /dev/null +++ b/old_code_ci3/views/Medical/Purchase/purchase_invoice_master_edit.php @@ -0,0 +1,286 @@ +
+
+
+
+
+
+ '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/Purchase/purchase_invoice_scan.php b/old_code_ci3/views/Medical/Purchase/purchase_invoice_scan.php new file mode 100644 index 0000000..b855675 --- /dev/null +++ b/old_code_ci3/views/Medical/Purchase/purchase_invoice_scan.php @@ -0,0 +1,112 @@ +
+
+

Inv ID :id?> + / Inv Code :Invoice_no?> + +

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

Loading state

+
+
+
+ + +
+ + +
+ +
+
+
+
+
+
+ + + \ No newline at end of file diff --git a/old_code_ci3/views/Medical/Purchase/purchase_item_old.php b/old_code_ci3/views/Medical/Purchase/purchase_item_old.php new file mode 100644 index 0000000..b95162a --- /dev/null +++ b/old_code_ci3/views/Medical/Purchase/purchase_item_old.php @@ -0,0 +1,37 @@ +0){ + $item_name=$purchase_item_old[0]->Item_name; + } +?> +

Item : Last 5 Purchase Orders

+ + + + + + + + + + + + '; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + } + echo ''; + ?> + +
DateMRPQtyRateSCH/DiscP.U.RateSupplier/Invoice
'.$row->date_of_invoice_str.''.$row->mrp.''.floatval($row->qty).'+'.floatval($row->qty_free).''.$row->purchase_price.''.$row->sch_disc_per.' / '.$row->discount.''.$row->purchase_unit_rate.''.$row->name_supplier.'/'.$row->Invoice_no.'
\ No newline at end of file diff --git a/old_code_ci3/views/Medical/Purchase/purchase_supp_list.php b/old_code_ci3/views/Medical/Purchase/purchase_supp_list.php new file mode 100644 index 0000000..35130ec --- /dev/null +++ b/old_code_ci3/views/Medical/Purchase/purchase_supp_list.php @@ -0,0 +1,74 @@ +
+
+
+
+ + + + + + + + + + + + ischallan==0){ + echo ''; + }else{ + echo ''; + } + ?> + + + + + + + + + + + + + + + + + + + + +
Invoice IDSupplierDateAmount
Invoice_no ?>name_supplier ?>date_of_invoice ?>tamount ?> + + Print + tamount==0){ ?> + + + +
Invoice IDSupplierDateAmount
+ +
+
+
+ + \ No newline at end of file diff --git a/old_code_ci3/views/Medical/Purchase/scan_purchase_list.php b/old_code_ci3/views/Medical/Purchase/scan_purchase_list.php new file mode 100644 index 0000000..1c71cb9 --- /dev/null +++ b/old_code_ci3/views/Medical/Purchase/scan_purchase_list.php @@ -0,0 +1,31 @@ + +
'; + $pos=strpos($purchase_invoice_scan_file[$i]->full_path,'/medical_uploads/purchase_invoice',1) ; + $file_path=substr($purchase_invoice_scan_file[$i]->full_path,$pos); + + + + //echo $file_path; + //$pos=strpos($file_path,'/uploads/',1) ; + //$file_path=str_replace('Hospital_DR_B_C_JOSHI/uploads','uploads',$purchase_invoice_scan_file[$i]->full_path); + + if($purchase_invoice_scan_file[$i]->file_ext=='.pdf') + { + echo ''; + }else + { + echo ''; + echo ' '; + echo '
+

'.$purchase_invoice_scan_file[$i]->file_name.'/'.$purchase_invoice_scan_file[$i]->insert_time.' +

+
'; + echo '
+
'; + + } +} +?> \ No newline at end of file diff --git a/old_code_ci3/views/Medical/Purchase/supplier_Edit.php b/old_code_ci3/views/Medical/Purchase/supplier_Edit.php new file mode 100644 index 0000000..0bf2290 --- /dev/null +++ b/old_code_ci3/views/Medical/Purchase/supplier_Edit.php @@ -0,0 +1,139 @@ + + +
+
+

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; + $active=$supplier_data[0]->active; + } + + ?> + +
+
+
+ + +
+
+
+
+ + +
+
+
+
+
+
+ + +
+
+
+
+ + +
+
+
+
+
+
+ + +
+
+
+ +
+ +
+
+
+
+ +
+
+ +
+
+
+
+
+
+ + +
+
+
+ +
+
+ \ No newline at end of file diff --git a/old_code_ci3/views/Medical/Purchase/supplier_account.php b/old_code_ci3/views/Medical/Purchase/supplier_account.php new file mode 100644 index 0000000..86cc95a --- /dev/null +++ b/old_code_ci3/views/Medical/Purchase/supplier_account.php @@ -0,0 +1,61 @@ +
+

+ Supplier +

+
+
+
+
+
+
+

Supplier List

+
+ Ledger +
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
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/Purchase/supplier_account_detail.php b/old_code_ci3/views/Medical/Purchase/supplier_account_detail.php new file mode 100644 index 0000000..6363639 --- /dev/null +++ b/old_code_ci3/views/Medical/Purchase/supplier_account_detail.php @@ -0,0 +1,91 @@ +
+
+
+
+

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/Purchase/supplier_account_payment.php b/old_code_ci3/views/Medical/Purchase/supplier_account_payment.php new file mode 100644 index 0000000..3ed8baa --- /dev/null +++ b/old_code_ci3/views/Medical/Purchase/supplier_account_payment.php @@ -0,0 +1,89 @@ +
+
+
+
+

Supplier Payments +

+ +
+
+ 'form_search'); + echo form_open('/Medical_backpanel/payment_supplier_data',$attributes); ?> +
+
+ +
+   + +
+ +
+
+ +
+ +
+
+ +
+ +
+ +
+
+
+ + \ No newline at end of file diff --git a/old_code_ci3/views/Medical/Purchase/supplier_list.php b/old_code_ci3/views/Medical/Purchase/supplier_list.php new file mode 100644 index 0000000..2928a8d --- /dev/null +++ b/old_code_ci3/views/Medical/Purchase/supplier_list.php @@ -0,0 +1,32 @@ +
+ +'form','class'=>'form2')); ?> +
+ + + + + + + + + + + + +
+ +
+
+ \ No newline at end of file diff --git a/old_code_ci3/views/Medical/Purchase/supplier_master.php b/old_code_ci3/views/Medical/Purchase/supplier_master.php new file mode 100644 index 0000000..0816194 --- /dev/null +++ b/old_code_ci3/views/Medical/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/Purchase/supplier_master_sub.php b/old_code_ci3/views/Medical/Purchase/supplier_master_sub.php new file mode 100644 index 0000000..a5551df --- /dev/null +++ b/old_code_ci3/views/Medical/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/Purchase_Invoice_Edit.php b/old_code_ci3/views/Medical/Purchase_Invoice_Edit.php new file mode 100644 index 0000000..5928ebd --- /dev/null +++ b/old_code_ci3/views/Medical/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/Report/IPD_Discharge_Report.php b/old_code_ci3/views/Medical/Report/IPD_Discharge_Report.php new file mode 100644 index 0000000..35134dc --- /dev/null +++ b/old_code_ci3/views/Medical/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/Report/Med_Payment_Recevie.php b/old_code_ci3/views/Medical/Report/Med_Payment_Recevie.php new file mode 100644 index 0000000..af60099 --- /dev/null +++ b/old_code_ci3/views/Medical/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/Report/Med_Report_1.php b/old_code_ci3/views/Medical/Report/Med_Report_1.php new file mode 100644 index 0000000..5445f11 --- /dev/null +++ b/old_code_ci3/views/Medical/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/Report/Med_Report_2.php b/old_code_ci3/views/Medical/Report/Med_Report_2.php new file mode 100644 index 0000000..3eae13d --- /dev/null +++ b/old_code_ci3/views/Medical/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/Medical/Report/Med_Report_2_Pending.php b/old_code_ci3/views/Medical/Report/Med_Report_2_Pending.php new file mode 100644 index 0000000..c4bb772 --- /dev/null +++ b/old_code_ci3/views/Medical/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/Report/Med_Report_2_Pending_paid.php b/old_code_ci3/views/Medical/Report/Med_Report_2_Pending_paid.php new file mode 100644 index 0000000..7573e2c --- /dev/null +++ b/old_code_ci3/views/Medical/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/Report/Med_Report_3.php b/old_code_ci3/views/Medical/Report/Med_Report_3.php new file mode 100644 index 0000000..25763de --- /dev/null +++ b/old_code_ci3/views/Medical/Report/Med_Report_3.php @@ -0,0 +1,79 @@ +
+

+ Sale GST Report + Panel +

+
+
+
+
+ +
+   + +
+ +
+
+ +
+ + +
+
+
+
+
+
+
+
+
+ \ No newline at end of file diff --git a/old_code_ci3/views/Medical/Report/Med_Report_4.php b/old_code_ci3/views/Medical/Report/Med_Report_4.php new file mode 100644 index 0000000..91fb7b4 --- /dev/null +++ b/old_code_ci3/views/Medical/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/Report/Med_Report_5.php b/old_code_ci3/views/Medical/Report/Med_Report_5.php new file mode 100644 index 0000000..651079c --- /dev/null +++ b/old_code_ci3/views/Medical/Report/Med_Report_5.php @@ -0,0 +1,101 @@ +
+

+ GST Invoice List + Panel +

+
+
+
+
+ +
+   + +
+ +
+
+ +
+ + +
+
+
+ +
+ + +
+
+ +
+
+
+
+
+
+
+ \ No newline at end of file diff --git a/old_code_ci3/views/Medical/Report/Med_Report_7.php b/old_code_ci3/views/Medical/Report/Med_Report_7.php new file mode 100644 index 0000000..bfc62a1 --- /dev/null +++ b/old_code_ci3/views/Medical/Report/Med_Report_7.php @@ -0,0 +1,106 @@ +
+

+ GST Invoice List + Panel +

+
+
+
+
+ +
+   + +
+ +
+
+ + +
+
+ + +
+
+ +
+ + +
+
+
+
+
+
+
+
+
+ \ No newline at end of file diff --git a/old_code_ci3/views/Medical/Report/Med_Report_Doc_med_sale.php b/old_code_ci3/views/Medical/Report/Med_Report_Doc_med_sale.php new file mode 100644 index 0000000..8b13562 --- /dev/null +++ b/old_code_ci3/views/Medical/Report/Med_Report_Doc_med_sale.php @@ -0,0 +1,100 @@ +
+

+ Company Wise Medicine Sale / Purchase Report +

+
+
+
+
+ +
+   + +
+ +
+
+ +
+ +
+
+
+ +
+ + +
+
+
+ +
+ +
+
+
+ +
+
+
+
+
+
+ \ No newline at end of file diff --git a/old_code_ci3/views/Medical/Report/Med_Report_IPD_Credit.php b/old_code_ci3/views/Medical/Report/Med_Report_IPD_Credit.php new file mode 100644 index 0000000..9e9e5ea --- /dev/null +++ b/old_code_ci3/views/Medical/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/Report/Med_Report_company_med_sale.php b/old_code_ci3/views/Medical/Report/Med_Report_company_med_sale.php new file mode 100644 index 0000000..e5ef06d --- /dev/null +++ b/old_code_ci3/views/Medical/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/Report/Med_Report_daily_med_doc_sale.php b/old_code_ci3/views/Medical/Report/Med_Report_daily_med_doc_sale.php new file mode 100644 index 0000000..551c897 --- /dev/null +++ b/old_code_ci3/views/Medical/Report/Med_Report_daily_med_doc_sale.php @@ -0,0 +1,110 @@ +
+

+ Daily Medicine Sale Report +

+
+
+
+
+ +
+   + +
+ +
+
+ + +
+
+ +
+ + +
+
+
+ +
+ + +
+
+
+ +
+
+
+
+
+
+ \ No newline at end of file diff --git a/old_code_ci3/views/Medical/Report/Med_Report_daily_med_sale.php b/old_code_ci3/views/Medical/Report/Med_Report_daily_med_sale.php new file mode 100644 index 0000000..d6b9cb6 --- /dev/null +++ b/old_code_ci3/views/Medical/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/Report/Med_high_pending.php b/old_code_ci3/views/Medical/Report/Med_high_pending.php new file mode 100644 index 0000000..4c8fa82 --- /dev/null +++ b/old_code_ci3/views/Medical/Report/Med_high_pending.php @@ -0,0 +1,69 @@ +
+

+ IPD High Pending Balance Patient +

+
+
+
+
+ + + + + + + + + + + + + + + + + + + + + + + +
+ Sr. + + IPD No. + + UHID No. + + Patient Name + + Phone No. + + Total Bill + + Paid Amount + + Balance +
+ + + ipd_code?> + + p_code?> + + p_fname?> + + mphone1?> + + net_amount?> + + payment_received?> + + payment_balance?> +
+
+
+
diff --git a/old_code_ci3/views/Medical/Report/Purchase_Invoice.php b/old_code_ci3/views/Medical/Report/Purchase_Invoice.php new file mode 100644 index 0000000..8aff4c0 --- /dev/null +++ b/old_code_ci3/views/Medical/Report/Purchase_Invoice.php @@ -0,0 +1,120 @@ +
+

+ Report Purchase Invoice + Panel +

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

+ Report Drug Sale to Patient + Panel +

+
+
+'form','class'=>'form2')); ?> +
+
+ +
+   + +
+ +
+
+ + +
+
+ + +
+
+ +
+ + +
+
+
+
+
+
+
+
+ +
+ \ No newline at end of file diff --git a/old_code_ci3/views/Medical/Report/Report_Med_patient_result.php b/old_code_ci3/views/Medical/Report/Report_Med_patient_result.php new file mode 100644 index 0000000..30ebf36 --- /dev/null +++ b/old_code_ci3/views/Medical/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/Report/Report_gst_1.php b/old_code_ci3/views/Medical/Report/Report_gst_1.php new file mode 100644 index 0000000..03b7e43 --- /dev/null +++ b/old_code_ci3/views/Medical/Report/Report_gst_1.php @@ -0,0 +1,79 @@ +
+

+ Purchase GST Report + Panel +

+
+
+
+
+ +
+   + +
+ +
+
+ +
+ + +
+
+
+
+
+
+
+
+
+ \ No newline at end of file diff --git a/old_code_ci3/views/Medical/Report/Report_org_invoice_list.php b/old_code_ci3/views/Medical/Report/Report_org_invoice_list.php new file mode 100644 index 0000000..c2ec7d6 --- /dev/null +++ b/old_code_ci3/views/Medical/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/Search_Patient.php b/old_code_ci3/views/Medical/Search_Patient.php new file mode 100644 index 0000000..8538815 --- /dev/null +++ b/old_code_ci3/views/Medical/Search_Patient.php @@ -0,0 +1,22 @@ +
+ 'form','class'=>'form2')); ?> +
+ + + + +
+ +
+
+ \ No newline at end of file diff --git a/old_code_ci3/views/Medical/Stock/Lost_medicine.php b/old_code_ci3/views/Medical/Stock/Lost_medicine.php new file mode 100644 index 0000000..706d40a --- /dev/null +++ b/old_code_ci3/views/Medical/Stock/Lost_medicine.php @@ -0,0 +1,80 @@ +
+

+ Medicine Lost Report +

+
+
+
+
+ +
+   + +
+ +
+
+ +
+ + +
+
+
+ +
+
+
+
+
+
+ \ No newline at end of file diff --git a/old_code_ci3/views/Medical/Stock/Short_medicine.php b/old_code_ci3/views/Medical/Stock/Short_medicine.php new file mode 100644 index 0000000..26fdf29 --- /dev/null +++ b/old_code_ci3/views/Medical/Stock/Short_medicine.php @@ -0,0 +1,106 @@ +
+

+ Medicine Short Report +

+
+
+
+
+ +
+   + +
+ +
+
+ + +
+
+ +
+ + +
+
+
+ +
+
+
+
+
+
+ \ No newline at end of file diff --git a/old_code_ci3/views/Medical/Stock/Stock_search_qty_result.php b/old_code_ci3/views/Medical/Stock/Stock_search_qty_result.php new file mode 100644 index 0000000..3a3cbea --- /dev/null +++ b/old_code_ci3/views/Medical/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/Stock/Stock_search_result.php b/old_code_ci3/views/Medical/Stock/Stock_search_result.php new file mode 100644 index 0000000..24ace19 --- /dev/null +++ b/old_code_ci3/views/Medical/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/Stock/expiry_stock_list.php b/old_code_ci3/views/Medical/Stock/expiry_stock_list.php new file mode 100644 index 0000000..b2ab83d --- /dev/null +++ b/old_code_ci3/views/Medical/Stock/expiry_stock_list.php @@ -0,0 +1,51 @@ +
+

Nearest Expiry / or Expired Medicine Stock

+
+
+ + '; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + $srno=0; + + echo ''; + foreach($purchase_list as $row) + { + + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + + echo ''; + + $inv_id=$row->pur_id; + } + echo ''; + ?> +
#ItemSupplierPur.DateBat.Exp.DtRateQtyC.Qty
'.$srno.''.$row->Item_name.''.$row->name_supplier.''.$row->str_date_of_invoice.''.$row->batch_no.''.$row->exp_date.''.$row->mrp.''.$row->tqty .''.$row->cur_qty.'
+
+ diff --git a/old_code_ci3/views/Medical/Stock/indent_accept_items_list.php b/old_code_ci3/views/Medical/Stock/indent_accept_items_list.php new file mode 100644 index 0000000..3ade01a --- /dev/null +++ b/old_code_ci3/views/Medical/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/Stock/indent_counter_edit.php b/old_code_ci3/views/Medical/Stock/indent_counter_edit.php new file mode 100644 index 0000000..43a4ab4 --- /dev/null +++ b/old_code_ci3/views/Medical/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/Stock/indent_counter_item_list.php b/old_code_ci3/views/Medical/Stock/indent_counter_item_list.php new file mode 100644 index 0000000..ce4a324 --- /dev/null +++ b/old_code_ci3/views/Medical/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/Stock/indent_counter_list.php b/old_code_ci3/views/Medical/Stock/indent_counter_list.php new file mode 100644 index 0000000..3487b50 --- /dev/null +++ b/old_code_ci3/views/Medical/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/Stock/indent_counter_search_result.php b/old_code_ci3/views/Medical/Stock/indent_counter_search_result.php new file mode 100644 index 0000000..ae59701 --- /dev/null +++ b/old_code_ci3/views/Medical/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/Stock/indent_issue.php b/old_code_ci3/views/Medical/Stock/indent_issue.php new file mode 100644 index 0000000..e69de29 diff --git a/old_code_ci3/views/Medical/Stock/indent_issue_item_view.php b/old_code_ci3/views/Medical/Stock/indent_issue_item_view.php new file mode 100644 index 0000000..9978455 --- /dev/null +++ b/old_code_ci3/views/Medical/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/Stock/indent_issue_items.php b/old_code_ci3/views/Medical/Stock/indent_issue_items.php new file mode 100644 index 0000000..937dae0 --- /dev/null +++ b/old_code_ci3/views/Medical/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/Stock/indent_req_view_with_store.php b/old_code_ci3/views/Medical/Stock/indent_req_view_with_store.php new file mode 100644 index 0000000..5e83dd4 --- /dev/null +++ b/old_code_ci3/views/Medical/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/Stock/indent_request.php b/old_code_ci3/views/Medical/Stock/indent_request.php new file mode 100644 index 0000000..1f30b32 --- /dev/null +++ b/old_code_ci3/views/Medical/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/Stock/indent_request_search_result.php b/old_code_ci3/views/Medical/Stock/indent_request_search_result.php new file mode 100644 index 0000000..ab8562c --- /dev/null +++ b/old_code_ci3/views/Medical/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/Stock/indent_stock_list.php b/old_code_ci3/views/Medical/Stock/indent_stock_list.php new file mode 100644 index 0000000..846f15c --- /dev/null +++ b/old_code_ci3/views/Medical/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/Stock/invoice_item_log.php b/old_code_ci3/views/Medical/Stock/invoice_item_log.php new file mode 100644 index 0000000..ba0da1e --- /dev/null +++ b/old_code_ci3/views/Medical/Stock/invoice_item_log.php @@ -0,0 +1,80 @@ +
+

+ Medical Invoice Item Log + Panel +

+
+
+ 'form_payment_log','role'=>'form')); ?> +
+
+ +
+   + +
+ +
+
+ +
+ +
+
+
+ +
+
+
+
+
+ +
+ \ No newline at end of file diff --git a/old_code_ci3/views/Medical/Stock/invoice_item_log_data.php b/old_code_ci3/views/Medical/Stock/invoice_item_log_data.php new file mode 100644 index 0000000..4f41b26 --- /dev/null +++ b/old_code_ci3/views/Medical/Stock/invoice_item_log_data.php @@ -0,0 +1,123 @@ + + + + + + + + + + + + + + + + + + + + + + + + + +
#Invoice CodeInvoice DateNameItem DeletedPayment LogUpdate Log
inv_med_code; ?>inv_date; ?>inv_name; ?> + del_item_list); + //print_r($item_removed_log); + if(count($item_removed_log)>0) { + echo ""; + echo ""; + echo ""; + echo ""; + echo ""; + echo ""; + echo ""; + echo ""; + $item_amount_total = 0; + foreach($item_removed_log as $row_item) { + + $item = explode("#",$row_item); + + echo ""; + echo ""; + echo ""; + echo ""; + echo ""; + echo ""; + echo ""; + $item_amount_total += $item[3]; + } + echo ""; + echo "
Item NameQtyPriceAmountDelete By
".$item[0]."".$item[1]."".$item[2]."".$item[3]."".$item[5]."
Total Amount : ".$item_amount_total."
"; + } else { + echo "No Item Deleted"; + } + + ?> +
+ payment_log); + //print_r($item_removed_log); + if(count($payment_log_list)>0) { + echo ""; + echo ""; + echo ""; + echo ""; + echo ""; + echo ""; + foreach($payment_log_list as $row_item) { + + $item = explode("#",$row_item); + + echo ""; + echo ""; + + echo ""; + + echo ""; + + echo ""; + } + + echo "
Payment TypeAmountPayment By
"; + if(isset($item[0])) { + if($item[0]==0) { + echo "Credit"; + }else if($item[0]==1) { + echo "Return"; + } + } + echo ""; + if(isset($item[1])) echo $item[1]; + echo ""; + if(isset($item[2])) echo $item[2]; + echo "
"; + } else { + echo "No Payment Log"; + } + ?> +
log; ?>
+ \ No newline at end of file diff --git a/old_code_ci3/views/Medical/Stock/main_store_dashboard.php b/old_code_ci3/views/Medical/Stock/main_store_dashboard.php new file mode 100644 index 0000000..54b6371 --- /dev/null +++ b/old_code_ci3/views/Medical/Stock/main_store_dashboard.php @@ -0,0 +1,75 @@ +
+

+ Store Main + Panel +

+
+
+
+ +
+
+
+ Inventory +
+ +
+
+ +
diff --git a/old_code_ci3/views/Medical/Stock/merge_product.php b/old_code_ci3/views/Medical/Stock/merge_product.php new file mode 100644 index 0000000..d7eff00 --- /dev/null +++ b/old_code_ci3/views/Medical/Stock/merge_product.php @@ -0,0 +1,109 @@ +
+

+ Purchase Item Transfer + +

+
+
+
+
+ +
+
+
+
+
+ + + +
+
+
+ +
+
+
+
+
+ + + +
+
+
+ +
+
+
+ +
+ \ No newline at end of file diff --git a/old_code_ci3/views/Medical/Stock/new_purchase_return_invoice.php b/old_code_ci3/views/Medical/Stock/new_purchase_return_invoice.php new file mode 100644 index 0000000..b776a49 --- /dev/null +++ b/old_code_ci3/views/Medical/Stock/new_purchase_return_invoice.php @@ -0,0 +1,63 @@ +
+
+
+
+
+
+

New Purchase Invoice

+
+
+ 'form','class'=>'form1')); ?> +
+
+
+ + +
+
+
+ +
+
+ +
+ +
+
+
+ +
+
+ +
+
+
+
+ \ No newline at end of file diff --git a/old_code_ci3/views/Medical/Stock/purchase_invoice_item_print.php b/old_code_ci3/views/Medical/Stock/purchase_invoice_item_print.php new file mode 100644 index 0000000..3cbd9b6 --- /dev/null +++ b/old_code_ci3/views/Medical/Stock/purchase_invoice_item_print.php @@ -0,0 +1,131 @@ + + + + + + + + + + + +

+

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

+

+ Invoice From : + Supplier : name_supplier?>
+ Purchase Invoice No.: Invoice_no?>
+ Invoice Date : date_of_invoice)?>
+

+
+

Purchase Invoice

+
+ + + + + + +
Page : {PAGENO}/{nbpg}Invoice No.:Invoice_no?> / Name : name_supplier?>
+
+ + + + + + + + + + + + + + + + + + item_return==1) + { + $style='style="color:Red;"'; + }else{ + $style=''; + } + 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/Stock/purchase_invoice_list.php b/old_code_ci3/views/Medical/Stock/purchase_invoice_list.php new file mode 100644 index 0000000..8482dcf --- /dev/null +++ b/old_code_ci3/views/Medical/Stock/purchase_invoice_list.php @@ -0,0 +1,68 @@ + + '; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + $srno=0; + + echo ''; + foreach($purchase_list as $row) + { + + $srno=$srno+1; + if($row->isExp==1) + { + echo ''; + }else{ + echo ''; + } + + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + if($row->item_return==0 && $row->remove_item==0){ + echo ''; + }else{ + echo ''; + } + echo ''; + + $inv_id=$row->pur_id; + } + echo ''; + ?> +
#Pur.DateItemBat./Exp.DtRatePur. Qty C.Unit QtyR.Unit Qty
'.$srno.''.$row->str_date_of_invoice.''.$row->Item_name.''.$row->batch_no.'
'.$row->exp_date.'
'.$row->mrp.''.$row->tqty .' /'.$row->packing .''.$row->cur_qty.' +
+ + + + +
'; + echo '
+ diff --git a/old_code_ci3/views/Medical/Stock/purchase_product_search.php b/old_code_ci3/views/Medical/Stock/purchase_product_search.php new file mode 100644 index 0000000..eca0352 --- /dev/null +++ b/old_code_ci3/views/Medical/Stock/purchase_product_search.php @@ -0,0 +1,120 @@ +
+
+
+
+ + + +
+
+
+
+ +
+
+
+
+ + +

+ + + + + + + + +

+
+
+
+
+
+ + +
+
+
+
+ + + +
+
+
+
+ + +
+
+
+
+ + +
+
+
+
+ +
+
+
+ \ No newline at end of file diff --git a/old_code_ci3/views/Medical/Stock/purchase_return.php b/old_code_ci3/views/Medical/Stock/purchase_return.php new file mode 100644 index 0000000..6ba648b --- /dev/null +++ b/old_code_ci3/views/Medical/Stock/purchase_return.php @@ -0,0 +1,29 @@ +
+ +'form','class'=>'form2')); ?> +
+ + + + + + + + + +
+ +
+
+ \ No newline at end of file diff --git a/old_code_ci3/views/Medical/Stock/purchase_return_invoice_edit.php b/old_code_ci3/views/Medical/Stock/purchase_return_invoice_edit.php new file mode 100644 index 0000000..fd14d9b --- /dev/null +++ b/old_code_ci3/views/Medical/Stock/purchase_return_invoice_edit.php @@ -0,0 +1,161 @@ +
+

Purchase Return Invoice / Supplier : name_supplier ?>

+ |Invoice No.: Invoice_no ?> | + Invoice Date : str_date_of_invoice ?> + + Print + +
+
+'form','class'=>'form1')); ?> +
+
+
+ +
+
+
+
+
+
+

Item List

+
+ + +
+
+ + +
+ +
+ + + +
+
+ +
+ + \ 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 new file mode 100644 index 0000000..3b33071 --- /dev/null +++ b/old_code_ci3/views/Medical/Stock/purchase_return_invoice_item.php @@ -0,0 +1,50 @@ + + + + + + + + + + + + + '; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + } + echo ''; + ?> + + + + + + + + + + + + + +
#RecNoItem NameBatch NoExp.MRP / P. Rate/UnitQty.(Unit / Pack)Rate
'.$srno.''.$row->r_id.''.$row->Item_name.''.$row->batch_no_r_s.''.$row->exp_date_str.''.$row->mrp.' / '.$row->purchase_unit_rate.''.floatval($row->r_qty).' / '.floatval($row->qty_pak).''.$row->r_amount.''; + if(1==1) + { + echo ''; + } + echo '
#
\ No newline at end of file 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 new file mode 100644 index 0000000..550b6b2 --- /dev/null +++ b/old_code_ci3/views/Medical/Stock/purchase_return_invoice_item_print.php @@ -0,0 +1,114 @@ + + + + + + + + + + + +

+

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

+

+ 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 ''; + $total_amt+=Round($row->r_qty*$row->purchase_unit_rate,2); + } + echo ''; + ?> + + + + + + + + + + + + + +
#RecNoItem NameBatch NoExp.MRP of PackReturn Unit Qty/ Pack.Rate UnitAmount
'.$srno.''.$row->r_id.''.$row->Item_name.''.$row->batch_no.' '.$row->exp_date_str.''.$row->mrp.''.floatval($row->r_qty).' / '.floatval($row->qty_pak).''.$row->purchase_price.' / '.$row->purchase_unit_rate.''.Round($row->r_qty*$row->purchase_unit_rate,2).'
#Total
\ No newline at end of file diff --git a/old_code_ci3/views/Medical/Stock/purchase_supp_list.php b/old_code_ci3/views/Medical/Stock/purchase_supp_list.php new file mode 100644 index 0000000..a5d55d7 --- /dev/null +++ b/old_code_ci3/views/Medical/Stock/purchase_supp_list.php @@ -0,0 +1,61 @@ +
+
+
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Invoice IDSupplierDate
p_r_invoice_no ?>name_supplier ?>date_of_invoice ?> + + Print +
Invoice IDSupplierDate
+ +
+
+
+ + \ No newline at end of file diff --git a/old_code_ci3/views/Medical/Stock/stock_search.php b/old_code_ci3/views/Medical/Stock/stock_search.php new file mode 100644 index 0000000..de502b8 --- /dev/null +++ b/old_code_ci3/views/Medical/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/Stock/stock_transfer.php b/old_code_ci3/views/Medical/Stock/stock_transfer.php new file mode 100644 index 0000000..54ca9eb --- /dev/null +++ b/old_code_ci3/views/Medical/Stock/stock_transfer.php @@ -0,0 +1,158 @@ +
+

+ Purchase Item Transfer + +

+
+
+
+
+ +
+
+
+
+
+ + + + + +
+
+
+ +
+
+
+
+
+ + + + + +
+
+
+ +
+
+
+
+
+ + + +
+
+
+
+ +
+ \ No newline at end of file diff --git a/old_code_ci3/views/Medical/Stock_Update.php b/old_code_ci3/views/Medical/Stock_Update.php new file mode 100644 index 0000000..f1bd0a9 --- /dev/null +++ b/old_code_ci3/views/Medical/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/Store/Stock_Item_history.php b/old_code_ci3/views/Medical/Store/Stock_Item_history.php new file mode 100644 index 0000000..2b165ba --- /dev/null +++ b/old_code_ci3/views/Medical/Store/Stock_Item_history.php @@ -0,0 +1,58 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Pur. IDSupplierInv.No / DateBat.No.Exp.Dt.MRPPurchaseQty / PackingUnit QtySale U.QtyReturn UnitCurr.U.QtyUpdate Lost UnitRemove
id?>name_supplier?>Invoice_no?>
date_of_invoice?>
batch_no?>expiry_date?>mrp?>purchase_price?>tqty?> / packing?>total_unit?>total_sale_unit?>total_return_unit?>cur_unit?> + + +
\ No newline at end of file diff --git a/old_code_ci3/views/Medical/Store/Stock_Item_history_removed.php b/old_code_ci3/views/Medical/Store/Stock_Item_history_removed.php new file mode 100644 index 0000000..0e3a61b --- /dev/null +++ b/old_code_ci3/views/Medical/Store/Stock_Item_history_removed.php @@ -0,0 +1,60 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Pur. IDSupplierInv.No / DateBat.No.Exp.Dt.MRPPurchaseQtyUnit QtySale U.QtyLost UnitCurr.U.QtyUpdate Lost UnitRemove
id?>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/Medical/Store/Stock_Item_history_return.php b/old_code_ci3/views/Medical/Store/Stock_Item_history_return.php new file mode 100644 index 0000000..8fec641 --- /dev/null +++ b/old_code_ci3/views/Medical/Store/Stock_Item_history_return.php @@ -0,0 +1,96 @@ +
+
+
+
+

Purchase Return

+
+
+ + + + + + + + + + + + qty; + ?> + + + + + + + + + + + + + + + +
Invoice NoSupplier NameDateItem NameUnit Qty
p_r_invoice_no; ?>name_supplier; ?>date_of_invoice; ?>Item_name; ?>qty; ?>
Total Return Qty
+
+
+
+
+
+
+

Purchase Invoice (Return Adjustment)

+
+
+ + + + + + + + + + + + + + qty; + $total_unit_invoice_qty += ($row->packing*$row->qty); + ?> + + + + + + + + + + + + + + + + + + + +
Invoice NoSupplier NameDateItem NameQtyPackingUnit Qty
Invoice_no; ?>name_supplier; ?>date_of_invoice; ?>Item_name; ?>qty; ?>packing; ?>packing*$row->qty; ?>
Total Invoice Qty
+
+
+
+
diff --git a/old_code_ci3/views/Medical/Store/Stock_search_result.php b/old_code_ci3/views/Medical/Store/Stock_search_result.php new file mode 100644 index 0000000..fe3539d --- /dev/null +++ b/old_code_ci3/views/Medical/Store/Stock_search_result.php @@ -0,0 +1,208 @@ + +
+
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Item NameCurrent Pak.Current Unit QtyTotal Sale Pak.Total Sale Unit QtyLost UnitPackage/Re-Order QtyRemoved Qty
+

+ item_name ?> + genericname)>0){ + echo '
'.$row->genericname.''; + } + ?>

+
+

C_Pak_Qty?>

+
+

C_Unit_Stock_Qty,2) ?>

+
+

C_Pak_Sale_Qty,2) ?>

+
+

sale_unit,2) ?>

+
+

total_lost_unit,2) ?>

+
+

packing ?>/re_order_qty ?>

+
+ +
Item Name Current 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/Medical/Store/stock_store_statement.php b/old_code_ci3/views/Medical/Store/stock_store_statement.php new file mode 100644 index 0000000..0c00f71 --- /dev/null +++ b/old_code_ci3/views/Medical/Store/stock_store_statement.php @@ -0,0 +1,147 @@ +
+'form','class'=>'form2')); ?> +
+
+ + +
+
+
+ +
+   + +
+ +
+
+ +
+ + + + + + + + + + +
+
+ +
+
+ \ No newline at end of file diff --git a/old_code_ci3/views/Medical/Store/stock_store_statement_data.php b/old_code_ci3/views/Medical/Store/stock_store_statement_data.php new file mode 100644 index 0000000..ba7a32c --- /dev/null +++ b/old_code_ci3/views/Medical/Store/stock_store_statement_data.php @@ -0,0 +1,197 @@ + +
+
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
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/Medical/Store/stock_store_statement_data_excel.php b/old_code_ci3/views/Medical/Store/stock_store_statement_data_excel.php new file mode 100644 index 0000000..c43d837 --- /dev/null +++ b/old_code_ci3/views/Medical/Store/stock_store_statement_data_excel.php @@ -0,0 +1,43 @@ + + + + + + + + + + + + + + + + + + + + + + + + + +
Item NamePur Pak.Pur CostCurrent Pak.Current Unit QtyTotal Sale Pak.Total Sale Unit QtyStock Cost
+

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 ?>

diff --git a/old_code_ci3/views/Medical/Store/store_stock_search.php b/old_code_ci3/views/Medical/Store/store_stock_search.php new file mode 100644 index 0000000..4bffa71 --- /dev/null +++ b/old_code_ci3/views/Medical/Store/store_stock_search.php @@ -0,0 +1,143 @@ +
+'form','class'=>'form2')); ?> +
+
+ +
+
+
+ +
+
+
+ + + + + + + + + + +
+
+ +
+
+ \ No newline at end of file diff --git a/old_code_ci3/views/Medical/Store_Dashboard.php b/old_code_ci3/views/Medical/Store_Dashboard.php new file mode 100644 index 0000000..42b94f4 --- /dev/null +++ b/old_code_ci3/views/Medical/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/Storestock/drug_master_list.php b/old_code_ci3/views/Medical/Storestock/drug_master_list.php new file mode 100644 index 0000000..718dff1 --- /dev/null +++ b/old_code_ci3/views/Medical/Storestock/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/Storestock/product_edit.php b/old_code_ci3/views/Medical/Storestock/product_edit.php new file mode 100644 index 0000000..d9008ea --- /dev/null +++ b/old_code_ci3/views/Medical/Storestock/product_edit.php @@ -0,0 +1,255 @@ +
+
+
+ 'form','class'=>'form1')); ?> +
+
+

Product

+ item_name?> +
+
+ + +
+
+
+
+ + ion_auth->in_group('MedicalStoreAdmin'))?'':'readonly'; ?>> +
+
+
+
+ + + +
+
+
+
+ + +
+
+
+
+
+ + +
+
+
+
+ + +
+
+ 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=""; + } + + + + ?> +
+
+ +
+
+
+
+ + +
+
+
+
+ + +
+
+ +
+
+ + +
+
+
+
+ + +
+
+
+
+ + +
+
+
+
+ + +
+
+
+ + +
+
+
+ +
+ +
+
+ + \ No newline at end of file diff --git a/old_code_ci3/views/Medical/Storestock/product_new.php b/old_code_ci3/views/Medical/Storestock/product_new.php new file mode 100644 index 0000000..d21a7a1 --- /dev/null +++ b/old_code_ci3/views/Medical/Storestock/product_new.php @@ -0,0 +1,167 @@ +
+
+
+ 'form','class'=>'form1')); ?> +
+
+

Product

+ New Product +
+
+ + +
+
+
+
+ + +
+
+
+
+
+
+
+
+ + +
+
+
+
+ + +
+
+
+ + +
+
+
+
+ + +
+
+
+
+
+
+ + +
+
+
+
+ + +
+
+
+
+ + +
+
+
+
+
+
+ + +
+
+
+
+ + +
+
+
+
+ + +
+
+
+ + +
+
+
+ +
+ +
+
+ \ No newline at end of file diff --git a/old_code_ci3/views/Medical/Storestock/product_search_result.php b/old_code_ci3/views/Medical/Storestock/product_search_result.php new file mode 100644 index 0000000..4dfcc62 --- /dev/null +++ b/old_code_ci3/views/Medical/Storestock/product_search_result.php @@ -0,0 +1,51 @@ +
+
+
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Prod. IDNameFormulationGeneric NamePacking Type
id ?>item_name ?>formulation ?>genericname ?>packing ?> + + +
Prod. IDNameFormulationGeneric NamePacking Type
+ +
+
+
+ + \ No newline at end of file diff --git a/old_code_ci3/views/Medical/Supplier_Edit.php b/old_code_ci3/views/Medical/Supplier_Edit.php new file mode 100644 index 0000000..39592ea --- /dev/null +++ b/old_code_ci3/views/Medical/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/Supplier_master.php b/old_code_ci3/views/Medical/Supplier_master.php new file mode 100644 index 0000000..db90a1f --- /dev/null +++ b/old_code_ci3/views/Medical/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/Supplier_master_sub.php b/old_code_ci3/views/Medical/Supplier_master_sub.php new file mode 100644 index 0000000..a5551df --- /dev/null +++ b/old_code_ci3/views/Medical/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/check_med_invoice.php b/old_code_ci3/views/Medical/check_med_invoice.php new file mode 100644 index 0000000..d17470e --- /dev/null +++ b/old_code_ci3/views/Medical/check_med_invoice.php @@ -0,0 +1,104 @@ +
+

+ 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: + +
+ + + +

+
+ +
+
+
+
+
+
+ +
+
+
+
+ +
+
+ +
diff --git a/old_code_ci3/views/Medical/invoice_master_edit.php b/old_code_ci3/views/Medical/invoice_master_edit.php new file mode 100644 index 0000000..42ca3e6 --- /dev/null +++ b/old_code_ci3/views/Medical/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/mini_invoice.php b/old_code_ci3/views/Medical/mini_invoice.php new file mode 100644 index 0000000..c52be4f --- /dev/null +++ b/old_code_ci3/views/Medical/mini_invoice.php @@ -0,0 +1,62 @@ +
+

+ Already created on today + + Add New Invoice + +

+
+
+
+
+ + $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 ''; + echo ''; + + $inv_id=$row->inv_id; + } + ?> +
#'.$row->inv_med_code.''.$row->inv_date.''.$row->net_amount.'Edit
#ItemBat./Exp.DtRateQtyN.Amt.
'.$srno.''.$row->item_Name.''.$row->batch_no.'
'.$row->exp_date.'
'.$row->price.''.$row->qty.''.$row->twdisc_amount.'
+ +
+
+
diff --git a/old_code_ci3/views/Medical/new_purchase_invoice.php b/old_code_ci3/views/Medical/new_purchase_invoice.php new file mode 100644 index 0000000..3e430d2 --- /dev/null +++ b/old_code_ci3/views/Medical/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/payment_edit.php b/old_code_ci3/views/Medical/payment_edit.php new file mode 100644 index 0000000..36db8a5 --- /dev/null +++ b/old_code_ci3/views/Medical/payment_edit.php @@ -0,0 +1,208 @@ +
+
+
+
+

+ 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/payment_log.php b/old_code_ci3/views/Medical/payment_log.php new file mode 100644 index 0000000..917abf1 --- /dev/null +++ b/old_code_ci3/views/Medical/payment_log.php @@ -0,0 +1,80 @@ +
+

+ Payment Log + Panel +

+
+
+ 'form_payment_log','role'=>'form')); ?> +
+
+ +
+   + +
+ +
+
+ +
+ +
+
+
+ +
+
+
+
+
+ +
+ \ No newline at end of file diff --git a/old_code_ci3/views/Medical/payment_log_data.php b/old_code_ci3/views/Medical/payment_log_data.php new file mode 100644 index 0000000..86bc98f --- /dev/null +++ b/old_code_ci3/views/Medical/payment_log_data.php @@ -0,0 +1,53 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
#Bill NoInvoice CodeBill TypeInsert Date TimeLog InsertUpdate LogAmount / New AmountLog TypeUpdate By
id; ?>Inv_code; ?>Bill_type; ?>insert_time; ?>log_insert; ?>update_log; ?>amount; ?>LOG_type; ?>update_by; ?>
+ \ No newline at end of file diff --git a/old_code_ci3/views/Medical/payment_search.php b/old_code_ci3/views/Medical/payment_search.php new file mode 100644 index 0000000..b7d4adb --- /dev/null +++ b/old_code_ci3/views/Medical/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/print_bill_on_uhid.php b/old_code_ci3/views/Medical/print_bill_on_uhid.php new file mode 100644 index 0000000..1ee4388 --- /dev/null +++ b/old_code_ci3/views/Medical/print_bill_on_uhid.php @@ -0,0 +1,88 @@ +
+

+ Report + Panel +

+
+
+
+
+ +
+   + +
+ +
+
+
+ + +
+ +
+
+ +
+ +
+
+
+ +
+
+
+
+
+
+ \ No newline at end of file diff --git a/old_code_ci3/views/Medical/purchase_invoice_item.php b/old_code_ci3/views/Medical/purchase_invoice_item.php new file mode 100644 index 0000000..468b73f --- /dev/null +++ b/old_code_ci3/views/Medical/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/purchase_supp_list.php b/old_code_ci3/views/Medical/purchase_supp_list.php new file mode 100644 index 0000000..ce4b75d --- /dev/null +++ b/old_code_ci3/views/Medical/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/sale_item_list_for_add.php b/old_code_ci3/views/Medical/sale_item_list_for_add.php new file mode 100644 index 0000000..dc1a5c7 --- /dev/null +++ b/old_code_ci3/views/Medical/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/supplier_list.php b/old_code_ci3/views/Medical/supplier_list.php new file mode 100644 index 0000000..734a017 --- /dev/null +++ b/old_code_ci3/views/Medical/supplier_list.php @@ -0,0 +1,30 @@ +
+ +'form','class'=>'form2')); ?> +
+ + + + + + + + + + +
+ +
+
+ \ No newline at end of file diff --git a/old_code_ci3/views/Medical_app/dash_main.php b/old_code_ci3/views/Medical_app/dash_main.php new file mode 100644 index 0000000..7e261d6 --- /dev/null +++ b/old_code_ci3/views/Medical_app/dash_main.php @@ -0,0 +1,41 @@ +session->userdata(); +?> +
+

+ +

+
+ +
+
+ +
+ +
+
+ +
diff --git a/old_code_ci3/views/Medical_app/index.php b/old_code_ci3/views/Medical_app/index.php new file mode 100644 index 0000000..2d2c005 --- /dev/null +++ b/old_code_ci3/views/Medical_app/index.php @@ -0,0 +1,378 @@ +session->all_userdata(); + +if (isset($session_set_value['remember_me']) && $session_set_value['remember_me'] == "1") { + $session_data = $this->session->userdata('logged_in'); + $login_status=1; +}else{ + $login_status=0; +} +?> + + + + + <?=H_Name?> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+load->view('Medical_app/dash_main'); + } else { ?> + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/old_code_ci3/views/Medical_app/ipd_panel.php b/old_code_ci3/views/Medical_app/ipd_panel.php new file mode 100644 index 0000000..40db403 --- /dev/null +++ b/old_code_ci3/views/Medical_app/ipd_panel.php @@ -0,0 +1,77 @@ + +
+
+
+ Current IPD List + +
+
+ + + + + + + + + + + + + + + + + + + + + +
IPD No. InfoAdmit /Discharge Dt
+ ipd_code?>
+ p_fname?>
+ str_age?> / xgender?>
+ pay_type?>

+ discount_group_2>0){ ?> + + + +
+ Admit Dt :admit_dt?>
+ Discharge Dt :discharge_dt?>
+ Net Amount : net_amount?>
+ Paid Amt. : payment_received?>
+ Balance. : payment_balance?> +
IPD No. InfoAdmit /Discharge Dt
+
+ +
+
+ + \ No newline at end of file diff --git a/old_code_ci3/views/Medical_app/ipd_panel_search.php b/old_code_ci3/views/Medical_app/ipd_panel_search.php new file mode 100644 index 0000000..69ffced --- /dev/null +++ b/old_code_ci3/views/Medical_app/ipd_panel_search.php @@ -0,0 +1,58 @@ + +
+
+
+ IPD List Search + +
+
+
+
+ 'myform'); + echo form_open('Medical_app/ipd_search_data', $attributes); ?> +
+ +
+ +
+
+ +
+
+
+
+

Results

+
+
+
+
+ +
+
+
+
+
+ + \ No newline at end of file diff --git a/old_code_ci3/views/Medical_app/ipd_panel_sub.php b/old_code_ci3/views/Medical_app/ipd_panel_sub.php new file mode 100644 index 0000000..323137d --- /dev/null +++ b/old_code_ci3/views/Medical_app/ipd_panel_sub.php @@ -0,0 +1,53 @@ + + + + + + + + + + + + + + + + + + + + + +
IPD No. InfoAdmit /Discharge Dt
+ ipd_code?>
+ p_fname?>
+ str_age?> / xgender?>
+ pay_type?>

+ discount_group_2>0){ ?> + + + +
+ Admit Dt :admit_dt?>
+ Discharge Dt :discharge_dt?>
+ Net Amount : net_amount?>
+ Paid Amt. : payment_received?>
+ Balance. : payment_balance?> +
IPD No. InfoAdmit /Discharge Dt
+
+ \ No newline at end of file diff --git a/old_code_ci3/views/Medical_app/login.php b/old_code_ci3/views/Medical_app/login.php new file mode 100644 index 0000000..f14b1d4 --- /dev/null +++ b/old_code_ci3/views/Medical_app/login.php @@ -0,0 +1,76 @@ +"; + echo $logout_message; + echo ""; + } +?> + +"; + echo $message_display; + echo ""; + } + +?> + + 'myform'); + echo form_open('Medical_app/login/'.$user_id,$attributes); ?> +
+

Welcome

+

+ User : first_name); ?> last_name); ?> +

+

+ username; ?> +

+
+
+
+
+
+
+
+
+
+ + +
+
+
+ Remember Me +
+
+ +
+
+ "; + if (isset($error_message)) { + echo $error_message; + } + echo validation_errors(); + echo "
"; + ?> +
+ + + \ No newline at end of file diff --git a/old_code_ci3/views/Medical_app/select_doctor.php b/old_code_ci3/views/Medical_app/select_doctor.php new file mode 100644 index 0000000..b15dc55 --- /dev/null +++ b/old_code_ci3/views/Medical_app/select_doctor.php @@ -0,0 +1,20 @@ + 'myform'); + echo form_open('Medical_app/login_pin',$attributes); ?> +
+

Select Your Self for Login

+ +
+ diff --git a/old_code_ci3/views/Mobile_app/dash_main.php b/old_code_ci3/views/Mobile_app/dash_main.php new file mode 100644 index 0000000..270135c --- /dev/null +++ b/old_code_ci3/views/Mobile_app/dash_main.php @@ -0,0 +1,76 @@ +session->userdata('logged_in'); +?> +
+

+ Dr. +

+

+ + All Patient +

+
+ +
+
+ +
+
+
+ +
+
+
+ +
+ diff --git a/old_code_ci3/views/Mobile_app/index.php b/old_code_ci3/views/Mobile_app/index.php new file mode 100644 index 0000000..759db16 --- /dev/null +++ b/old_code_ci3/views/Mobile_app/index.php @@ -0,0 +1,365 @@ +session->all_userdata(); + +if (isset($session_set_value['remember_me']) && $session_set_value['remember_me'] == "1") { + $session_data = $this->session->userdata('logged_in'); + $login_status=1; +}else{ + $login_status=0; +} +?> + + + + + <?=H_Name?> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+load->view('Mobile_app/dash_main'); + } else { ?> + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/old_code_ci3/views/Mobile_app/ipd_panel.php b/old_code_ci3/views/Mobile_app/ipd_panel.php new file mode 100644 index 0000000..3f4673f --- /dev/null +++ b/old_code_ci3/views/Mobile_app/ipd_panel.php @@ -0,0 +1,41 @@ + + + +
+
+
+ + title.' '.$c->p_fname ; ?>
{p_relative?> p_rname?>} +
+
+
+

Age : str_age; ?>

+

p_code; ?>

+

+ + + mphone1; ?> + + +

+ + OPD View +
+
+ profile_picture,'/uploads/',1) ; + $profile_file_path=substr($c->profile_picture,$pos); + ?> + ' +
+
+
+
+ \ No newline at end of file diff --git a/old_code_ci3/views/Mobile_app/login.php b/old_code_ci3/views/Mobile_app/login.php new file mode 100644 index 0000000..8e8c5b9 --- /dev/null +++ b/old_code_ci3/views/Mobile_app/login.php @@ -0,0 +1,76 @@ +"; + echo $logout_message; + echo ""; + } +?> + +"; + echo $message_display; + echo ""; + } + +?> + + 'myform'); + echo form_open('Mobile_app/login/'.$doc_id,$attributes); ?> +
+

Welcome

+

+ Dr. p_fname); ?> +

+

+ SpecName; ?> +

+
+
+
+
+
+
+
+
+
+ + +
+
+
+ Remember Me +
+
+ +
+
+ "; + if (isset($error_message)) { + echo $error_message; + } + echo validation_errors(); + echo "
"; + ?> +
+ + + \ No newline at end of file diff --git a/old_code_ci3/views/Mobile_app/opd_scan.php b/old_code_ci3/views/Mobile_app/opd_scan.php new file mode 100644 index 0000000..9aaaae7 --- /dev/null +++ b/old_code_ci3/views/Mobile_app/opd_scan.php @@ -0,0 +1,98 @@ + + +
+
+
+ + title.' '.$c->p_fname ; ?>
{p_relative?> p_rname?>} +
+
+
+

str_age; ?>

+

p_code; ?>

+

+ + + mphone1; ?> + + + mphone1; ?> +

+ + View +
+
+ profile_picture,'/uploads/',1) ; + $profile_file_path=substr($c->profile_picture,$pos); + ?> + ' +
+ 'opd_form'); + echo form_open_multipart('/Opd/save_image_mobile/'.$opd_id,$attributes ); + ?> +
+ +
+ + +
+
+ +
+
+ +
+
+
+ + \ No newline at end of file diff --git a/old_code_ci3/views/Mobile_app/opd_scan1.php b/old_code_ci3/views/Mobile_app/opd_scan1.php new file mode 100644 index 0000000..021242b --- /dev/null +++ b/old_code_ci3/views/Mobile_app/opd_scan1.php @@ -0,0 +1,160 @@ + + +
+
+
+ + title.' '.$c->p_fname ; ?>
{p_relative?> p_rname?>} +
+
+
+

str_age; ?>

+

p_code; ?>

+

+ + + mphone1; ?> + + + mphone1; ?> +

+ + View +
+
+ profile_picture,'/uploads/',1) ; + $profile_file_path=substr($c->profile_picture,$pos); + ?> + ' +
+ 'opd_form'); + echo form_open_multipart('/Opd/save_image_mobile/'.$opd_id,$attributes ); + ?> +
+ +
+ + + +
+
+ +
+
+ +
+
+
+ + \ No newline at end of file diff --git a/old_code_ci3/views/Mobile_app/patient_opd_profile.php b/old_code_ci3/views/Mobile_app/patient_opd_profile.php new file mode 100644 index 0000000..8d9e60d --- /dev/null +++ b/old_code_ci3/views/Mobile_app/patient_opd_profile.php @@ -0,0 +1,138 @@ +0) +{ + $c=$data[0]; +?> + +
+
+
+ + title.' '.$c->p_fname ; ?>
{p_relative?> p_rname?>} +
+
+
+

str_age; ?>

+

p_code; ?>

+

+ + + mphone1; ?> + + + mphone1; ?> +

+ + View +
+
+ profile_picture,'/uploads/',1) ; + $profile_file_path=substr($c->profile_picture,$pos); + ?> + ' +
+
+
+
+
+ +
    + +
  • + + 10 Feb. 2014 + +
  • + + +
  • + + +
    + 12:05 + +

    Support Team sent you an email

    + +
    + Etsy doostang zoodles disqus groupon greplin oooj voxy zoodles, + weebly ning heekya handango imeem plugg dopplr jibjab, movity + jajah plickers sifteo edmodo ifttt zimbra. Babblely odeo kaboodle + quora plaxo ideeli hulu weebly balihoo... +
    + +
    +
  • + + +
  • + + +
    + 5 mins ago + +

    Sarah Young accepted your friend request +

    +
    +
  • + + +
  • + + +
    + 27 mins ago + +

    Jay White commented on your post

    + +
    + Take me to your leader! + Switzerland is small and neutral! + We are more like Germany, ambitious and misunderstood! +
    + +
    +
  • + + +
  • + + 3 Jan. 2014 + +
  • + + +
  • + + +
    + 2 days ago + +

    Mina Lee uploaded new photos

    + +
    + ... + ... + ... + ... +
    +
    +
  • + +
  • + +
  • +
+
+ + \ No newline at end of file diff --git a/old_code_ci3/views/Mobile_app/patient_page.php b/old_code_ci3/views/Mobile_app/patient_page.php new file mode 100644 index 0000000..e4d9fed --- /dev/null +++ b/old_code_ci3/views/Mobile_app/patient_page.php @@ -0,0 +1,70 @@ +
+
+ 'myform'); + echo form_open('Mobile_app/patient_search',$attributes); ?> + + +
+ +
+ +
+
+ +
+
+
+
+

Results

+
+
+
+
+ load->view($_view); + ?> +
+
+ \ No newline at end of file diff --git a/old_code_ci3/views/Mobile_app/patient_search_v.php b/old_code_ci3/views/Mobile_app/patient_search_v.php new file mode 100644 index 0000000..c1273ee --- /dev/null +++ b/old_code_ci3/views/Mobile_app/patient_search_v.php @@ -0,0 +1,49 @@ + + +
+
+
+ + title.' '.$c->p_fname ; ?> + / Age:str_age; ?> +
{p_relative?> p_rname?>} +
+
+
+

p_code; ?>

+

+ + + mphone1; ?> + + +

+ + View + opd_today=='0'){?> +

Today Visit : opd_today; ?> +
Dr. doc_name; ?> +

+ + Scan + +
+
+

Last Visit last_date_visit; ?>

+ profile_picture,'/uploads/',1) ; + $profile_file_path=substr($c->profile_picture,$pos); + ?> + ' +
+
+
+
+ \ No newline at end of file diff --git a/old_code_ci3/views/Mobile_app/person_file_show.php b/old_code_ci3/views/Mobile_app/person_file_show.php new file mode 100644 index 0000000..e6bfc25 --- /dev/null +++ b/old_code_ci3/views/Mobile_app/person_file_show.php @@ -0,0 +1,206 @@ + + 0) + { + $opd_current=$opd_master_current[0]->opd_id; + } + ?> +
+
+
+ + title.' '.$c->p_fname ; ?>
{p_relative?> p_rname?>} +
+
+
+

str_age; ?>

+

p_code; ?>

+

+ + + mphone1; ?> + + + mphone1; ?> +

+ + View + 0){?> + + Scan [Today] + +
+
+ profile_picture,'/uploads/',1) ; + $profile_file_path=substr($c->profile_picture,$pos); + ?> + ' +
+
+
+
+ opd_id"; + $query = $this->db->query($sql); + $opd_data= $query->result(); + + $sql="select * from file_upload_data where show_type=0 and opd_id=$row->opd_id order by id"; + $query = $this->db->query($sql); + $opd_file_list= $query->result(); + + $sql="select * from file_opd_rec where opd_id=$row->opd_id order by id"; + $query = $this->db->query($sql); + $file_opd_rec= $query->result(); + + if(count($opd_data)>0) + { + echo '
+
+
+
+
'; + echo '
+
'; + + echo 'OPD ID :'.$opd_data[0]->opd_code.' /Doctor Name :Dr. '.$opd_data[0]->doc_name; + echo '/OPD Date :'.$opd_data[0]->str_date_opd_visit.' /Queue No.:'.$opd_data[0]->queue_no.'
'; + + if($opd_data[0]->bp!='') + { + echo 'BP : '.$opd_data[0]->bp.' '; + } + + if($opd_data[0]->diastolic!='') + { + echo 'Diastolic : '.$opd_data[0]->diastolic.' '; + } + + if($opd_data[0]->pulse!='') + { + echo 'Pulse : '.$opd_data[0]->pulse.' '; + } + + if($opd_data[0]->temp!='') + { + echo 'Temp. : '.$opd_data[0]->temp.' '; + } + + echo ' + Scan ['.$opd_data[0]->str_date_opd_visit.'] '; + + echo '
+
'; + + + + } + + $i=0; + //Files Show + foreach($opd_file_list as $opd_file_row) + { + $i=$i+1; + echo '
+
'; + $pos=strpos($opd_file_row->full_path,'/uploads/',1) ; + $file_path=substr($opd_file_row->full_path,$pos); + + //$file_path=str_replace('hms_uploads','uploads',$opd_file_row->full_path); + + if($opd_file_row->file_ext=='.pdf') + { + echo ''; + }else + { + echo 'Photo'; + } + + echo '
+
'; + } + + //OPD Movies Show + foreach($file_opd_rec as $file_opd_rec_row) + { + echo '
+
'; + + $pos=strpos($file_opd_rec_row->full_path,'uploads/',1) ; + $file_path=substr($file_opd_rec_row->full_path,$pos); + + + //$file_path=str_replace('hms_uploads','uploads',$file_opd_rec_row->full_path); + + echo ' '; + + echo '
+
'; + } + + + } + ?> + + + + + \ No newline at end of file diff --git a/old_code_ci3/views/PathLab_Report/lab_report_edit_request.php b/old_code_ci3/views/PathLab_Report/lab_report_edit_request.php new file mode 100644 index 0000000..8c17563 --- /dev/null +++ b/old_code_ci3/views/PathLab_Report/lab_report_edit_request.php @@ -0,0 +1,49 @@ +'form','class'=>'form_reason')); ?> + +
+
+ + +
+
+
+
+ + +
+
+
+ +
+ + + \ No newline at end of file diff --git a/old_code_ci3/views/PathLab_Report/lab_report_file_show.php b/old_code_ci3/views/PathLab_Report/lab_report_file_show.php new file mode 100644 index 0000000..cf5ce36 --- /dev/null +++ b/old_code_ci3/views/PathLab_Report/lab_report_file_show.php @@ -0,0 +1,59 @@ +
+
+ +
diff --git a/old_code_ci3/views/PathLab_Report/lab_report_item_edit.php b/old_code_ci3/views/PathLab_Report/lab_report_item_edit.php new file mode 100644 index 0000000..17f1ae3 --- /dev/null +++ b/old_code_ci3/views/PathLab_Report/lab_report_item_edit.php @@ -0,0 +1,376 @@ +0) + { + $mstTestKey=$lab_test_parameter[0]->mstTestKey; + $Test=$lab_test_parameter[0]->Test; + $TestID=$lab_test_parameter[0]->TestID; + $Result=$lab_test_parameter[0]->Result; + $Formula=$lab_test_parameter[0]->Formula; + $VRule=$lab_test_parameter[0]->VRule; + $VMsg=$lab_test_parameter[0]->VMsg; + $Unit=$lab_test_parameter[0]->Unit; + $FixedNormals=$lab_test_parameter[0]->FixedNormals; + $isGenderSpecific=$lab_test_parameter[0]->isGenderSpecific; + $FixedNormalsWomen=$lab_test_parameter[0]->FixedNormalsWomen; + + if($isGenderSpecific==1) + { + $checkbox_checked="checked"; + } + + + } +?> + +
+
+

Test Parameter

+
+ +
+
+
+
+ + + + +
+
+
+
+ + +
+
+
+
+
+
+ + +
+
+
+
+ + +
+
+
+
+
+
+ + +
+
+
+
+ + +
+
+
+
+
+
+ + +
+
+
+
+ + +
+
+
+
+
+
+ +
+
+
+
+ + +
+
+
+
+
+
+ + + + + + + + + + + + + + + + + + + +
#CodeBoldAction
sort_id ?>option_value ?>option_bold_str ?> +
+ + id; + $sort_current=$lab_test_option[$i]->sort_id; + + if($i+1 < count($lab_test_option)) + { + $option_next=$lab_test_option[$i+1]->id; + $sort_next=$lab_test_option[$i+1]->sort_id; + + echo ''; + } + if($i>0) + { + $option_prev=$lab_test_option[$i-1]->id; + $sort_prev=$lab_test_option[$i-1]->sort_id; + + echo ''; + + } + ?> +
+
+
+
+
+
+ + +
+
+
+
+
+
+ +
+
+ +
+
+
+
+ + +
+
+
+
+
+
+
+ + +
+
+
+
+ + +
+
+
+
+ +
+
+
+
+
+
+ +
+ + diff --git a/old_code_ci3/views/PathLab_Report/lab_report_list.php b/old_code_ci3/views/PathLab_Report/lab_report_list.php new file mode 100644 index 0000000..eb4a31c --- /dev/null +++ b/old_code_ci3/views/PathLab_Report/lab_report_list.php @@ -0,0 +1,60 @@ +
+

+ Test Name +

+
+
+
+
+
+
+ +

Report List

+
+
+ +
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + +
Report TitleGroupAction
Title ?>RepoGrp ?> + + +
Report TitleGroupAction
+ +
+ +
+
+
+ +
+
+
+ + \ No newline at end of file diff --git a/old_code_ci3/views/PathLab_Report/lab_report_print.php b/old_code_ci3/views/PathLab_Report/lab_report_print.php new file mode 100644 index 0000000..1b92aa8 --- /dev/null +++ b/old_code_ci3/views/PathLab_Report/lab_report_print.php @@ -0,0 +1,105 @@ +
+
+
+

IPD List

+
+
+ + + + + + + + + + + + + + + + + + + + + + + + + +
Invoice No./DatePerson NameTest NameTest Type
+
+ +
+
+ + \ No newline at end of file diff --git a/old_code_ci3/views/PathLab_Report/lab_report_show.php b/old_code_ci3/views/PathLab_Report/lab_report_show.php new file mode 100644 index 0000000..a112cc4 --- /dev/null +++ b/old_code_ci3/views/PathLab_Report/lab_report_show.php @@ -0,0 +1,55 @@ +
+ diff --git a/old_code_ci3/views/PathLab_Report/lab_report_tab_1.php b/old_code_ci3/views/PathLab_Report/lab_report_tab_1.php new file mode 100644 index 0000000..e35791b --- /dev/null +++ b/old_code_ci3/views/PathLab_Report/lab_report_tab_1.php @@ -0,0 +1,74 @@ +
+
+
+
+

Report List

+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Invoice No.Person NameDateTests Name
invoice_code ?>inv_name ?> / age ?>inv_date ?> + data_array); + echo ''; + foreach ($data_array as $value) { + echo ''; + $value_array=explode(";",$value); + + echo ''; + + echo ''; + } + echo '
'; + ?> +
Invoice No.Person NameDateTests Name
+
+ +
+
+
+ \ No newline at end of file diff --git a/old_code_ci3/views/PathLab_Report/lab_report_tab_1_1.php b/old_code_ci3/views/PathLab_Report/lab_report_tab_1_1.php new file mode 100644 index 0000000..6b659a5 --- /dev/null +++ b/old_code_ci3/views/PathLab_Report/lab_report_tab_1_1.php @@ -0,0 +1,142 @@ +
+
+
+
+

Report List

+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + +
Invoice No.CustomersCodeTest NameTest TypeBalance
+
+ +
+
+
+ + \ No newline at end of file diff --git a/old_code_ci3/views/PathLab_Report/lab_report_tab_2.php b/old_code_ci3/views/PathLab_Report/lab_report_tab_2.php new file mode 100644 index 0000000..892086a --- /dev/null +++ b/old_code_ci3/views/PathLab_Report/lab_report_tab_2.php @@ -0,0 +1,170 @@ +
+
+
+
+

Report List

+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + +
Invoice No./DatePerson NameTest Name
invoice_code ?> +
+ inv_date ?> +
inv_name ?> + data_array); + echo ''; + foreach ($data_array as $value) { + echo ''; + $value_array=explode(";",$value); + echo ''; + echo ''; + + echo ' + '; + + echo ' + '; + + + echo ' + '; + echo ''; + } + echo '
'.$value_array[0].'
'; + ?> +
Invoice No./DatePerson NameTest Name
+ +
+ +
+
+ +
+ + \ No newline at end of file diff --git a/old_code_ci3/views/PathLab_Report/lab_report_tab_2_1.php b/old_code_ci3/views/PathLab_Report/lab_report_tab_2_1.php new file mode 100644 index 0000000..a98388e --- /dev/null +++ b/old_code_ci3/views/PathLab_Report/lab_report_tab_2_1.php @@ -0,0 +1,209 @@ +
+
+
+
+

Report List

+
+ +
+ + + + + + + + + + + + + + + + + + + + + + +
Invoice No.CustomersCodeAgeDateTest Name
+
+ +
+
+
+ + + \ No newline at end of file diff --git a/old_code_ci3/views/PathLab_Report/lab_report_tab_3.php b/old_code_ci3/views/PathLab_Report/lab_report_tab_3.php new file mode 100644 index 0000000..f748a26 --- /dev/null +++ b/old_code_ci3/views/PathLab_Report/lab_report_tab_3.php @@ -0,0 +1,126 @@ +
+
+
+
+

Report List

+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Invoice No./DatePerson NameTest Name
invoice_code ?> +
+ inv_date ?> +
inv_name ?> + data_array); + echo ''; + foreach ($data_array as $value) { + echo ''; + $value_array=explode(";",$value); + echo ''; + echo ''; + echo ' + '; + echo ''; + } + echo '
'.$value_array[0].'
'; + + ?> +
Invoice No./DatePerson NameTest Name
+ +
+ +
+
+
+ + \ No newline at end of file diff --git a/old_code_ci3/views/PathLab_Report/lab_report_tab_4.php b/old_code_ci3/views/PathLab_Report/lab_report_tab_4.php new file mode 100644 index 0000000..a273549 --- /dev/null +++ b/old_code_ci3/views/PathLab_Report/lab_report_tab_4.php @@ -0,0 +1,129 @@ +
+
+
+
+

Report List

+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Invoice No./DatePerson NameTest NameTest Type
invoice_code ?> +
+ inv_date ?> +
inv_name ?>Test_List ?>item_type_desc ?> + + + + +
Invoice No./DatePerson NameTest NameCharge Type
+
+ +
+
+
+ + \ No newline at end of file diff --git a/old_code_ci3/views/PathLab_Report/lab_report_tab_4_1.php b/old_code_ci3/views/PathLab_Report/lab_report_tab_4_1.php new file mode 100644 index 0000000..8227b7d --- /dev/null +++ b/old_code_ci3/views/PathLab_Report/lab_report_tab_4_1.php @@ -0,0 +1,182 @@ +
+
+
+
+

Report List

+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Invoice No.CustomersCodeAgeTest NameTest TypeBalance
+
+ +
+
+
+ + + \ No newline at end of file diff --git a/old_code_ci3/views/PathLab_Report/lab_report_tab_4_2.php b/old_code_ci3/views/PathLab_Report/lab_report_tab_4_2.php new file mode 100644 index 0000000..8d72b64 --- /dev/null +++ b/old_code_ci3/views/PathLab_Report/lab_report_tab_4_2.php @@ -0,0 +1,28 @@ +
+'form','class'=>'form2')); ?> + +
+ + + + +
+ +
+ +
+ + \ No newline at end of file diff --git a/old_code_ci3/views/PathLab_Report/lab_report_test_list.php b/old_code_ci3/views/PathLab_Report/lab_report_test_list.php new file mode 100644 index 0000000..006830f --- /dev/null +++ b/old_code_ci3/views/PathLab_Report/lab_report_test_list.php @@ -0,0 +1,103 @@ + +
+
+

Test List

+
+
+ +
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + +
#Test NameTest CodeAction
Test ?>TestID ?> +
+ + + id; + $sort_current=$lab_Rep_Item_List[$i]->EOrder; + + if($i+1 < count($lab_Rep_Item_List)) + { + $option_next=$lab_Rep_Item_List[$i+1]->id; + $sort_next=$lab_Rep_Item_List[$i+1]->EOrder; + + echo ''; + } + if($i>0) + { + $option_prev=$lab_Rep_Item_List[$i-1]->id; + $sort_prev=$lab_Rep_Item_List[$i-1]->EOrder; + + echo ''; + + } + ?> +
+
#Test NameTest CodeAction
+
+ +
+ + \ No newline at end of file diff --git a/old_code_ci3/views/PathLab_Report/lab_test_entry.php b/old_code_ci3/views/PathLab_Report/lab_test_entry.php new file mode 100644 index 0000000..1d76657 --- /dev/null +++ b/old_code_ci3/views/PathLab_Report/lab_test_entry.php @@ -0,0 +1,131 @@ + + +
+
+

Patient Name :patient_name ?>

+ / invoice_code ?> +
+ +
+ 0) { ?> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Test Name/Test IDSaved ValueNew ValueFixedNormals
Test ?>[TestID ?>] + Formula)<>''){ + echo '
'.trim($lab_request_item_entry[$i]->Formula); + echo ''; + } + ?> + +
lab_test_value ?>
+ option_value != null) + { + echo ""; + echo ''; + }else{ + if(trim($lab_request_item_entry[$i]->Formula)<>''){ + echo 'After Calculate'; + //echo ''; + }else{ + echo ''; + } + } + + ?> + + FixedNormals ?> + + +
Test Name/Test IDSaved ValueNew ValueFixedNormals
+
+ +
+
+ +
+
+
+ +
+
+ + \ No newline at end of file diff --git a/old_code_ci3/views/PathLab_Report/lab_test_search.php b/old_code_ci3/views/PathLab_Report/lab_test_search.php new file mode 100644 index 0000000..ef65d29 --- /dev/null +++ b/old_code_ci3/views/PathLab_Report/lab_test_search.php @@ -0,0 +1,70 @@ + +
+
+

Test Parameter

+ + +
+ +
+
+
+
+ + +
+
+
+
+ + +
+
+
+
+
+ +
+
+
+
+ + diff --git a/old_code_ci3/views/PathLab_Report/pathlab_request_list.php b/old_code_ci3/views/PathLab_Report/pathlab_request_list.php new file mode 100644 index 0000000..93d349a --- /dev/null +++ b/old_code_ci3/views/PathLab_Report/pathlab_request_list.php @@ -0,0 +1,45 @@ +
+

+ Lab Panel +

+ +
+
+
+
+ +
+
+ +
+ \ 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 new file mode 100644 index 0000000..33c82a8 --- /dev/null +++ b/old_code_ci3/views/PathLab_Report/ultrasound_report_edit.php @@ -0,0 +1,146 @@ + +
+
+

Radiology Report Edit

+
+ +
+
+ +
+
+
+
+ + 0) + { + $repo_id=$labReport_master[0]->id; + $repo_name=$labReport_master[0]->template_name; + $repo_title=$labReport_master[0]->title; + $HTMLData=$labReport_master[0]->Findings; + $Impression=$labReport_master[0]->Impression; + $impression_cat=$labReport_master[0]->impression_cat; + } + ?> + + +
+
+
+
+ + +
+
+
+
+ + +
+
+
+
+
+
+ + + +
+
+
+
+
+ + +
+
+
+
+
+
+ + +
+
+
+ +
+
+ + \ No newline at end of file diff --git a/old_code_ci3/views/PathLab_Report/ultrasound_template_list.php b/old_code_ci3/views/PathLab_Report/ultrasound_template_list.php new file mode 100644 index 0000000..93c8e21 --- /dev/null +++ b/old_code_ci3/views/PathLab_Report/ultrasound_template_list.php @@ -0,0 +1,59 @@ +
+

+ Ultra Sound Template +

+
+
+
+
+
+
+ +

Report List

+
+
+ +
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + +
Report TitleGroupAction
template_name ?>title ?> + +
Report TitleGroupAction
+ +
+ +
+
+
+ +
+
+ +
+ \ No newline at end of file diff --git a/old_code_ci3/views/Patient_Search_V.php b/old_code_ci3/views/Patient_Search_V.php new file mode 100644 index 0000000..92aef55 --- /dev/null +++ b/old_code_ci3/views/Patient_Search_V.php @@ -0,0 +1,45 @@ +

+
+
+

Result

+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Sr.No.Patient/UHID CodeName {Relative Name}AgeLast VisitInsurance
p_code ?>p_fname ?> {p_rname ?>}age ?>Last_Visit ?>insurance_id==0 ? 'Self': 'Insuranced'); ?>
Sr.No.Patient/UHID CodeName {Relative Name}AgeLast VisitInsurance
+
+ +
+ \ No newline at end of file diff --git a/old_code_ci3/views/Patient_Search_opd.php b/old_code_ci3/views/Patient_Search_opd.php new file mode 100644 index 0000000..c050da8 --- /dev/null +++ b/old_code_ci3/views/Patient_Search_opd.php @@ -0,0 +1,51 @@ +

+
+
+

Result

+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
OPD No.Patient/UHID CodeName {Relative Name}AgeDoctorOPD DateInsurance
opd_code?>p_code ?>p_fname ?> {p_rname ?>}age ?>doc_name ?>opd_Visit ?>insurance_id==0 ? 'Self': $data[$i]->short_name); ?>
Sr.No.Patient/UHID CodeName {Relative Name}AgeDoctorOPD DateInsurance
+
+ +
+ + \ No newline at end of file diff --git a/old_code_ci3/views/Patient_V.php b/old_code_ci3/views/Patient_V.php new file mode 100644 index 0000000..157bdb2 --- /dev/null +++ b/old_code_ci3/views/Patient_V.php @@ -0,0 +1,458 @@ +
+

+ Person + Registration +

+ +
+ +
+
+
+ +
+
+
+ + + \ No newline at end of file diff --git a/old_code_ci3/views/Person/OPD_file_upload.php b/old_code_ci3/views/Person/OPD_file_upload.php new file mode 100644 index 0000000..7f79d60 --- /dev/null +++ b/old_code_ci3/views/Person/OPD_file_upload.php @@ -0,0 +1,114 @@ +
+
+

Name :p_fname?> + / Age :age?> + / Gender :xgender?> + / P Code :p_code?> + / OPD :opd_code?> +

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

Loading state

+
+
+
+ + +
+ + +
+ +
+
+
+
+
+
+ + + \ No newline at end of file diff --git a/old_code_ci3/views/Person/Person_Profile.php b/old_code_ci3/views/Person/Person_Profile.php new file mode 100644 index 0000000..1d0d34a --- /dev/null +++ b/old_code_ci3/views/Person/Person_Profile.php @@ -0,0 +1,177 @@ +0) + { + $opd_current=$opd_master_current[0]->opd_id; + } + ?> +
+

+ p_fname); ?> + p_code; ?> +

+
+
+
+
+ +
+
+ profile_picture,'/uploads/',1) ; + $profile_file_path=substr($c->profile_picture,$pos); + ?> + User profile picture +

title.' '.$c->p_fname ; ?>

+

p_relative?> p_rname?>

+ +
+ +
+ + +
+
+

About

+
+ +
+ Address +

+ p_address ?> +

+
+ +
+ +
+ +
+ + +
+ +
+ + + + +
+ diff --git a/old_code_ci3/views/Person/opd_file_show.php b/old_code_ci3/views/Person/opd_file_show.php new file mode 100644 index 0000000..12821f3 --- /dev/null +++ b/old_code_ci3/views/Person/opd_file_show.php @@ -0,0 +1,76 @@ +
+
+ +
diff --git a/old_code_ci3/views/Person/opd_scan_desktop.php b/old_code_ci3/views/Person/opd_scan_desktop.php new file mode 100644 index 0000000..e85064e --- /dev/null +++ b/old_code_ci3/views/Person/opd_scan_desktop.php @@ -0,0 +1,149 @@ +
+

+ OPD + Scan +

+
+
+
+
+
+
+ OPD Search +
+
+
+ 'form','class'=>'form2')); ?> +
+
+
+ + + + +
+
+
+ +
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Scan +
+
+
+
+
+
+
+ + +
+
+
Your captured image will appear here...
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+'form','class'=>'form1')); ?> +
+
+
+ + + \ No newline at end of file diff --git a/old_code_ci3/views/Person/opd_scan_search.php b/old_code_ci3/views/Person/opd_scan_search.php new file mode 100644 index 0000000..bdbbbfb --- /dev/null +++ b/old_code_ci3/views/Person/opd_scan_search.php @@ -0,0 +1,40 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
OPD CodeNameDoctor NamePhone NumberAction
opd_code ?>
[ App_Date ?> ]
p_fname ?>
{p_code ?>}
doc_name ?>mphone1 ?>
OPD CodeNameDoctor NamePhone NumberAction
+ + diff --git a/old_code_ci3/views/Person/opd_scanfile_upload.php b/old_code_ci3/views/Person/opd_scanfile_upload.php new file mode 100644 index 0000000..95192bd --- /dev/null +++ b/old_code_ci3/views/Person/opd_scanfile_upload.php @@ -0,0 +1,27 @@ +
+
+
+
Upload
+ + + +
+
+
+ diff --git a/old_code_ci3/views/Person/person_file_show.php b/old_code_ci3/views/Person/person_file_show.php new file mode 100644 index 0000000..173ab6a --- /dev/null +++ b/old_code_ci3/views/Person/person_file_show.php @@ -0,0 +1,181 @@ +
+

+ p_fname); ?> + p_code; ?> +

+
+ +
+ + + +
+
+
+ + title.' '.$c->p_fname ; ?>
{p_relative?> p_rname?>} +
+
+
+

str_age; ?>

+

p_code; ?>

+

+ + + mphone1; ?> + + + mphone1; ?> +

+ + View +
+
+ profile_picture,'/uploads/',1) ; + $profile_file_path=substr($c->profile_picture,$pos); + ?> + ' +
+
+
+
+ opd_id; + + if($opd_id!=$opd_id_new) + { + $sql="select p.*,o.opd_code,o.doc_name from opd_prescription p + join opd_master o on o.opd_id=p.opd_id + where p.opd_id=$opd_id_new"; + $query = $this->db->query($sql); + $opd_data= $query->result(); + + if(count($opd_data)>0) + { + echo '
+
+
+
+
'; + + echo '
+
'; + + echo 'OPD ID :'.$opd_data[0]->opd_code.' /Doctor Name :Dr. '.$opd_data[0]->doc_name; + echo '/OPD Date :'.$opd_data[0]->date_opd_visit.' /Queue No.:'.$opd_data[0]->queue_no.'
'; + + if($opd_data[0]->bp!='') + { + echo 'BP : '.$opd_data[0]->bp.' '; + } + + if($opd_data[0]->diastolic!='') + { + echo 'Diastolic : '.$opd_data[0]->diastolic.' '; + } + + if($opd_data[0]->pulse!='') + { + echo 'Pulse : '.$opd_data[0]->pulse.' '; + } + + if($opd_data[0]->temp!='') + { + echo 'Temp. : '.$opd_data[0]->temp.' '; + } + + echo '
+
'; + } + } + + $opd_id=$opd_id_new; + + echo '
+
'; + + $pos=strpos($opd_file_list[$i]->full_path,'/uploads/',1) ; + + $file_path=substr($opd_file_list[$i]->full_path,$pos); + + //$file_path=str_replace('hms_uploads','uploads',$opd_file_list[$i]->full_path); + + if($opd_file_list[$i]->file_ext=='.pdf') + { + echo ''; + }else + { + echo 'Photo'; + } + + echo '
+
'; + } + ?> +
+ +'; + + } +} +?> \ No newline at end of file diff --git a/old_code_ci3/views/Person_Edit_V.php b/old_code_ci3/views/Person_Edit_V.php new file mode 100644 index 0000000..b401a70 --- /dev/null +++ b/old_code_ci3/views/Person_Edit_V.php @@ -0,0 +1,349 @@ +
+

+ p_fname; ?> + p_code; ?> +

+ +
+p_edit==1 || $this->ion_auth->in_group('admin')){ + $readonly=""; +}else{ + $readonly="readonly"; +} +?> + +
+
+
+
+
+
+

Person Profile

+
+
+ 'form','class'=>'form1')); ?> + +
+
+
+ + +
+
+
+
+ + > +
+
+
+
+ +
+ + +
+
+
+
+
+ + +
+
+
+
+ + +
+
+
+
+ estimate_dob; + if($chk_age==1) + { + $checkbox_checked="checked"; + $age_input_2='style="display: none;"'; + $age_input_1=''; + $DateofBirth=''; + }else{ + $checkbox_checked=""; + $age_input_1='style="display: none;"'; + $age_input_2=''; + $DateofBirth=MysqlDate_to_str($data[0]->dob); + } + ?> +
+
+ +
+
+
> +
+
+ + + + + + + + + +
Year : + Month :
+
+
+
+
> +
+ +
+
+ +
+ +
+
+
+
+
+
+
+ + +
+
+
+
+ + +
+
+
+
+ + +
+
+
+
+ + +
+
+
+
+
+
+ + +
+
+
+
+ + +
+
+
+
+ + +
+
+
+
+
+
+ + +
+
+
+
+ + +
+
+
+
+
+ +
+
+ + +
+
+
+
+ +
+ + + \ No newline at end of file diff --git a/old_code_ci3/views/Person_profile_V.php b/old_code_ci3/views/Person_profile_V.php new file mode 100644 index 0000000..37edce3 --- /dev/null +++ b/old_code_ci3/views/Person_profile_V.php @@ -0,0 +1,359 @@ +
+

+ p_fname); ?> + p_code; ?> +

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

Person Profile

+
+ +
+
+ +
+
+

Full Name : p_fname) ?>

+
+
+

Gender : xgender?> + / Age : str_age?> +

+
+
+
+
+

Relation : p_relative?> + Relative Name : p_rname)?> +

+
+
+

Aadhar No. : udai?> +

+
+
+
+
+

Phone Number : mphone1?>

+
+
+

Email : email1?>

+
+
+

Blood Group : blood_group?>

+
+
+
+
+

Address : add1?> + city ?> + district ?> + state ?> + zip ?> +

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

Insurance Details + Insurance Update +

+
+ + +
+ insurance_id>0) { ?> +
+
+

Company Name : ins_company_name?>

+

Card Holder Name : card_holder_name?>

+

Relation : relation_patient_cardholder?>

+

Insurance ID : insurance_no?>

+
+
+
+ 0){ ?> +

Case Code : case_id_code?>

+

Visit Date Start : str_date_registration?>

+

Clam or Case No.: insurance_no_1?>

+

Any Other IDs : insurance_no_2?>

+

+ +

+ + + 0){ ?> + +

Case Code : case_id_code?>

+

Org. Date Start : str_date_registration?>

+

Clam or Case No.: insurance_no_1?>

+

Any Other IDs : insurance_no_2?>

+

IPD No : ipd_code?>

+

IPD Admit Date : str_date_registration?>

+

+ +

+ + + +
+ + +
+
+
+
+ opd_allowed==1) { ?> +

+ +

+ + charge_cash==1) { ?> +

+ +

+ +
+ +
+
+
+
+ + + + +
+
+
+
+ 0) { ?> +
+
+
+
+

OPD Registration

+
+
+ '.$row->opd_code.''; + echo '

'; + echo 'Dr.'.$row->doc_name.' '; + echo ' D:'.$row->str_apointment_date.' '; + echo ' P:'.$row->p_fname.'
'; + + if($this->ion_auth->in_group('OPDEdit') || $row->new_opd==1){ + echo 'Edit OPD '; + echo 'Print Day Care '; + } + echo '

'; + echo '
'; + } + ?> +
+
+
+
+ + 0) { ?> +
+
+
+
+

Charges Invoice

+
+
+ '.$row->invoice_code.''; + echo ' D:'.$row->str_inv_date.' '; + echo ' N:'.$row->inv_name.' '; + echo '

'; + echo ''.$row->Item_List.'
'; + + if($row->invoice_status==0) + { + echo 'Edit Charges Invoice '; + echo 'Delete : Un-confirm Invoice '; + }else{ + echo 'Show Charges Invoice '; + } + echo '

'; + echo '
'; + } + ?> + +
+
+
+
+ +
+
+ + +
+ + + \ No newline at end of file diff --git a/old_code_ci3/views/Person_profile_V_backup.php b/old_code_ci3/views/Person_profile_V_backup.php new file mode 100644 index 0000000..37edce3 --- /dev/null +++ b/old_code_ci3/views/Person_profile_V_backup.php @@ -0,0 +1,359 @@ +
+

+ p_fname); ?> + p_code; ?> +

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

Person Profile

+
+ +
+
+ +
+
+

Full Name : p_fname) ?>

+
+
+

Gender : xgender?> + / Age : str_age?> +

+
+
+
+
+

Relation : p_relative?> + Relative Name : p_rname)?> +

+
+
+

Aadhar No. : udai?> +

+
+
+
+
+

Phone Number : mphone1?>

+
+
+

Email : email1?>

+
+
+

Blood Group : blood_group?>

+
+
+
+
+

Address : add1?> + city ?> + district ?> + state ?> + zip ?> +

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

Insurance Details + Insurance Update +

+
+ + +
+ insurance_id>0) { ?> +
+
+

Company Name : ins_company_name?>

+

Card Holder Name : card_holder_name?>

+

Relation : relation_patient_cardholder?>

+

Insurance ID : insurance_no?>

+
+
+
+ 0){ ?> +

Case Code : case_id_code?>

+

Visit Date Start : str_date_registration?>

+

Clam or Case No.: insurance_no_1?>

+

Any Other IDs : insurance_no_2?>

+

+ +

+ + + 0){ ?> + +

Case Code : case_id_code?>

+

Org. Date Start : str_date_registration?>

+

Clam or Case No.: insurance_no_1?>

+

Any Other IDs : insurance_no_2?>

+

IPD No : ipd_code?>

+

IPD Admit Date : str_date_registration?>

+

+ +

+ + + +
+ + +
+
+
+
+ opd_allowed==1) { ?> +

+ +

+ + charge_cash==1) { ?> +

+ +

+ +
+ +
+
+
+
+ + + + +
+
+
+
+ 0) { ?> +
+
+
+
+

OPD Registration

+
+
+ '.$row->opd_code.''; + echo '

'; + echo 'Dr.'.$row->doc_name.' '; + echo ' D:'.$row->str_apointment_date.' '; + echo ' P:'.$row->p_fname.'
'; + + if($this->ion_auth->in_group('OPDEdit') || $row->new_opd==1){ + echo 'Edit OPD '; + echo 'Print Day Care '; + } + echo '

'; + echo '
'; + } + ?> +
+
+
+
+ + 0) { ?> +
+
+
+
+

Charges Invoice

+
+
+ '.$row->invoice_code.''; + echo ' D:'.$row->str_inv_date.' '; + echo ' N:'.$row->inv_name.' '; + echo '

'; + echo ''.$row->Item_List.'
'; + + if($row->invoice_status==0) + { + echo 'Edit Charges Invoice '; + echo 'Delete : Un-confirm Invoice '; + }else{ + echo 'Show Charges Invoice '; + } + echo '

'; + echo '
'; + } + ?> + +
+
+
+
+ +
+
+ + +
+ + + \ No newline at end of file diff --git a/old_code_ci3/views/Person_profile_V_test.php b/old_code_ci3/views/Person_profile_V_test.php new file mode 100644 index 0000000..a4aa9b3 --- /dev/null +++ b/old_code_ci3/views/Person_profile_V_test.php @@ -0,0 +1,683 @@ + + */ + +// Data validation and sanitization helper +function safe_output($data, $default = '') { + return !empty($data) ? htmlspecialchars($data, ENT_QUOTES, 'UTF-8') : $default; +} +?> + +
+
+
+

+ p_fname ?? ''), 'Unknown Patient'); ?> + + + p_code ?? '', 'No Code'); ?> + + +

+ +
+
+
+ + +
+ + + + +
+ + 'form','class'=>'form1', 'id'=>'person-profile-form')); ?> + +
+ +
+ +
+
+
+
+

+ Person Profile +

+
+
+
+ + + +
+
+
+
+ +
+ + + +
+
+
+ +
+ Full Name + + p_fname ?? ''), 'Not provided'); ?> + +
+
+
+ +
+
+ +
+ Gender + + xgender ?? '', 'Not specified'); ?> + +
+
+
+ +
+
+ +
+ Age + + str_age ?? '', 'Unknown'); ?> + +
+
+
+
+ + +
+
+

+ Phone Number: + + mphone1 ?? '', 'Not provided'); ?> + +

+
+
+

+ Email: + + email1 ?? '', 'Not provided'); ?> + +

+
+
+ + +
+
+

+ Relation: + + p_relative ?? '', 'Not specified'); ?> + + p_rname)): ?> + | Relative Name: + + p_rname)); ?> + + +

+
+
+

+ Blood Group: + + blood_group ?? '', 'Not specified'); ?> + +

+
+
+ + +
+
+

+ Address: + + add1 ?? '', + $data[0]->city ?? '', + $data[0]->district ?? '', + $data[0]->state ?? '', + $data[0]->zip ?? '' + ]); + echo !empty($address_parts) ? safe_output(implode(', ', $address_parts)) : 'Not provided'; + ?> + +

+
+
+ + +
+
+
+ Patient Photo +
+
+
+
+ +
+ + + + +
+ 12-digit Aadhar number +
+
+
+
+
+ + +
+
+

+ Insurance Details + + + +

+
+ + + + +
+ insurance_id) && $data[0]->insurance_id > 0): ?> + +
+
+

+ Company Name: + + ins_company_name ?? '', 'Not specified'); ?> + +

+

+ Card Holder Name: + + card_holder_name ?? '', 'Not specified'); ?> + +

+

+ Relation: + + relation_patient_cardholder ?? '', 'Not specified'); ?> + +

+

+ Insurance ID: + + insurance_no ?? '', 'Not specified'); ?> + +

+
+ +
+ + 0): ?> +
+
OPD Case Active
+

Case Code: case_id_code ?? ''); ?>

+

Visit Date: str_date_registration ?? ''); ?>

+ +
+ 0): ?> + +
+
IPD Case Active
+

Case Code: case_id_code ?? ''); ?>

+

IPD No: ipd_code ?? ''); ?>

+ +
+ +
+
Create New Case
+ + +
+ +
+
+ + +
+
+ opd_allowed) && $data_insurance_card[0]->opd_allowed == 1): ?> + + + + charge_cash) && $data_insurance_card[0]->charge_cash == 1): ?> + + +
+
+ +
+ +

No Insurance Information

+

No insurance details found for this patient.

+ +
+ +
+
+ + +
+
+
+
+ +
+
+ +
+
+ +
+
+ +
+
+
+
+
+ + +
+ + 0): ?> +
+
+

+ OPD Registration + +

+
+
+ +
+
opd_code ?? ''); ?>
+

+ Dr. doc_name ?? ''); ?>
+ str_apointment_date ?? ''); ?>
+ p_fname ?? ''); ?> +

+ ion_auth->in_group('OPDEdit') || ($row->new_opd ?? 0) == 1): ?> + + +
+ +
+
+ + + + 0): ?> +
+
+

+ Charges Invoice + +

+
+
+ +
+
invoice_code ?? ''); ?>
+

+ str_inv_date ?? ''); ?>
+ inv_name ?? ''); ?>
+ Item_List ?? ''); ?> +

+ +
+ invoice_status ?? 1) == 0): ?> + + Edit + + + Delete + + + + View + + +
+
+ +
+
+ +
+
+ + +
+ + + + + + \ No newline at end of file diff --git a/old_code_ci3/views/Report/IPD_Current_List.php b/old_code_ci3/views/Report/IPD_Current_List.php new file mode 100644 index 0000000..24890f6 --- /dev/null +++ b/old_code_ci3/views/Report/IPD_Current_List.php @@ -0,0 +1,111 @@ +
+

+ Current Admit IPD List + Panel +

+
+
+
+
+ + +
+
+ + +
+
+ + +
+
+ +
+ + +
+
+
+ +
+
+
+
+
+
+ \ No newline at end of file diff --git a/old_code_ci3/views/Report/OPD_Report_Doctor.php b/old_code_ci3/views/Report/OPD_Report_Doctor.php new file mode 100644 index 0000000..033c6c1 --- /dev/null +++ b/old_code_ci3/views/Report/OPD_Report_Doctor.php @@ -0,0 +1,97 @@ +
+

+ Report + Panel +

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

+ Report + Panel +

+
+
+
diff --git a/old_code_ci3/views/Report/Report_IPD.php b/old_code_ci3/views/Report/Report_IPD.php new file mode 100644 index 0000000..5c12cae --- /dev/null +++ b/old_code_ci3/views/Report/Report_IPD.php @@ -0,0 +1,200 @@ +
+

+ Report + Panel +

+
+
+
+
+ + +
+
+ +
+   + +
+ +
+
+ + +
+
+ + +
+
+ + +
+
+ +
+ + + + +
+
+
+ +
+
+
+
+
+
+ \ No newline at end of file diff --git a/old_code_ci3/views/Report/Report_medical.php b/old_code_ci3/views/Report/Report_medical.php new file mode 100644 index 0000000..4a8dd08 --- /dev/null +++ b/old_code_ci3/views/Report/Report_medical.php @@ -0,0 +1,153 @@ +
+

+ Report + Panel +

+
+
+
+
+ +
+   + +
+ +
+
+ + +
+
+ + +
+
+ + +
+
+ +
+ + +
+
+
+
+
+
+
+
+
+ \ No newline at end of file diff --git a/old_code_ci3/views/Report/Report_medical_template.php b/old_code_ci3/views/Report/Report_medical_template.php new file mode 100644 index 0000000..cbf362a --- /dev/null +++ b/old_code_ci3/views/Report/Report_medical_template.php @@ -0,0 +1,41 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
IPD CodePatient NameIPD Doc.Admit
Discharge Date
Item NameRateQtyAmt.After Bill Amt.Doc. Name
ipd_code?>p_fname?>ipd_doc_name?>register_date_str?>
discharge_date_str?>
item_name?>item_rate?>item_qty?>item_amount?>Aft_Amt?>doc_name?>
\ No newline at end of file diff --git a/old_code_ci3/views/Report/Report_refer_ipd.php b/old_code_ci3/views/Report/Report_refer_ipd.php new file mode 100644 index 0000000..664f213 --- /dev/null +++ b/old_code_ci3/views/Report/Report_refer_ipd.php @@ -0,0 +1,126 @@ +
+

+ Report + Panel +

+
+
+
+
+ +
+   + +
+ +
+
+ + +
+
+ + +
+
+ +
+ + +
+
+
+
+
+
+
+
+
+ \ No newline at end of file diff --git a/old_code_ci3/views/Report/Report_refer_template.php b/old_code_ci3/views/Report/Report_refer_template.php new file mode 100644 index 0000000..9ffee0f --- /dev/null +++ b/old_code_ci3/views/Report/Report_refer_template.php @@ -0,0 +1,35 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + +
IPD CodePatient NameIPD Doc.Admit
Discharge Date
Refer NameNet AmountBalance
ipd_code?>p_fname?>ipd_doc_name?>register_date_str?>
discharge_date_str?>
title?> f_name?> [type_desc?>] net_amount?>balance_amount?>
\ No newline at end of file diff --git a/old_code_ci3/views/Report/ipd_payment_report.php b/old_code_ci3/views/Report/ipd_payment_report.php new file mode 100644 index 0000000..ca59dba --- /dev/null +++ b/old_code_ci3/views/Report/ipd_payment_report.php @@ -0,0 +1,158 @@ +
+

+ Report + Panel +

+
+
+
+
+ +
+   + +
+ +
+
+ + +
+
+ + +
+
+ + +
+
+
+
+ + +
+
+ + +
+
+ + +
+
+ +
+ + +
+
+
+
+
+
+
+
+
+ \ No newline at end of file diff --git a/old_code_ci3/views/Report/new 1.php b/old_code_ci3/views/Report/new 1.php new file mode 100644 index 0000000..7a3eb2b --- /dev/null +++ b/old_code_ci3/views/Report/new 1.php @@ -0,0 +1,60 @@ +// storing request (ie, get/post) global array to a variable +$requestData= $_REQUEST; + +$columns = array( +// datatable column index => database column name + 0 =>'employee_name', + 1 => 'employee_salary', + 2=> 'employee_age' +); +// getting total number records without any search +$sql = "SELECT employee_name, employee_salary, employee_age "; +$sql.=" FROM employee"; +$query=mysqli_query($conn, $sql) or die("employee-grid-data.php: get employees"); +$totalData = mysqli_num_rows($query); +$totalFiltered = $totalData; // when there is no search parameter then total number rows = total number filtered rows. + = '".$minRange."' AND employee_age <= '".$maxRange."' ) "; +} +$query=mysqli_query($conn, $sql) or die("employee-grid-data.php: get employees"); +$totalFiltered = mysqli_num_rows($query); // when there is a search parameter then we have to modify total number filtered rows as per search result. + +$sql.=" ORDER BY ". $columns[$requestData['order'][0]['column']]." ".$requestData['order'][0]['dir']." LIMIT ".$requestData['start']." ,".$requestData['length']." "; // adding length + +$query=mysqli_query($conn, $sql) or die("employee-grid-data.php: get employees"); + +$data = array(); +while( $row=mysqli_fetch_array($query) ) { // preparing an array + $nestedData=array(); + + $nestedData[] = $row["employee_name"]; + $nestedData[] = $row["employee_salary"]; + $nestedData[] = $row["employee_age"]; + + $data[] = $nestedData; +} + +$json_data = 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" => $data // total data array + ); + +echo json_encode($json_data); // send data as json format + +?> \ No newline at end of file diff --git a/old_code_ci3/views/Report/new 1.txt b/old_code_ci3/views/Report/new 1.txt new file mode 100644 index 0000000..262c9bf --- /dev/null +++ b/old_code_ci3/views/Report/new 1.txt @@ -0,0 +1,143 @@ +
+

+ Report + Panel +

+
+
+
+
+ +
+   + +
+ +
+
+ + +
+
+ + +
+
+ + +
+
+
+
+ + +
+
+ + +
+
+ + +
+
+ +
+ +
+
+
+
+
+
+
+
+
+ \ No newline at end of file diff --git a/old_code_ci3/views/Report/opd_report_total.php b/old_code_ci3/views/Report/opd_report_total.php new file mode 100644 index 0000000..6e34049 --- /dev/null +++ b/old_code_ci3/views/Report/opd_report_total.php @@ -0,0 +1,128 @@ +
+

+ OPD Total Report + Panel +

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

+ OPD List + List +

+
+ +
+
+
+
+ +
+   + +
+
+
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
OPD CodeNamePatient CodeOPD DateDoc. NameTypePayModeFee
+ + + +
Total:
+
+
+
+ + \ No newline at end of file diff --git a/old_code_ci3/views/Report/rep_collocation_emp.php b/old_code_ci3/views/Report/rep_collocation_emp.php new file mode 100644 index 0000000..ba760ff --- /dev/null +++ b/old_code_ci3/views/Report/rep_collocation_emp.php @@ -0,0 +1,156 @@ +
+

+ Report Payment + Panel +

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

+ Report + Panel +

+
+
+
+
+ +
+   + +
+ +
+
+ + +
+
+ + +
+
+ + +
+
+ +
+ +
+
+
+ +
+
+
+
+
+
+ \ No newline at end of file diff --git a/old_code_ci3/views/Report/rep_diagnosis_cash.php b/old_code_ci3/views/Report/rep_diagnosis_cash.php new file mode 100644 index 0000000..6b9d631 --- /dev/null +++ b/old_code_ci3/views/Report/rep_diagnosis_cash.php @@ -0,0 +1,153 @@ +
+

+ Report + Panel +

+
+
+
+
+ +
+   + +
+ +
+
+ + +
+
+ + +
+
+ +
+ + +
+
+
+ +
+
+
+
+
+
+ \ No newline at end of file diff --git a/old_code_ci3/views/Report/rep_diagnosis_empwise.php b/old_code_ci3/views/Report/rep_diagnosis_empwise.php new file mode 100644 index 0000000..07a823d --- /dev/null +++ b/old_code_ci3/views/Report/rep_diagnosis_empwise.php @@ -0,0 +1,121 @@ +
+

+ Report + Panel +

+
+
+
+
+ +
+   + +
+ +
+
+ + +
+
+ + +
+
+
+
+ +
+ +
+
+
+ +
+
+
+
+
+
+ \ No newline at end of file diff --git a/old_code_ci3/views/Report/rep_diagnosis_empwise_2.php b/old_code_ci3/views/Report/rep_diagnosis_empwise_2.php new file mode 100644 index 0000000..4c2601d --- /dev/null +++ b/old_code_ci3/views/Report/rep_diagnosis_empwise_2.php @@ -0,0 +1,121 @@ +
+

+ Report + Panel +

+
+
+
+
+ +
+   + +
+ +
+
+ + +
+
+ + +
+
+
+
+ +
+ +
+
+
+ +
+
+
+
+
+
+ \ No newline at end of file diff --git a/old_code_ci3/views/Report/rep_lab_item.php b/old_code_ci3/views/Report/rep_lab_item.php new file mode 100644 index 0000000..4c2601d --- /dev/null +++ b/old_code_ci3/views/Report/rep_lab_item.php @@ -0,0 +1,121 @@ +
+

+ Report + Panel +

+
+
+
+
+ +
+   + +
+ +
+
+ + +
+
+ + +
+
+
+
+ +
+ +
+
+
+ +
+
+
+
+
+
+ \ No newline at end of file diff --git a/old_code_ci3/views/Report/rep_opd_p.php b/old_code_ci3/views/Report/rep_opd_p.php new file mode 100644 index 0000000..75dbb89 --- /dev/null +++ b/old_code_ci3/views/Report/rep_opd_p.php @@ -0,0 +1,160 @@ +
+

+ Report + Panel +

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

+ Report + Panel +

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

+ Report Payment + Panel +

+
+
+
+
+ +
+   + +
+ +
+
+ + +
+
+ + +
+
+ +
+ + +
+
+
+
+
+
+
+
+
+ \ No newline at end of file diff --git a/old_code_ci3/views/Report/rep_total_payment.php b/old_code_ci3/views/Report/rep_total_payment.php new file mode 100644 index 0000000..19deeb4 --- /dev/null +++ b/old_code_ci3/views/Report/rep_total_payment.php @@ -0,0 +1,135 @@ +
+

+ Report Payment + Panel +

+
+
+
+
+ +
+   + +
+ +
+ +
+ + +
+
+
+
+ + +
+
+ + +
+
+ +
+ + +
+
+
+
+
+
+
+
+
+ \ No newline at end of file diff --git a/old_code_ci3/views/Report/report_Diagnosis_Emp_total_3.php b/old_code_ci3/views/Report/report_Diagnosis_Emp_total_3.php new file mode 100644 index 0000000..37be24a --- /dev/null +++ b/old_code_ci3/views/Report/report_Diagnosis_Emp_total_3.php @@ -0,0 +1,11 @@ + + + + + + + + + + + +

+ Report Insurance Case IPD + Panel +

+ +
+
+
+ +
+   + +
+ +
+
+ + +
+
+ + +
+
+ +
+ + +
+
+
+ +
+
+
+
+
+
+ \ No newline at end of file diff --git a/old_code_ci3/views/Report3/ECHS_OPD.php b/old_code_ci3/views/Report3/ECHS_OPD.php new file mode 100644 index 0000000..1ed168b --- /dev/null +++ b/old_code_ci3/views/Report3/ECHS_OPD.php @@ -0,0 +1,137 @@ +
+

+ Report Insurance Case OPD + Panel +

+
+
+
+
+ +
+   + +
+ +
+
+ + +
+
+ + +
+
+ +
+ + +
+
+
+ +
+
+
+
+
+
+ \ No newline at end of file diff --git a/old_code_ci3/views/Report3/diagnosis_qty.php b/old_code_ci3/views/Report3/diagnosis_qty.php new file mode 100644 index 0000000..6e3f377 --- /dev/null +++ b/old_code_ci3/views/Report3/diagnosis_qty.php @@ -0,0 +1,116 @@ +
+

+ Report + Panel +

+
+
+
+
+ +
+   + +
+ +
+
+ + +
+
+
+
+ +
+ + +
+
+
+
+
+
+
+
+
+ \ No newline at end of file diff --git a/old_code_ci3/views/Report4/Report_echs_opd.php b/old_code_ci3/views/Report4/Report_echs_opd.php new file mode 100644 index 0000000..3195a14 --- /dev/null +++ b/old_code_ci3/views/Report4/Report_echs_opd.php @@ -0,0 +1,128 @@ +
+

+ Report + Panel +

+
+
+
+
+ +
+   + +
+ +
+
+ + +
+
+ +
+ + + +
+
+
+ +
+
+
+
+
+
+ \ No newline at end of file diff --git a/old_code_ci3/views/Report5/Report_Document.php b/old_code_ci3/views/Report5/Report_Document.php new file mode 100644 index 0000000..0f3f14a --- /dev/null +++ b/old_code_ci3/views/Report5/Report_Document.php @@ -0,0 +1,109 @@ +
+

+ Document Issue + Report +

+
+
+
+
+ +
+   + +
+ +
+
+ + +
+
+ +
+ + +
+
+
+
+
+
+
+
+
+ \ No newline at end of file diff --git a/old_code_ci3/views/Report5/Report_XRay_chest.php b/old_code_ci3/views/Report5/Report_XRay_chest.php new file mode 100644 index 0000000..65a5455 --- /dev/null +++ b/old_code_ci3/views/Report5/Report_XRay_chest.php @@ -0,0 +1,79 @@ +
+

+ X-Ray Chest List + Report +

+
+
+
+
+ +
+   + +
+ +
+
+ +
+ + +
+
+
+
+
+
+
+
+
+ diff --git a/old_code_ci3/views/Report5/Report_corona_suspected.php b/old_code_ci3/views/Report5/Report_corona_suspected.php new file mode 100644 index 0000000..ac9ed5a --- /dev/null +++ b/old_code_ci3/views/Report5/Report_corona_suspected.php @@ -0,0 +1,79 @@ +
+

+ Corona Suspected Data + Report +

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

+ Dengue Data + Report +

+
+
+
+
+ +
+   + +
+ +
+
+ +
+ + +
+
+
+
+
+
+
+
+
+ \ No newline at end of file diff --git a/old_code_ci3/views/Report5/Report_pregnancy_suspected.php b/old_code_ci3/views/Report5/Report_pregnancy_suspected.php new file mode 100644 index 0000000..253c800 --- /dev/null +++ b/old_code_ci3/views/Report5/Report_pregnancy_suspected.php @@ -0,0 +1,79 @@ +
+

+ Pregnancy Data + Report +

+
+
+
+
+ +
+   + +
+ +
+
+ +
+ + +
+
+
+
+
+
+
+
+
+ \ No newline at end of file diff --git a/old_code_ci3/views/Report6/Report_Lab_Log.php b/old_code_ci3/views/Report6/Report_Lab_Log.php new file mode 100644 index 0000000..6b59060 --- /dev/null +++ b/old_code_ci3/views/Report6/Report_Lab_Log.php @@ -0,0 +1,109 @@ +
+

+ Lab Log + Report +

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

+ Report + Panel +

+
+
+
diff --git a/old_code_ci3/views/Storestock/Dashboard.php b/old_code_ci3/views/Storestock/Dashboard.php new file mode 100644 index 0000000..5d1a815 --- /dev/null +++ b/old_code_ci3/views/Storestock/Dashboard.php @@ -0,0 +1,37 @@ +
+

+ Store Stock + Dashboard +

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

Indent List

+
+
+
#Test NamePatient NameUHIDAgePhone No.
+ + + + + + + + + + + + + + + +
Indent No.DepartmentDate
+
+ + + + + \ No newline at end of file diff --git a/old_code_ci3/views/Storestock/Medical_stock_drug.php b/old_code_ci3/views/Storestock/Medical_stock_drug.php new file mode 100644 index 0000000..3c8afae --- /dev/null +++ b/old_code_ci3/views/Storestock/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/Storestock/Purchase/new_purchase_invoice.php b/old_code_ci3/views/Storestock/Purchase/new_purchase_invoice.php new file mode 100644 index 0000000..7dc48d6 --- /dev/null +++ b/old_code_ci3/views/Storestock/Purchase/new_purchase_invoice.php @@ -0,0 +1,78 @@ +
+
+
+
+
+
+

New Purchase Invoice

+
+
+ 'form','class'=>'form1')); ?> +
+
+
+ + +
+
+
+
+ + +
+
+
+
+ + +
+
+
+ +
+
+ +
+ +
+
+
+ +
+
+ +
+
+
+
+ \ No newline at end of file diff --git a/old_code_ci3/views/Storestock/Purchase/purchase_challan_list.php b/old_code_ci3/views/Storestock/Purchase/purchase_challan_list.php new file mode 100644 index 0000000..b96c12e --- /dev/null +++ b/old_code_ci3/views/Storestock/Purchase/purchase_challan_list.php @@ -0,0 +1,37 @@ +
+
+ + $row->id) + { + echo ''; + echo ' '; + echo ''; + + echo ''; + echo ' '; + echo ' '; + echo ' '; + echo ' '; + echo ''; + } + + echo ''; + echo ' '; + echo ' '; + echo ' '; + echo ' '; + echo ''; + + $purchase_id=$row->id; + + } + ?> +
Challan No :'.$row->Invoice_no.' / Date : '.$row->str_date_of_invoice.' /Net Amount :'.$row->tamount.'
Item NameQty + FreeMRPAdd
'.$row->Item_name.''.$row->qty.' + '.$row->qty_free.''.$row->mrp.'Add
+
+
+ + \ No newline at end of file diff --git a/old_code_ci3/views/Storestock/Purchase/purchase_invoice_edit.php b/old_code_ci3/views/Storestock/Purchase/purchase_invoice_edit.php new file mode 100644 index 0000000..35566e1 --- /dev/null +++ b/old_code_ci3/views/Storestock/Purchase/purchase_invoice_edit.php @@ -0,0 +1,531 @@ +
+
+
+
+
+

Purchase Invoice Information

+ Supplier: | name_supplier ?> + ischallan == 1) { ?> + | Challan No.: Invoice_no ?> + + 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/Storestock/Purchase/purchase_invoice_item.php b/old_code_ci3/views/Storestock/Purchase/purchase_invoice_item.php new file mode 100644 index 0000000..11f4f55 --- /dev/null +++ b/old_code_ci3/views/Storestock/Purchase/purchase_invoice_item.php @@ -0,0 +1,79 @@ + + + + + + + + + + + + + + + + + + + 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 ''; + } + echo ''; + ?> + + + + + + + + + + + + + + + + + + + +
#RecNoItem NameBatch NoExp.MRPQty.RateAmountDisc.Tax AmountCGSTSGSTNet Amount
'.$srno.''.$row->id.''.$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 ' + '; + if($row->old_purchase_id>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/Storestock/Purchase/purchase_invoice_item_print.php b/old_code_ci3/views/Storestock/Purchase/purchase_invoice_item_print.php new file mode 100644 index 0000000..67947ce --- /dev/null +++ b/old_code_ci3/views/Storestock/Purchase/purchase_invoice_item_print.php @@ -0,0 +1,130 @@ + + + + + + + + + + + +

+

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

+

+ Invoice From : + Supplier : name_supplier?>
+ Purchase Invoice No.: Invoice_no?>
+ Invoice Date : date_of_invoice)?>
+

+
+

Purchase Invoice

+
+ + + + + + +
Page : {PAGENO}/{nbpg}Invoice No.:Invoice_no?> / Name : name_supplier?>
+
+ + + + + + + + + + + + + + + + + + item_return==1) + { + $style='style="color:Red;"'; + }else{ + $style=''; + } + 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/Storestock/Purchase/purchase_invoice_master_edit.php b/old_code_ci3/views/Storestock/Purchase/purchase_invoice_master_edit.php new file mode 100644 index 0000000..d4eb5f5 --- /dev/null +++ b/old_code_ci3/views/Storestock/Purchase/purchase_invoice_master_edit.php @@ -0,0 +1,231 @@ +
+
+
+
+
+
+ '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/Storestock/Purchase/purchase_item_old.php b/old_code_ci3/views/Storestock/Purchase/purchase_item_old.php new file mode 100644 index 0000000..2fcb615 --- /dev/null +++ b/old_code_ci3/views/Storestock/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/Storestock/Purchase/purchase_supp_list.php b/old_code_ci3/views/Storestock/Purchase/purchase_supp_list.php new file mode 100644 index 0000000..5216fb7 --- /dev/null +++ b/old_code_ci3/views/Storestock/Purchase/purchase_supp_list.php @@ -0,0 +1,74 @@ +
+
+
+
+ + + + + + + + + + + + ischallan==0){ + echo ''; + }else{ + echo ''; + } + ?> + + + + + + + + + + + + + + + + + + + + +
Invoice IDSupplierDateAmount
Invoice_no ?>name_supplier ?>date_of_invoice ?>tamount ?> + + Print + tamount==0){ ?> + + + +
Invoice IDSupplierDateAmount
+ +
+
+
+ + \ No newline at end of file diff --git a/old_code_ci3/views/Storestock/Purchase/supplier_Edit.php b/old_code_ci3/views/Storestock/Purchase/supplier_Edit.php new file mode 100644 index 0000000..2aedfd9 --- /dev/null +++ b/old_code_ci3/views/Storestock/Purchase/supplier_Edit.php @@ -0,0 +1,120 @@ + + +
+
+

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/Storestock/Purchase/supplier_list.php b/old_code_ci3/views/Storestock/Purchase/supplier_list.php new file mode 100644 index 0000000..e0a5567 --- /dev/null +++ b/old_code_ci3/views/Storestock/Purchase/supplier_list.php @@ -0,0 +1,32 @@ +
+ +'form','class'=>'form2')); ?> +
+ + + + + + + + + + + + +
+ +
+
+ \ No newline at end of file diff --git a/old_code_ci3/views/Storestock/Purchase/supplier_master.php b/old_code_ci3/views/Storestock/Purchase/supplier_master.php new file mode 100644 index 0000000..327b85b --- /dev/null +++ b/old_code_ci3/views/Storestock/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/Storestock/Purchase/supplier_master_sub.php b/old_code_ci3/views/Storestock/Purchase/supplier_master_sub.php new file mode 100644 index 0000000..651aa18 --- /dev/null +++ b/old_code_ci3/views/Storestock/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/Storestock/Stock/location_master_list.php b/old_code_ci3/views/Storestock/Stock/location_master_list.php new file mode 100644 index 0000000..5c90f8b --- /dev/null +++ b/old_code_ci3/views/Storestock/Stock/location_master_list.php @@ -0,0 +1,52 @@ +
+
+
+
+

Location

+
+ +
+ + + + + + + + + + + + + + + + + + + +
+ ID + + Location Name + + Location Description + + Action +
+ l_id ?> + + loc_name ?> + + loc_desc ?> + + Edit +
+
+ + +
+
+
\ No newline at end of file diff --git a/old_code_ci3/views/Storestock/Stock/main_store_dashboard.php b/old_code_ci3/views/Storestock/Stock/main_store_dashboard.php new file mode 100644 index 0000000..c28a01c --- /dev/null +++ b/old_code_ci3/views/Storestock/Stock/main_store_dashboard.php @@ -0,0 +1,70 @@ +
+

+ Store Main + Panel +

+
+
+
+ +
+
+
+ Inventory +
+ +
+
+ +
diff --git a/old_code_ci3/views/Storestock/Stock_Item_history.php b/old_code_ci3/views/Storestock/Stock_Item_history.php new file mode 100644 index 0000000..5d0f09c --- /dev/null +++ b/old_code_ci3/views/Storestock/Stock_Item_history.php @@ -0,0 +1,58 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Pur. IDSupplierInv.No / DateBat.No.Exp.Dt.MRPPurchaseQty / PackingUnit QtySale U.QtyLost UnitCurr.U.QtyUpdate Lost UnitRemove
id?>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/Storestock/Stock_search_qty_result.php b/old_code_ci3/views/Storestock/Stock_search_qty_result.php new file mode 100644 index 0000000..2c34dc8 --- /dev/null +++ b/old_code_ci3/views/Storestock/Stock_search_qty_result.php @@ -0,0 +1,190 @@ + +
+
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Item NameCurrent Pak.Current Unit QtyTotal Sale Pak.Total Sale Unit QtyLost UnitPackage/Re-Order QtyRemoved Qty
+

+ item_name ?>

+
+

C_Pak_Qty?>

+
+

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/Storestock/Store_Final_Invoice.php b/old_code_ci3/views/Storestock/Store_Final_Invoice.php new file mode 100644 index 0000000..dc36a3b --- /dev/null +++ b/old_code_ci3/views/Storestock/Store_Final_Invoice.php @@ -0,0 +1,308 @@ +
+
+

+ Indent + No. : indent_code?> +

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

Location Name : + issued_name?> + / Indent No. :indent_code?> + / Date : indent_date)?> +

+
+ +
+
+
+
+
+ + + + + + + + + + + + + + + + + + '; + 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 TotalGtotal ?>tamt?>
+
+
+ +
+
+ Print +
+
+ +
+
+ +
+ + + +
\ No newline at end of file diff --git a/old_code_ci3/views/Storestock/Store_Print.php b/old_code_ci3/views/Storestock/Store_Print.php new file mode 100644 index 0000000..b64c445 --- /dev/null +++ b/old_code_ci3/views/Storestock/Store_Print.php @@ -0,0 +1,103 @@ + + + + + + + + +
+

+

,
+

+
+

Location Name : + issued_name?>
+ Indent No. :indent_code?>
+ Date : indent_date)?> +

+
+
+

Indent

+
+ + + + + + +
Page : {PAGENO}/{nbpg}Invoice No.:indent_code ?> / Location : issued_name ?>
+
+ + '; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + } + + $srno=$srno+1; + $head_start=$head_start+1; + + if($row->sale_return==1){ + echo ''; + echo ''; + echo ''; + } + + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + } + + if(count($invoice_stock_master)>0) { + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + } + ?> +
Invoice ID : '.$row->indent_code.' [Dated : '.$row->str_inv_date.']
#Item NameBatch NoExp.RateQty.Gross Amt
Sale Return
'.$srno.''.$row->item_Name.' '.$row->formulation.''.$row->batch_no.''.$row->expiry.''.$row->price.''.$row->qty.''.$row->amount.'
#Total'.$invoice_stock_master[0]->gross_amount.'
+ +

+ + + + +
+ + + + For +
diff --git a/old_code_ci3/views/Storestock/indent_edit.php b/old_code_ci3/views/Storestock/indent_edit.php new file mode 100644 index 0000000..3acedfd --- /dev/null +++ b/old_code_ci3/views/Storestock/indent_edit.php @@ -0,0 +1,444 @@ +
+

+ Indent No. indent_code?> + + Edit + +

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

Location Name : + issued_name?> + / Indent No. :indent_code?> + / Date : indent_date)?> +

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

+ + + + + + + + +

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

Sale Medicine

+
+ +
+
+ + +
+ +
+ + + +
+
+ + +
+ + \ No newline at end of file diff --git a/old_code_ci3/views/Storestock/indent_item_list.php b/old_code_ci3/views/Storestock/indent_item_list.php new file mode 100644 index 0000000..5ec0772 --- /dev/null +++ b/old_code_ci3/views/Storestock/indent_item_list.php @@ -0,0 +1,108 @@ +item_code); + } + +?> + + + + + + + + + + + + + + sale_return==1){ + $style='style="background:orange;"'; + + }else{ + $style=""; + } + + if($row->no_day<90){ + $style='style="color:red;"'; + } + + $style_repeat=''; + + if(in_array($row->item_code,$Item_List)){ + $style_repeat='style="color:green;"'; + } + + if($row->cur_qty<6){ + $style='style="color:red;"'; + } + + echo ''; + + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + + echo ''; + + echo ''; + echo ''; + } + echo ''; + echo ''; + ?> + + + + + + + + + + + + + + + + + + + + + + + + +
#Item NameBatch NoExp.RateS.Qty.Qty.PriceAmount
'.$srno.''.$row->item_Name.''.$row->batch_no.''.$row->expiry.''.$row->price.''.$row->qty.''; + if($row->sale_return==0){ + echo '
+ + + + +
'; + } + echo '
'.$row->amount.''.$row->tamount.''; + echo ' '; + echo '
#Gross TotalGtotal ?>tamt?>
#Tax TotalTCGST : TCGST?> / TSGST :TSGST?>
\ No newline at end of file diff --git a/old_code_ci3/views/Storestock/new_indent.php b/old_code_ci3/views/Storestock/new_indent.php new file mode 100644 index 0000000..d8bb9e6 --- /dev/null +++ b/old_code_ci3/views/Storestock/new_indent.php @@ -0,0 +1,88 @@ +
+
+
+

New Indent

+
+
+
+
+
+ +
+
+ +
+ +
+
+
+
+
+
+
+ + +
+
+
+
+ +
+
+
+
+
+
+
+ + +
+
+
+
+ +
+
+
+
+ +
+
+ \ No newline at end of file diff --git a/old_code_ci3/views/Storestock/store_stock_search.php b/old_code_ci3/views/Storestock/store_stock_search.php new file mode 100644 index 0000000..c467693 --- /dev/null +++ b/old_code_ci3/views/Storestock/store_stock_search.php @@ -0,0 +1,143 @@ +
+'form','class'=>'form2')); ?> +
+
+ +
+
+
+ +
+
+
+ + + + + + + + + + +
+
+ +
+
+ \ No newline at end of file diff --git a/old_code_ci3/views/TestForm.php b/old_code_ci3/views/TestForm.php new file mode 100644 index 0000000..93c820e --- /dev/null +++ b/old_code_ci3/views/TestForm.php @@ -0,0 +1,66 @@ +
+

+ Dashboard + Control panel +

+ +
+ +
+
+
+
+
+

CK Editor + Advanced and full of features +

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

Bootstrap WYSIHTML5 + Simple and fast +

+ +
+ + +
+ +
+ +
+
+ +
+
+
+
+ +
+ +
+ \ No newline at end of file diff --git a/old_code_ci3/views/TestForm2.php b/old_code_ci3/views/TestForm2.php new file mode 100644 index 0000000..568e1d3 --- /dev/null +++ b/old_code_ci3/views/TestForm2.php @@ -0,0 +1,405 @@ +
+

+ Advanced Form Elements + Preview +

+ +
+ + +
+ + +
+
+

Select2

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

Input masks

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

Color & Time Picker

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

Date picker

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

iCheck - Checkbox & Radio Inputs

+
+
+ + + +
+ + + +
+ + +
+ + + +
+ + + + +
+ + + +
+ + +
+ + + +
+ + + + +
+ + + +
+ + +
+ + + +
+
+ + +
+ +
+ +
+ + +
+ \ No newline at end of file diff --git a/old_code_ci3/views/Website.php b/old_code_ci3/views/Website.php new file mode 100644 index 0000000..ce7152a --- /dev/null +++ b/old_code_ci3/views/Website.php @@ -0,0 +1,42 @@ +load->view('form'); + } + + public function submission() + { + + if (!$this->input->is_ajax_request()) { exit('no valid req.'); } + + $FormRules = array( + array( + 'field' => 'website', + 'label' => 'Website Address', + 'rules' => 'required|min_length[5]|max_length[30]' + ) + ); + + $this->form_validation->set_rules($FormRules); + + if ($this->form_validation->run() == TRUE) + { + echo '
Your website is submitted
'; + } + else + { + echo '
'.validation_errors().'
'; + } + } + + } diff --git a/old_code_ci3/views/auth_dst/create_group.php b/old_code_ci3/views/auth_dst/create_group.php new file mode 100644 index 0000000..e8c6f25 --- /dev/null +++ b/old_code_ci3/views/auth_dst/create_group.php @@ -0,0 +1,43 @@ +
+

+ + +

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

+
+ +

+ +

+
+ +

+ +

+ + +
+
+ \ No newline at end of file diff --git a/old_code_ci3/views/auth_dst/create_user.php b/old_code_ci3/views/auth_dst/create_user.php new file mode 100644 index 0000000..5c0d2e5 --- /dev/null +++ b/old_code_ci3/views/auth_dst/create_user.php @@ -0,0 +1,95 @@ +
+

+ + +

+ +
+ +
+
+
+ +'form','class'=>'form1'));?> +
+
+
+
+ +
+
+
+
+
+ +
+
+ '; + echo '
'; + echo lang('create_user_identity_label', 'identity'); + + echo form_error('identity'); + echo form_input($identity); + echo '
+
'; + } + ?> +
+
+
+
+
+ +
+
+
+
+
+ +
+
+
+
+
+
+
+ +
+
+
+
+
+ +
+
+
+
+
+

+
+
+ + + +
+ \ No newline at end of file diff --git a/old_code_ci3/views/auth_dst/edit_group.php b/old_code_ci3/views/auth_dst/edit_group.php new file mode 100644 index 0000000..080dad7 --- /dev/null +++ b/old_code_ci3/views/auth_dst/edit_group.php @@ -0,0 +1,20 @@ +

+

+ +
+ + + +

+
+ +

+ +

+
+ +

+ +

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

+ + +

+
+
+
+ +'form','class'=>'form1'));?> +
+
+
+
+ +
+
+
+
+
+ +
+
+ '; + echo '
'; + echo lang('edit_user_identity_label', 'identity'); + echo form_input($identity); + echo '
+
'; + } + ?> + +
+
+
+
+ +
+
+
+
+
+ +
+
+
+
+
+ +
+
+
+
+
+
+
+

Role Assign

+
+
+ ion_auth->is_admin()): ?> + module_name): + if($module_head_name!=""){ + echo '
'; + echo '
'; + } + echo '
'; + echo '
'; + echo '

'.$group->module_name.'

'; + $module_head_name=$group->module_name; + endif + ?> + + + ';?> + +
+
+
+
+
+
+
+ id);?> + +

+
+
+
+ +
+ diff --git a/old_code_ci3/views/auth_dst/index.php b/old_code_ci3/views/auth_dst/index.php new file mode 100644 index 0000000..f2aa6a7 --- /dev/null +++ b/old_code_ci3/views/auth_dst/index.php @@ -0,0 +1,52 @@ +

+
+
+
+

+
+ +
+

+ + + + + + + + + + + + + + + + + + + + + + + +
User Name
username,ENT_QUOTES,'UTF-8');?>first_name,ENT_QUOTES,'UTF-8');?>last_name,ENT_QUOTES,'UTF-8');?>email,ENT_QUOTES,'UTF-8');?> + active){ + echo "".lang('index_active_link').""; + + }else{ + echo "".lang('index_inactive_link').""; + } + ?> + Edit
+ +
+ + +
\ No newline at end of file diff --git a/old_code_ci3/views/auth_dst/login.php b/old_code_ci3/views/auth_dst/login.php new file mode 100644 index 0000000..60c0a51 --- /dev/null +++ b/old_code_ci3/views/auth_dst/login.php @@ -0,0 +1,100 @@ + + + + + + Log in + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/old_code_ci3/views/auth_dst/profile_update.php b/old_code_ci3/views/auth_dst/profile_update.php new file mode 100644 index 0000000..b6199ae --- /dev/null +++ b/old_code_ci3/views/auth_dst/profile_update.php @@ -0,0 +1,64 @@ +
+

+ + +

+ +
+
+
+ +'form','class'=>'form1'));?> +
+ '; + echo '
'; + echo lang('edit_user_identity_label', 'identity'); + echo form_input($identity); + echo '
+
'; + } + ?> + +
+
+
+
+ +
+
+
+
+
+
+
+ +
+
+
+
+
+
+ id);?> + + +

+
+
+
+ +
+ diff --git a/old_code_ci3/views/center_room/center_room.php b/old_code_ci3/views/center_room/center_room.php new file mode 100644 index 0000000..e8f8e26 --- /dev/null +++ b/old_code_ci3/views/center_room/center_room.php @@ -0,0 +1,75 @@ + + + + + + + + + + + + + +
+
+
+ + + \ No newline at end of file diff --git a/old_code_ci3/views/dashboard/Investigation_history.php b/old_code_ci3/views/dashboard/Investigation_history.php new file mode 100644 index 0000000..b38d138 --- /dev/null +++ b/old_code_ci3/views/dashboard/Investigation_history.php @@ -0,0 +1,69 @@ + +id; + $query = $this->db->query($sql); + $lab_request= $query->result(); + + $sql="select * from file_upload_data + where show_type=0 and pid=$row->attach_id and charge_id=$row->id order by id"; + $query = $this->db->query($sql); + $opd_file_list= $query->result(); + + ?> +
+
+ User Image + + Report On inv_date_str?> / Amount : net_amount?> + + Test Name : Item_list?> +
+ +
+ '; + echo $lab_request_row->Report_Data; + echo '
'; + } + ?> +
+ +
+ '; + $pos=strpos($opd_file_row->full_path,'/uploads/',1) ; + $file_path=substr($opd_file_row->full_path,$pos); + + //$file_path=str_replace('hms_uploads','uploads',$opd_file_row->full_path); + + if($opd_file_row->file_ext=='.pdf') + { + echo ''; + }else + { + echo 'Photo'; + } + + echo '
'; + } + + ?> + + + + + + \ No newline at end of file diff --git a/old_code_ci3/views/dashboard/OPDPrescription.php b/old_code_ci3/views/dashboard/OPDPrescription.php new file mode 100644 index 0000000..316d72e --- /dev/null +++ b/old_code_ci3/views/dashboard/OPDPrescription.php @@ -0,0 +1,1203 @@ +
+
+ + + + + + + + + + +
+

Name : p_fname); ?>
p_relative) . ' ' . ucwords($data[0]->p_rname); ?> +
UHID ID : p_code ?> +
Gender : xgender ?> + / Age : str_age ?> +
OPD ID : opd_code ?> +

+
+ profile_picture, '/uploads/', 1); + $profile_file_path = substr($data[0]->profile_picture, $pos); + ?> + + + + +
+
+
+
+ + + + + + Print OPD HEAD in Letter Head + Print OPD HEAD in Blank Page +

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

General Examination

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

Pain Measurement Scale

+
+
+
+
+
+ +
+
+
+
+
+
+ pain_value)?> > + +
+
+ pain_value)?> > + +
+
+ pain_value)?> > + +
+
+ pain_value)?> > + +
+
+ pain_value)?> > + +
+ +
+
+
+
+
+
+
Complication
+
+ +
+
+ +
+
+ +
+
+ +
+
+ +
+
+ +
+
+ +
+
+
+
+
+
Addiction(if any)
+
+ +
+
+ +
+
+ +
+
+
+
+
+
Co-Morbidities
+
+ + + +
+
+
+
+
+ + + + + + + +
+
+
+ +
+ + + + \ No newline at end of file diff --git a/old_code_ci3/views/dashboard/OPD_old_prescription.php b/old_code_ci3/views/dashboard/OPD_old_prescription.php new file mode 100644 index 0000000..bf9b6da --- /dev/null +++ b/old_code_ci3/views/dashboard/OPD_old_prescription.php @@ -0,0 +1,195 @@ + + + diff --git a/old_code_ci3/views/dashboard/appointment.php b/old_code_ci3/views/dashboard/appointment.php new file mode 100644 index 0000000..014b9d7 --- /dev/null +++ b/old_code_ci3/views/dashboard/appointment.php @@ -0,0 +1,48 @@ +
+
+
+
+ +
+
+
+ +
+ + + + +
+
+
+
+
+ +
+
+ + +
+
+
+
+
+ +
+
+ \ No newline at end of file diff --git a/old_code_ci3/views/dashboard/dash1.php b/old_code_ci3/views/dashboard/dash1.php new file mode 100644 index 0000000..1c55c59 --- /dev/null +++ b/old_code_ci3/views/dashboard/dash1.php @@ -0,0 +1,158 @@ +
+

+ Dashboard + panel +

+ +
+
+
+
+
+ +
+ OPD + T_opd ?> + More info +
+
+
+ +
+
+ +
+ Admit & Discharge Status + Discharge Today : + Admit Today : +
+
+
+
+
+ +
+ Current IPD Status + Total Admit : + Org. Admit : +
+
+
+ +
+
+ + +
+ CPU & Memory Load + + CPU % + Memory % + Free Disk % + Total Disk +
+ +
+ +
+
+
+
+
+
+
+
+

OPD

+
+
+ + + + + + + + + + + +
OrganizationNo of OPD
Ins_name ?>No_OPD ?>
+
+
+
+
+
+
+

OPD

+
+
+ + + + + + + + + + + + + + + +
Doctor NameNo of OPDDirectOrg.
p_fname ?>No_opd ?>Direct_OPD ?>Org_OPD ?>
+
+
+
+
+
+
+
+
+

IPD Doctors

+
+
+ + + + + + + + + + + +
Doctor NameNo of IPD
doc_name ?>No_patient ?>
+
+
+
+
+
+
+

IPD

+
+
+ + + + + + + + + + + +
OrganizationNo of IPD
ins_company_name ?>No_IPD ?>
+
+
+
+ +
+ +
diff --git a/old_code_ci3/views/dashboard/day_care_format.php b/old_code_ci3/views/dashboard/day_care_format.php new file mode 100644 index 0000000..0c1871b --- /dev/null +++ b/old_code_ci3/views/dashboard/day_care_format.php @@ -0,0 +1,65 @@ + + + +

DAY CARE DISCHARGE

+
+ + + +udai<>"") + { + $old_uhid= ' /'.$patient_master[0]->udai; + } +?> +
+ + + + + +
+ UHID : p_code?>
+ Name : title?> p_fname)?>
+ p_relative?> p_rname)?>
+ Sex : xgender?> age?>
+
+ Date: str_apointment_date ?>

+ Admit Time: ____________________

+ Discharge Time: ___________________
+
+
+
+

Hospital Course

+
+
+
+
+
+
+
+
+
+
+

Treatment Advice

+
+
+
+
+
+
+
+
diff --git a/old_code_ci3/views/dashboard/invoice_print_a4_double.php b/old_code_ci3/views/dashboard/invoice_print_a4_double.php new file mode 100644 index 0000000..5e1c309 --- /dev/null +++ b/old_code_ci3/views/dashboard/invoice_print_a4_double.php @@ -0,0 +1 @@ +Hello World \ No newline at end of file diff --git a/old_code_ci3/views/dashboard/jkhospital.php b/old_code_ci3/views/dashboard/jkhospital.php new file mode 100644 index 0000000..023254d --- /dev/null +++ b/old_code_ci3/views/dashboard/jkhospital.php @@ -0,0 +1,21 @@ + + + +

+
+ +

Print Time :

+
+ \ No newline at end of file diff --git a/old_code_ci3/views/dashboard/khrc_opd_parcha.php b/old_code_ci3/views/dashboard/khrc_opd_parcha.php new file mode 100644 index 0000000..b11697a --- /dev/null +++ b/old_code_ci3/views/dashboard/khrc_opd_parcha.php @@ -0,0 +1,82 @@ + + +
+ +
+
+ +
+
+ +
+
+ +
+
+ +
+ + diff --git a/old_code_ci3/views/dashboard/khrc_opd_parcha_drManmeet.php b/old_code_ci3/views/dashboard/khrc_opd_parcha_drManmeet.php new file mode 100644 index 0000000..f88d88f --- /dev/null +++ b/old_code_ci3/views/dashboard/khrc_opd_parcha_drManmeet.php @@ -0,0 +1,82 @@ + + +
+ +
+
+ +
+
+ +
+
+ +
+
+ +
+ + diff --git a/old_code_ci3/views/dashboard/khrc_opd_parcha_drRahul.php b/old_code_ci3/views/dashboard/khrc_opd_parcha_drRahul.php new file mode 100644 index 0000000..14ea3d5 --- /dev/null +++ b/old_code_ci3/views/dashboard/khrc_opd_parcha_drRahul.php @@ -0,0 +1,82 @@ + + +
+ +
+
+ +
+
+ +
+
+ +
+
+ +
+ + diff --git a/old_code_ci3/views/dashboard/opd_appointment_panel.php b/old_code_ci3/views/dashboard/opd_appointment_panel.php new file mode 100644 index 0000000..87fa952 --- /dev/null +++ b/old_code_ci3/views/dashboard/opd_appointment_panel.php @@ -0,0 +1,36 @@ + +
+ +
+ +
+ +
+ +

Dr. p_fname ?>

+
Spec ?>
+
+ +
+ +
+
'; + } + } ?> +
\ No newline at end of file diff --git a/old_code_ci3/views/dashboard/opd_blank_print_ssc.php b/old_code_ci3/views/dashboard/opd_blank_print_ssc.php new file mode 100644 index 0000000..6f66125 --- /dev/null +++ b/old_code_ci3/views/dashboard/opd_blank_print_ssc.php @@ -0,0 +1,50 @@ + + + + + + + + + +
+ + +

+



+ + Email : '.H_Email; + } + ?> +

+

+ Dr. doc_name ?> +

+ doc_sign)?> +
+
+
+ + + + diff --git a/old_code_ci3/views/dashboard/opd_display.php b/old_code_ci3/views/dashboard/opd_display.php new file mode 100644 index 0000000..0e76d59 --- /dev/null +++ b/old_code_ci3/views/dashboard/opd_display.php @@ -0,0 +1,166 @@ + + + + + + + + <?=H_Name?> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+

+
+
+
+
+
+
+

Dr. B.C. Joshi

+
+
+ + + + + + + + +
queue_no?>p_code?>P_name?>
+
+
+
+
+
+
+

Dr. Paritosh Joshi

+
+
+ + + + + + + + +
queue_no?>p_code?>P_name?>
+
+
+
+
+
+ + diff --git a/old_code_ci3/views/dashboard/opd_invoice_print.php b/old_code_ci3/views/dashboard/opd_invoice_print.php new file mode 100644 index 0000000..4457972 --- /dev/null +++ b/old_code_ci3/views/dashboard/opd_invoice_print.php @@ -0,0 +1,44 @@ + + + + + + + + + +
+ + +

+

, Uttarakhand
+ '; + ?> +

+ +
+
+ + \ No newline at end of file diff --git a/old_code_ci3/views/dashboard/opd_letter_head_print.php b/old_code_ci3/views/dashboard/opd_letter_head_print.php new file mode 100644 index 0000000..684e442 --- /dev/null +++ b/old_code_ci3/views/dashboard/opd_letter_head_print.php @@ -0,0 +1,45 @@ + + + + + + + + + +
+ + +

+

, Uttarakhand
+ +

+

+ Dr. doc_name ?> +

+ doc_sign)?> +
+
+
+ +

Print Time :

+
+ +
\ No newline at end of file diff --git a/old_code_ci3/views/dashboard/opd_letter_head_print_agarwal_hospital.php b/old_code_ci3/views/dashboard/opd_letter_head_print_agarwal_hospital.php new file mode 100644 index 0000000..2ea9073 --- /dev/null +++ b/old_code_ci3/views/dashboard/opd_letter_head_print_agarwal_hospital.php @@ -0,0 +1,44 @@ + + + + + + + + + +
+ + +

+

, Uttarakhand
+ +

+

+ Dr. doc_name ?> +

+ doc_sign)?> +
+
+
+ +

Print Time :

+
+ diff --git a/old_code_ci3/views/dashboard/opd_letter_head_print_bajaj_neuro.php b/old_code_ci3/views/dashboard/opd_letter_head_print_bajaj_neuro.php new file mode 100644 index 0000000..976546f --- /dev/null +++ b/old_code_ci3/views/dashboard/opd_letter_head_print_bajaj_neuro.php @@ -0,0 +1,61 @@ + + + +

+
+ +

+
+
+ + + + + + +
+ Name :
+
+ Gender/Age :
+ Mob. :
+ Add. : +
+ Sr No :
+ UHID :
+ OPD No. :
+ Date :
+
+ OPD Fee : +
+ Dr. Ajay Bajaj / Dr Vibhu Shankar
+ MBBS,MS,MCh.(Neuro Surgery)
+ Senior Consultant Neuro Surgery

+
+
diff --git a/old_code_ci3/views/dashboard/opd_letter_head_print_chamunda_hospital.php b/old_code_ci3/views/dashboard/opd_letter_head_print_chamunda_hospital.php new file mode 100644 index 0000000..6109d11 --- /dev/null +++ b/old_code_ci3/views/dashboard/opd_letter_head_print_chamunda_hospital.php @@ -0,0 +1,44 @@ + + + + + + + + + +
+ + +

+

,
+ +

+

+ Dr. doc_name ?> +

+ doc_sign)?> +
+
+
+ +

Print Time :

+
+ diff --git a/old_code_ci3/views/dashboard/opd_letter_head_print_khrc.php b/old_code_ci3/views/dashboard/opd_letter_head_print_khrc.php new file mode 100644 index 0000000..c354f39 --- /dev/null +++ b/old_code_ci3/views/dashboard/opd_letter_head_print_khrc.php @@ -0,0 +1,51 @@ + + + + + + + + + +
+ + +

+



+ + Email : '.H_Email; + } + ?> +

+

+ Dr. doc_name ?> +

+ doc_sign)?> +
+
+
+ +

Not Valid for Medico legal Purpose / Print Time :

+
+ +

BP : __________ Pulse Rate : __________ SPO2 : __________ Ht : __________ Wt.: __________ RBS : __________

diff --git a/old_code_ci3/views/dashboard/opd_letter_head_print_mehrotra_hospital.php b/old_code_ci3/views/dashboard/opd_letter_head_print_mehrotra_hospital.php new file mode 100644 index 0000000..6109d11 --- /dev/null +++ b/old_code_ci3/views/dashboard/opd_letter_head_print_mehrotra_hospital.php @@ -0,0 +1,44 @@ + + + + + + + + + +
+ + +

+

,
+ +

+

+ Dr. doc_name ?> +

+ doc_sign)?> +
+
+
+ +

Print Time :

+
+ diff --git a/old_code_ci3/views/dashboard/opd_letter_head_print_radiant.php b/old_code_ci3/views/dashboard/opd_letter_head_print_radiant.php new file mode 100644 index 0000000..43f4459 --- /dev/null +++ b/old_code_ci3/views/dashboard/opd_letter_head_print_radiant.php @@ -0,0 +1,55 @@ + + + + + + + + + +
+ + +

+



+ + Email : '.H_Email; + } + ?> +

+

+ Dr. doc_name ?> +

+ doc_sign)?> +

+

Appointment Number : 8171010848

+
+
+
+ +

Review after _______________ days

+


+

Appointment Number : 8171010848 / Not Valid for Medico legal Purpose / Print Time :

+
+ +

BP : __________ Pulse Rate : __________ SPO2 : __________ Ht : __________ Wt.: __________ RBS : __________

diff --git a/old_code_ci3/views/dashboard/opd_letter_head_print_radiant_drpoonam.php b/old_code_ci3/views/dashboard/opd_letter_head_print_radiant_drpoonam.php new file mode 100644 index 0000000..9e8d642 --- /dev/null +++ b/old_code_ci3/views/dashboard/opd_letter_head_print_radiant_drpoonam.php @@ -0,0 +1,164 @@ + + + + + + + + + +
+ + +

+

OBSTETRICS, GYNECOLOGY AND FERTILITY CENTRE

+
+ +
+ + + + + +
+

Address :Near KVM School, +
Mukhani Road, Haldwani, Uttarakhand

+

+ Phone No. :05946-365929
+ Email :radianthospitalhaldwani@gmail.com
+

+ +
+

+ Dr. doc_name ?> +

+ doc_sign)?> +
+
+ + + + + + +
+ OPD Timing : Morning 11.30am to 3.00pm | Evening 4.30pm to 7.00pm | Sunday:By Appointment only | Phone No.:05946-365929, 9760644918 | Valid for 7 days +
+
+ +
+ +
+ +
+ + + + + + + +
+ BP : + + PR : + + Weight : + + LMP : +
+ +
+ diff --git a/old_code_ci3/views/dashboard/opd_letter_head_print_radiant_drpoonam_1.php b/old_code_ci3/views/dashboard/opd_letter_head_print_radiant_drpoonam_1.php new file mode 100644 index 0000000..f0d809b --- /dev/null +++ b/old_code_ci3/views/dashboard/opd_letter_head_print_radiant_drpoonam_1.php @@ -0,0 +1,22 @@ + + + + + +

Not Valid for Medico legal Purpose / Print Time :

+
+ diff --git a/old_code_ci3/views/dashboard/opd_letter_head_print_radiant_drpoonam_21052025.php b/old_code_ci3/views/dashboard/opd_letter_head_print_radiant_drpoonam_21052025.php new file mode 100644 index 0000000..574bd93 --- /dev/null +++ b/old_code_ci3/views/dashboard/opd_letter_head_print_radiant_drpoonam_21052025.php @@ -0,0 +1,168 @@ + + + + + + + + + +
+ + +

RADIANT FERTILITY AND IVF CENTRE

+

A Unit of Radiant Hospital

+
+ +
+ + + + + +
+

Address :Near KVM School, +
Mukhani Road, +
Haldwani, Uttarakhand

+

+ Phone No. :+91 8979565771
+ Email :radianthospitalhaldwani@gmail.com
+

+ +
+

+ Dr. doc_name ?> +

+ doc_sign)?> +
+
+ + + + + + +
+ OPD Timing : 11am to 05pm | Sunday : By Appointment only | Phone No. : 8171010848 | Valid for 7 days + + Not Valid for Medico legal Purpose +
+
+ +
+ +
+ +
+ + + + + + + +
+ BP : + + PR : + + Weight : + + LMP : +
+ +
+ diff --git a/old_code_ci3/views/dashboard/opd_letter_head_print_radiant_drpuneet.php b/old_code_ci3/views/dashboard/opd_letter_head_print_radiant_drpuneet.php new file mode 100644 index 0000000..f118265 --- /dev/null +++ b/old_code_ci3/views/dashboard/opd_letter_head_print_radiant_drpuneet.php @@ -0,0 +1,164 @@ + + + + + + + + + +
+ + +
+ NEURO-BRAIN & SPINE CENTRE +
+ +
+ + + + + +
+


Address :
Near KVM School, + Mukhani Road, Haldwani +

+

+ Phone No. :7817844055, 9068429666, 05946-365929
+

+
+

+ Dr. doc_name ?> +

+ doc_sign)?> +
+
+ + + + + + +
+ OPD Timing : 10AM to 5PM | Sunday OPD by Appointment only + + Not Valid for Medico legal Purpose +
+
+ +
+
+ +
+ +
+ + +
+ diff --git a/old_code_ci3/views/dashboard/opd_letter_head_print_radiant_drvk blank.php b/old_code_ci3/views/dashboard/opd_letter_head_print_radiant_drvk blank.php new file mode 100644 index 0000000..fc607ca --- /dev/null +++ b/old_code_ci3/views/dashboard/opd_letter_head_print_radiant_drvk blank.php @@ -0,0 +1,20 @@ + + + + + + + + diff --git a/old_code_ci3/views/dashboard/opd_letter_head_print_radiant_drvk.php b/old_code_ci3/views/dashboard/opd_letter_head_print_radiant_drvk.php new file mode 100644 index 0000000..7505c08 --- /dev/null +++ b/old_code_ci3/views/dashboard/opd_letter_head_print_radiant_drvk.php @@ -0,0 +1,54 @@ + + + + + + + + + +
+ + +

+



+ + Email : '.H_Email; + } + ?> +

+

+ Dr. doc_name ?> +

+ doc_sign)?> +
+ +

FOR APPOINTMENT
MOB - 7466985557

+
+
+
+ +

Not Valid for Medico legal Purpose / Print Time :

+
+ +

BP : __________ Pulse Rate : __________ SPO2 : __________ Ht : __________ Wt.: __________ RBS : __________

diff --git a/old_code_ci3/views/dashboard/opd_letter_head_print_ssc.php b/old_code_ci3/views/dashboard/opd_letter_head_print_ssc.php new file mode 100644 index 0000000..60d7d9a --- /dev/null +++ b/old_code_ci3/views/dashboard/opd_letter_head_print_ssc.php @@ -0,0 +1,20 @@ + + + + + + + + diff --git a/old_code_ci3/views/dashboard/opd_letter_head_print_vedanta_hospital.php b/old_code_ci3/views/dashboard/opd_letter_head_print_vedanta_hospital.php new file mode 100644 index 0000000..6109d11 --- /dev/null +++ b/old_code_ci3/views/dashboard/opd_letter_head_print_vedanta_hospital.php @@ -0,0 +1,44 @@ + + + + + + + + + +
+ + +

+

,
+ +

+

+ Dr. doc_name ?> +

+ doc_sign)?> +
+
+
+ +

Print Time :

+
+ diff --git a/old_code_ci3/views/dashboard/opd_letter_head_singhal_drparul.php b/old_code_ci3/views/dashboard/opd_letter_head_singhal_drparul.php new file mode 100644 index 0000000..2b7e06c --- /dev/null +++ b/old_code_ci3/views/dashboard/opd_letter_head_singhal_drparul.php @@ -0,0 +1,59 @@ + + + + + + + + + +
+

+ Dr. doc_name ?> +

+ doc_sign)?> +
+ +

SINGHAL CLINIC +
ENDO-NEURO CENTER +

+
+

+ Formerly at:
+ MAMC & LNJP Hospital, Delhi
+ UCMS & GTB Hospital, Delhi
+ AIIMS New Delhi
+ AIIMS Jodhpur +

+
+
+ +
+

Singhal Clinic & Endo-Neuro Center

+

Cheema Chauraha, Behind Spectrum Mall, Ramnagar Road, Kashipur - 244713
+ Contact : 9045424198,05947-274865, 7017369216
+ Monday to Friday : 11 A.M. - 3 P.M. And 6 P.M. - 8 P.M.
+ Saturday : 11 A.M. - 3 P.M.
+ Saturday evening & Sunday closed
+ website : www.singhalclinickashipur.in +

+
+ diff --git a/old_code_ci3/views/dashboard/opd_letter_head_singhal_drrahul.php b/old_code_ci3/views/dashboard/opd_letter_head_singhal_drrahul.php new file mode 100644 index 0000000..4686a72 --- /dev/null +++ b/old_code_ci3/views/dashboard/opd_letter_head_singhal_drrahul.php @@ -0,0 +1,50 @@ + + + + + + + + + + +
+

+ Dr. doc_name ?> +

+ doc_sign)?> +
+ +

SINGHAL CLINIC +
ENDO-NEURO CENTER +

+
+

+ Formerly at:
+ GB Pant Hospital, Delhi
+ IHBAS Hospital, Delhi
+ AIIMS, New Delhi +

+
+
+ +
+

Singhal Clinic & Endo-Neuro Center

+

Cheema Chauraha, Behind Spectrum Mall, Ramnagar Road, Kashipur - 244713
+ Contact : 05947-274865, 7017369216 / Time : 6 P.M. - 8 P.M. Monday to Friday
+ website : www.singhalclinickashipur.in +

+
+ diff --git a/old_code_ci3/views/dashboard/opd_line_list.php b/old_code_ci3/views/dashboard/opd_line_list.php new file mode 100644 index 0000000..b697d04 --- /dev/null +++ b/old_code_ci3/views/dashboard/opd_line_list.php @@ -0,0 +1,48 @@ +'form','class'=>'form1')); ?> +
+

+ Online OPD Booked : Date +

+
+ +
+
+
+
+

Online OPD Book List

+
+
+ + + + + + + + + + + + + +
+ p_code?> + + p_fname?> + + opd_code?> + + opd_book_date?> + + apointment_date?> + + Dr. doc_name?> + + doc_spec?> + + Print OPD +
+
+
+
+
diff --git a/old_code_ci3/views/dashboard/opd_list_doc.php b/old_code_ci3/views/dashboard/opd_list_doc.php new file mode 100644 index 0000000..4294774 --- /dev/null +++ b/old_code_ci3/views/dashboard/opd_list_doc.php @@ -0,0 +1,194 @@ + 'form', 'class' => 'form1')); ?> +
+
+
+

Dr. p_fname ?> + Spec ?> +

+
+
+ +
+ +
+
+
+
+ +
+
+ +
+
+
+
+ + + \ No newline at end of file diff --git a/old_code_ci3/views/dashboard/opd_medical_bill.php b/old_code_ci3/views/dashboard/opd_medical_bill.php new file mode 100644 index 0000000..3e4108e --- /dev/null +++ b/old_code_ci3/views/dashboard/opd_medical_bill.php @@ -0,0 +1,40 @@ +
+id + ORDER BY t.id "; + $query = $this->db->query($sql); + $medical_store_item= $query->result(); +?> +
+
+

inv_med_code?> Date : inv_date?>

+
+ +
+ + + + + + + + +
+ item_Name?> + + formulation?> + + qty?> +
+
+ +
+ +
\ No newline at end of file diff --git a/old_code_ci3/views/dashboard/opd_parcha_ent_care.php b/old_code_ci3/views/dashboard/opd_parcha_ent_care.php new file mode 100644 index 0000000..917425d --- /dev/null +++ b/old_code_ci3/views/dashboard/opd_parcha_ent_care.php @@ -0,0 +1,85 @@ + + +
+ +
+
+ +
+
+ +
+
+ PID:
+ Ph.:
+ FEE:
+ Visit:
+
+ Pr.T: +
+ + diff --git a/old_code_ci3/views/dashboard/opd_parcha_radiant.php b/old_code_ci3/views/dashboard/opd_parcha_radiant.php new file mode 100644 index 0000000..00ca00a --- /dev/null +++ b/old_code_ci3/views/dashboard/opd_parcha_radiant.php @@ -0,0 +1,85 @@ + + +
+ +
+
+ +
+
+ +
+
+ PID:
+ Ph.:
+ FEE:
+ Visit:
+
+ Pr.T: +
+ + diff --git a/old_code_ci3/views/dashboard/opd_prescribed_advice.php b/old_code_ci3/views/dashboard/opd_prescribed_advice.php new file mode 100644 index 0000000..ce3183d --- /dev/null +++ b/old_code_ci3/views/dashboard/opd_prescribed_advice.php @@ -0,0 +1,13 @@ +0){ + echo ''; + foreach($opd_patient_advice as $row) + { + echo ''; + echo ''; + echo ''; + } + + echo '
'.$row->advice_txt.'
'.$row->advice_txt_hindi.'
Del
'; + } +?> \ No newline at end of file diff --git a/old_code_ci3/views/dashboard/opd_prescribed_dose.php b/old_code_ci3/views/dashboard/opd_prescribed_dose.php new file mode 100644 index 0000000..b958eb8 --- /dev/null +++ b/old_code_ci3/views/dashboard/opd_prescribed_dose.php @@ -0,0 +1,563 @@ +'form','class'=>'form2','autocomplete'=>'on')); ?> +
+
+
+
+

Prescribed/ Dosage

+
+
+
+ + + + +
+
+
+
+
+
+ + 0) + { echo ' + + + + + + + '; } ?> + + + + + + + + + + +
TypePrescribedDosageRemarks
med_type?>med_name?>dose_shed?>dose_when?> + dose_frequency?> dose_where?> + qty?> no_of_days?> remark?> + + + +
+
+
+
+ +
+
+
+
+
+
+ +
+
+
+
+ + +
+
+
+
+
+
+ + +
+
+
+ + + +
+
+
+
+
+ + +
+
+
+ +
+
+
+
+
+
+
+

+ + Rx Group +

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

+ + Pre define Advise + +

+
+
+
+ 0){ + echo ''; + foreach($opd_advise as $row) + { + echo ''; + echo ''; + echo ''; + } + echo '
'.$row->advice.'+Add
'; + } + ?> +
+
+
+
+
+ + + + \ No newline at end of file diff --git a/old_code_ci3/views/dashboard/opd_prescription_med_list.php b/old_code_ci3/views/dashboard/opd_prescription_med_list.php new file mode 100644 index 0000000..f7a58f2 --- /dev/null +++ b/old_code_ci3/views/dashboard/opd_prescription_med_list.php @@ -0,0 +1,29 @@ +
+ +0) + { echo ' + + + + + + + '; } ?> + + + + + + + + + + +
TypePrescribedDosageRemarks
med_type?>med_name?>dose_shed?>dose_when?> + dose_frequency?> dose_where?> + qty?>no_of_days?>remark?> + + + +
+
\ No newline at end of file diff --git a/old_code_ci3/views/dashboard/opd_prescription_print.php b/old_code_ci3/views/dashboard/opd_prescription_print.php new file mode 100644 index 0000000..20543ca --- /dev/null +++ b/old_code_ci3/views/dashboard/opd_prescription_print.php @@ -0,0 +1,87 @@ + + + + + + + + + +
+

+ +

+
+

+

, Uttarakhand
+ '; + ?> +

+
+ + + + + + +
Page : {PAGENO}/{nbpg}
+
+ + + + + +
+

Rx

+ '; + echo $Complaint; + echo '
'; + echo $diagnosis; + echo '
'; + echo $investigation; + echo '
'; + echo $medical; + echo '
'; + echo $doctor; + echo '
'; + + ?> +
diff --git a/old_code_ci3/views/dashboard/opd_prescription_suggest_panel/opd_medicine_edit.php b/old_code_ci3/views/dashboard/opd_prescription_suggest_panel/opd_medicine_edit.php new file mode 100644 index 0000000..3034950 --- /dev/null +++ b/old_code_ci3/views/dashboard/opd_prescription_suggest_panel/opd_medicine_edit.php @@ -0,0 +1,127 @@ +
+
+

Medicine

+
+
+
+
+
+
+ + + + +
+
+
+
+
+
+ + +
+
+
+
+
+
+ + +
+
+
+
+
+
+ + +
+
+
+
+
+
+ + +
+
+
+
+
+
+ + +
+
+
+
+
+
+ + +
+
+
+
+
+
+ + +
+
+
+
+
+
+ + +
+
+
+
+
+
+ + +
+
+
+
+
+
+ + +
+
+
+
+
+
\ No newline at end of file diff --git a/old_code_ci3/views/dashboard/opd_prescription_suggest_panel/opd_medicine_panel.php b/old_code_ci3/views/dashboard/opd_prescription_suggest_panel/opd_medicine_panel.php new file mode 100644 index 0000000..f6d84c6 --- /dev/null +++ b/old_code_ci3/views/dashboard/opd_prescription_suggest_panel/opd_medicine_panel.php @@ -0,0 +1,175 @@ + 'form', 'class' => 'form2')); ?> +
+
+
+

Medicine List

+
+
+
+
+ + 0) { + echo ' + + + + + + '; + } ?> + + + + + + + + + +
TypePrescribedDosageRemarks
formulation ?>item_name ?>dose_shed ?>dose_when ?> + dose_frequency ?> dose_where ?> + qty ?> no_of_days ?> remark ?> + +
+
+
+
+ +
+
+
+
+ + \ No newline at end of file diff --git a/old_code_ci3/views/dashboard/opd_prescription_suggest_panel/rx_group_list.php b/old_code_ci3/views/dashboard/opd_prescription_suggest_panel/rx_group_list.php new file mode 100644 index 0000000..026e5ea --- /dev/null +++ b/old_code_ci3/views/dashboard/opd_prescription_suggest_panel/rx_group_list.php @@ -0,0 +1,31 @@ + +id % count($Color)) ; + ?> +
+ + + +
+ diff --git a/old_code_ci3/views/dashboard/opd_prescription_suggest_panel/rx_group_medicine.php b/old_code_ci3/views/dashboard/opd_prescription_suggest_panel/rx_group_medicine.php new file mode 100644 index 0000000..3d2ca5e --- /dev/null +++ b/old_code_ci3/views/dashboard/opd_prescription_suggest_panel/rx_group_medicine.php @@ -0,0 +1,303 @@ +'form','class'=>'form2')); ?> +
+
+

Prescribed/ Dosage : rx_group_name?>

+
+
+
+
+ + 0) + { echo ' + + + + + + '; } ?> + + + + + + + + + +
TypePrescribedDosageRemarks
+ med_type?>med_name?>dose_shed?>dose_when?> + dose_frequency?> dose_where?> + qty?> no_of_days?> remark?> + + +
+
+
+
+ +
+ + \ No newline at end of file diff --git a/old_code_ci3/views/dashboard/opd_prescription_suggest_panel/rx_group_medicine_list.php b/old_code_ci3/views/dashboard/opd_prescription_suggest_panel/rx_group_medicine_list.php new file mode 100644 index 0000000..5c6cae8 --- /dev/null +++ b/old_code_ci3/views/dashboard/opd_prescription_suggest_panel/rx_group_medicine_list.php @@ -0,0 +1,26 @@ +
+ + 0) + { echo ' + + + + + + '; } ?> + + + + + + + + + +
TypePrescribedDosageRemarks
med_type?>med_name?>dose_shed?>dose_when?> + dose_frequency?> dose_where?> + qty?> no_of_days?> remark?> + + +
+
\ No newline at end of file diff --git a/old_code_ci3/views/dashboard/opd_prescription_suggest_panel/rx_group_new.php b/old_code_ci3/views/dashboard/opd_prescription_suggest_panel/rx_group_new.php new file mode 100644 index 0000000..ba16e88 --- /dev/null +++ b/old_code_ci3/views/dashboard/opd_prescription_suggest_panel/rx_group_new.php @@ -0,0 +1,60 @@ +'form','class'=>'form2')); ?> +
+
+
+ + +
+
+
+
+ + +
+
+
+
+ + +
+
+
+
+ + +
+
+
+
+ + +
+
+
+
+
+ + +
+
+ + \ No newline at end of file diff --git a/old_code_ci3/views/dashboard/opd_prescription_suggest_panel/rx_group_patient.php b/old_code_ci3/views/dashboard/opd_prescription_suggest_panel/rx_group_patient.php new file mode 100644 index 0000000..8a0a2f5 --- /dev/null +++ b/old_code_ci3/views/dashboard/opd_prescription_suggest_panel/rx_group_patient.php @@ -0,0 +1,12 @@ +id % count($Color)) ; + ?> + + \ No newline at end of file diff --git a/old_code_ci3/views/dashboard/opd_prescription_suggest_panel/rx_group_save.php b/old_code_ci3/views/dashboard/opd_prescription_suggest_panel/rx_group_save.php new file mode 100644 index 0000000..f160c84 --- /dev/null +++ b/old_code_ci3/views/dashboard/opd_prescription_suggest_panel/rx_group_save.php @@ -0,0 +1,34 @@ +
+
+
+ + +
+
+
+
+
+ + + +
+
+ \ No newline at end of file diff --git a/old_code_ci3/views/dashboard/opd_prescription_suggest_panel/rx_group_show.php b/old_code_ci3/views/dashboard/opd_prescription_suggest_panel/rx_group_show.php new file mode 100644 index 0000000..27f8f17 --- /dev/null +++ b/old_code_ci3/views/dashboard/opd_prescription_suggest_panel/rx_group_show.php @@ -0,0 +1,80 @@ +'form','class'=>'form2')); ?> +
+
+
+ + +
+
+
+
+ + +
+
+
+
+ + +
+
+
+
+ + +
+
+
+
+ + +
+
+
+
+
+ + + + +
+
+ + \ No newline at end of file diff --git a/old_code_ci3/views/dashboard/opd_prescription_suggest_panel/rx_patient_old_medicine.php b/old_code_ci3/views/dashboard/opd_prescription_suggest_panel/rx_patient_old_medicine.php new file mode 100644 index 0000000..48d7542 --- /dev/null +++ b/old_code_ci3/views/dashboard/opd_prescription_suggest_panel/rx_patient_old_medicine.php @@ -0,0 +1,163 @@ +opd_id"; + $query = $this->db->query($sql); + $opd_data= $query->result(); + + ?> +
+ OPD Date :'.MysqlDate_to_str($row->apointment_date).'
'; + + if(count($opd_data)>0) + { + + $sql="SELECT pt.* ,d.dose_show_sign AS dose_shed,dw.dose_sign_desc AS dose_when, + df.dose_sign_desc AS dose_frequency,d_on.dose_sign_desc AS dose_where + FROM (((opd_prescrption_prescribed pt + LEFT JOIN opd_dose_shed d ON pt.dosage=d.dose_shed_id) + LEFT JOIN opd_dose_when dw ON pt.dosage_when=dw.dose_when_id) + LEFT JOIN opd_dose_frequency df ON pt.dosage_freq=df.dose_freq_id) + LEFT JOIN opd_dose_where d_on ON pt.dosage_where=d_on.dose_where_id + where pt.opd_pre_id=".$opd_data[0]->id; + $query = $this->db->query($sql); + $opd_prescribed= $query->result(); + + + if($opd_data[0]->bp!='') + { + $opd_details_str.= 'BP : '.$opd_data[0]->bp.' '; + } + + if($opd_data[0]->diastolic!='') + { + $opd_details_str.= 'Diastolic : '.$opd_data[0]->diastolic.' '; + } + + if($opd_data[0]->pulse!='') + { + $opd_details_str.= 'Pulse : '.$opd_data[0]->pulse.' '; + } + + if($opd_data[0]->temp!='') + { + $opd_details_str.= 'Temp. : '.$opd_data[0]->temp.' '; + } + + $Complaint=""; + + if($opd_data[0]->complaints!='') + { + $Complaint="
Complaint : "; + $Complaint.=''.$opd_data[0]->complaints.''; + } + + $diagnosis=""; + + if($opd_data[0]->diagnosis!='') + { + $diagnosis="
Diagnosis : "; + $diagnosis.=' '.$opd_data[0]->diagnosis.''; + + } + + $investigation=""; + if($opd_data[0]->investigation!='') + { + $investigation="
Investigation Advised : "; + $investigation.=' '.$opd_data[0]->investigation.''; + } + + $opd_details_str.=$Complaint.$diagnosis.$investigation; + + //New Start + + if(count($opd_prescribed)>0) + { + $medical=""; + $sr_no=1; + $medical.= ' + + + + + + '; + + foreach($opd_prescribed as $row_prescribed) + { + $medical_extend=""; + + $medical.=' + + + '; + if(strlen($row_prescribed->remark)>0) + { + $medical_extend=' + + '; + } + $sr_no=$sr_no+1; + } + $medical.="
Rx : Add All
PrescribedDose
'.$sr_no.'-'.$row_prescribed->med_type.' '.$row_prescribed->med_name.''.$row_prescribed->dose_shed.'
'.$row_prescribed->remark.'
"; + $opd_details_str.=$medical; + } + + $advice=""; + + if($opd_data[0]->advice!='') + { + $advice="
Advice : "; + $advice.=''.$opd_data[0]->advice.''; + } + + $opd_details_str.=$advice; + + $next_visit=""; + + if($opd_data[0]->next_visit!='') + { + $next_visit="
Next Visit : "; + $next_visit.=''.$opd_data[0]->next_visit.''; + } + + $opd_details_str.=$next_visit; + + $refer_to=""; + + if($opd_data[0]->refer_to!='') + { + $refer_to="
Refer To : "; + $refer_to.=''.$opd_data[0]->refer_to.''; + } + + $opd_details_str.=$refer_to; + //New End + } + ?> + +

OPD By :Dr. doc_name?>

+

+
+ + +
+ + \ No newline at end of file diff --git a/old_code_ci3/views/dashboard/opd_prev.php b/old_code_ci3/views/dashboard/opd_prev.php new file mode 100644 index 0000000..048ca2b --- /dev/null +++ b/old_code_ci3/views/dashboard/opd_prev.php @@ -0,0 +1,93 @@ +
+
+
+

Preview

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

Complaint

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

Investigation

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

History

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

Diagnosis

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

Pharmacological Treatment

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

Follow Up

+
+
+ +
+
+
+
+
+
+
+
\ No newline at end of file diff --git a/old_code_ci3/views/dashboard/opd_print_parcha.php b/old_code_ci3/views/dashboard/opd_print_parcha.php new file mode 100644 index 0000000..258cc7b --- /dev/null +++ b/old_code_ci3/views/dashboard/opd_print_parcha.php @@ -0,0 +1,21 @@ + + + +

+
+ +

Print Time :

+
+ \ No newline at end of file diff --git a/old_code_ci3/views/dashboard/opd_print_parcha_2 copy.php b/old_code_ci3/views/dashboard/opd_print_parcha_2 copy.php new file mode 100644 index 0000000..4e90ce4 --- /dev/null +++ b/old_code_ci3/views/dashboard/opd_print_parcha_2 copy.php @@ -0,0 +1,21 @@ + + + +

+
+ +

Print Time :
P.T.O.

+
+ \ No newline at end of file diff --git a/old_code_ci3/views/dashboard/opd_print_parcha_2.php b/old_code_ci3/views/dashboard/opd_print_parcha_2.php new file mode 100644 index 0000000..4e90ce4 --- /dev/null +++ b/old_code_ci3/views/dashboard/opd_print_parcha_2.php @@ -0,0 +1,21 @@ + + + +

+
+ +

Print Time :
P.T.O.

+
+ \ No newline at end of file diff --git a/old_code_ci3/views/dashboard/opd_print_parcha_3.php b/old_code_ci3/views/dashboard/opd_print_parcha_3.php new file mode 100644 index 0000000..375c3b3 --- /dev/null +++ b/old_code_ci3/views/dashboard/opd_print_parcha_3.php @@ -0,0 +1,21 @@ + + + +

CIN No. U74999UR2018PTC008810 [Chaumu Healthcare Private Limited]

+
+ +

Print Time :
P.T.O.

+
+ \ No newline at end of file diff --git a/old_code_ci3/views/dashboard/opd_print_parcha_4.php b/old_code_ci3/views/dashboard/opd_print_parcha_4.php new file mode 100644 index 0000000..44c92ae --- /dev/null +++ b/old_code_ci3/views/dashboard/opd_print_parcha_4.php @@ -0,0 +1,20 @@ + + + +

+
+ + + \ No newline at end of file diff --git a/old_code_ci3/views/dashboard/opd_print_parcha_Mehrotra_DrAseemMehrotra.php b/old_code_ci3/views/dashboard/opd_print_parcha_Mehrotra_DrAseemMehrotra.php new file mode 100644 index 0000000..8fca07d --- /dev/null +++ b/old_code_ci3/views/dashboard/opd_print_parcha_Mehrotra_DrAseemMehrotra.php @@ -0,0 +1,20 @@ + + + + + + + + \ No newline at end of file diff --git a/old_code_ci3/views/dashboard/opd_print_parcha_Mehrotra_hospital.php b/old_code_ci3/views/dashboard/opd_print_parcha_Mehrotra_hospital.php new file mode 100644 index 0000000..b746f0f --- /dev/null +++ b/old_code_ci3/views/dashboard/opd_print_parcha_Mehrotra_hospital.php @@ -0,0 +1,20 @@ + + + + + + + + \ No newline at end of file diff --git a/old_code_ci3/views/dashboard/opd_print_parcha_agarwal_hospital_ksp.php b/old_code_ci3/views/dashboard/opd_print_parcha_agarwal_hospital_ksp.php new file mode 100644 index 0000000..c9acdbd --- /dev/null +++ b/old_code_ci3/views/dashboard/opd_print_parcha_agarwal_hospital_ksp.php @@ -0,0 +1,21 @@ + + + +

+
+ +

Print Time :

+
+ \ No newline at end of file diff --git a/old_code_ci3/views/dashboard/opd_print_parcha_agarwal_hospital_ksp_new.php b/old_code_ci3/views/dashboard/opd_print_parcha_agarwal_hospital_ksp_new.php new file mode 100644 index 0000000..6caa127 --- /dev/null +++ b/old_code_ci3/views/dashboard/opd_print_parcha_agarwal_hospital_ksp_new.php @@ -0,0 +1,93 @@ + + +
+ +
+
+ +
+ +
+ +
+
+ Sr.No. :
OPD Fee :
+
OPD ID :
UHID : +
+
+ +
diff --git a/old_code_ci3/views/dashboard/opd_print_parcha_agarwal_hospital_ksp_ss.php b/old_code_ci3/views/dashboard/opd_print_parcha_agarwal_hospital_ksp_ss.php new file mode 100644 index 0000000..c4e8ec2 --- /dev/null +++ b/old_code_ci3/views/dashboard/opd_print_parcha_agarwal_hospital_ksp_ss.php @@ -0,0 +1,97 @@ + + +
+ +
+
+ +
+ +
+ +
+
+ Sr.No. :
OPD Fee :
+
OPD ID :
UHID :
+ +
+
+ +
diff --git a/old_code_ci3/views/dashboard/opd_print_parcha_ah.php b/old_code_ci3/views/dashboard/opd_print_parcha_ah.php new file mode 100644 index 0000000..34da663 --- /dev/null +++ b/old_code_ci3/views/dashboard/opd_print_parcha_ah.php @@ -0,0 +1,20 @@ + + + + + + + + diff --git a/old_code_ci3/views/dashboard/opd_print_parcha_bajaj.php b/old_code_ci3/views/dashboard/opd_print_parcha_bajaj.php new file mode 100644 index 0000000..85dc78f --- /dev/null +++ b/old_code_ci3/views/dashboard/opd_print_parcha_bajaj.php @@ -0,0 +1,35 @@ + + + +

+
+ +

+
+
+ +
diff --git a/old_code_ci3/views/dashboard/opd_print_parcha_bajaj_blank.php b/old_code_ci3/views/dashboard/opd_print_parcha_bajaj_blank.php new file mode 100644 index 0000000..6733d88 --- /dev/null +++ b/old_code_ci3/views/dashboard/opd_print_parcha_bajaj_blank.php @@ -0,0 +1,35 @@ + + + +

+
+ +

+
+
+ +
diff --git a/old_code_ci3/views/dashboard/opd_print_parcha_chamunda_hospital_ksp.php b/old_code_ci3/views/dashboard/opd_print_parcha_chamunda_hospital_ksp.php new file mode 100644 index 0000000..2cfdf9e --- /dev/null +++ b/old_code_ci3/views/dashboard/opd_print_parcha_chamunda_hospital_ksp.php @@ -0,0 +1,47 @@ + + + +

+
+ +

Print Time :

+
+ + + + + + +
+ Name :
+
+ Gender/Age :
+ Mob :'
+ Address :' +
+ UHID :
+ Sr No.:
+ OPD No.:
+
Date:
+ +
+ DEPARTMENT :
+ +
+ +
No. of Visit : + +
Book Time : +
\ No newline at end of file diff --git a/old_code_ci3/views/dashboard/opd_print_parcha_drAnkurChauhan.php b/old_code_ci3/views/dashboard/opd_print_parcha_drAnkurChauhan.php new file mode 100644 index 0000000..45af032 --- /dev/null +++ b/old_code_ci3/views/dashboard/opd_print_parcha_drAnkurChauhan.php @@ -0,0 +1,97 @@ + + +
+ +
+
+ +
+
+ OPD ID : / UHID : +
+
+ +
+
+ Sr.No. :
OPD Fee :
+
+
+ +
+ + diff --git a/old_code_ci3/views/dashboard/opd_print_parcha_radiant.php b/old_code_ci3/views/dashboard/opd_print_parcha_radiant.php new file mode 100644 index 0000000..0538295 --- /dev/null +++ b/old_code_ci3/views/dashboard/opd_print_parcha_radiant.php @@ -0,0 +1,22 @@ + + + +

+
+ +

Review after _______________ days / Appointment Number : 8171010848

+

Print Time :

+
+ \ No newline at end of file diff --git a/old_code_ci3/views/dashboard/opd_print_parcha_radiant_drpoonam.php b/old_code_ci3/views/dashboard/opd_print_parcha_radiant_drpoonam.php new file mode 100644 index 0000000..8514eb3 --- /dev/null +++ b/old_code_ci3/views/dashboard/opd_print_parcha_radiant_drpoonam.php @@ -0,0 +1,21 @@ + + + +

+
+ +

Print Time :

+
+ \ No newline at end of file diff --git a/old_code_ci3/views/dashboard/opd_print_parcha_singhal.php b/old_code_ci3/views/dashboard/opd_print_parcha_singhal.php new file mode 100644 index 0000000..2532c6e --- /dev/null +++ b/old_code_ci3/views/dashboard/opd_print_parcha_singhal.php @@ -0,0 +1,21 @@ + + + +

+
+ +

Print Time :

+
+ \ No newline at end of file diff --git a/old_code_ci3/views/dashboard/opd_print_parcha_vedanta_hospital_ksp.php b/old_code_ci3/views/dashboard/opd_print_parcha_vedanta_hospital_ksp.php new file mode 100644 index 0000000..2cfdf9e --- /dev/null +++ b/old_code_ci3/views/dashboard/opd_print_parcha_vedanta_hospital_ksp.php @@ -0,0 +1,47 @@ + + + +

+
+ +

Print Time :

+
+ + + + + + +
+ Name :
+
+ Gender/Age :
+ Mob :'
+ Address :' +
+ UHID :
+ Sr No.:
+ OPD No.:
+
Date:
+ +
+ DEPARTMENT :
+ +
+ +
No. of Visit : + +
Book Time : +
\ No newline at end of file diff --git a/old_code_ci3/views/dashboard/opd_queue_status.php b/old_code_ci3/views/dashboard/opd_queue_status.php new file mode 100644 index 0000000..1ac0112 --- /dev/null +++ b/old_code_ci3/views/dashboard/opd_queue_status.php @@ -0,0 +1,41 @@ + +
+
+
+
+
+

Dr. p_fname?>

+

Spec?>

+ +

Refresh

+
+ +
+
+
+
+
+ +
+
diff --git a/old_code_ci3/views/dashboard/opd_queue_status_tab_0.php b/old_code_ci3/views/dashboard/opd_queue_status_tab_0.php new file mode 100644 index 0000000..834c2d0 --- /dev/null +++ b/old_code_ci3/views/dashboard/opd_queue_status_tab_0.php @@ -0,0 +1,50 @@ +
+
+

On Booking List

+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + +
Patient NameOPD No.Booking No.UHIDOPD ID.OPD TypeAction
P_name?>opd_id?>opd_no?>p_code?>opd_code?>Paymode?> + payment_status==1) { ?> + + + + Go For Payment

+ +
+
+
\ No newline at end of file diff --git a/old_code_ci3/views/dashboard/opd_queue_status_tab_1.php b/old_code_ci3/views/dashboard/opd_queue_status_tab_1.php new file mode 100644 index 0000000..1dc0445 --- /dev/null +++ b/old_code_ci3/views/dashboard/opd_queue_status_tab_1.php @@ -0,0 +1,71 @@ +
+
+

On Waiting List

+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
OPD No.Current PatientQ No.UHIDOPD TypeAction
opd_id?> + P_name?> { p_rname?> } + queue_no?>p_code?>opd_fee_desc?>/ Amt.:opd_fee_amount?> + + + + + +
OPD No.Current PatientQueue No.UHIDOPD TypeAction
+
+
+ diff --git a/old_code_ci3/views/dashboard/opd_queue_status_tab_2.php b/old_code_ci3/views/dashboard/opd_queue_status_tab_2.php new file mode 100644 index 0000000..3368e0c --- /dev/null +++ b/old_code_ci3/views/dashboard/opd_queue_status_tab_2.php @@ -0,0 +1,38 @@ +
+
+

Visited List

+
+ +
+ + + + + + + + + + + + +
opd_id?>opd_code?>P_name?> { p_rname?> }queue_no?>p_code?>opd_fee_desc?>/ Amt.:opd_fee_amount?> + + + +
+
+
\ No newline at end of file diff --git a/old_code_ci3/views/dashboard/opd_queue_status_tab_3.php b/old_code_ci3/views/dashboard/opd_queue_status_tab_3.php new file mode 100644 index 0000000..6c03a43 --- /dev/null +++ b/old_code_ci3/views/dashboard/opd_queue_status_tab_3.php @@ -0,0 +1,37 @@ +
+
+

OPD Cancellation List

+
+ +
+ + + + + + + + + + + + +
opd_id?>opd_code?>P_name?> { p_rname?> }queue_no?>p_code?>opd_fee_desc?>/ Amt.:opd_fee_amount?> + + +
+
+
\ No newline at end of file diff --git a/old_code_ci3/views/dashboard/opd_queue_status_total.php b/old_code_ci3/views/dashboard/opd_queue_status_total.php new file mode 100644 index 0000000..ede6ad8 --- /dev/null +++ b/old_code_ci3/views/dashboard/opd_queue_status_total.php @@ -0,0 +1,5 @@ +
On Waiting :count_wait?>
+
No. of Visited :count_visit?>
+
Canceled :count_cancel?>
+
Total : No_opd?>
+ \ No newline at end of file diff --git a/old_code_ci3/views/dashboard/opd_scan.php b/old_code_ci3/views/dashboard/opd_scan.php new file mode 100644 index 0000000..1d70208 --- /dev/null +++ b/old_code_ci3/views/dashboard/opd_scan.php @@ -0,0 +1,26 @@ +
+
+
+
Upload
+ + + +
+
+
\ No newline at end of file diff --git a/old_code_ci3/views/dashboard/patient_glucose_data.php b/old_code_ci3/views/dashboard/patient_glucose_data.php new file mode 100644 index 0000000..9c0e555 --- /dev/null +++ b/old_code_ci3/views/dashboard/patient_glucose_data.php @@ -0,0 +1,222 @@ +
+
+
+ +
+
+

Glucose Chart

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

Glucose Value

+
+
+ 'form','class'=>'form_g')); ?> +
+
+
+ +
+
+ +
+ +
+ +
+
+
+
+ + +
+
+
+
+ + +
+
+
+ +
+
+ +
+ + + + + + + + + + + + + + + + + +
DateFast GlucoseAfter Food GlucoseRandom GlucoseRemove
test_date?>r_sugar?>f_sugar?>a_sugar?>
+
+
+ +
+
+
+
+ \ No newline at end of file diff --git a/old_code_ci3/views/dashboard/patient_investigation.php b/old_code_ci3/views/dashboard/patient_investigation.php new file mode 100644 index 0000000..53651b9 --- /dev/null +++ b/old_code_ci3/views/dashboard/patient_investigation.php @@ -0,0 +1,122 @@ +
+
+
+
+
+

Investigation Value

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

Investigation Value

+
+
+
+ + + + + + + + + + + + + + + + + + + +
DateInvestigationValueNormal RangeResultRemove
date_investigation?>investigation_name?>result?>normal_range?>result_text?>
+
+
+
+
+
+ \ No newline at end of file diff --git a/old_code_ci3/views/dashboard/patient_remark.php b/old_code_ci3/views/dashboard/patient_remark.php new file mode 100644 index 0000000..0aa4e78 --- /dev/null +++ b/old_code_ci3/views/dashboard/patient_remark.php @@ -0,0 +1,158 @@ +

+
+
+
+
+
+

Patient Personal Remark

+
+ +
+ +

Write By insert_by?> + Date : : ins_time?>

+

remark) ?>

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

Remark

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

Assign Tag

+
+ +
+
+
+ + '; + echo '
'.$row->tag_name.'
'.$row->assign_by.'
'; + echo ' '; + echo ' '; + echo '
'; + } + ?> +
+
+
+ + +
+
+
+
+ diff --git a/old_code_ci3/views/dashboard/person_profile_photo_from_doctor.php b/old_code_ci3/views/dashboard/person_profile_photo_from_doctor.php new file mode 100644 index 0000000..2ce3058 --- /dev/null +++ b/old_code_ci3/views/dashboard/person_profile_photo_from_doctor.php @@ -0,0 +1,99 @@ +
+

+ Profile Picture : p_fname; ?> + Scan +

+ +
+
+
+
+
+
+
+
+ Scan +
+
+
+
+
+
+
+ + +
+
+
Your captured image will appear here...
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ + \ No newline at end of file diff --git a/old_code_ci3/views/dashboard/rx_group.php b/old_code_ci3/views/dashboard/rx_group.php new file mode 100644 index 0000000..c1fff91 --- /dev/null +++ b/old_code_ci3/views/dashboard/rx_group.php @@ -0,0 +1,62 @@ +
+

+ Rx-Group +

+ +
+
+
+
+
+
+ +
+

Rx-Group List List

+
+
+
+ +
+ +
+ +
+ + + + + + + + + + + + + + + + + + + + + +
Rx-Group NameAction
rx_group_name ?> + +
Rx-Group NameAction
+ +
+ +
+
+
+ +
+
+ +
\ No newline at end of file diff --git a/old_code_ci3/views/dashboard/rx_group_list.php b/old_code_ci3/views/dashboard/rx_group_list.php new file mode 100644 index 0000000..3a04733 --- /dev/null +++ b/old_code_ci3/views/dashboard/rx_group_list.php @@ -0,0 +1,27 @@ + + + + + + + + + + + + + + + + + + + + + +
Rx-Group NameAction
rx_group_name ?> + +
Rx-Group NameAction
+ \ No newline at end of file diff --git a/old_code_ci3/views/dashboard/rx_print_chamunda_plain_paper.php b/old_code_ci3/views/dashboard/rx_print_chamunda_plain_paper.php new file mode 100644 index 0000000..4228b70 --- /dev/null +++ b/old_code_ci3/views/dashboard/rx_print_chamunda_plain_paper.php @@ -0,0 +1,172 @@ + + + + + + + + + +
+ + +

+

An ISO Certified 9001 : 2015
+ NABH (Fully Accredited) Hospital +

+

,
+ +

+

+ Dr. doc_name ?> +

+ doc_sign)?> +
+
+
+ +

Print Time :

+
+ + + + + + +
+ Name :
+
+ Gender/Age :
+ Mob :'
+ Address :' +
+ UHID :
+ Sr No.:
+ OPD No.:
+
Date:
+
+ DEPARTMENT :
+ +
+ +
No. of Visit : + +
Book Time : +
+
+
+ '; + if(strlen($vital_content)>0){ + echo $vital_content; + echo '
'; + } + + if(strlen($Complaint)>0){ + echo $Complaint; + echo '
'; + } + + if(strlen($painscale)>0){ + echo $painscale; + echo '
'; + } + + if(strlen($diagnosis)>0){ + echo $diagnosis; + echo '
'; + } + + if(strlen($morbidities)>0){ + echo 'Co-Morbidities : '.$morbidities; + echo '
'; + } + + if(strlen($Addiction)>0){ + echo 'Addiction : '.$Addiction; + echo '
'; + } + + if(strlen($Complication)>0){ + echo 'Complication : '.$Complication; + echo '
'; + } + + + if(strlen($Finding_Examinations)>0){ + echo $Finding_Examinations; + echo '
'; + } + + + echo $medical; + echo '
'; + + if(strlen($investigation)>0){ + echo $investigation; + echo '
'; + } + + + if(strlen($Prescriber_Remarks)>0){ + echo $Prescriber_Remarks; + echo '
'; + } + + if(strlen($advice)>0){ + echo $advice; + echo '
'; + } + + if(strlen($next_visit)>0){ + echo $next_visit; + echo '
'; + } + + if(strlen($refer_to)>0){ + echo $refer_to; + echo '
'; + } + echo '
'; + + + ?> +
\ No newline at end of file diff --git a/old_code_ci3/views/dashboard/rx_print_chamunda_pre_print_letter_head_format.php b/old_code_ci3/views/dashboard/rx_print_chamunda_pre_print_letter_head_format.php new file mode 100644 index 0000000..ea2b366 --- /dev/null +++ b/old_code_ci3/views/dashboard/rx_print_chamunda_pre_print_letter_head_format.php @@ -0,0 +1,120 @@ + + + +

+
+ +

Print Time :

+
+
+ '; + if(strlen($Complaint)>0){ + echo $Complaint; + echo '
'; + } + + if(strlen($painscale)>0){ + echo $painscale; + echo '
'; + } + + if(strlen($vital_content)>0){ + echo $vital_content; + echo '
'; + } + + + if(strlen($diagnosis)>0){ + echo $diagnosis; + echo '
'; + } + + if(strlen($morbidities)>0){ + echo 'Co-Morbidities : '.$morbidities; + echo '
'; + } + + if(strlen($Addiction)>0){ + echo 'Addiction : '.$Addiction; + echo '
'; + } + + if(strlen($Complication)>0){ + echo 'Complication : '.$Complication; + echo '
'; + } + + + if(strlen($Finding_Examinations)>0){ + echo $Finding_Examinations; + echo '
'; + } + + echo $medical; + echo '
'; + + if(strlen($investigation)>0){ + echo $investigation; + echo '
'; + } + + + + if(strlen($Prescriber_Remarks)>0){ + echo $Prescriber_Remarks; + echo '
'; + } + + + if(strlen($advice)>0){ + echo $advice; + echo '
'; + } + + if(strlen($next_visit)>0){ + echo $next_visit; + echo '
'; + } + + if(strlen($refer_to)>0){ + echo $refer_to; + echo '
'; + } + echo '
'; + + + ?> +
\ No newline at end of file diff --git a/old_code_ci3/views/dashboard/rx_print_chamunda_rx_blank_letter_head.php b/old_code_ci3/views/dashboard/rx_print_chamunda_rx_blank_letter_head.php new file mode 100644 index 0000000..ae5bac8 --- /dev/null +++ b/old_code_ci3/views/dashboard/rx_print_chamunda_rx_blank_letter_head.php @@ -0,0 +1,150 @@ + + + +

+
+ +

Print Time :

+
+
+ + + + + + +
+ Name :
+
+ Gender/Age :
+ Mob :'
+ Address :' +
+ UHID :
+ Sr No.:
+ OPD No.:
+
Date:
+
+ DEPARTMENT :
+ +
+ +
No. of Visit : + +
Book Time : +
+
+
+ + +
+ '; + if(strlen($Complaint)>0){ + echo $Complaint; + echo '
'; + } + + if(strlen($vital_content)>0){ + echo $vital_content; + echo '
'; + } + + if(strlen($painscale)>0){ + echo $painscale; + echo '
'; + } + + if(strlen($diagnosis)>0){ + echo $diagnosis; + echo '
'; + } + + if(strlen($morbidities)>0){ + echo 'Co-Morbidities : '.$morbidities; + echo '
'; + } + + if(strlen($Addiction)>0){ + echo 'Addiction : '.$Addiction; + echo '
'; + } + + if(strlen($Complication)>0){ + echo 'Complication : '.$Complication; + echo '
'; + } + + + if(strlen($Finding_Examinations)>0){ + echo $Finding_Examinations; + echo '
'; + } + + echo $medical; + echo '
'; + + if(strlen($investigation)>0){ + echo $investigation; + echo '
'; + } + + + + if(strlen($Prescriber_Remarks)>0){ + echo $Prescriber_Remarks; + echo '
'; + } + + + if(strlen($advice)>0){ + echo $advice; + echo '
'; + } + + if(strlen($next_visit)>0){ + echo $next_visit; + echo '
'; + } + + if(strlen($refer_to)>0){ + echo $refer_to; + echo '
'; + } + echo '
'; + + + ?> +
\ No newline at end of file diff --git a/old_code_ci3/views/dashboard/rx_print_devbhumi_plain.php b/old_code_ci3/views/dashboard/rx_print_devbhumi_plain.php new file mode 100644 index 0000000..7a9cd00 --- /dev/null +++ b/old_code_ci3/views/dashboard/rx_print_devbhumi_plain.php @@ -0,0 +1,144 @@ + + + + + + + + + +
+ + +

+

,
+ +

+

+ Dr. doc_name ?> +

+ doc_sign)?> +
+
+
+ +

Print Time :

+
+ + + + + + +
+ Name :
+
+ Gender/Age :
+ Mob :'
+ Address :' +
+ UHID :
+ Sr No.:
+ OPD No.:
+
Date:
+
+ DEPARTMENT :
+ +
+ +
No. of Visit : + +
Book Time : +
+
+
+ 0){ + echo $vital_content; + echo '
'; + } + + if(strlen($Complaint)>0){ + echo $Complaint; + echo '
'; + } + + if(strlen($diagnosis)>0){ + echo $diagnosis; + echo '
'; + } + + echo $medical; + echo '
'; + + if(strlen($investigation)>0){ + echo $investigation; + echo '
'; + } + + if(strlen($Finding_Examinations)>0){ + echo $Finding_Examinations; + echo '
'; + } + + if(strlen($Prescriber_Remarks)>0){ + echo $Prescriber_Remarks; + echo '
'; + } + + if(strlen($advice)>0){ + echo $advice; + echo '
'; + } + + if(strlen($next_visit)>0){ + echo $next_visit; + echo '
'; + } + + if(strlen($refer_to)>0){ + echo $refer_to; + echo '
'; + } + echo '
'; + + + ?> +
\ No newline at end of file diff --git a/old_code_ci3/views/dashboard/rx_print_drJoshiclinic_letterhead - Copy.php b/old_code_ci3/views/dashboard/rx_print_drJoshiclinic_letterhead - Copy.php new file mode 100644 index 0000000..a9da963 --- /dev/null +++ b/old_code_ci3/views/dashboard/rx_print_drJoshiclinic_letterhead - Copy.php @@ -0,0 +1,65 @@ + + + +

+
+ +

Print Time :

+
+
+ '; + echo $Complaint; + echo '
'; + echo $Provisional_diagnosis; + echo '
'; + echo $diagnosis; + echo '
'; + echo $medical; + echo '
'; + echo $investigation; + echo '
'; + echo $advice; + echo '
'; + echo $next_visit; + echo '
'; + echo $refer_to; + echo '
'; + echo $doctor; + echo '
'; + + ?> +
\ No newline at end of file diff --git a/old_code_ci3/views/dashboard/rx_print_drJoshiclinic_letterhead.php b/old_code_ci3/views/dashboard/rx_print_drJoshiclinic_letterhead.php new file mode 100644 index 0000000..61a3ab6 --- /dev/null +++ b/old_code_ci3/views/dashboard/rx_print_drJoshiclinic_letterhead.php @@ -0,0 +1,75 @@ + + + +

+
+ +

+
+
+ '; + echo $Complaint; + echo '
'; + echo $Finding_Examinations; + echo '
'; + echo $Provisional_diagnosis; + echo '
'; + echo $diagnosis; + echo '
'; + echo $medical; + echo '
'; + echo $investigation; + echo '
'; + echo $advice; + echo '
'; + echo $next_visit; + echo '
'; + echo $refer_to; + echo '
'; + echo '
'; + + echo '

'; + echo '
'; + echo '
'; + echo '
'; + echo ''.$doc_name.''; + echo '
'; + echo $doc_sign; + echo '

'; + + ?> +
\ No newline at end of file diff --git a/old_code_ci3/views/dashboard/rx_print_drjoshiclinic_plain_paper.php b/old_code_ci3/views/dashboard/rx_print_drjoshiclinic_plain_paper.php new file mode 100644 index 0000000..8d3d290 --- /dev/null +++ b/old_code_ci3/views/dashboard/rx_print_drjoshiclinic_plain_paper.php @@ -0,0 +1,162 @@ + + + + + + + + + +
+ + +

+

,
+ +

+

+ Dr. doc_name ?> +

+ doc_sign)?> +
+
+
+ +

+
+ + + + + + +
+ Name :
+
+ Gender/Age :
+ Mob :'
+ Address :' +
+ UHID :
+ Sr No.:
+ OPD No.:
+
Date:
+
+ DEPARTMENT :
+ +
+ +
No. of Visit : + +
Book Time : +
+
+
+ 0){ + echo $vital_content; + echo '
'; + } + + if(strlen($Complaint)>0){ + echo $Complaint; + echo '
'; + } + + if(strlen($Finding_Examinations)>0){ + echo $Finding_Examinations; + echo '
'; + } + + if(strlen($Provisional_diagnosis)>0){ + echo $Provisional_diagnosis; + echo '
'; + } + + if(strlen($diagnosis)>0){ + echo $diagnosis; + echo '
'; + } + + echo $medical; + echo '
'; + + if(strlen($investigation)>0){ + echo $investigation; + echo '
'; + } + + + + if(strlen($Prescriber_Remarks)>0){ + echo $Prescriber_Remarks; + echo '
'; + } + + if(strlen($advice)>0){ + echo $advice; + echo '
'; + } + + if(strlen($next_visit)>0){ + echo $next_visit; + echo '
'; + } + + if(strlen($refer_to)>0){ + echo $refer_to; + echo '
'; + } + echo '
'; + + //echo $doctor; + + echo '

'; + echo '
'; + echo '
'; + echo '
'; + echo ''.$doc_name.''; + echo '
'; + echo $doc_sign; + echo '

'; + + + ?> +
\ No newline at end of file diff --git a/old_code_ci3/views/dashboard/rx_print_drjoshiclinic_pre_print_letter_head_format.php b/old_code_ci3/views/dashboard/rx_print_drjoshiclinic_pre_print_letter_head_format.php new file mode 100644 index 0000000..c327d2e --- /dev/null +++ b/old_code_ci3/views/dashboard/rx_print_drjoshiclinic_pre_print_letter_head_format.php @@ -0,0 +1,114 @@ + + + +

+
+ +

+
+
+ 0){ + echo $vital_content; + echo '
'; + } + + if(strlen($Complaint)>0){ + echo $Complaint; + echo '
'; + } + + if(strlen($Finding_Examinations)>0){ + echo $Finding_Examinations; + echo '
'; + } + + if(strlen($Provisional_diagnosis)>0){ + echo $Provisional_diagnosis; + echo '
'; + } + + if(strlen($diagnosis)>0){ + echo $diagnosis; + echo '
'; + } + + echo $medical; + echo '
'; + + if(strlen($investigation)>0){ + echo $investigation; + echo '
'; + } + + + + if(strlen($Prescriber_Remarks)>0){ + echo $Prescriber_Remarks; + echo '
'; + } + + if(strlen($advice)>0){ + echo $advice; + echo '
'; + } + + if(strlen($next_visit)>0){ + echo $next_visit; + echo '
'; + } + + if(strlen($refer_to)>0){ + echo $refer_to; + echo '
'; + } + echo '
'; + + //echo $doctor; +echo '
'; + + echo '

'; + echo '
'; + echo '
'; + echo '
'; + echo ''.$doc_name.''; + echo '
'; + echo $doc_sign; + echo '

'; + + + ?> +
\ No newline at end of file diff --git a/old_code_ci3/views/dashboard/rx_print_drjoshiclinic_rx_blank_letter_head.php b/old_code_ci3/views/dashboard/rx_print_drjoshiclinic_rx_blank_letter_head.php new file mode 100644 index 0000000..77e606b --- /dev/null +++ b/old_code_ci3/views/dashboard/rx_print_drjoshiclinic_rx_blank_letter_head.php @@ -0,0 +1,143 @@ + + + +

+
+ +

+
+
+ + + + + + +
+ Name :
+
+ Gender/Age :
+ Mob :'
+ Address :' +
+ UHID :
+ Sr No.:
+ OPD No.:
+
Date:
+
+ DEPARTMENT :
+ +
+ +
No. of Visit : + +
Book Time : +
+
+
+ 0){ + echo $vital_content; + echo '
'; + } + + if(strlen($Complaint)>0){ + echo $Complaint; + echo '
'; + } + + if(strlen($Finding_Examinations)>0){ + echo $Finding_Examinations; + echo '
'; + } + + if(strlen($Provisional_diagnosis)>0){ + echo $Provisional_diagnosis; + echo '
'; + } + + if(strlen($diagnosis)>0){ + echo $diagnosis; + echo '
'; + } + + echo $medical; + echo '
'; + + if(strlen($investigation)>0){ + echo $investigation; + echo '
'; + } + + + + if(strlen($Prescriber_Remarks)>0){ + echo $Prescriber_Remarks; + echo '
'; + } + + if(strlen($advice)>0){ + echo $advice; + echo '
'; + } + + if(strlen($next_visit)>0){ + echo $next_visit; + echo '
'; + } + + if(strlen($refer_to)>0){ + echo $refer_to; + echo '
'; + } + echo '
'; + + //echo $doctor; +echo '
'; + + echo '

'; + echo '
'; + echo '
'; + echo '
'; + echo ''.$doc_name.''; + echo '
'; + echo $doc_sign; + echo '

'; + + ?> +
\ No newline at end of file diff --git a/old_code_ci3/views/dashboard/rx_print_letterhead_drbcjoshi.php b/old_code_ci3/views/dashboard/rx_print_letterhead_drbcjoshi.php new file mode 100644 index 0000000..1278fa5 --- /dev/null +++ b/old_code_ci3/views/dashboard/rx_print_letterhead_drbcjoshi.php @@ -0,0 +1,102 @@ + + + +

+
+ +

Print Time :

+
+ +
+ 0){ + echo $vital_content; + echo '
'; + } + + if(strlen($Complaint)>0){ + echo $Complaint; + echo '
'; + } + + if(strlen($Provisional_diagnosis)>0){ + echo $Provisional_diagnosis; + echo '
'; + } + + if(strlen($diagnosis)>0){ + echo $diagnosis; + echo '
'; + } + + echo $medical; + echo '
'; + + if(strlen($investigation)>0){ + echo $investigation; + echo '
'; + } + + if(strlen($Finding_Examinations)>0){ + echo $Finding_Examinations; + echo '
'; + } + + if(strlen($Prescriber_Remarks)>0){ + echo $Prescriber_Remarks; + echo '
'; + } + + if(strlen($advice)>0){ + echo $advice; + echo '
'; + } + + if(strlen($next_visit)>0){ + echo $next_visit; + echo '
'; + } + + if(strlen($refer_to)>0){ + echo $refer_to; + echo '
'; + } + echo '
'; + + echo $doctor; + + ?> +
\ No newline at end of file diff --git a/old_code_ci3/views/dashboard/rx_print_letterhead_singhal.php b/old_code_ci3/views/dashboard/rx_print_letterhead_singhal.php new file mode 100644 index 0000000..65038bc --- /dev/null +++ b/old_code_ci3/views/dashboard/rx_print_letterhead_singhal.php @@ -0,0 +1,64 @@ + + + +

+
+ +

Print Time :

+
+ +
+ '; + echo $Complaint; + echo $diagnosis; + echo '
'; + echo $medical; + echo '
'; + echo $investigation; + echo '
'; + echo $advice; + echo '
'; + echo $next_visit; + echo '
'; + echo $refer_to; + echo '
'; + echo $doctor; + echo '
'; + + ?> +
\ No newline at end of file diff --git a/old_code_ci3/views/dashboard/rx_print_mehrotra_aseem_blank_letter_head.php b/old_code_ci3/views/dashboard/rx_print_mehrotra_aseem_blank_letter_head.php new file mode 100644 index 0000000..44480e0 --- /dev/null +++ b/old_code_ci3/views/dashboard/rx_print_mehrotra_aseem_blank_letter_head.php @@ -0,0 +1,124 @@ + + + +

+
+ + +
+ + + + + + +
+ Name :
+
+ Gender/Age :
+ Mob :'
+ Address :' +
+ UHID :
+ Sr No.:
+ OPD No.:
+
Date:
+
+ DEPARTMENT :
+ +
+ +
No. of Visit : + +
Book Time : +
+
+
+ + +
+ 0){ + echo $vital_content; + echo '
'; + } + + if(strlen($Complaint)>0){ + echo $Complaint; + echo '
'; + } + + if(strlen($diagnosis)>0){ + echo $diagnosis; + echo '
'; + } + + echo $medical; + echo '
'; + + if(strlen($investigation)>0){ + echo $investigation; + echo '
'; + } + + if(strlen($Finding_Examinations)>0){ + echo $Finding_Examinations; + echo '
'; + } + + if(strlen($Prescriber_Remarks)>0){ + echo $Prescriber_Remarks; + echo '
'; + } + + + if(strlen($advice)>0){ + echo $advice; + echo '
'; + } + + if(strlen($next_visit)>0){ + echo $next_visit; + echo '
'; + } + + if(strlen($refer_to)>0){ + echo $refer_to; + echo '
'; + } + echo '
'; + + + ?> +
\ No newline at end of file diff --git a/old_code_ci3/views/dashboard/rx_print_mehrotra_aseem_pre_print_letter_head_format.php b/old_code_ci3/views/dashboard/rx_print_mehrotra_aseem_pre_print_letter_head_format.php new file mode 100644 index 0000000..034d74b --- /dev/null +++ b/old_code_ci3/views/dashboard/rx_print_mehrotra_aseem_pre_print_letter_head_format.php @@ -0,0 +1,98 @@ + + + +

+
+ + +
+ +
+ + +
+ 0){ + echo $vital_content; + echo '
'; + } + + if(strlen($Complaint)>0){ + echo $Complaint; + echo '
'; + } + + if(strlen($diagnosis)>0){ + echo $diagnosis; + echo '
'; + } + + echo $medical; + echo '
'; + + if(strlen($investigation)>0){ + echo $investigation; + echo '
'; + } + + if(strlen($Finding_Examinations)>0){ + echo $Finding_Examinations; + echo '
'; + } + + if(strlen($Prescriber_Remarks)>0){ + echo $Prescriber_Remarks; + echo '
'; + } + + + if(strlen($advice)>0){ + echo $advice; + echo '
'; + } + + if(strlen($next_visit)>0){ + echo $next_visit; + echo '
'; + } + + if(strlen($refer_to)>0){ + echo $refer_to; + echo '
'; + } + echo '
'; + + + ?> +
\ No newline at end of file diff --git a/old_code_ci3/views/dashboard/rx_print_mehrotra_plain_paper.php b/old_code_ci3/views/dashboard/rx_print_mehrotra_plain_paper.php new file mode 100644 index 0000000..7a9cd00 --- /dev/null +++ b/old_code_ci3/views/dashboard/rx_print_mehrotra_plain_paper.php @@ -0,0 +1,144 @@ + + + + + + + + + +
+ + +

+

,
+ +

+

+ Dr. doc_name ?> +

+ doc_sign)?> +
+
+
+ +

Print Time :

+
+ + + + + + +
+ Name :
+
+ Gender/Age :
+ Mob :'
+ Address :' +
+ UHID :
+ Sr No.:
+ OPD No.:
+
Date:
+
+ DEPARTMENT :
+ +
+ +
No. of Visit : + +
Book Time : +
+
+
+ 0){ + echo $vital_content; + echo '
'; + } + + if(strlen($Complaint)>0){ + echo $Complaint; + echo '
'; + } + + if(strlen($diagnosis)>0){ + echo $diagnosis; + echo '
'; + } + + echo $medical; + echo '
'; + + if(strlen($investigation)>0){ + echo $investigation; + echo '
'; + } + + if(strlen($Finding_Examinations)>0){ + echo $Finding_Examinations; + echo '
'; + } + + if(strlen($Prescriber_Remarks)>0){ + echo $Prescriber_Remarks; + echo '
'; + } + + if(strlen($advice)>0){ + echo $advice; + echo '
'; + } + + if(strlen($next_visit)>0){ + echo $next_visit; + echo '
'; + } + + if(strlen($refer_to)>0){ + echo $refer_to; + echo '
'; + } + echo '
'; + + + ?> +
\ No newline at end of file diff --git a/old_code_ci3/views/dashboard/rx_print_mehrotra_pre_print_letter_head_format.php b/old_code_ci3/views/dashboard/rx_print_mehrotra_pre_print_letter_head_format.php new file mode 100644 index 0000000..eb9a851 --- /dev/null +++ b/old_code_ci3/views/dashboard/rx_print_mehrotra_pre_print_letter_head_format.php @@ -0,0 +1,94 @@ + + + +

+
+ +

Print Time :

+
+
+ 0){ + echo $vital_content; + echo '
'; + } + + if(strlen($Complaint)>0){ + echo $Complaint; + echo '
'; + } + + if(strlen($diagnosis)>0){ + echo $diagnosis; + echo '
'; + } + + echo $medical; + echo '
'; + + if(strlen($investigation)>0){ + echo $investigation; + echo '
'; + } + + if(strlen($Finding_Examinations)>0){ + echo $Finding_Examinations; + echo '
'; + } + + if(strlen($Prescriber_Remarks)>0){ + echo $Prescriber_Remarks; + echo '
'; + } + + + if(strlen($advice)>0){ + echo $advice; + echo '
'; + } + + if(strlen($next_visit)>0){ + echo $next_visit; + echo '
'; + } + + if(strlen($refer_to)>0){ + echo $refer_to; + echo '
'; + } + echo '
'; + + + ?> +
\ No newline at end of file diff --git a/old_code_ci3/views/dashboard/rx_print_mehrotra_rx_blank_letter_head..php b/old_code_ci3/views/dashboard/rx_print_mehrotra_rx_blank_letter_head..php new file mode 100644 index 0000000..3f803d0 --- /dev/null +++ b/old_code_ci3/views/dashboard/rx_print_mehrotra_rx_blank_letter_head..php @@ -0,0 +1,124 @@ + + + +

+
+ +

Print Time :

+
+
+ + + + + + +
+ Name :
+
+ Gender/Age :
+ Mob :'
+ Address :' +
+ UHID :
+ Sr No.:
+ OPD No.:
+
Date:
+
+ DEPARTMENT :
+ +
+ +
No. of Visit : + +
Book Time : +
+
+ + +
+ 0){ + echo $vital_content; + echo '
'; + } + + if(strlen($Complaint)>0){ + echo $Complaint; + echo '
'; + } + + if(strlen($diagnosis)>0){ + echo $diagnosis; + echo '
'; + } + + echo $medical; + echo '
'; + + if(strlen($investigation)>0){ + echo $investigation; + echo '
'; + } + + if(strlen($Finding_Examinations)>0){ + echo $Finding_Examinations; + echo '
'; + } + + if(strlen($Prescriber_Remarks)>0){ + echo $Prescriber_Remarks; + echo '
'; + } + + + if(strlen($advice)>0){ + echo $advice; + echo '
'; + } + + if(strlen($next_visit)>0){ + echo $next_visit; + echo '
'; + } + + if(strlen($refer_to)>0){ + echo $refer_to; + echo '
'; + } + echo '
'; + + + ?> +
\ No newline at end of file diff --git a/old_code_ci3/views/dashboard/rx_print_sahara_plain_paper.php b/old_code_ci3/views/dashboard/rx_print_sahara_plain_paper.php new file mode 100644 index 0000000..d4bca80 --- /dev/null +++ b/old_code_ci3/views/dashboard/rx_print_sahara_plain_paper.php @@ -0,0 +1,90 @@ + + + + + + + + + +
+ + +

+ +

,
+ +

+

+ Dr. doc_name ?> +

+ doc_sign)?> +
+
+
+ +

Print Time :

+
+ + + + + + +
+ Name :
+
+ Gender/Age :
+ Mob :'
+ Address :' +
+ UHID :
+ Sr No.:
+ OPD No.:
+
Date:
+
+ DEPARTMENT :
+ +
+ +
No. of Visit : + +
Book Time : +
diff --git a/old_code_ci3/views/dashboard/rx_print_singhal_plain_paper.php b/old_code_ci3/views/dashboard/rx_print_singhal_plain_paper.php new file mode 100644 index 0000000..bcb0941 --- /dev/null +++ b/old_code_ci3/views/dashboard/rx_print_singhal_plain_paper.php @@ -0,0 +1,144 @@ + + + + + + + + + +
+ + +

+

,
+ +

+

+ Dr. doc_name ?> +

+ doc_sign)?> +
+
+
+ +

Print Time :

+
+ + + + + + +
+ Name :
+
+ Gender/Age :
+ Mob :'
+ Address :' +
+ UHID :
+ Sr No.:
+ OPD No.:
+
Date:
+
+ DEPARTMENT :
+ +
+ +
No. of Visit : + +
Book Time : +
+
+
+ 0){ + echo $vital_content; + echo '
'; + } + + if(strlen($Complaint)>0){ + echo $Complaint; + echo '
'; + } + + if(strlen($diagnosis)>0){ + echo $diagnosis; + echo '
'; + } + + echo $medical; + echo '
'; + + if(strlen($investigation)>0){ + echo $investigation; + echo '
'; + } + + if(strlen($Finding_Examinations)>0){ + echo $Finding_Examinations; + echo '
'; + } + + if(strlen($Prescriber_Remarks)>0){ + echo $Prescriber_Remarks; + echo '
'; + } + + if(strlen($advice)>0){ + echo $advice; + echo '
'; + } + + if(strlen($next_visit)>0){ + echo $next_visit; + echo '
'; + } + + if(strlen($refer_to)>0){ + echo $refer_to; + echo '
'; + } + echo '
'; + echo $doctor; + + ?> +
\ No newline at end of file diff --git a/old_code_ci3/views/dashboard/rx_print_singhal_pre_print_letter_head_format.php b/old_code_ci3/views/dashboard/rx_print_singhal_pre_print_letter_head_format.php new file mode 100644 index 0000000..370f9cd --- /dev/null +++ b/old_code_ci3/views/dashboard/rx_print_singhal_pre_print_letter_head_format.php @@ -0,0 +1,94 @@ + + + +

+
+ +

Print Time :

+
+
+ 0){ + echo $vital_content; + echo '
'; + } + + if(strlen($Complaint)>0){ + echo $Complaint; + echo '
'; + } + + if(strlen($diagnosis)>0){ + echo $diagnosis; + echo '
'; + } + + echo $medical; + echo '
'; + + if(strlen($investigation)>0){ + echo $investigation; + echo '
'; + } + + if(strlen($Finding_Examinations)>0){ + echo $Finding_Examinations; + echo '
'; + } + + if(strlen($Prescriber_Remarks)>0){ + echo $Prescriber_Remarks; + echo '
'; + } + + + if(strlen($advice)>0){ + echo $advice; + echo '
'; + } + + if(strlen($next_visit)>0){ + echo $next_visit; + echo '
'; + } + + if(strlen($refer_to)>0){ + echo $refer_to; + echo '
'; + } + echo '
'; + echo $doctor; + + ?> +
\ No newline at end of file diff --git a/old_code_ci3/views/dashboard/rx_print_singhal_rx_blank_letter_head.php b/old_code_ci3/views/dashboard/rx_print_singhal_rx_blank_letter_head.php new file mode 100644 index 0000000..d6dc329 --- /dev/null +++ b/old_code_ci3/views/dashboard/rx_print_singhal_rx_blank_letter_head.php @@ -0,0 +1,124 @@ + + + +

+
+ +

Print Time :

+
+
+ + + + + + +
+ Name :
+
+ Gender/Age :
+ Mob :'
+ Address :' +
+ UHID :
+ Sr No.:
+ OPD No.:
+
Date:
+
+ DEPARTMENT :
+ +
+ +
No. of Visit : + +
Book Time : +
+
+ + +
+ 0){ + echo $vital_content; + echo '
'; + } + + if(strlen($Complaint)>0){ + echo $Complaint; + echo '
'; + } + + if(strlen($diagnosis)>0){ + echo $diagnosis; + echo '
'; + } + + echo $medical; + echo '
'; + + if(strlen($investigation)>0){ + echo $investigation; + echo '
'; + } + + if(strlen($Finding_Examinations)>0){ + echo $Finding_Examinations; + echo '
'; + } + + if(strlen($Prescriber_Remarks)>0){ + echo $Prescriber_Remarks; + echo '
'; + } + + + if(strlen($advice)>0){ + echo $advice; + echo '
'; + } + + if(strlen($next_visit)>0){ + echo $next_visit; + echo '
'; + } + + if(strlen($refer_to)>0){ + echo $refer_to; + echo '
'; + } + echo '
'; + echo $doctor; + + ?> +
\ No newline at end of file diff --git a/old_code_ci3/views/dashboard/rx_print_svh_plain_paper.php b/old_code_ci3/views/dashboard/rx_print_svh_plain_paper.php new file mode 100644 index 0000000..6eb400d --- /dev/null +++ b/old_code_ci3/views/dashboard/rx_print_svh_plain_paper.php @@ -0,0 +1,152 @@ + + + + + + + + + +
+ + +

+

,
+ +

+

+ Dr. doc_name ?> +

+ doc_sign)?> +
+
+
+ +

Print Time :

+
+ + + + + + +
+ Name :
+
+ Gender/Age :
+ Mob :'
+ Address :' +
+ UHID :
+ Sr No.:
+ OPD No.:
+
Date:
+
+ DEPARTMENT :
+ +
+ +
No. of Visit : + +
Book Time : +
+
+
+ '; + if(strlen($vital_content)>0){ + echo $vital_content; + echo '
'; + } + + if(strlen($Complaint)>0){ + echo $Complaint; + echo '
'; + } + + if(strlen($diagnosis)>0){ + echo $diagnosis; + echo '
'; + } + + echo $medical; + echo '
'; + + if(strlen($investigation)>0){ + echo $investigation; + echo '
'; + } + + if(strlen($Finding_Examinations)>0){ + echo $Finding_Examinations; + echo '
'; + } + + if(strlen($Prescriber_Remarks)>0){ + echo $Prescriber_Remarks; + echo '
'; + } + + if(strlen($advice)>0){ + echo $advice; + echo '
'; + } + + if(strlen($next_visit)>0){ + echo $next_visit; + echo '
'; + } + + if(strlen($refer_to)>0){ + echo $refer_to; + echo '
'; + } + + echo '

'; + echo '
'; + echo '
'; + echo '
'; + echo ''.$doc_name.''; + echo '
'; + echo $doc_sign; + echo '

'; + ?> +
\ No newline at end of file diff --git a/old_code_ci3/views/dashboard/rx_print_svh_pre_print_letter_head_format.php b/old_code_ci3/views/dashboard/rx_print_svh_pre_print_letter_head_format.php new file mode 100644 index 0000000..3409f87 --- /dev/null +++ b/old_code_ci3/views/dashboard/rx_print_svh_pre_print_letter_head_format.php @@ -0,0 +1,104 @@ + + + +

+
+ +

Print Time :

+
+
+ 0){ + echo $Complaint; + echo '
'; + } + + if(strlen($vital_content)>0){ + echo $vital_content; + echo '
'; + } + + + if(strlen($diagnosis)>0){ + echo $diagnosis; + echo '
'; + } + + echo $medical; + echo '
'; + + if(strlen($investigation)>0){ + echo $investigation; + echo '
'; + } + + if(strlen($Finding_Examinations)>0){ + echo $Finding_Examinations; + echo '
'; + } + + if(strlen($Prescriber_Remarks)>0){ + echo $Prescriber_Remarks; + echo '
'; + } + + + if(strlen($advice)>0){ + echo $advice; + echo '
'; + } + + if(strlen($next_visit)>0){ + echo $next_visit; + echo '
'; + } + + if(strlen($refer_to)>0){ + echo $refer_to; + echo '
'; + } + echo '
'; + + + echo '

'; + echo '
'; + echo '
'; + echo '
'; + echo ''.$doc_name.''; + echo '
'; + echo $doc_sign; + echo '

'; + ?> +
\ No newline at end of file diff --git a/old_code_ci3/views/dashboard/rx_print_svh_rx_blank_letter_head.php b/old_code_ci3/views/dashboard/rx_print_svh_rx_blank_letter_head.php new file mode 100644 index 0000000..d5c6051 --- /dev/null +++ b/old_code_ci3/views/dashboard/rx_print_svh_rx_blank_letter_head.php @@ -0,0 +1,131 @@ + + + +

+
+ +

Print Time :

+
+
+ + + + + + +
+ Name :
+
+ Gender/Age :
+ Mob :'
+ Address :' +
+ UHID :
+ Sr No.:
+ OPD No.:
+
Date:
+
+ DEPARTMENT :
+ +
+ +
No. of Visit : + +
Book Time : +
+
+
+
+ 0){ + echo $Complaint; + echo '
'; + } + + if(strlen($vital_content)>0){ + echo $vital_content; + echo '
'; + } + + if(strlen($diagnosis)>0){ + echo $diagnosis; + echo '
'; + } + + echo $medical; + echo '
'; + + if(strlen($investigation)>0){ + echo $investigation; + echo '
'; + } + + if(strlen($Finding_Examinations)>0){ + echo $Finding_Examinations; + echo '
'; + } + + if(strlen($Prescriber_Remarks)>0){ + echo $Prescriber_Remarks; + echo '
'; + } + + + if(strlen($advice)>0){ + echo $advice; + echo '
'; + } + + if(strlen($next_visit)>0){ + echo $next_visit; + echo '
'; + } + + if(strlen($refer_to)>0){ + echo $refer_to; + echo '
'; + } + echo '
'; + + echo '

'; + echo '
'; + echo '
'; + echo '
'; + echo ''.$doc_name.''; + echo '
'; + echo $doc_sign; + echo '

'; + ?> +
\ No newline at end of file diff --git a/old_code_ci3/views/dashboard/rx_print_vedanta_plain_paper.php b/old_code_ci3/views/dashboard/rx_print_vedanta_plain_paper.php new file mode 100644 index 0000000..7a9cd00 --- /dev/null +++ b/old_code_ci3/views/dashboard/rx_print_vedanta_plain_paper.php @@ -0,0 +1,144 @@ + + + + + + + + + +
+ + +

+

,
+ +

+

+ Dr. doc_name ?> +

+ doc_sign)?> +
+
+
+ +

Print Time :

+
+ + + + + + +
+ Name :
+
+ Gender/Age :
+ Mob :'
+ Address :' +
+ UHID :
+ Sr No.:
+ OPD No.:
+
Date:
+
+ DEPARTMENT :
+ +
+ +
No. of Visit : + +
Book Time : +
+
+
+ 0){ + echo $vital_content; + echo '
'; + } + + if(strlen($Complaint)>0){ + echo $Complaint; + echo '
'; + } + + if(strlen($diagnosis)>0){ + echo $diagnosis; + echo '
'; + } + + echo $medical; + echo '
'; + + if(strlen($investigation)>0){ + echo $investigation; + echo '
'; + } + + if(strlen($Finding_Examinations)>0){ + echo $Finding_Examinations; + echo '
'; + } + + if(strlen($Prescriber_Remarks)>0){ + echo $Prescriber_Remarks; + echo '
'; + } + + if(strlen($advice)>0){ + echo $advice; + echo '
'; + } + + if(strlen($next_visit)>0){ + echo $next_visit; + echo '
'; + } + + if(strlen($refer_to)>0){ + echo $refer_to; + echo '
'; + } + echo '
'; + + + ?> +
\ No newline at end of file diff --git a/old_code_ci3/views/dashboard/rx_print_vedanta_pre_print_letter_head_format.php b/old_code_ci3/views/dashboard/rx_print_vedanta_pre_print_letter_head_format.php new file mode 100644 index 0000000..eb9a851 --- /dev/null +++ b/old_code_ci3/views/dashboard/rx_print_vedanta_pre_print_letter_head_format.php @@ -0,0 +1,94 @@ + + + +

+
+ +

Print Time :

+
+
+ 0){ + echo $vital_content; + echo '
'; + } + + if(strlen($Complaint)>0){ + echo $Complaint; + echo '
'; + } + + if(strlen($diagnosis)>0){ + echo $diagnosis; + echo '
'; + } + + echo $medical; + echo '
'; + + if(strlen($investigation)>0){ + echo $investigation; + echo '
'; + } + + if(strlen($Finding_Examinations)>0){ + echo $Finding_Examinations; + echo '
'; + } + + if(strlen($Prescriber_Remarks)>0){ + echo $Prescriber_Remarks; + echo '
'; + } + + + if(strlen($advice)>0){ + echo $advice; + echo '
'; + } + + if(strlen($next_visit)>0){ + echo $next_visit; + echo '
'; + } + + if(strlen($refer_to)>0){ + echo $refer_to; + echo '
'; + } + echo '
'; + + + ?> +
\ No newline at end of file diff --git a/old_code_ci3/views/dashboard/rx_print_vedanta_rx_blank_letter_head.php b/old_code_ci3/views/dashboard/rx_print_vedanta_rx_blank_letter_head.php new file mode 100644 index 0000000..3f803d0 --- /dev/null +++ b/old_code_ci3/views/dashboard/rx_print_vedanta_rx_blank_letter_head.php @@ -0,0 +1,124 @@ + + + +

+
+ +

Print Time :

+
+
+ + + + + + +
+ Name :
+
+ Gender/Age :
+ Mob :'
+ Address :' +
+ UHID :
+ Sr No.:
+ OPD No.:
+
Date:
+
+ DEPARTMENT :
+ +
+ +
No. of Visit : + +
Book Time : +
+
+ + +
+ 0){ + echo $vital_content; + echo '
'; + } + + if(strlen($Complaint)>0){ + echo $Complaint; + echo '
'; + } + + if(strlen($diagnosis)>0){ + echo $diagnosis; + echo '
'; + } + + echo $medical; + echo '
'; + + if(strlen($investigation)>0){ + echo $investigation; + echo '
'; + } + + if(strlen($Finding_Examinations)>0){ + echo $Finding_Examinations; + echo '
'; + } + + if(strlen($Prescriber_Remarks)>0){ + echo $Prescriber_Remarks; + echo '
'; + } + + + if(strlen($advice)>0){ + echo $advice; + echo '
'; + } + + if(strlen($next_visit)>0){ + echo $next_visit; + echo '
'; + } + + if(strlen($refer_to)>0){ + echo $refer_to; + echo '
'; + } + echo '
'; + + + ?> +
\ No newline at end of file diff --git a/old_code_ci3/views/dashboard/samarpit_opd_parcha.php b/old_code_ci3/views/dashboard/samarpit_opd_parcha.php new file mode 100644 index 0000000..459d14d --- /dev/null +++ b/old_code_ci3/views/dashboard/samarpit_opd_parcha.php @@ -0,0 +1,98 @@ + + +
+ +
+
+ +
+
+ OPD No : / UHID : / OPD Fee : +
+
+ +
+
+ +
+ + diff --git a/old_code_ci3/views/dashboard/shri_ram_hospital.php b/old_code_ci3/views/dashboard/shri_ram_hospital.php new file mode 100644 index 0000000..64c5257 --- /dev/null +++ b/old_code_ci3/views/dashboard/shri_ram_hospital.php @@ -0,0 +1,57 @@ + + + +

Shri Ram Hospital
श्री राम अस्पताल

+ + + + + + +
+

+ Dr. Krishna Sah +

+ M.B.B.S, M.S. (Obstetrics & Gynaecology),
+ Consultant
+ Regd. No. UK-1261 +
+ + +

+ Dr. Sana Anshari +

+ M.B.B.S, D.G.O.
+ Regd. No. UK-6583 +
+
+ +
+

Civil Lines, Tikonia, Haldwani (Nainital) U.K.
+ Contact : 9756389281 (M), 05946-282751,224422, Hospital - 7088020108 +
Morning Time : 10 A.M. - 2 P.M. And Evening Time : 5 P.M. - 8 P.M. (Sunday evening closed)

+
+ A3 Reception No. +91 8755904991
+ Not For Medico-legal Purpose
+ +

+
+ diff --git a/old_code_ci3/views/doctor_conf_room/doctor_room.php b/old_code_ci3/views/doctor_conf_room/doctor_room.php new file mode 100644 index 0000000..e69de29 diff --git a/old_code_ci3/views/echs_profile_V.php b/old_code_ci3/views/echs_profile_V.php new file mode 100644 index 0000000..eab4c95 --- /dev/null +++ b/old_code_ci3/views/echs_profile_V.php @@ -0,0 +1,247 @@ +
+

+ ECHS Card : + name; ?> +

+ +
+ +
+
+
+ 'form','class'=>'form1')); ?> + +
+
+
+
+ + +
+
+
+
+ + +
+
+
+
+
+ + +
+
+
+
+
+
+
+ +
+
+ +
+ +
+
+
+
+
+ +
+
+ +
+ +
+
+
+
+
+ + +
+
+
+
+ + +
+
+ +
+
+
+
+ + +
+
+
+
+ + +
+
+
+
+ + +
+
+ +
+ +
+
+ +
+
+
+ +
+
+
+ mem_gender==1) + $mem_gender_str='Male'; + else + $mem_gender_str='FeMale'; + + echo '
'; + echo '
'; + echo '
'; + echo ' '; + echo ' '; + echo '
'; + echo '
'; + echo '
'; + echo '
'; + echo ' '; + echo ' '; + echo '
'; + echo '
'; + echo '
'; + echo '
'; + echo ' '; + echo ' '; + echo '
'; + echo '
'; + echo '
'; + echo '
'; + echo ' '; + echo ' '; + echo '
'; + echo '
'; + echo '
'; + echo '
'; + echo ' '; + echo '
'; + echo '
'; + echo '
'; + } + ?> +
+
+ 'form','class'=>'form2')); ?> + +
+
+
+ + +
+
+
+
+ +
+ + +
+
+
+
+
+ + +
+
+
+
+ +
+
+ +
+ +
+
+
+
+
+ + +
+
+
+ + +
+ + + \ No newline at end of file diff --git a/old_code_ci3/views/echs_register_V.php b/old_code_ci3/views/echs_register_V.php new file mode 100644 index 0000000..0562758 --- /dev/null +++ b/old_code_ci3/views/echs_register_V.php @@ -0,0 +1,174 @@ +
+

+ ECHS Person + Registration +

+ +
+ +
+
+
+ +
+
+ + + +
+ + + \ No newline at end of file diff --git a/old_code_ci3/views/echs_search_V.php b/old_code_ci3/views/echs_search_V.php new file mode 100644 index 0000000..81d29a0 --- /dev/null +++ b/old_code_ci3/views/echs_search_V.php @@ -0,0 +1,42 @@ +

+
+
+

Result

+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
ECHS CodeNamePhone NumberDate of BirthAction
service_no ?>/reg_no ?>name ?>mphone1 ?>dob ?>
Patient CodeNamePhone NumberEMailAction
+
+ +
+ \ No newline at end of file diff --git a/old_code_ci3/views/errors/cli/error_404.php b/old_code_ci3/views/errors/cli/error_404.php new file mode 100644 index 0000000..6984b61 --- /dev/null +++ b/old_code_ci3/views/errors/cli/error_404.php @@ -0,0 +1,8 @@ + + +An uncaught Exception was encountered + +Type: +Message: +Filename: getFile(), "\n"; ?> +Line Number: getLine(); ?> + + + +Backtrace: +getTrace() as $error): ?> + + File: + Line: + Function: + + + + diff --git a/old_code_ci3/views/errors/cli/error_general.php b/old_code_ci3/views/errors/cli/error_general.php new file mode 100644 index 0000000..6984b61 --- /dev/null +++ b/old_code_ci3/views/errors/cli/error_general.php @@ -0,0 +1,8 @@ + + +A PHP Error was encountered + +Severity: +Message: +Filename: +Line Number: + + + +Backtrace: + + + File: + Line: + Function: + + + + diff --git a/old_code_ci3/views/errors/cli/index.html b/old_code_ci3/views/errors/cli/index.html new file mode 100644 index 0000000..b702fbc --- /dev/null +++ b/old_code_ci3/views/errors/cli/index.html @@ -0,0 +1,11 @@ + + + + 403 Forbidden + + + +

Directory access is forbidden.

+ + + diff --git a/old_code_ci3/views/errors/html/error_404.php b/old_code_ci3/views/errors/html/error_404.php new file mode 100644 index 0000000..756ea9d --- /dev/null +++ b/old_code_ci3/views/errors/html/error_404.php @@ -0,0 +1,64 @@ + + + + +404 Page Not Found + + + +
+

+ +
+ + \ No newline at end of file diff --git a/old_code_ci3/views/errors/html/error_db.php b/old_code_ci3/views/errors/html/error_db.php new file mode 100644 index 0000000..f5a43f6 --- /dev/null +++ b/old_code_ci3/views/errors/html/error_db.php @@ -0,0 +1,64 @@ + + + + +Database Error + + + +
+

+ +
+ + \ No newline at end of file diff --git a/old_code_ci3/views/errors/html/error_exception.php b/old_code_ci3/views/errors/html/error_exception.php new file mode 100644 index 0000000..8784886 --- /dev/null +++ b/old_code_ci3/views/errors/html/error_exception.php @@ -0,0 +1,32 @@ + + +
+ +

An uncaught Exception was encountered

+ +

Type:

+

Message:

+

Filename: getFile(); ?>

+

Line Number: getLine(); ?>

+ + + +

Backtrace:

+ getTrace() as $error): ?> + + + +

+ File:
+ Line:
+ Function: +

+ + + + + + +
\ No newline at end of file diff --git a/old_code_ci3/views/errors/html/error_general.php b/old_code_ci3/views/errors/html/error_general.php new file mode 100644 index 0000000..fc3b2eb --- /dev/null +++ b/old_code_ci3/views/errors/html/error_general.php @@ -0,0 +1,64 @@ + + + + +Error + + + +
+

+ +
+ + \ No newline at end of file diff --git a/old_code_ci3/views/errors/html/error_php.php b/old_code_ci3/views/errors/html/error_php.php new file mode 100644 index 0000000..b146f9c --- /dev/null +++ b/old_code_ci3/views/errors/html/error_php.php @@ -0,0 +1,33 @@ + + +
+ +

A PHP Error was encountered

+ +

Severity:

+

Message:

+

Filename:

+

Line Number:

+ + + +

Backtrace:

+ + + + +

+ File:
+ Line:
+ Function: +

+ + + + + + + +
\ No newline at end of file diff --git a/old_code_ci3/views/errors/html/index.html b/old_code_ci3/views/errors/html/index.html new file mode 100644 index 0000000..b702fbc --- /dev/null +++ b/old_code_ci3/views/errors/html/index.html @@ -0,0 +1,11 @@ + + + + 403 Forbidden + + + +

Directory access is forbidden.

+ + + diff --git a/old_code_ci3/views/errors/index.html b/old_code_ci3/views/errors/index.html new file mode 100644 index 0000000..b702fbc --- /dev/null +++ b/old_code_ci3/views/errors/index.html @@ -0,0 +1,11 @@ + + + + 403 Forbidden + + + +

Directory access is forbidden.

+ + + diff --git a/old_code_ci3/views/form.php b/old_code_ci3/views/form.php new file mode 100644 index 0000000..2b91ab1 --- /dev/null +++ b/old_code_ci3/views/form.php @@ -0,0 +1,66 @@ +
+

+ Dashboard + Control panel +

+ +
+ +
+
+

Horizontal Form

+
+
+ + + 'form-horizontal')); ?> + +
+
+ + +
+ +
+
+
+ + +
+ +
+
+
+
+
+ +
+
+
+
+ + + + +
+ + + + + diff --git a/old_code_ci3/views/hospital_refer/reffer_add.php b/old_code_ci3/views/hospital_refer/reffer_add.php new file mode 100644 index 0000000..2351380 --- /dev/null +++ b/old_code_ci3/views/hospital_refer/reffer_add.php @@ -0,0 +1,78 @@ +
+

+ New Refferal Client + +

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

+ Edit Refferal Client + +

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

+
+
+

Reffer Person Name / clinic / Hospital

+
+ +
+ + + + + + + + + + + + + + + + + + + + + +
NameTypeRegister DateStatusEdit
title.' '.$row->f_name?>refer_type==0){ + echo 'Person'; + } elseif($row->refer_type==1){ + echo 'Doctor'; + }elseif($row->refer_type==2){ + echo 'Staff'; + }elseif($row->refer_type==3){ + echo 'Hospital/Clinic'; + }else{ + echo 'Others'; + } + + ?>str_dateadd?> + active){ + echo "".lang('index_active_link').""; + }else{ + echo "".lang('index_inactive_link').""; + } + ?> + Edit
+ +
+ + +
\ No newline at end of file diff --git a/old_code_ci3/views/index.html b/old_code_ci3/views/index.html new file mode 100644 index 0000000..b702fbc --- /dev/null +++ b/old_code_ci3/views/index.html @@ -0,0 +1,11 @@ + + + + 403 Forbidden + + + +

Directory access is forbidden.

+ + + diff --git a/old_code_ci3/views/insurance/insurance_card.php b/old_code_ci3/views/insurance/insurance_card.php new file mode 100644 index 0000000..ceb9bc5 --- /dev/null +++ b/old_code_ci3/views/insurance/insurance_card.php @@ -0,0 +1,135 @@ +
+

+ Person + p_fname); ?> +

+ +
+ +
+
+
+
+ 'form','class'=>'form1')); ?> + + + 0) + { + $ins_card_id=$data_insurance_card[0]->id; + $ins_company_id=$data_insurance_card[0]->insurance_id; + $ins_insurance_no=$data_insurance_card[0]->insurance_no; + $card_holder_name=$data_insurance_card[0]->card_holder_name; + $relation_patient_cardholder=$data_insurance_card[0]->relation_patient_cardholder; + $issue_date=MysqlDate_to_str($data_insurance_card[0]->issue_date); + $expiry_date=MysqlDate_to_str($data_insurance_card[0]->expiry_date); + } + ?> + +
+
+
+ + +
+
+
+
+ + +
+
+
+
+ + +
+
+
+
+
+
+ +
+
+ +
+ +
+
+
+
+
+ +
+
+ +
+ +
+
+
+
+
+ + +
+
+
+
+
+ +
+
+ + +
+
+ + +
+ + \ No newline at end of file diff --git a/old_code_ci3/views/insurance/insurance_create_V.php b/old_code_ci3/views/insurance/insurance_create_V.php new file mode 100644 index 0000000..2c33b54 --- /dev/null +++ b/old_code_ci3/views/insurance/insurance_create_V.php @@ -0,0 +1,74 @@ +
+

+ Insurance Company + Add New +

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

+ Insurance Company + ins_company_name; ?> +

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

OPD

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

Charges And Medicine

+
+
+
+
+
+ +
+ + +
+
+
+
+
+
+
+ + +
+
+
+
+ +
+
+
+
+ +
+
+
+
+
+
+
+
+
+ +
+
+ +
+
+ +
+ + + \ No newline at end of file diff --git a/old_code_ci3/views/insurance/insurance_search_v.php b/old_code_ci3/views/insurance/insurance_search_v.php new file mode 100644 index 0000000..13c8d29 --- /dev/null +++ b/old_code_ci3/views/insurance/insurance_search_v.php @@ -0,0 +1,62 @@ +
+

+ Insurance Company + List +

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

Result

+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Company NameContact NumberOPD FeeActive
ins_company_name ?>ins_contact_number ?>opd_fee?>activestatus ?>
Company NameContact NumberContact Person NameE-Mail
+ +
+ +
+
+
\ No newline at end of file diff --git a/old_code_ci3/views/insurance_V.php b/old_code_ci3/views/insurance_V.php new file mode 100644 index 0000000..dce0180 --- /dev/null +++ b/old_code_ci3/views/insurance_V.php @@ -0,0 +1,7 @@ +
+

+ Insurance + Company +

+ +
\ No newline at end of file diff --git a/old_code_ci3/views/invoice_pathlab_print_V.php b/old_code_ci3/views/invoice_pathlab_print_V.php new file mode 100644 index 0000000..71033c5 --- /dev/null +++ b/old_code_ci3/views/invoice_pathlab_print_V.php @@ -0,0 +1,223 @@ + + + + + + <?=H_Name?> | Invoice + + + + + + + + + + + + + + + + + + + + +
+
+ +
+
+ +
+ +
+ +
+
+ + + +
+ Invoice #invoice_code ?>
+ Date : inv_date ?>
+ Patient ID : p_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.'
'; + } + } + ?> + + +
+
+ From +
+
+
+
+ Phone:
+ Email: +
+
+ +
+ To +
+ p_fname) ?>
+ p_relative ?> : p_rname) ?>
+ Gender : xgender ?>
+ Age : age ?>
+ Phone No : mphone1 ?>
+ Refer By : refer_by_other ?>
+
+
+ + +
+ + + +
+
+ + + + + + + + + + + + '; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + $srno=$srno+1; + echo ''; + echo ''; + } + ?> + + + + + + + + + + + discount_amount>0) {?> + + + + + + + + + + + ipd_id<1) {?> + + + + + + + + + + + correction_amount>0) {?> + + + + + + + + + + + + + + + + + + + +
#Charges GroupCharge NameOrg.CodeRateQtyAmount
'.$srno.''.$row->group_desc.''.$row->item_name.''.$row->org_code.''.$row->item_rate.''.$row->item_qty.''.$row->item_amount.'
#Gross TotalGtotal?>
#Deductiondiscount_desc ?>-discount_amount ?>
#Amount received : payment_part_received?>Balance Amount : payment_part_balance?>Net Amountnet_amount?>
#Cancel Invoicecorrection_remark ?>-correction_amount ?>
#Final Amountcorrection_net_amount?>
+
+ +
+

Invoice_status_str?>

+ + payment_mode>2) { ?> +
+
+ Payment Details [Payment_type_str ?>] +
+
+ +
+
+ Payment Details [Payment No.:Mode of Payment:Amount]: + id.':'.$row->Payment_type_str.':'.$row->amount.']/'; + } + ?> +
+
+ +
+
+ Prepared By : prepared_by ?> +
+
+ +
+
+ Signature +
+
+
+
+ +
+
+ This is computer generated provisional invoice , Signature and stamp not required +
+ + +
+ + + diff --git a/old_code_ci3/views/invoice_print_v.php b/old_code_ci3/views/invoice_print_v.php new file mode 100644 index 0000000..48772d2 --- /dev/null +++ b/old_code_ci3/views/invoice_print_v.php @@ -0,0 +1,183 @@ + + + + + + <?=H_Name?> | Invoice + + + + + + + + + + + + + + + + + + + +ion_auth->user()->row(); + $user_id = $user->id; + $user_name = $user->first_name.''. $user->last_name.'-'.$user->id.''; +?> + + +
+ +
+
+ +
+ +
+ +
+
+ + +
+
+ OPD Invoice ID: opd_code ?>
+ Patient ID : p_code ?>
+ + insurance_id>1) + { + echo ' Ins. Comp. :'.$insurance[0]->ins_company_name.'
'; + if($opd_master[0]->insurance_case_id>0) + { + echo ' Org.Case No. :'.$case_master[0]->case_id_code.'
'; + } + } + ?> + + payment_id>0 ) + { + echo 'Payment No. :'.$opd_master[0]->payment_id.'
'; + } + ?> +
+
+ From +
+
+
+
+ Phone:
+ Email: +
+ opd_no=='' || $opd_master[0]->opd_no==0)) { ?> +

Sr.No.opd_no ?>

+ +
+ +
+ To +
+ title ?> p_fname) ?>
+ Date : str_apointment_date ?>
+ Gender : xgender ?>
+ Age : age ?>
+ Phone No : mphone1 ?>
+ No. of Times Visit : no_visit ?> +
+
+ +
+ + +
+
+ + + + + + + + + + + + + + + + + + + opd_discount>0 ) + { + ?> + + + + + + + + + + + + + + + +
DateDoctorDepartmentDescOPD Fee
apointment_date ?>Dr. doc_name ?>doc_spec ?>opd_fee_desc ?> opd_fee_gross_amount ?>
Deductionopd_disc_remark ?> -opd_discount ?>
Net Amount opd_fee_amount ?>
+
+ +
+ +
+ + opd_status==3) { + echo '

OPD cancelled


'; + echo '

'.$opd_master[0]->opd_status_remark.'

'; + }else{ + ?> + + Mode of Payment : payment_mode_desc ?> + + +
+
+
+ Prepared By : prepared_by ?> +
+
+ +
+
+ Signature +
+
+
+
+ +
+
+ This is computer generated invoice , Signature and stamp not required +
+ + +
+ + + diff --git a/old_code_ci3/views/invoice_show.php b/old_code_ci3/views/invoice_show.php new file mode 100644 index 0000000..cc00450 --- /dev/null +++ b/old_code_ci3/views/invoice_show.php @@ -0,0 +1,145 @@ +
+

OPD Invoice

+
+
+ +
+
+ +
+ +
+ +
+
+ From +
+
+
+
+ Phone:
+ Email: +
+
+ +
+ To +
+ P_name ?>
+ Date : apointment_date) ?>
+ Gender : gender==1)?'Male':'Female' ?>
+ Age : age ?>
+ Phone No : mphone1 ?> +
+
+ +
+ OPD ID: opd_code ?>
+ Patient ID : p_code ?> + + insurance_id>1) + { + echo ' Ins. Comp. :'.$insurance[0]->ins_company_name.'
'; + } + + if($opd_master[0]->payment_id>0 ) + { + echo 'Payment No. :'.$opd_master[0]->payment_id.'
'; + } + ?> +
+ +
+ + +
+
+ + + + + + + + + + + + + + + + + +
TypeDoctor NameFee AmountDescription
Dr. doc_name ?>doc_spec ?>opd_fee_amount ?>opd_fee_desc ?>
+
+ +
+ +
+
+
+ +
+
+
+
+ + +
+
+
+ +
+
+ +
+ +
+

Payment Methods:

+

+
+ +
+

Amount Due 2/22/2014

+ +
+ + + + + + + + + + + + + + + + + +
Subtotal:$250.30
Tax (9.3%)$10.34
Shipping:$5.80
Total:$265.24
+
+
+ +
+ +
+ +
+ + \ No newline at end of file diff --git a/old_code_ci3/views/invoiceshow/invoice_charges.php b/old_code_ci3/views/invoiceshow/invoice_charges.php new file mode 100644 index 0000000..d9593d9 --- /dev/null +++ b/old_code_ci3/views/invoiceshow/invoice_charges.php @@ -0,0 +1,161 @@ +
+ +
+
+ +
+ +
+ +
+
+ + +
+ Invoice #invoice_code ?>
+ Date : inv_date ?>
+ Patient ID : p_code ?>
+ + + payment_id>0 ) + { + echo 'Payment No. :'.$invoice_master[0]->payment_id.'
'; + } + ?> +
+
+ From +
+
+
+
+ Phone:
+ Email: +
+
+ +
+ To +
+ p_fname ?>
+ Gender : xgender ?>
+ Age : age ?>
+ Phone No : mphone1 ?>
+ Refer By : refer_by_other ?>
+
+
+ + +
+ + + +
+
+ + + + + + + + + + + '; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + $srno=$srno+1; + echo ''; + echo ''; + } + ?> + + + + + + + + + + + discount_amount>0) {?> + + + + + + + + + + + + + + + + + + + + correction_amount>0) {?> + + + + + + + + + + + + + + + + + + + +
#Charges GroupCharge NameRateQtyAmount
'.$srno.''.$row->desc.''.$row->item_name.''.$row->item_rate.''.$row->item_qty.''.$row->item_amount.'
#Gross TotalGtotal?>
#Deductiondiscount_desc ?>-discount_amount ?>
#Net Amountnet_amount?>
#Correctioncorrection_remark ?>-correction_amount ?>
#Final Amountcorrection_net_amount?>
+
+ +
+ +
+ + Mode of Payment : payment_mode_desc ?> +
+
+
+ Prepared By : prepared_by ?> +
+
+ +
+
+ Signature +
+
+
+
+ This is computer generated invoice , Signature and stamp not required +
+ + +
\ No newline at end of file diff --git a/old_code_ci3/views/invoiceshow/invoice_medical.php b/old_code_ci3/views/invoiceshow/invoice_medical.php new file mode 100644 index 0000000..5212239 --- /dev/null +++ b/old_code_ci3/views/invoiceshow/invoice_medical.php @@ -0,0 +1,138 @@ + +
+ +
+
+ +
+ +
+ +
+
+ +
+
+ Invoice #inv_med_code ?>
+ Date : inv_date ?>
+ Patient ID : patient_code ?>
+ payment_id>0 ) + { + echo 'Payment No. :'.$invoice_master[0]->payment_id.'
'; + } + ?> + +
+
+ From +
+
+
+
+ Phone:
+ Email: +
+
+ +
+ To +
+ inv_name ?>
+ Refer By : doc_name ?>
+
+
+ +
+ + + +
+
+ + + + + + + + + + + + + + + + + + + + '; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + } + ?> + + + + + + + + + + + + + + + + + + +
#Item codeItem NameFormulationBatch NoExp.RateQty.PriceDisc.VatTax Amount Amount
'.$srno.''.$row->item_code.''.$row->item_Name.''.$row->formulation.''.$row->batch_no.''.$row->expiry.''.$row->price.''.$row->qty.''.$row->amount.''.$row->disc_amount.''.$row->vat.''.$row->vamount.''.$row->tamount.'
#Gross Totalamt ?>vamt ?>Gtotal?>
+
+ +
+ +
+ + Mode of Payment : payment_mode_desc ?> +
+
+
+ Prepared By : prepared_by ?> +
+
+ +
+
+ Signature +
+
+
+
+ This is computer generated invoice , Signature and stamp not required +
+ \ No newline at end of file diff --git a/old_code_ci3/views/item/item_create_V.php b/old_code_ci3/views/item/item_create_V.php new file mode 100644 index 0000000..d28b8d4 --- /dev/null +++ b/old_code_ci3/views/item/item_create_V.php @@ -0,0 +1,77 @@ +
+

+ OPD Charges + Add New +

+ +
+ +
+
+
+
+ 'form','class'=>'form1')); ?> + +
+
+
+ + +
+
+
+
+ + +
+
+
+
+ + +
+
+
+
+
+ +
+
+ + +
+
+ +
+ + + \ No newline at end of file diff --git a/old_code_ci3/views/item/item_item_list.php b/old_code_ci3/views/item/item_item_list.php new file mode 100644 index 0000000..2fe8893 --- /dev/null +++ b/old_code_ci3/views/item/item_item_list.php @@ -0,0 +1,69 @@ + + + + + + <?=H_Name?> + + + + + + + + + + + + + + + + + + + + +
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
OPD or IPDGroupCharge NameCharge DetailsAmount
isIPD_OPD ?>group_desc ?>idesc ?>idesc_detail ?>amount ?>
OPD or IPDGroupCharge NameAmount
+
+
+ + + \ No newline at end of file diff --git a/old_code_ci3/views/item/item_list_all.php b/old_code_ci3/views/item/item_list_all.php new file mode 100644 index 0000000..457a6fe --- /dev/null +++ b/old_code_ci3/views/item/item_list_all.php @@ -0,0 +1,71 @@ + + + + + + <?=H_Name?> + + + + + + + + + + + + + + + + + + + + +
+
+ + + + + + + + + + group_desc) + { + echo ''; + $Head=$data[$i]->group_desc; + } + ?> + + + + + + + + + + + + + + +
Group/Charge NameCharge DetailsAmount
'.$data[$i]->group_desc.'
idesc ?>idesc_detail ?>amount ?>
Group/Charge NameCharge NameAmount
+
+
+ + + \ No newline at end of file diff --git a/old_code_ci3/views/item/item_profile_V.php b/old_code_ci3/views/item/item_profile_V.php new file mode 100644 index 0000000..0030259 --- /dev/null +++ b/old_code_ci3/views/item/item_profile_V.php @@ -0,0 +1,181 @@ +
+

+ OPD Charge Name : idesc; ?> +

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

Insurance Rates

+
+ +
+ 'form','class'=>'form1')); ?> +
+ + + + + + + + + + + + + + + + + + + + +
Company NameAmountCodeAction
ins_company_name ?>i_amount ?>code ?>
+
+ +
+
+
+ + +
+
+
+
+ + +
+
+
+
+ + +
+
+
+ +
+
+
+
+ + +
+ + + \ No newline at end of file diff --git a/old_code_ci3/views/item/item_search_V.php b/old_code_ci3/views/item/item_search_V.php new file mode 100644 index 0000000..8d55edf --- /dev/null +++ b/old_code_ci3/views/item/item_search_V.php @@ -0,0 +1,135 @@ +
+

+ OPD Charges + +

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

Result +

+ +
+ +
+
+ Print + Print ALL +

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
OPD or IPDGroupCharge NameAmount
isIPD_OPD ?>group_desc ?>idesc ?>amount ?>
OPD or IPDGroupCharge NameAmount
+ +
+
+ +
+
+
+ + + + \ No newline at end of file diff --git a/old_code_ci3/views/item/item_type_create.php b/old_code_ci3/views/item/item_type_create.php new file mode 100644 index 0000000..de6af24 --- /dev/null +++ b/old_code_ci3/views/item/item_type_create.php @@ -0,0 +1,63 @@ +
+

+ OPD Charges Group + +

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

+ OPD Charges Group + group_desc ?> +

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

+ IPD Charges + Add New +

+ +
+ +
+
+
+
+ 'form','class'=>'form1')); ?> + +
+
+
+ + +
+
+
+
+ + +
+
+
+
+ + +
+
+
+
+
+ +
+
+ + +
+
+ +
+ + + \ No newline at end of file diff --git a/old_code_ci3/views/item_ipd/item_item_list.php b/old_code_ci3/views/item_ipd/item_item_list.php new file mode 100644 index 0000000..2fe8893 --- /dev/null +++ b/old_code_ci3/views/item_ipd/item_item_list.php @@ -0,0 +1,69 @@ + + + + + + <?=H_Name?> + + + + + + + + + + + + + + + + + + + + +
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
OPD or IPDGroupCharge NameCharge DetailsAmount
isIPD_OPD ?>group_desc ?>idesc ?>idesc_detail ?>amount ?>
OPD or IPDGroupCharge NameAmount
+
+
+ + + \ No newline at end of file diff --git a/old_code_ci3/views/item_ipd/item_list_all.php b/old_code_ci3/views/item_ipd/item_list_all.php new file mode 100644 index 0000000..457a6fe --- /dev/null +++ b/old_code_ci3/views/item_ipd/item_list_all.php @@ -0,0 +1,71 @@ + + + + + + <?=H_Name?> + + + + + + + + + + + + + + + + + + + + +
+
+ + + + + + + + + + group_desc) + { + echo ''; + $Head=$data[$i]->group_desc; + } + ?> + + + + + + + + + + + + + + +
Group/Charge NameCharge DetailsAmount
'.$data[$i]->group_desc.'
idesc ?>idesc_detail ?>amount ?>
Group/Charge NameCharge NameAmount
+
+
+ + + \ No newline at end of file diff --git a/old_code_ci3/views/item_ipd/item_profile_V.php b/old_code_ci3/views/item_ipd/item_profile_V.php new file mode 100644 index 0000000..30cff7c --- /dev/null +++ b/old_code_ci3/views/item_ipd/item_profile_V.php @@ -0,0 +1,177 @@ +
+

+ IPD Charge Name : idesc; ?> +

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

Insurance Rates

+
+ +
+ 'form','class'=>'form1')); ?> +
+ + + + + + + + + + + + + + + + + + + + +
Company NameAmountCodeAction
ins_company_name ?>i_amount ?>code ?>
+
+ +
+
+
+ + +
+
+
+
+ + +
+
+
+
+ + +
+
+
+ +
+
+
+
+
+
+ + \ No newline at end of file diff --git a/old_code_ci3/views/item_ipd/item_search_V.php b/old_code_ci3/views/item_ipd/item_search_V.php new file mode 100644 index 0000000..bb9f403 --- /dev/null +++ b/old_code_ci3/views/item_ipd/item_search_V.php @@ -0,0 +1,131 @@ +
+

+ IPD Charges + +

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

Result +

+ +
+ +
+
+ Print + Print ALL +

+ + + + + + + + + + + + + + + + + + + + + + + + + + + +
GroupCharge NameAmount
group_desc ?>idesc ?>amount ?>
GroupCharge NameAmount
+ +
+
+ +
+
+
+ + + \ No newline at end of file diff --git a/old_code_ci3/views/item_ipd/item_type_create.php b/old_code_ci3/views/item_ipd/item_type_create.php new file mode 100644 index 0000000..7ea689e --- /dev/null +++ b/old_code_ci3/views/item_ipd/item_type_create.php @@ -0,0 +1,50 @@ +
+

+ IPD Charges Group +

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

+ IPD Charges Group + group_desc ?> +

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

+ OPD + Registration +

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

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

+
+
+
+
+
+ +
+
+ +
+ /> +
+
+
+
+
+
+
+
+ '; + echo ' '; + echo $row->p_fname.' ['.$row->SpecName.']'; + echo '
'; + } + ?> + +
+ +
+
+
+
+
+
+
+
+ +
+
+ +
+ +
+
+
+
+ + +
+
+
+
+
+ +
+ + \ No newline at end of file diff --git a/old_code_ci3/views/opd_appointment_V.php b/old_code_ci3/views/opd_appointment_V.php new file mode 100644 index 0000000..88279b1 --- /dev/null +++ b/old_code_ci3/views/opd_appointment_V.php @@ -0,0 +1,156 @@ +
+

+ OPD + Registration +

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

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

+
+
+
+
+
+ +
+
+ +
+ Readonly=true /> +
+
+
+
+
+
+
+
+ '; + echo ' '; + echo $row->p_fname.' ['.$row->SpecName.']'; + echo '
'; + } + ?> + +
+ +
+
+
+
+
+
+
+
+ +
+
+ +
+ +
+
+
+
+ + +
+
+
+
+
+ +
+ + \ No newline at end of file diff --git a/old_code_ci3/views/opd_invoice_V.php b/old_code_ci3/views/opd_invoice_V.php new file mode 100644 index 0000000..ac06980 --- /dev/null +++ b/old_code_ci3/views/opd_invoice_V.php @@ -0,0 +1,516 @@ +
+

OPD Invoice

+ +
+
+ 'form','class'=>'form1')); ?> +
+ +
+ To +
+ P_name) ?>
+ p_relative ?> : p_rname ?>
+ OPD Book Date (y-m-d time) : opd_book_date ?>
+ Gender : gender==1)?'Male':'Female' ?>
+ Age : age ?>
+ Phone No : mphone1 ?> +
+
+ +
+ OPD ID: opd_code ?>
+ Date of Appointment: str_apointment_date ?>
+ Patient ID : p_code ?>
+ insurance_id>1) + { + echo ' Ins. Comp. :'.$insurance[0]->ins_company_name.'
'; + } + ?> + + payment_id>0 ) + { + echo 'Payment No. :'.$opd_master[0]->payment_id.'
'; + } + ?> +
+ +
+ + + +
+
+ + + + + + + + + + + + + + + + + + + payment_status==0) { ?> + + + + + + + opd_discount>0 ) + { + ?> + + + + + + + + + + + + + + +
DateDoctorDepartmentOPD Fee
apointment_date) ?>Dr. doc_name ?>doc_spec ?>opd_fee_gross_amount ?>opd_fee_desc ?>
Any Deduction +
Deductionopd_disc_remark ?>opd_discount ?>
#Net Amountopd_fee_amount?>
+
+ +
+ + payment_status==0 && $refund_status==0) { ?> +
+ +
+
+
+
+ +
+ 0 ) { ?> +
+
+

+ + Cash +

+
+
+
+ +
+
+
+
+ +
+
+
+
+
+ + +
+
+
+
+ + +
+
+
+
+ + +
+
+
+
+
+
+ +
+ +
+
+
+
+ +
+
+
+
+
+ + insurance_id>0 ) { ?> +
+ +
+
+ +
+
+
+ + case_id_code ?> autocomplete="off" readonly> + +
+
+
+
+ + +
+
+
+ +
+
+
+ +
+
+
+
+
+ +
+ +
+ opd_status==3){ + echo '

Status is Cancelled

' ; + }else{?> + Payment Method by : payment_mode_desc ?> + +
+
+ + + ion_auth->in_group('OPDEdit') && ($opd_master[0]->opd_status==1 || $opd_master[0]->opd_status==2)) { ?> +
+
+ opd_status==1) { ?> +
+ +
+
+ +
+ +
+ opd_status==1 || $opd_master[0]->opd_status==2 ) { + if(count($case_master)>0) + { + ?> + + +
+
+
+
+ + +
+
+
+ +
+
+ +
+ +
+
+
+
+
+ + +
+
+
+
+ +
+
+
+
+
+ opd_status==1 or $opd_master[0]->opd_status==2) AND ($opd_master[0]->payment_mode==4)){ ?> +
+ +
+ +
+
+ +
+ +
+ + + \ No newline at end of file diff --git a/old_code_ci3/views/opd_letter_head.php b/old_code_ci3/views/opd_letter_head.php new file mode 100644 index 0000000..58c70c3 --- /dev/null +++ b/old_code_ci3/views/opd_letter_head.php @@ -0,0 +1,86 @@ + + + + + + <?php + if(defined('C_EST')) + { + echo C_EST ; + }else{ + echo H_Name ; + } + + + ?> + + + + + + + + + + + + + + + + + + + +ion_auth->user()->row(); + $user_id = $user->id; + $user_name = $user->first_name.''. $user->last_name.'-'.$user->id.''; +?> + +
+
+
+ +
+
+
+
+ UHID : p_code ?> + udai<>"") + { + echo ' /'.$patient_master[0]->udai; + } + ?>
+ Name : title ?> p_fname) ?>
+ p_relative ?> p_rname) ?>
+ Sex : xgender ?> age ?>
+
+
+ OPD No.: opd_code ?>/ opd_id?>
+ OPD Fee: opd_fee_amount ?> [opd_fee_desc ?>]
+ Date: str_apointment_date ?>
+ opd_fee_type=='3'){ + if(count($old_opd)>0){ + echo 'Valid Upto :'.$opd_master[0]->opd_Exp_Date.'
'; + } + }else{ ?> + Valid Upto : opd_Exp_Date ?>
+ + +
+
+ Sr No.:opd_no ?>
+ P.No. : mphone1 ?>
+ Address : add1.','.$patient_master[0]->city?>
+ +
+
+
+ + + diff --git a/old_code_ci3/views/print_format/opd_print_letter_head.php b/old_code_ci3/views/print_format/opd_print_letter_head.php new file mode 100644 index 0000000..cbea32d --- /dev/null +++ b/old_code_ci3/views/print_format/opd_print_letter_head.php @@ -0,0 +1,35 @@ + + + + + + + + +
+ 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).'
+ Gender/Age : '.$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]->add2. + '
'.$patient_master[0]->city.' '.$patient_master[0]->district. + ' '.$patient_master[0]->state.' +
\ No newline at end of file diff --git a/old_code_ci3/views/search_adv_data.php b/old_code_ci3/views/search_adv_data.php new file mode 100644 index 0000000..e5c390e --- /dev/null +++ b/old_code_ci3/views/search_adv_data.php @@ -0,0 +1,11 @@ +0) { ?> +
+ + + + + +
Name of Person/Sex/Relative Name
+ Sresult?> +
+ \ No newline at end of file diff --git a/old_code_ci3/views/setting/setting_main.php b/old_code_ci3/views/setting/setting_main.php new file mode 100644 index 0000000..0b15cff --- /dev/null +++ b/old_code_ci3/views/setting/setting_main.php @@ -0,0 +1,64 @@ +
+

+ Admin Panel + Dashboard +

+
+ +
+'form','class'=>'form1')); ?> + + +
+
+ +
+
+
+ \ No newline at end of file diff --git a/old_code_ci3/views/temp_edit.php b/old_code_ci3/views/temp_edit.php new file mode 100644 index 0000000..d811a91 --- /dev/null +++ b/old_code_ci3/views/temp_edit.php @@ -0,0 +1,22 @@ + \ No newline at end of file diff --git a/old_code_ci3/views/test.html b/old_code_ci3/views/test.html new file mode 100644 index 0000000..53ff075 --- /dev/null +++ b/old_code_ci3/views/test.html @@ -0,0 +1,146 @@ +
+ +
+
+

Report Edit

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

Report Parameter

+
+ +
+
+ +
+
+
+
+
+
+
+ +
+
+
+
+
+ + \ No newline at end of file diff --git a/old_code_ci3/views/testcode/test2.html b/old_code_ci3/views/testcode/test2.html new file mode 100644 index 0000000..9160503 --- /dev/null +++ b/old_code_ci3/views/testcode/test2.html @@ -0,0 +1,68 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
#DateNo. PatientsNo. Inv.Net Amt.PaymentCash PendingIPD_Credit_AmountOrg_Credit_Amount
101-10-2017386193349.864314.955673.7728786.41207.70
202-10-20173989199379.6433671.1841470.7341116.151061.90
303-10-20172864211654.9629988.3311862.7648344.53476.77
404-10-2017214469002.4516697.8313006.6415528.500.00
# + Total72258573386.9184672.2972013.90133775.591746.37
\ No newline at end of file diff --git a/old_code_ci3/views/testcode/test_1.php b/old_code_ci3/views/testcode/test_1.php new file mode 100644 index 0000000..0f25b52 --- /dev/null +++ b/old_code_ci3/views/testcode/test_1.php @@ -0,0 +1,52 @@ +
+
+
+ +
+ +
+ +
+
Your captured image will appear here...
+ \ No newline at end of file diff --git a/old_code_ci3/views/testcode/test_2 b/old_code_ci3/views/testcode/test_2 new file mode 100644 index 0000000..203f9f7 --- /dev/null +++ b/old_code_ci3/views/testcode/test_2 @@ -0,0 +1 @@ +test_2 \ No newline at end of file diff --git a/old_code_ci3/views/testphp.php b/old_code_ci3/views/testphp.php new file mode 100644 index 0000000..415f0bb --- /dev/null +++ b/old_code_ci3/views/testphp.php @@ -0,0 +1,33 @@ + + + + + + + +
+ + + + + + + + + \ No newline at end of file diff --git a/old_code_ci3/views/welcome_message.php b/old_code_ci3/views/welcome_message.php new file mode 100644 index 0000000..2f73093 --- /dev/null +++ b/old_code_ci3/views/welcome_message.php @@ -0,0 +1,89 @@ + + + + + Welcome to CodeIgniter Custom Hello + + + + + +
+

Welcome to CodeIgniter Hospital

+ +
+

The page you are looking at is being generated dynamically by CodeIgniter.

+ +

If you would like to edit this page you'll find it located at:

+ application/views/welcome_message.php + +

The corresponding controller for this page is found at:

+ application/controllers/Welcome.php + +

If you are exploring CodeIgniter for the very first time, you should start by reading the User Guide.

+
+ + +
+ + + \ No newline at end of file diff --git a/old_code_ci3/views/welcome_message.txt b/old_code_ci3/views/welcome_message.txt new file mode 100644 index 0000000..abd69c6 --- /dev/null +++ b/old_code_ci3/views/welcome_message.txt @@ -0,0 +1,10 @@ +
+

+ Doctor + Add New +

+ +
\ No newline at end of file diff --git a/old_code_ci3/views/workplace/Adminpanel.php b/old_code_ci3/views/workplace/Adminpanel.php new file mode 100644 index 0000000..e69de29 diff --git a/old_code_ci3/views/workplace/workpanel.php b/old_code_ci3/views/workplace/workpanel.php new file mode 100644 index 0000000..c476f8e --- /dev/null +++ b/old_code_ci3/views/workplace/workpanel.php @@ -0,0 +1,46 @@ +
+
+ +
+
+
+
+
+
+
diff --git a/phpunit.xml.dist b/phpunit.xml.dist new file mode 100644 index 0000000..b408a99 --- /dev/null +++ b/phpunit.xml.dist @@ -0,0 +1,63 @@ + + + + + + + + + + + + + ./tests + + + + + + + + + + ./app + + + ./app/Views + ./app/Config/Routes.php + + + + + + + + + + + + + + + diff --git a/preload.php b/preload.php new file mode 100644 index 0000000..288b30b --- /dev/null +++ b/preload.php @@ -0,0 +1,112 @@ + + * + * For the full copyright and license information, please view + * the LICENSE file that was distributed with this source code. + */ + +use CodeIgniter\Boot; +use Config\Paths; + +/* + *--------------------------------------------------------------- + * Sample file for Preloading + *--------------------------------------------------------------- + * See https://www.php.net/manual/en/opcache.preloading.php + * + * How to Use: + * 0. Copy this file to your project root folder. + * 1. Set the $paths property of the preload class below. + * 2. Set opcache.preload in php.ini. + * php.ini: + * opcache.preload=/path/to/preload.php + */ + +// Load the paths config file +require __DIR__ . '/app/Config/Paths.php'; + +// Path to the front controller +define('FCPATH', __DIR__ . DIRECTORY_SEPARATOR . 'public' . DIRECTORY_SEPARATOR); + +class preload +{ + /** + * @var array Paths to preload. + */ + private array $paths = [ + [ + 'include' => __DIR__ . '/vendor/codeigniter4/framework/system', // Change this path if using manual installation + 'exclude' => [ + // Not needed if you don't use them. + '/system/Database/OCI8/', + '/system/Database/Postgre/', + '/system/Database/SQLite3/', + '/system/Database/SQLSRV/', + // Not needed for web apps. + '/system/Database/Seeder.php', + '/system/Test/', + '/system/CLI/', + '/system/Commands/', + '/system/Publisher/', + '/system/ComposerScripts.php', + // Not Class/Function files. + '/system/Config/Routes.php', + '/system/Language/', + '/system/bootstrap.php', + '/system/util_bootstrap.php', + '/system/rewrite.php', + '/Views/', + // Errors occur. + '/system/ThirdParty/', + ], + ], + ]; + + public function __construct() + { + $this->loadAutoloader(); + } + + private function loadAutoloader(): void + { + $paths = new Paths(); + require rtrim($paths->systemDirectory, '\\/ ') . DIRECTORY_SEPARATOR . 'Boot.php'; + + Boot::preload($paths); + } + + /** + * Load PHP files. + */ + public function load(): void + { + foreach ($this->paths as $path) { + $directory = new RecursiveDirectoryIterator($path['include']); + $fullTree = new RecursiveIteratorIterator($directory); + $phpFiles = new RegexIterator( + $fullTree, + '/.+((? $file) { + foreach ($path['exclude'] as $exclude) { + if (str_contains($file[0], $exclude)) { + continue 2; + } + } + + require_once $file[0]; + // Uncomment only for debugging (to inspect which files are included). + // Never use this in production - preload scripts must not generate output. + // echo 'Loaded: ' . $file[0] . "\n"; + } + } + } +} + +(new preload())->load(); diff --git a/public/.htaccess b/public/.htaccess new file mode 100644 index 0000000..abac3cb --- /dev/null +++ b/public/.htaccess @@ -0,0 +1,49 @@ +# Disable directory browsing +Options -Indexes + +# ---------------------------------------------------------------------- +# Rewrite engine +# ---------------------------------------------------------------------- + +# Turning on the rewrite engine is necessary for the following rules and features. +# FollowSymLinks must be enabled for this to work. + + Options +FollowSymlinks + RewriteEngine On + + # If you installed CodeIgniter in a subfolder, you will need to + # change the following line to match the subfolder you need. + # http://httpd.apache.org/docs/current/mod/mod_rewrite.html#rewritebase + # RewriteBase / + + # Redirect Trailing Slashes... + RewriteCond %{REQUEST_FILENAME} !-d + RewriteCond %{REQUEST_URI} (.+)/$ + RewriteRule ^ %1 [L,R=301] + + # Rewrite "www.example.com -> example.com" + RewriteCond %{HTTPS} !=on + RewriteCond %{HTTP_HOST} ^www\.(.+)$ [NC] + RewriteRule ^ http://%1%{REQUEST_URI} [R=301,L] + + # Checks to see if the user is attempting to access a valid file, + # such as an image or css document, if this isn't true it sends the + # request to the front controller, index.php + RewriteCond %{REQUEST_FILENAME} !-f + RewriteCond %{REQUEST_FILENAME} !-d + RewriteRule ^([\s\S]*)$ index.php/$1 [L,NC,QSA] + + # Ensure Authorization header is passed along + RewriteCond %{HTTP:Authorization} . + RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}] + + + + # If we don't have mod_rewrite installed, all 404's + # can be sent to index.php, and everything works as normal. + ErrorDocument 404 index.php + + +# Disable server signature start +ServerSignature Off +# Disable server signature end diff --git a/public/assets/css/style.css b/public/assets/css/style.css new file mode 100644 index 0000000..69ff1c2 --- /dev/null +++ b/public/assets/css/style.css @@ -0,0 +1,1233 @@ +/** +* Template Name: NiceAdmin +* Template URL: https://bootstrapmade.com/nice-admin-bootstrap-admin-html-template/ +* Updated: Apr 20 2024 with Bootstrap v5.3.3 +* Author: BootstrapMade.com +* License: https://bootstrapmade.com/license/ +*/ + +/*-------------------------------------------------------------- +# General +--------------------------------------------------------------*/ +:root { + scroll-behavior: smooth; +} + +body { + font-family: "Open Sans", sans-serif; + background: #f6f9ff; + color: #444444; +} + +a { + color: #4154f1; + text-decoration: none; +} + +a:hover { + color: #717ff5; + text-decoration: none; +} + +h1, +h2, +h3, +h4, +h5, +h6 { + font-family: "Nunito", sans-serif; +} + +/*-------------------------------------------------------------- +# Main +--------------------------------------------------------------*/ +#main { + margin-top: 60px; + padding: 20px 30px; + transition: all 0.3s; +} + +@media (max-width: 1199px) { + #main { + padding: 20px; + } +} + +/*-------------------------------------------------------------- +# Page Title +--------------------------------------------------------------*/ +.pagetitle { + margin-bottom: 10px; +} + +.pagetitle h1 { + font-size: 24px; + margin-bottom: 0; + font-weight: 600; + color: #012970; +} + +/*-------------------------------------------------------------- +# Back to top button +--------------------------------------------------------------*/ +.back-to-top { + position: fixed; + visibility: hidden; + opacity: 0; + right: 15px; + bottom: 15px; + z-index: 99999; + background: #4154f1; + width: 40px; + height: 40px; + border-radius: 4px; + transition: all 0.4s; +} + +.back-to-top i { + font-size: 24px; + color: #fff; + line-height: 0; +} + +.back-to-top:hover { + background: #6776f4; + color: #fff; +} + +.back-to-top.active { + visibility: visible; + opacity: 1; +} + +/*-------------------------------------------------------------- +# Override some default Bootstrap stylings +--------------------------------------------------------------*/ +/* Dropdown menus */ +.dropdown-menu { + border-radius: 4px; + padding: 10px 0; + animation-name: dropdown-animate; + animation-duration: 0.2s; + animation-fill-mode: both; + border: 0; + box-shadow: 0 5px 30px 0 rgba(82, 63, 105, 0.2); +} + +.dropdown-menu .dropdown-header, +.dropdown-menu .dropdown-footer { + text-align: center; + font-size: 15px; + padding: 10px 25px; +} + +.dropdown-menu .dropdown-footer a { + color: #444444; + text-decoration: underline; +} + +.dropdown-menu .dropdown-footer a:hover { + text-decoration: none; +} + +.dropdown-menu .dropdown-divider { + color: #a5c5fe; + margin: 0; +} + +.dropdown-menu .dropdown-item { + font-size: 14px; + padding: 10px 15px; + transition: 0.3s; +} + +.dropdown-menu .dropdown-item i { + margin-right: 10px; + font-size: 18px; + line-height: 0; +} + +.dropdown-menu .dropdown-item:hover { + background-color: #f6f9ff; +} + +@media (min-width: 768px) { + .dropdown-menu-arrow::before { + content: ""; + width: 13px; + height: 13px; + background: #fff; + position: absolute; + top: -7px; + right: 20px; + transform: rotate(45deg); + border-top: 1px solid #eaedf1; + border-left: 1px solid #eaedf1; + } +} + +@keyframes dropdown-animate { + 0% { + opacity: 0; + } + + 100% { + opacity: 1; + } + + 0% { + opacity: 0; + } +} + +/* Light Backgrounds */ +.bg-primary-light { + background-color: #cfe2ff; + border-color: #cfe2ff; +} + +.bg-secondary-light { + background-color: #e2e3e5; + border-color: #e2e3e5; +} + +.bg-success-light { + background-color: #d1e7dd; + border-color: #d1e7dd; +} + +.bg-danger-light { + background-color: #f8d7da; + border-color: #f8d7da; +} + +.bg-warning-light { + background-color: #fff3cd; + border-color: #fff3cd; +} + +.bg-info-light { + background-color: #cff4fc; + border-color: #cff4fc; +} + +.bg-dark-light { + background-color: #d3d3d4; + border-color: #d3d3d4; +} + +/* Card */ +.card { + margin-bottom: 30px; + border: none; + border-radius: 5px; + box-shadow: 0px 0 30px rgba(1, 41, 112, 0.1); +} + +.card-header, +.card-footer { + border-color: #ebeef4; + background-color: #fff; + color: #798eb3; + padding: 15px; +} + +.card-title { + padding: 20px 0 15px 0; + font-size: 18px; + font-weight: 500; + color: #012970; + font-family: "Poppins", sans-serif; +} + +.card-title span { + color: #899bbd; + font-size: 14px; + font-weight: 400; +} + +.card-body { + padding: 0 20px 20px 20px; +} + +.card-img-overlay { + background-color: rgba(255, 255, 255, 0.6); +} + +/* Alerts */ +.alert-heading { + font-weight: 500; + font-family: "Poppins", sans-serif; + font-size: 20px; +} + +/* Close Button */ +.btn-close { + background-size: 25%; +} + +.btn-close:focus { + outline: 0; + box-shadow: none; +} + +/* Accordion */ +.accordion-item { + border: 1px solid #ebeef4; +} + +.accordion-button:focus { + outline: 0; + box-shadow: none; +} + +.accordion-button:not(.collapsed) { + color: #012970; + background-color: #f6f9ff; +} + +.accordion-flush .accordion-button { + padding: 15px 0; + background: none; + border: 0; +} + +.accordion-flush .accordion-button:not(.collapsed) { + box-shadow: none; + color: #4154f1; +} + +.accordion-flush .accordion-body { + padding: 0 0 15px 0; + color: #3e4f6f; + font-size: 15px; +} + +/* Breadcrumbs */ +.breadcrumb { + font-size: 14px; + font-family: "Nunito", sans-serif; + color: #899bbd; + font-weight: 600; +} + +.breadcrumb a { + color: #899bbd; + transition: 0.3s; +} + +.breadcrumb a:hover { + color: #51678f; +} + +.breadcrumb .breadcrumb-item::before { + color: #899bbd; +} + +.breadcrumb .active { + color: #51678f; + font-weight: 600; +} + +/* Bordered Tabs */ +.nav-tabs-bordered { + border-bottom: 2px solid #ebeef4; +} + +.nav-tabs-bordered .nav-link { + margin-bottom: -2px; + border: none; + color: #2c384e; +} + +.nav-tabs-bordered .nav-link:hover, +.nav-tabs-bordered .nav-link:focus { + color: #4154f1; +} + +.nav-tabs-bordered .nav-link.active { + background-color: #fff; + color: #4154f1; + border-bottom: 2px solid #4154f1; +} + +/*-------------------------------------------------------------- +# Header +--------------------------------------------------------------*/ +.logo { + line-height: 1; +} + +@media (min-width: 1200px) { + .logo { + width: 280px; + } +} + +.logo img { + max-height: 26px; + margin-right: 6px; +} + +.logo span { + font-size: 26px; + font-weight: 700; + color: #012970; + font-family: "Nunito", sans-serif; +} + +.header { + transition: all 0.5s; + z-index: 997; + height: 60px; + box-shadow: 0px 2px 20px rgba(1, 41, 112, 0.1); + background-color: #fff; + padding-left: 20px; + /* Toggle Sidebar Button */ + /* Search Bar */ +} + +.header .toggle-sidebar-btn { + font-size: 32px; + padding-left: 10px; + cursor: pointer; + color: #012970; +} + +.header .search-bar { + min-width: 360px; + padding: 0 20px; +} + +@media (max-width: 1199px) { + .header .search-bar { + position: fixed; + top: 50px; + left: 0; + right: 0; + padding: 20px; + box-shadow: 0px 0px 15px 0px rgba(1, 41, 112, 0.1); + background: white; + z-index: 9999; + transition: 0.3s; + visibility: hidden; + opacity: 0; + } + + .header .search-bar-show { + top: 60px; + visibility: visible; + opacity: 1; + } +} + +.header .search-form { + width: 100%; +} + +.header .search-form input { + border: 0; + font-size: 14px; + color: #012970; + border: 1px solid rgba(1, 41, 112, 0.2); + padding: 7px 38px 7px 8px; + border-radius: 3px; + transition: 0.3s; + width: 100%; +} + +.header .search-form input:focus, +.header .search-form input:hover { + outline: none; + box-shadow: 0 0 10px 0 rgba(1, 41, 112, 0.15); + border: 1px solid rgba(1, 41, 112, 0.3); +} + +.header .search-form button { + border: 0; + padding: 0; + margin-left: -30px; + background: none; +} + +.header .search-form button i { + color: #012970; +} + +/*-------------------------------------------------------------- +# Header Nav +--------------------------------------------------------------*/ +.header-nav ul { + list-style: none; +} + +.header-nav>ul { + margin: 0; + padding: 0; +} + +.header-nav .nav-icon { + font-size: 22px; + color: #012970; + margin-right: 25px; + position: relative; +} + +.header-nav .nav-profile { + color: #012970; +} + +.header-nav .nav-profile img { + max-height: 36px; +} + +.header-nav .nav-profile span { + font-size: 14px; + font-weight: 600; +} + +.header-nav .badge-number { + position: absolute; + inset: -2px -5px auto auto; + font-weight: normal; + font-size: 12px; + padding: 3px 6px; +} + +.header-nav .notifications { + inset: 8px -15px auto auto !important; +} + +.header-nav .notifications .notification-item { + display: flex; + align-items: center; + padding: 15px 10px; + transition: 0.3s; +} + +.header-nav .notifications .notification-item i { + margin: 0 20px 0 10px; + font-size: 24px; +} + +.header-nav .notifications .notification-item h4 { + font-size: 16px; + font-weight: 600; + margin-bottom: 5px; +} + +.header-nav .notifications .notification-item p { + font-size: 13px; + margin-bottom: 3px; + color: #919191; +} + +.header-nav .notifications .notification-item:hover { + background-color: #f6f9ff; +} + +.header-nav .messages { + inset: 8px -15px auto auto !important; +} + +.header-nav .messages .message-item { + padding: 15px 10px; + transition: 0.3s; +} + +.header-nav .messages .message-item a { + display: flex; +} + +.header-nav .messages .message-item img { + margin: 0 20px 0 10px; + max-height: 40px; +} + +.header-nav .messages .message-item h4 { + font-size: 16px; + font-weight: 600; + margin-bottom: 5px; + color: #444444; +} + +.header-nav .messages .message-item p { + font-size: 13px; + margin-bottom: 3px; + color: #919191; +} + +.header-nav .messages .message-item:hover { + background-color: #f6f9ff; +} + +.header-nav .profile { + min-width: 240px; + padding-bottom: 0; + top: 8px !important; +} + +.header-nav .profile .dropdown-header h6 { + font-size: 18px; + margin-bottom: 0; + font-weight: 600; + color: #444444; +} + +.header-nav .profile .dropdown-header span { + font-size: 14px; +} + +.header-nav .profile .dropdown-item { + font-size: 14px; + padding: 10px 15px; + transition: 0.3s; +} + +.header-nav .profile .dropdown-item i { + margin-right: 10px; + font-size: 18px; + line-height: 0; +} + +.header-nav .profile .dropdown-item:hover { + background-color: #f6f9ff; +} + +/*-------------------------------------------------------------- +# Sidebar +--------------------------------------------------------------*/ +.sidebar { + position: fixed; + top: 60px; + left: 0; + bottom: 0; + width: 300px; + z-index: 996; + transition: all 0.3s; + padding: 20px; + overflow-y: auto; + scrollbar-width: thin; + scrollbar-color: #aab7cf transparent; + box-shadow: 0px 0px 20px rgba(1, 41, 112, 0.1); + background-color: #fff; +} + +@media (max-width: 1199px) { + .sidebar { + left: -300px; + } +} + +.sidebar::-webkit-scrollbar { + width: 5px; + height: 8px; + background-color: #fff; +} + +.sidebar::-webkit-scrollbar-thumb { + background-color: #aab7cf; +} + +@media (min-width: 1200px) { + + #main, + #footer { + margin-left: 300px; + } +} + +@media (max-width: 1199px) { + .toggle-sidebar .sidebar { + left: 0; + } +} + +@media (min-width: 1200px) { + + .toggle-sidebar #main, + .toggle-sidebar #footer { + margin-left: 0; + } + + .toggle-sidebar .sidebar { + left: -300px; + } +} + +.sidebar-nav { + padding: 0; + margin: 0; + list-style: none; +} + +.sidebar-nav li { + padding: 0; + margin: 0; + list-style: none; +} + +.sidebar-nav .nav-item { + margin-bottom: 5px; +} + +.sidebar-nav .nav-heading { + font-size: 11px; + text-transform: uppercase; + color: #899bbd; + font-weight: 600; + margin: 10px 0 5px 15px; +} + +.sidebar-nav .nav-link { + display: flex; + align-items: center; + font-size: 15px; + font-weight: 600; + color: #4154f1; + transition: 0.3; + background: #f6f9ff; + padding: 10px 15px; + border-radius: 4px; +} + +.sidebar-nav .nav-link i { + font-size: 16px; + margin-right: 10px; + color: #4154f1; +} + +.sidebar-nav .nav-link.collapsed { + color: #012970; + background: #fff; +} + +.sidebar-nav .nav-link.collapsed i { + color: #899bbd; +} + +.sidebar-nav .nav-link:hover { + color: #4154f1; + background: #f6f9ff; +} + +.sidebar-nav .nav-link:hover i { + color: #4154f1; +} + +.sidebar-nav .nav-link .bi-chevron-down { + margin-right: 0; + transition: transform 0.2s ease-in-out; +} + +.sidebar-nav .nav-link:not(.collapsed) .bi-chevron-down { + transform: rotate(180deg); +} + +.sidebar-nav .nav-content { + padding: 5px 0 0 0; + margin: 0; + list-style: none; +} + +.sidebar-nav .nav-content a { + display: flex; + align-items: center; + font-size: 14px; + font-weight: 600; + color: #012970; + transition: 0.3; + padding: 10px 0 10px 40px; + transition: 0.3s; +} + +.sidebar-nav .nav-content a i { + font-size: 6px; + margin-right: 8px; + line-height: 0; + border-radius: 50%; +} + +.sidebar-nav .nav-content a:hover, +.sidebar-nav .nav-content a.active { + color: #4154f1; +} + +.sidebar-nav .nav-content a.active i { + background-color: #4154f1; +} + +/*-------------------------------------------------------------- +# Dashboard +--------------------------------------------------------------*/ +/* Filter dropdown */ +.dashboard .filter { + position: absolute; + right: 0px; + top: 15px; +} + +.dashboard .filter .icon { + color: #aab7cf; + padding-right: 20px; + padding-bottom: 5px; + transition: 0.3s; + font-size: 16px; +} + +.dashboard .filter .icon:hover, +.dashboard .filter .icon:focus { + color: #4154f1; +} + +.dashboard .filter .dropdown-header { + padding: 8px 15px; +} + +.dashboard .filter .dropdown-header h6 { + text-transform: uppercase; + font-size: 14px; + font-weight: 600; + letter-spacing: 1px; + color: #aab7cf; + margin-bottom: 0; + padding: 0; +} + +.dashboard .filter .dropdown-item { + padding: 8px 15px; +} + +/* Info Cards */ +.dashboard .info-card { + padding-bottom: 10px; +} + +.dashboard .info-card h6 { + font-size: 28px; + color: #012970; + font-weight: 700; + margin: 0; + padding: 0; +} + +.dashboard .card-icon { + font-size: 32px; + line-height: 0; + width: 64px; + height: 64px; + flex-shrink: 0; + flex-grow: 0; +} + +.dashboard .sales-card .card-icon { + color: #4154f1; + background: #f6f6fe; +} + +.dashboard .revenue-card .card-icon { + color: #2eca6a; + background: #e0f8e9; +} + +.dashboard .customers-card .card-icon { + color: #ff771d; + background: #ffecdf; +} + +/* Activity */ +.dashboard .activity { + font-size: 14px; +} + +.dashboard .activity .activity-item .activite-label { + color: #888; + position: relative; + flex-shrink: 0; + flex-grow: 0; + min-width: 64px; +} + +.dashboard .activity .activity-item .activite-label::before { + content: ""; + position: absolute; + right: -11px; + width: 4px; + top: 0; + bottom: 0; + background-color: #eceefe; +} + +.dashboard .activity .activity-item .activity-badge { + margin-top: 3px; + z-index: 1; + font-size: 11px; + line-height: 0; + border-radius: 50%; + flex-shrink: 0; + border: 3px solid #fff; + flex-grow: 0; +} + +.dashboard .activity .activity-item .activity-content { + padding-left: 10px; + padding-bottom: 20px; +} + +.dashboard .activity .activity-item:first-child .activite-label::before { + top: 5px; +} + +.dashboard .activity .activity-item:last-child .activity-content { + padding-bottom: 0; +} + +/* News & Updates */ +.dashboard .news .post-item+.post-item { + margin-top: 15px; +} + +.dashboard .news img { + width: 80px; + float: left; + border-radius: 5px; +} + +.dashboard .news h4 { + font-size: 15px; + margin-left: 95px; + font-weight: bold; + margin-bottom: 5px; +} + +.dashboard .news h4 a { + color: #012970; + transition: 0.3s; +} + +.dashboard .news h4 a:hover { + color: #4154f1; +} + +.dashboard .news p { + font-size: 14px; + color: #777777; + margin-left: 95px; +} + +/* Recent Sales */ +.dashboard .recent-sales { + font-size: 14px; +} + +.dashboard .recent-sales .table thead { + background: #f6f6fe; +} + +.dashboard .recent-sales .table thead th { + border: 0; +} + +.dashboard .recent-sales .dataTable-top { + padding: 0 0 10px 0; +} + +.dashboard .recent-sales .dataTable-bottom { + padding: 10px 0 0 0; +} + +/* Top Selling */ +.dashboard .top-selling { + font-size: 14px; +} + +.dashboard .top-selling .table thead { + background: #f6f6fe; +} + +.dashboard .top-selling .table thead th { + border: 0; +} + +.dashboard .top-selling .table tbody td { + vertical-align: middle; +} + +.dashboard .top-selling img { + border-radius: 5px; + max-width: 60px; +} + +/*-------------------------------------------------------------- +# Icons list page +--------------------------------------------------------------*/ +.iconslist { + display: grid; + max-width: 100%; + grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); + gap: 1.25rem; + padding-top: 15px; +} + +.iconslist .icon { + background-color: #fff; + border-radius: 0.25rem; + text-align: center; + color: #012970; + padding: 15px 0; +} + +.iconslist i { + margin: 0.25rem; + font-size: 2.5rem; +} + +.iconslist .label { + font-family: var(--bs-font-monospace); + display: inline-block; + width: 100%; + overflow: hidden; + padding: 0.25rem; + font-size: 12px; + text-overflow: ellipsis; + white-space: nowrap; + color: #666; +} + +/*-------------------------------------------------------------- +# Profie Page +--------------------------------------------------------------*/ +.profile .profile-card img { + max-width: 120px; +} + +.profile .profile-card h2 { + font-size: 24px; + font-weight: 700; + color: #2c384e; + margin: 10px 0 0 0; +} + +.profile .profile-card h3 { + font-size: 18px; +} + +.profile .profile-card .social-links a { + font-size: 20px; + display: inline-block; + color: rgba(1, 41, 112, 0.5); + line-height: 0; + margin-right: 10px; + transition: 0.3s; +} + +.profile .profile-card .social-links a:hover { + color: #012970; +} + +.profile .profile-overview .row { + margin-bottom: 20px; + font-size: 15px; +} + +.profile .profile-overview .card-title { + color: #012970; +} + +.profile .profile-overview .label { + font-weight: 600; + color: rgba(1, 41, 112, 0.6); +} + +.profile .profile-edit label { + font-weight: 600; + color: rgba(1, 41, 112, 0.6); +} + +.profile .profile-edit img { + max-width: 120px; +} + +/*-------------------------------------------------------------- +# F.A.Q Page +--------------------------------------------------------------*/ +.faq .basic h6 { + font-size: 18px; + font-weight: 600; + color: #4154f1; +} + +.faq .basic p { + color: #6980aa; +} + +/*-------------------------------------------------------------- +# Contact +--------------------------------------------------------------*/ +.contact .info-box { + padding: 28px 30px; +} + +.contact .info-box i { + font-size: 38px; + line-height: 0; + color: #4154f1; +} + +.contact .info-box h3 { + font-size: 20px; + color: #012970; + font-weight: 700; + margin: 20px 0 10px 0; +} + +.contact .info-box p { + padding: 0; + line-height: 24px; + font-size: 14px; + margin-bottom: 0; +} + +.contact .php-email-form .error-message { + display: none; + color: #fff; + background: #ed3c0d; + text-align: left; + padding: 15px; + margin-bottom: 24px; + font-weight: 600; +} + +.contact .php-email-form .sent-message { + display: none; + color: #fff; + background: #18d26e; + text-align: center; + padding: 15px; + margin-bottom: 24px; + font-weight: 600; +} + +.contact .php-email-form .loading { + display: none; + background: #fff; + text-align: center; + padding: 15px; + margin-bottom: 24px; +} + +.contact .php-email-form .loading:before { + content: ""; + display: inline-block; + border-radius: 50%; + width: 24px; + height: 24px; + margin: 0 10px -6px 0; + border: 3px solid #18d26e; + border-top-color: #eee; + animation: animate-loading 1s linear infinite; +} + +.contact .php-email-form input, +.contact .php-email-form textarea { + border-radius: 0; + box-shadow: none; + font-size: 14px; + border-radius: 0; +} + +.contact .php-email-form input:focus, +.contact .php-email-form textarea:focus { + border-color: #4154f1; +} + +.contact .php-email-form input { + padding: 10px 15px; +} + +.contact .php-email-form textarea { + padding: 12px 15px; +} + +.contact .php-email-form button[type=submit] { + background: #4154f1; + border: 0; + padding: 10px 30px; + color: #fff; + transition: 0.4s; + border-radius: 4px; +} + +.contact .php-email-form button[type=submit]:hover { + background: #5969f3; +} + +@keyframes animate-loading { + 0% { + transform: rotate(0deg); + } + + 100% { + transform: rotate(360deg); + } +} + +/*-------------------------------------------------------------- +# Error 404 +--------------------------------------------------------------*/ +.error-404 { + padding: 30px; +} + +.error-404 h1 { + font-size: 180px; + font-weight: 700; + color: #4154f1; + margin-bottom: 0; + line-height: 150px; +} + +.error-404 h2 { + font-size: 24px; + font-weight: 700; + color: #012970; + margin-bottom: 30px; +} + +.error-404 .btn { + background: #51678f; + color: #fff; + padding: 8px 30px; +} + +.error-404 .btn:hover { + background: #3e4f6f; +} + +@media (min-width: 992px) { + .error-404 img { + max-width: 50%; + } +} + +/*-------------------------------------------------------------- +# Footer +--------------------------------------------------------------*/ +.footer { + padding: 20px 0; + font-size: 14px; + transition: all 0.3s; + border-top: 1px solid #cddfff; +} + +.footer .copyright { + text-align: center; + color: #012970; +} + +.footer .credits { + padding-top: 5px; + text-align: center; + font-size: 13px; + color: #012970; +} \ No newline at end of file diff --git a/public/assets/images/no_image.svg b/public/assets/images/no_image.svg new file mode 100644 index 0000000..0b3518c --- /dev/null +++ b/public/assets/images/no_image.svg @@ -0,0 +1,5 @@ + + + + No Image + diff --git a/public/assets/img/apple-touch-icon.png b/public/assets/img/apple-touch-icon.png new file mode 100644 index 0000000..78b2586 Binary files /dev/null and b/public/assets/img/apple-touch-icon.png differ diff --git a/public/assets/img/card.jpg b/public/assets/img/card.jpg new file mode 100644 index 0000000..3ee97ef Binary files /dev/null and b/public/assets/img/card.jpg differ diff --git a/public/assets/img/favicon.png b/public/assets/img/favicon.png new file mode 100644 index 0000000..f9bc174 Binary files /dev/null and b/public/assets/img/favicon.png differ diff --git a/public/assets/img/logo.png b/public/assets/img/logo.png new file mode 100644 index 0000000..9cfbaf2 Binary files /dev/null and b/public/assets/img/logo.png differ diff --git a/public/assets/img/messages-1.jpg b/public/assets/img/messages-1.jpg new file mode 100644 index 0000000..a337d97 Binary files /dev/null and b/public/assets/img/messages-1.jpg differ diff --git a/public/assets/img/messages-2.jpg b/public/assets/img/messages-2.jpg new file mode 100644 index 0000000..1d75b4e Binary files /dev/null and b/public/assets/img/messages-2.jpg differ diff --git a/public/assets/img/messages-3.jpg b/public/assets/img/messages-3.jpg new file mode 100644 index 0000000..390712b Binary files /dev/null and b/public/assets/img/messages-3.jpg differ diff --git a/public/assets/img/news-1.jpg b/public/assets/img/news-1.jpg new file mode 100644 index 0000000..a2c77f1 Binary files /dev/null and b/public/assets/img/news-1.jpg differ diff --git a/public/assets/img/news-2.jpg b/public/assets/img/news-2.jpg new file mode 100644 index 0000000..8a39581 Binary files /dev/null and b/public/assets/img/news-2.jpg differ diff --git a/public/assets/img/news-3.jpg b/public/assets/img/news-3.jpg new file mode 100644 index 0000000..710ec0a Binary files /dev/null and b/public/assets/img/news-3.jpg differ diff --git a/public/assets/img/news-4.jpg b/public/assets/img/news-4.jpg new file mode 100644 index 0000000..81caaf3 Binary files /dev/null and b/public/assets/img/news-4.jpg differ diff --git a/public/assets/img/news-5.jpg b/public/assets/img/news-5.jpg new file mode 100644 index 0000000..779068f Binary files /dev/null and b/public/assets/img/news-5.jpg differ diff --git a/public/assets/img/not-found.svg b/public/assets/img/not-found.svg new file mode 100644 index 0000000..3822279 --- /dev/null +++ b/public/assets/img/not-found.svg @@ -0,0 +1 @@ +not found \ No newline at end of file diff --git a/public/assets/img/product-1.jpg b/public/assets/img/product-1.jpg new file mode 100644 index 0000000..10ea6ea Binary files /dev/null and b/public/assets/img/product-1.jpg differ diff --git a/public/assets/img/product-2.jpg b/public/assets/img/product-2.jpg new file mode 100644 index 0000000..1b879f6 Binary files /dev/null and b/public/assets/img/product-2.jpg differ diff --git a/public/assets/img/product-3.jpg b/public/assets/img/product-3.jpg new file mode 100644 index 0000000..595f121 Binary files /dev/null and b/public/assets/img/product-3.jpg differ diff --git a/public/assets/img/product-4.jpg b/public/assets/img/product-4.jpg new file mode 100644 index 0000000..44c5bf3 Binary files /dev/null and b/public/assets/img/product-4.jpg differ diff --git a/public/assets/img/product-5.jpg b/public/assets/img/product-5.jpg new file mode 100644 index 0000000..f3fbb0e Binary files /dev/null and b/public/assets/img/product-5.jpg differ diff --git a/public/assets/img/profile-img.jpg b/public/assets/img/profile-img.jpg new file mode 100644 index 0000000..16ac229 Binary files /dev/null and b/public/assets/img/profile-img.jpg differ diff --git a/public/assets/img/slides-1.jpg b/public/assets/img/slides-1.jpg new file mode 100644 index 0000000..a37af6c Binary files /dev/null and b/public/assets/img/slides-1.jpg differ diff --git a/public/assets/img/slides-2.jpg b/public/assets/img/slides-2.jpg new file mode 100644 index 0000000..e859463 Binary files /dev/null and b/public/assets/img/slides-2.jpg differ diff --git a/public/assets/img/slides-3.jpg b/public/assets/img/slides-3.jpg new file mode 100644 index 0000000..66c6868 Binary files /dev/null and b/public/assets/img/slides-3.jpg differ diff --git a/public/assets/js/main.js b/public/assets/js/main.js new file mode 100644 index 0000000..b390c6c --- /dev/null +++ b/public/assets/js/main.js @@ -0,0 +1,319 @@ +/** +* Template Name: NiceAdmin +* Template URL: https://bootstrapmade.com/nice-admin-bootstrap-admin-html-template/ +* Updated: Apr 20 2024 with Bootstrap v5.3.3 +* Author: BootstrapMade.com +* License: https://bootstrapmade.com/license/ +*/ + +(function() { + "use strict"; + + /** + * Easy selector helper function + */ + const select = (el, all = false) => { + el = el.trim() + if (all) { + return [...document.querySelectorAll(el)] + } else { + return document.querySelector(el) + } + } + + /** + * Easy event listener function + */ + const on = (type, el, listener, all = false) => { + if (all) { + select(el, all).forEach(e => e.addEventListener(type, listener)) + } else { + select(el, all).addEventListener(type, listener) + } + } + + /** + * Easy on scroll event listener + */ + const onscroll = (el, listener) => { + el.addEventListener('scroll', listener) + } + + /** + * Sidebar toggle + */ + if (select('.toggle-sidebar-btn')) { + on('click', '.toggle-sidebar-btn', function(e) { + select('body').classList.toggle('toggle-sidebar') + }) + } + + /** + * Search bar toggle + */ + if (select('.search-bar-toggle')) { + on('click', '.search-bar-toggle', function(e) { + select('.search-bar').classList.toggle('search-bar-show') + }) + } + + /** + * Navbar links active state on scroll + */ + let navbarlinks = select('#navbar .scrollto', true) + const navbarlinksActive = () => { + let position = window.scrollY + 200 + navbarlinks.forEach(navbarlink => { + if (!navbarlink.hash) return + let section = select(navbarlink.hash) + if (!section) return + if (position >= section.offsetTop && position <= (section.offsetTop + section.offsetHeight)) { + navbarlink.classList.add('active') + } else { + navbarlink.classList.remove('active') + } + }) + } + window.addEventListener('load', navbarlinksActive) + onscroll(document, navbarlinksActive) + + /** + * Toggle .header-scrolled class to #header when page is scrolled + */ + let selectHeader = select('#header') + if (selectHeader) { + const headerScrolled = () => { + if (window.scrollY > 100) { + selectHeader.classList.add('header-scrolled') + } else { + selectHeader.classList.remove('header-scrolled') + } + } + window.addEventListener('load', headerScrolled) + onscroll(document, headerScrolled) + } + + /** + * Back to top button + */ + let backtotop = select('.back-to-top') + if (backtotop) { + const toggleBacktotop = () => { + if (window.scrollY > 100) { + backtotop.classList.add('active') + } else { + backtotop.classList.remove('active') + } + } + window.addEventListener('load', toggleBacktotop) + onscroll(document, toggleBacktotop) + } + + /** + * Initiate tooltips + */ + var tooltipTriggerList = [].slice.call(document.querySelectorAll('[data-bs-toggle="tooltip"]')) + var tooltipList = tooltipTriggerList.map(function(tooltipTriggerEl) { + return new bootstrap.Tooltip(tooltipTriggerEl) + }) + + /** + * Initiate quill editors + */ + if (select('.quill-editor-default')) { + new Quill('.quill-editor-default', { + theme: 'snow' + }); + } + + if (select('.quill-editor-bubble')) { + new Quill('.quill-editor-bubble', { + theme: 'bubble' + }); + } + + if (select('.quill-editor-full')) { + new Quill(".quill-editor-full", { + modules: { + toolbar: [ + [{ + font: [] + }, { + size: [] + }], + ["bold", "italic", "underline", "strike"], + [{ + color: [] + }, + { + background: [] + } + ], + [{ + script: "super" + }, + { + script: "sub" + } + ], + [{ + list: "ordered" + }, + { + list: "bullet" + }, + { + indent: "-1" + }, + { + indent: "+1" + } + ], + ["direction", { + align: [] + }], + ["link", "image", "video"], + ["clean"] + ] + }, + theme: "snow" + }); + } + + /** + * Initiate TinyMCE Editor + */ + + const useDarkMode = window.matchMedia('(prefers-color-scheme: dark)').matches; + const isSmallScreen = window.matchMedia('(max-width: 1023.5px)').matches; + + tinymce.init({ + selector: 'textarea.tinymce-editor', + plugins: 'preview importcss searchreplace autolink autosave save directionality code visualblocks visualchars fullscreen image link media codesample table charmap pagebreak nonbreaking anchor insertdatetime advlist lists wordcount help charmap quickbars emoticons accordion', + editimage_cors_hosts: ['picsum.photos'], + menubar: 'file edit view insert format tools table help', + toolbar: "undo redo | accordion accordionremove | blocks fontfamily fontsize | bold italic underline strikethrough | align numlist bullist | link image | table media | lineheight outdent indent| forecolor backcolor removeformat | charmap emoticons | code fullscreen preview | save print | pagebreak anchor codesample | ltr rtl", + autosave_ask_before_unload: true, + autosave_interval: '30s', + autosave_prefix: '{path}{query}-{id}-', + autosave_restore_when_empty: false, + autosave_retention: '2m', + image_advtab: true, + link_list: [{ + title: 'My page 1', + value: 'https://www.tiny.cloud' + }, + { + title: 'My page 2', + value: 'http://www.moxiecode.com' + } + ], + image_list: [{ + title: 'My page 1', + value: 'https://www.tiny.cloud' + }, + { + title: 'My page 2', + value: 'http://www.moxiecode.com' + } + ], + image_class_list: [{ + title: 'None', + value: '' + }, + { + title: 'Some class', + value: 'class-name' + } + ], + importcss_append: true, + file_picker_callback: (callback, value, meta) => { + /* Provide file and text for the link dialog */ + if (meta.filetype === 'file') { + callback('https://www.google.com/logos/google.jpg', { + text: 'My text' + }); + } + + /* Provide image and alt text for the image dialog */ + if (meta.filetype === 'image') { + callback('https://www.google.com/logos/google.jpg', { + alt: 'My alt text' + }); + } + + /* Provide alternative source and posted for the media dialog */ + if (meta.filetype === 'media') { + callback('movie.mp4', { + source2: 'alt.ogg', + poster: 'https://www.google.com/logos/google.jpg' + }); + } + }, + height: 600, + image_caption: true, + quickbars_selection_toolbar: 'bold italic | quicklink h2 h3 blockquote quickimage quicktable', + noneditable_class: 'mceNonEditable', + toolbar_mode: 'sliding', + contextmenu: 'link image table', + skin: useDarkMode ? 'oxide-dark' : 'oxide', + content_css: useDarkMode ? 'dark' : 'default', + content_style: 'body { font-family:Helvetica,Arial,sans-serif; font-size:16px }' + }); + + /** + * Initiate Bootstrap validation check + */ + var needsValidation = document.querySelectorAll('.needs-validation') + + Array.prototype.slice.call(needsValidation) + .forEach(function(form) { + form.addEventListener('submit', function(event) { + if (!form.checkValidity()) { + event.preventDefault() + event.stopPropagation() + } + + form.classList.add('was-validated') + }, false) + }) + + /** + * Initiate Datatables + */ + const datatables = select('.datatable', true) + datatables.forEach(datatable => { + new simpleDatatables.DataTable(datatable, { + perPageSelect: [5, 10, 15, ["All", -1]], + columns: [{ + select: 2, + sortSequence: ["desc", "asc"] + }, + { + select: 3, + sortSequence: ["desc"] + }, + { + select: 4, + cellClass: "green", + headerClass: "red" + } + ] + }); + }) + + /** + * Autoresize echart charts + */ + const mainContainer = select('#main'); + if (mainContainer) { + setTimeout(() => { + new ResizeObserver(function() { + select('.echart', true).forEach(getEchart => { + echarts.getInstanceByDom(getEchart).resize(); + }) + }).observe(mainContainer); + }, 200); + } + +})(); \ No newline at end of file diff --git a/public/assets/scss/_dashboard.scss b/public/assets/scss/_dashboard.scss new file mode 100644 index 0000000..810f6d5 --- /dev/null +++ b/public/assets/scss/_dashboard.scss @@ -0,0 +1,226 @@ +/*-------------------------------------------------------------- +# Dashboard +--------------------------------------------------------------*/ +/* Filter dropdown */ +.dashboard { + + .filter { + position: absolute; + right: 0px; + top: 15px; + + .icon { + color: lighten($tertiary, 50); + padding-right: 20px; + padding-bottom: 5px; + transition: 0.3s; + font-size: 16px; + &:hover, &:focus { + color: $primary; + } + } + + .dropdown-header { + padding: 8px 15px; + } + + .dropdown-header h6 { + text-transform: uppercase; + font-size: 14px; + font-weight: 600; + letter-spacing: 1px; + color: lighten($tertiary, 50); + margin-bottom: 0; + padding: 0; + } + + .dropdown-item { + padding: 8px 15px; + } + } +} + +/* Info Cards */ +.dashboard { + .info-card { + padding-bottom: 10px; + h6 { + font-size: 28px; + color: $secondary; + font-weight: 700; + margin: 0; + padding: 0; + } + } + + .card-icon { + font-size: 32px; + line-height: 0; + width: 64px; + height: 64px; + flex-shrink: 0; + flex-grow: 0; + } + + .sales-card { + .card-icon { + color: $primary; + background: lighten($primary, 38); + } + } + + .revenue-card { + .card-icon { + color: #2eca6a; + background: lighten(#2eca6a, 44); + } + } + + .customers-card { + .card-icon { + color: #ff771d; + background: lighten(#ff771d, 38); + } + } +} + +/* Activity */ +.dashboard { + .activity { + font-size: 14px; + + .activity-item { + + .activite-label { + color: #888; + position: relative; + flex-shrink: 0; + flex-grow: 0; + min-width: 64px; + + &::before { + content: ""; + position: absolute; + right: -11px; + width: 4px; + top: 0; + bottom: 0; + background-color: lighten($primary, 36); + } + } + + .activity-badge { + margin-top: 3px; + z-index: 1; + font-size: 11px; + line-height: 0; + border-radius: 50%; + flex-shrink: 0; + border: 3px solid #fff; + flex-grow: 0; + } + + .activity-content { + padding-left: 10px; + padding-bottom: 20px; + } + + &:first-child .activite-label::before { + top: 5px; + } + + &:last-child .activity-content { + padding-bottom: 0; + } + + } + + } + +} + +/* News & Updates */ +.dashboard { + .news { + .post-item + .post-item { + margin-top: 15px; + } + + img { + width: 80px; + float: left; + border-radius: 5px; + } + + h4 { + font-size: 15px; + margin-left: 95px; + font-weight: bold; + margin-bottom: 5px; + a { + color: $secondary; + transition: 0.3s; + &:hover { + color: $primary; + } + } + } + + p { + font-size: 14px; + color: lighten($default, 20); + margin-left: 95px; + } + + } +} + +/* Recent Sales */ +.dashboard { + .recent-sales { + font-size: 14px; + .table thead { + background: lighten($primary, 38); + th { + border: 0; + } + } + + .dataTable-top { + padding: 0 0 10px 0; + } + + .dataTable-bottom { + padding: 10px 0 0 0; + } + + } +} + +/* Top Selling */ +.dashboard { + + .top-selling { + font-size: 14px; + .table { + thead { + background: lighten($primary, 38); + th { + border: 0; + } + } + + tbody td { + vertical-align: middle; + } + + } + + img { + border-radius: 5px; + max-width: 60px; + } + + + } +} diff --git a/public/assets/scss/_footer.scss b/public/assets/scss/_footer.scss new file mode 100644 index 0000000..b1b811e --- /dev/null +++ b/public/assets/scss/_footer.scss @@ -0,0 +1,21 @@ +/*-------------------------------------------------------------- +# Footer +--------------------------------------------------------------*/ +.footer { + padding: 20px 0; + font-size: 14px; + transition: all 0.3s; + border-top: 1px solid lighten($secondary, 68); + + .copyright { + text-align: center; + color: $secondary; + } + + .credits { + padding-top: 5px; + text-align: center; + font-size: 13px; + color: $secondary; + } +} diff --git a/public/assets/scss/_general.scss b/public/assets/scss/_general.scss new file mode 100644 index 0000000..ae21ba2 --- /dev/null +++ b/public/assets/scss/_general.scss @@ -0,0 +1,85 @@ +/*-------------------------------------------------------------- +# General +--------------------------------------------------------------*/ +:root { + scroll-behavior: smooth; +} + +body { + font-family: $font-default; + background: lighten($secondary, 76); + color: $default; +} + +a { + color: $primary; + text-decoration: none; +} + +a:hover { + color: lighten($primary, 10); + text-decoration: none; +} + +h1, h2, h3, h4, h5, h6 { + font-family: $font-primary; +} + +/*-------------------------------------------------------------- +# Main +--------------------------------------------------------------*/ +#main { + margin-top: 60px; + padding: 20px 30px; + transition: all 0.3s; + @media (max-width: 1199px) { + padding: 20px; + } +} + +/*-------------------------------------------------------------- +# Page Title +--------------------------------------------------------------*/ +.pagetitle { + margin-bottom: 10px; + h1 { + font-size: 24px; + margin-bottom: 0; + font-weight: 600; + color: $secondary; + } +} + +/*-------------------------------------------------------------- +# Back to top button +--------------------------------------------------------------*/ +.back-to-top { + position: fixed; + visibility: hidden; + opacity: 0; + right:15px; + bottom: 15px; + z-index: 99999; + background: $primary; + width: 40px; + height: 40px; + border-radius: 4px; + transition: all 0.4s; + + i { + font-size: 24px; + color: #fff; + line-height: 0; + } + + &:hover { + background: lighten($primary, 8); + color: #fff; + } + + &.active { + visibility: visible; + opacity: 1; + } + +} diff --git a/public/assets/scss/_header.scss b/public/assets/scss/_header.scss new file mode 100644 index 0000000..31d6b4d --- /dev/null +++ b/public/assets/scss/_header.scss @@ -0,0 +1,238 @@ +/*-------------------------------------------------------------- +# Header +--------------------------------------------------------------*/ +.logo { + line-height: 1; + @media (min-width: 1200px) { + width: 280px; + } + + img { + max-height: 26px; + margin-right: 6px; + } + + span { + font-size: 26px; + font-weight: 700; + color: $secondary; + font-family: $font-primary; + } + +} + +.header { + transition: all 0.5s; + z-index: 997; + height: 60px; + box-shadow: 0px 2px 20px rgba($secondary, 0.10); + background-color: #fff; + padding-left: 20px; + + /* Toggle Sidebar Button */ + .toggle-sidebar-btn { + font-size: 32px; + padding-left: 10px; + cursor: pointer; + color: $secondary; + } + + /* Search Bar */ + + .search-bar { + min-width: 360px; + padding: 0 20px; + } + + @media (max-width: 1199px) { + .search-bar { + position: fixed; + top: 50px; + left: 0; + right: 0; + padding: 20px; + box-shadow: 0px 0px 15px 0px rgba($secondary, 0.1); + background: lighten($primary, 58); + z-index: 9999; + transition: 0.3s; + visibility: hidden; + opacity: 0; + } + + .search-bar-show { + top: 60px; + visibility: visible; + opacity: 1; + } + } + + .search-form { + width: 100%; + input { + border: 0; + font-size: 14px; + color: $secondary; + border: 1px solid rgba($secondary, .2); + padding: 7px 38px 7px 8px; + border-radius: 3px; + transition: 0.3s; + width: 100%; + &:focus, &:hover { + outline: none; + box-shadow: 0 0 10px 0 rgba($secondary, 0.15); + border: 1px solid rgba($secondary, .3); + } + } + + button { + border: 0; + padding: 0; + margin-left: -30px; + background: none; + i { + color: $secondary; + } + } + } + +} + +/*-------------------------------------------------------------- +# Header Nav +--------------------------------------------------------------*/ +.header-nav { + ul { + list-style: none; + } + + > ul { + margin: 0; + padding: 0; + } + + .nav-icon { + font-size: 22px; + color: $secondary; + margin-right: 25px; + position: relative; + } + + .nav-profile { + color: $secondary; + img { + max-height: 36px; + } + span { + font-size: 14px; + font-weight: 600; + } + } + + .badge-number { + position: absolute; + inset: -2px -5px auto auto; + font-weight: normal; + font-size: 12px; + padding: 3px 6px; + } + + .notifications { + inset: 8px -15px auto auto !important; + .notification-item { + display: flex; + align-items: center; + padding: 15px 10px; + transition: 0.3s; + + i { + margin: 0 20px 0 10px; + font-size: 24px; + } + + h4 { + font-size: 16px; + font-weight: 600; + margin-bottom: 5px; + } + + p { + font-size: 13px; + margin-bottom: 3px; + color: lighten($default, 30); + } + + &:hover { + background-color: lighten($secondary, 76); + } + } + + } + + .messages { + inset: 8px -15px auto auto !important; + .message-item { + padding: 15px 10px; + transition: 0.3s; + + a { + display: flex; + } + + img { + margin: 0 20px 0 10px; + max-height: 40px; + } + + h4 { + font-size: 16px; + font-weight: 600; + margin-bottom: 5px; + color: $default; + } + + p { + font-size: 13px; + margin-bottom: 3px; + color: lighten($default, 30); + } + + &:hover { + background-color: lighten($secondary, 76); + } + } + } + + .profile { + min-width: 240px; + padding-bottom: 0; + top: 8px !important; + + .dropdown-header { + h6 { + font-size: 18px; + margin-bottom: 0; + font-weight: 600; + color: $default; + } + span { + font-size: 14px; + } + } + + .dropdown-item { + font-size: 14px; + padding: 10px 15px; + transition: 0.3s; + i { + margin-right: 10px; + font-size: 18px; + line-height: 0; + } + &:hover { + background-color: lighten($secondary, 76); + } + } + + } + +} diff --git a/public/assets/scss/_override.scss b/public/assets/scss/_override.scss new file mode 100644 index 0000000..d24c75d --- /dev/null +++ b/public/assets/scss/_override.scss @@ -0,0 +1,252 @@ +/*-------------------------------------------------------------- +# Override some default Bootstrap stylings +--------------------------------------------------------------*/ + +/* Dropdown menus */ +.dropdown-menu { + border-radius: 4px; + padding: 10px 0; + animation-name: dropdown-animate; + animation-duration: 0.2s; + animation-fill-mode: both; + border: 0; + box-shadow: 0 5px 30px 0 rgba(82,63,105,.20); + + .dropdown-header, .dropdown-footer { + text-align: center; + font-size: 15px; + padding: 10px 25px; + } + + .dropdown-footer { + a { + color: $default; + text-decoration: underline; + &:hover { + text-decoration: none; + } + } + } + + .dropdown-divider { + color: lighten($secondary, 60); + margin: 0; + } + + .dropdown-item { + font-size: 14px; + padding: 10px 15px; + transition: 0.3s; + i { + margin-right: 10px; + font-size: 18px; + line-height: 0; + } + &:hover { + background-color: lighten($secondary, 76); + } + } + +} + +@media (min-width: 768px) { + .dropdown-menu-arrow::before { + content: ""; + width: 13px; + height: 13px; + background: #fff; + position: absolute; + top: -7px; + right: 20px; + transform: rotate(45deg); + border-top: 1px solid #eaedf1; + border-left: 1px solid #eaedf1; + } +} + +@keyframes dropdown-animate { + 0% { + opacity: 0; + } + 100% { + opacity: 1; + } + 0% { + opacity: 0; + } +} + + +/* Light Backgrounds */ +.bg-primary-light { + background-color: #cfe2ff; + border-color: #cfe2ff; +} + +.bg-secondary-light { + background-color: #e2e3e5; + border-color: #e2e3e5; +} + +.bg-success-light { + background-color: #d1e7dd; + border-color: #d1e7dd; +} + +.bg-danger-light { + background-color: #f8d7da; + border-color: #f8d7da; +} + +.bg-warning-light { + background-color: #fff3cd; + border-color: #fff3cd; +} + +.bg-info-light { + background-color: #cff4fc; + border-color: #cff4fc; +} + +.bg-dark-light { + background-color: #d3d3d4; + border-color: #d3d3d4; +} + +/* Card */ +.card { + margin-bottom: 30px; + border: none; + border-radius: 5px; + box-shadow: 0px 0 30px rgba($secondary, 0.1); +} + +.card-header, .card-footer { + border-color: lighten($tertiary, 70); + background-color: #fff; + color: lighten($tertiary, 35); + padding: 15px; +} + +.card-title { + padding: 20px 0 15px 0; + font-size: 18px; + font-weight: 500; + color: $secondary; + font-family: $font-secondary; + span { + color: lighten($tertiary, 40); + font-size: 14px; + font-weight: 400; + } + @media (max-width: px) { + + } +} + +.card-body { + padding: 0 20px 20px 20px; +} + +.card-img-overlay { + background-color: rgba(#fff, .6); +} + +/* Alerts */ +.alert-heading { + font-weight: 500; + font-family: $font-secondary; + font-size: 20px; +} + +/* Close Button */ +.btn-close { + background-size: 25%; + &:focus { + outline: 0; + box-shadow: none; + } +} + +/* Accordion */ +.accordion-item { + border: 1px solid lighten($tertiary, 70); +} +.accordion-button { + &:focus { + outline: 0; + box-shadow: none; + } + &:not(.collapsed) { + color: $secondary; + background-color: lighten($secondary, 76); + } +} + +.accordion-flush { + .accordion-button { + padding: 15px 0; + background: none; + border: 0; + &:not(.collapsed) { + box-shadow: none; + color: $primary; + } + } + + .accordion-body { + padding: 0 0 15px 0; + color: lighten($tertiary, 10); + font-size: 15px; + } +} + +/* Breadcrumbs */ +.breadcrumb { + font-size: 14px; + font-family: $font-primary; + color: lighten($tertiary, 40); + font-weight: 600; + + a { + color: lighten($tertiary, 40); + transition: 0.3s; + + &:hover { + color: lighten($tertiary, 20); + } + } + + .breadcrumb-item::before { + color: lighten($tertiary, 40); + } + + .active { + color: lighten($tertiary, 20); + font-weight: 600; + } +} + + +/* Bordered Tabs */ +.nav-tabs-bordered { + border-bottom: 2px solid lighten($tertiary, 70); + + .nav-link { + margin-bottom: -2px; + border: none; + color: $tertiary; + + &:hover, &:focus { + color: $primary; + } + + &.active { + background-color: #fff; + color: $primary; + border-bottom: 2px solid $primary; + } + + } + +} diff --git a/public/assets/scss/_pages.scss b/public/assets/scss/_pages.scss new file mode 100644 index 0000000..aac0426 --- /dev/null +++ b/public/assets/scss/_pages.scss @@ -0,0 +1,270 @@ +/*-------------------------------------------------------------- +# Icons list page +--------------------------------------------------------------*/ +.iconslist { + display: grid; + max-width: 100%; + grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); + gap: 1.25rem; + padding-top: 15px; + + .icon { + background-color: #fff; + border-radius: .25rem; + text-align: center; + color: #012970; + padding: 15px 0; + } + + i { + margin: .25rem; + font-size: 2.5rem; + } + + .label { + font-family: var(--bs-font-monospace); + display: inline-block; + width: 100%; + overflow: hidden; + padding: .25rem; + font-size: 12px; + text-overflow: ellipsis; + white-space: nowrap; + color: #666; + } + +} + +/*-------------------------------------------------------------- +# Profie Page +--------------------------------------------------------------*/ +.profile { + + .profile-card { + img { + max-width: 120px; + } + + h2 { + font-size: 24px; + font-weight: 700; + color: $tertiary; + margin: 10px 0 0 0; + } + + h3 { + font-size: 18px; + } + + .social-links { + a { + font-size: 20px; + display: inline-block; + color: rgba($secondary, .5); + line-height: 0; + margin-right: 10px; + transition: 0.3s; + &:hover { + color: rgba($secondary, 1); + } + } + } + } + + .profile-overview { + .row { + margin-bottom: 20px; + font-size: 15px; + } + + .card-title { + color: $secondary; + } + + .label { + font-weight: 600; + color: rgba($secondary, .6); + } + } + + .profile-edit { + + label { + font-weight: 600; + color: rgba($secondary, .6); + } + + img { + max-width: 120px; + } + } + +} + +/*-------------------------------------------------------------- +# F.A.Q Page +--------------------------------------------------------------*/ +.faq { + + .basic { + h6 { + font-size: 18px; + font-weight: 600; + color: $primary; + } + + p { + color: lighten($tertiary, 30); + } + } + +} + + +/*-------------------------------------------------------------- +# Contact +--------------------------------------------------------------*/ +.contact { + + .info-box { + padding: 28px 30px; + i { + font-size: 38px; + line-height: 0; + color: $primary; + } + + h3 { + font-size: 20px; + color: $secondary; + font-weight: 700; + margin: 20px 0 10px 0; + } + + p { + padding: 0; + line-height: 24px; + font-size: 14px; + margin-bottom: 0; + } + + } + + .php-email-form { + + .error-message { + display: none; + color: #fff; + background: #ed3c0d; + text-align: left; + padding: 15px; + margin-bottom: 24px; + font-weight: 600; + } + + .sent-message { + display: none; + color: #fff; + background: #18d26e; + text-align: center; + padding: 15px; + margin-bottom: 24px; + font-weight: 600; + } + + .loading { + display: none; + background: #fff; + text-align: center; + padding: 15px; + margin-bottom: 24px; + + &:before { + content: ""; + display: inline-block; + border-radius: 50%; + width: 24px; + height: 24px; + margin: 0 10px -6px 0; + border: 3px solid #18d26e; + border-top-color: #eee; + animation: animate-loading 1s linear infinite; + } + + } + + input, textarea { + border-radius: 0; + box-shadow: none; + font-size: 14px; + border-radius: 0; + &:focus { + border-color: $primary; + } + } + + input { + padding: 10px 15px; + } + + textarea { + padding: 12px 15px; + } + + button[type="submit"] { + background: $primary; + border: 0; + padding: 10px 30px; + color: #fff; + transition: 0.4s; + border-radius: 4px; + &:hover { + background: lighten($primary, 5); + } + } + + } + + @keyframes animate-loading { + 0% { transform: rotate(0deg); } + 100% { transform: rotate(360deg); } + } +} + +/*-------------------------------------------------------------- +# Error 404 +--------------------------------------------------------------*/ +.error-404 { + padding: 30px; + + h1 { + font-size: 180px; + font-weight: 700; + color: $primary; + margin-bottom: 0; + line-height: 150px; + } + + h2 { + font-size: 24px; + font-weight: 700; + color: $secondary; + margin-bottom: 30px; + } + + .btn { + background: lighten($tertiary, 20); + color: #fff; + padding: 8px 30px; + &:hover { + background: lighten($tertiary, 10); + } + } + + @media (min-width: 992px) { + img { + max-width: 50%; + } + } + +} diff --git a/public/assets/scss/_sidebar.scss b/public/assets/scss/_sidebar.scss new file mode 100644 index 0000000..7cb46ba --- /dev/null +++ b/public/assets/scss/_sidebar.scss @@ -0,0 +1,156 @@ +/*-------------------------------------------------------------- +# Sidebar +--------------------------------------------------------------*/ +.sidebar { + position: fixed; + top: 60px; + left: 0; + bottom: 0; + width: 300px; + z-index: 996; + transition: all 0.3s; + padding: 20px; + overflow-y: auto; + scrollbar-width: thin; + scrollbar-color: lighten($tertiary, 50) transparent; + box-shadow: 0px 0px 20px rgba($secondary, 0.10); + background-color: #fff; + @media (max-width: 1199px) { + left: -300px; + } + + &::-webkit-scrollbar { + width: 5px; + height: 8px; + background-color: #fff; + } + &::-webkit-scrollbar-thumb { + background-color: lighten($tertiary, 50); + } +} + +@media (min-width: 1200px) { + #main, #footer { + margin-left: 300px; + } +} + +.toggle-sidebar { + + @media (max-width: 1199px) { + .sidebar { + left: 0; + } + } + + + @media (min-width: 1200px) { + #main, #footer { + margin-left: 0; + } + .sidebar { + left: -300px; + } + } +} + +.sidebar-nav { + padding: 0; + margin: 0; + list-style: none; + + li { + padding: 0; + margin: 0; + list-style: none; + } + + .nav-item { + margin-bottom: 5px; + } + + .nav-heading { + font-size: 11px; + text-transform: uppercase; + color: lighten($tertiary, 40); + font-weight: 600; + margin: 10px 0 5px 15px; + } + + .nav-link { + display: flex; + align-items: center; + font-size: 15px; + font-weight: 600; + color: $primary; + transition: 0.3; + background: lighten($secondary, 76); + padding: 10px 15px; + border-radius: 4px; + + i { + font-size: 16px; + margin-right: 10px; + color: $primary + } + + &.collapsed { + color: $secondary; + background: #fff; + i { + color: lighten($tertiary, 40); + } + } + + &:hover { + color: $primary; + background: lighten($secondary, 76); + i { + color: $primary + } + } + + .bi-chevron-down { + margin-right: 0; + transition: transform .2s ease-in-out; + } + + &:not(.collapsed) .bi-chevron-down { + transform: rotate(180deg); + } + + } + + .nav-content { + padding: 5px 0 0 0; + margin: 0; + list-style: none; + + a { + display: flex; + align-items: center; + font-size: 14px; + font-weight: 600; + color: $secondary; + transition: 0.3; + padding: 10px 0 10px 40px; + transition: 0.3s; + i { + font-size: 6px; + margin-right: 8px; + line-height: 0; + border-radius: 50%; + } + + &:hover, &.active { + color: $primary; + } + &.active { + i { + background-color:$primary; + } + } + } + + } +} diff --git a/public/assets/scss/_variables.scss b/public/assets/scss/_variables.scss new file mode 100644 index 0000000..245bfbb --- /dev/null +++ b/public/assets/scss/_variables.scss @@ -0,0 +1,25 @@ +// Fonts +$font-default: 'Open Sans', sans-serif; +$font-primary: 'Nunito', sans-serif; +$font-secondary: 'Poppins', sans-serif; + +// Colors +$default: #444444; +$primary: #4154f1; +$secondary: #012970; +$tertiary: #2c384e; + +// General Colors +$red: #dc3545; +$green: #28a745; +$blue: #007bff; +$yellow: #ffc107; +$orange: #fd7e14; +$brown: #7b4f2c; +$purple: #6f42c1; +$pink: #e83e8c; +$white: #fff; +$gray: #6c757d; +$black: #343a40; +$teal: #20c997; +$cyan: #17a2b8; diff --git a/public/assets/scss/style.scss b/public/assets/scss/style.scss new file mode 100644 index 0000000..fc52f18 --- /dev/null +++ b/public/assets/scss/style.scss @@ -0,0 +1,12 @@ +@import 'variables'; + +@import 'general'; +@import 'override'; + +@import 'header'; +@import 'sidebar'; +@import 'dashboard'; + +@import 'pages'; + +@import 'footer'; diff --git a/public/favicon.ico b/public/favicon.ico new file mode 100644 index 0000000..7ecfce2 Binary files /dev/null and b/public/favicon.ico differ diff --git a/public/index.php b/public/index.php new file mode 100644 index 0000000..8e834f2 --- /dev/null +++ b/public/index.php @@ -0,0 +1,59 @@ +systemDirectory . '/Boot.php'; + +exit(Boot::bootWeb($paths)); diff --git a/public/robots.txt b/public/robots.txt new file mode 100644 index 0000000..9e60f97 --- /dev/null +++ b/public/robots.txt @@ -0,0 +1,2 @@ +User-agent: * +Disallow: diff --git a/public/uploads/20260224/OPD-2039655-1771950192.jpg b/public/uploads/20260224/OPD-2039655-1771950192.jpg new file mode 100644 index 0000000..d879605 Binary files /dev/null and b/public/uploads/20260224/OPD-2039655-1771950192.jpg differ diff --git a/public/uploads/20260224/OPD-2039655-1771960747.jpg b/public/uploads/20260224/OPD-2039655-1771960747.jpg new file mode 100644 index 0000000..b6d7005 Binary files /dev/null and b/public/uploads/20260224/OPD-2039655-1771960747.jpg differ diff --git a/public/uploads/20260224/OPD-2039656-1771950821.jpg b/public/uploads/20260224/OPD-2039656-1771950821.jpg new file mode 100644 index 0000000..d879605 Binary files /dev/null and b/public/uploads/20260224/OPD-2039656-1771950821.jpg differ diff --git a/public/uploads/20260224/OPD-2039657-1771951558.jpg b/public/uploads/20260224/OPD-2039657-1771951558.jpg new file mode 100644 index 0000000..d879605 Binary files /dev/null and b/public/uploads/20260224/OPD-2039657-1771951558.jpg differ diff --git a/public/uploads/20260224/OPD-2039658-1771952012.jpg b/public/uploads/20260224/OPD-2039658-1771952012.jpg new file mode 100644 index 0000000..d879605 Binary files /dev/null and b/public/uploads/20260224/OPD-2039658-1771952012.jpg differ diff --git a/public/uploads/20260224/OPD-2039658-1771952047.jpg b/public/uploads/20260224/OPD-2039658-1771952047.jpg new file mode 100644 index 0000000..b6d7005 Binary files /dev/null and b/public/uploads/20260224/OPD-2039658-1771952047.jpg differ diff --git a/public/uploads/20260224/OPD-2039659-1771952773.jpg b/public/uploads/20260224/OPD-2039659-1771952773.jpg new file mode 100644 index 0000000..b6d7005 Binary files /dev/null and b/public/uploads/20260224/OPD-2039659-1771952773.jpg differ diff --git a/public/uploads/20260224/OPD-2039659-1771953025.jpg b/public/uploads/20260224/OPD-2039659-1771953025.jpg new file mode 100644 index 0000000..b6d7005 Binary files /dev/null and b/public/uploads/20260224/OPD-2039659-1771953025.jpg differ diff --git a/public/uploads/20260224/OPD-2039660-1771953326.jpg b/public/uploads/20260224/OPD-2039660-1771953326.jpg new file mode 100644 index 0000000..b6d7005 Binary files /dev/null and b/public/uploads/20260224/OPD-2039660-1771953326.jpg differ diff --git a/public/uploads/20260224/OPD-2039660-1771953522.jpg b/public/uploads/20260224/OPD-2039660-1771953522.jpg new file mode 100644 index 0000000..b6d7005 Binary files /dev/null and b/public/uploads/20260224/OPD-2039660-1771953522.jpg differ diff --git a/public/uploads/20260224/OPD-2039660-1771953704.jpg b/public/uploads/20260224/OPD-2039660-1771953704.jpg new file mode 100644 index 0000000..b6d7005 Binary files /dev/null and b/public/uploads/20260224/OPD-2039660-1771953704.jpg differ diff --git a/public/uploads/20260224/OPD-2039661-1771953846.jpg b/public/uploads/20260224/OPD-2039661-1771953846.jpg new file mode 100644 index 0000000..b6d7005 Binary files /dev/null and b/public/uploads/20260224/OPD-2039661-1771953846.jpg differ diff --git a/public/uploads/20260224/OPD-2039661-1771960355.jpg b/public/uploads/20260224/OPD-2039661-1771960355.jpg new file mode 100644 index 0000000..3efb861 Binary files /dev/null and b/public/uploads/20260224/OPD-2039661-1771960355.jpg differ diff --git a/public/uploads/20260224/OPD-2039662-1771954055.jpg b/public/uploads/20260224/OPD-2039662-1771954055.jpg new file mode 100644 index 0000000..b6d7005 Binary files /dev/null and b/public/uploads/20260224/OPD-2039662-1771954055.jpg differ diff --git a/public/uploads/20260224/OPD-2039662-1771955886.jpg b/public/uploads/20260224/OPD-2039662-1771955886.jpg new file mode 100644 index 0000000..b6d7005 Binary files /dev/null and b/public/uploads/20260224/OPD-2039662-1771955886.jpg differ diff --git a/public/uploads/20260224/OPD-2039662-1771960420.jpg b/public/uploads/20260224/OPD-2039662-1771960420.jpg new file mode 100644 index 0000000..c2f7eb1 Binary files /dev/null and b/public/uploads/20260224/OPD-2039662-1771960420.jpg differ diff --git a/public/uploads/20260224/OPD-2039663-1771956114.jpg b/public/uploads/20260224/OPD-2039663-1771956114.jpg new file mode 100644 index 0000000..b6d7005 Binary files /dev/null and b/public/uploads/20260224/OPD-2039663-1771956114.jpg differ diff --git a/public/uploads/20260224/OPD-2039664-1771956306.jpg b/public/uploads/20260224/OPD-2039664-1771956306.jpg new file mode 100644 index 0000000..b6d7005 Binary files /dev/null and b/public/uploads/20260224/OPD-2039664-1771956306.jpg differ diff --git a/public/uploads/20260224/OPD-2039664-1771959964.jpg b/public/uploads/20260224/OPD-2039664-1771959964.jpg new file mode 100644 index 0000000..83be915 Binary files /dev/null and b/public/uploads/20260224/OPD-2039664-1771959964.jpg differ diff --git a/public/uploads/20260224/OPD-2039665-1771957663.jpg b/public/uploads/20260224/OPD-2039665-1771957663.jpg new file mode 100644 index 0000000..b6d7005 Binary files /dev/null and b/public/uploads/20260224/OPD-2039665-1771957663.jpg differ diff --git a/public/uploads/20260224/OPD-2039665-1771958057.jpg b/public/uploads/20260224/OPD-2039665-1771958057.jpg new file mode 100644 index 0000000..b6d7005 Binary files /dev/null and b/public/uploads/20260224/OPD-2039665-1771958057.jpg differ diff --git a/public/uploads/patient/profile_284688_1770403396.jpg b/public/uploads/patient/profile_284688_1770403396.jpg new file mode 100644 index 0000000..055108d Binary files /dev/null and b/public/uploads/patient/profile_284688_1770403396.jpg differ diff --git a/public/uploads/patient/profile_284688_1770403403.jpg b/public/uploads/patient/profile_284688_1770403403.jpg new file mode 100644 index 0000000..bcec9e0 Binary files /dev/null and b/public/uploads/patient/profile_284688_1770403403.jpg differ diff --git a/public/uploads/patient/profile_284688_1770403428.jpg b/public/uploads/patient/profile_284688_1770403428.jpg new file mode 100644 index 0000000..73d3b3f Binary files /dev/null and b/public/uploads/patient/profile_284688_1770403428.jpg differ diff --git a/public/uploads/patient/profile_284688_1770469356.jpg b/public/uploads/patient/profile_284688_1770469356.jpg new file mode 100644 index 0000000..897b2cb Binary files /dev/null and b/public/uploads/patient/profile_284688_1770469356.jpg differ diff --git a/public/uploads/patient/profile_295041_1770404193.jpg b/public/uploads/patient/profile_295041_1770404193.jpg new file mode 100644 index 0000000..c950d77 Binary files /dev/null and b/public/uploads/patient/profile_295041_1770404193.jpg differ diff --git a/spark b/spark new file mode 100644 index 0000000..61bc572 --- /dev/null +++ b/spark @@ -0,0 +1,87 @@ +#!/usr/bin/env php + + * + * For the full copyright and license information, please view + * the LICENSE file that was distributed with this source code. + */ + +use CodeIgniter\Boot; +use Config\Paths; + +/* + * -------------------------------------------------------------------- + * CODEIGNITER COMMAND-LINE TOOLS + * -------------------------------------------------------------------- + * The main entry point into the CLI system and allows you to run + * commands and perform maintenance on your application. + */ + +/* + *--------------------------------------------------------------- + * CHECK SERVER API + *--------------------------------------------------------------- + */ + +// Refuse to run when called from php-cgi +if (str_starts_with(PHP_SAPI, 'cgi')) { + exit("The cli tool is not supported when running php-cgi. It needs php-cli to function!\n\n"); +} + +/* + *--------------------------------------------------------------- + * CHECK PHP VERSION + *--------------------------------------------------------------- + */ + +$minPhpVersion = '8.2'; // If you update this, don't forget to update `public/index.php`. +if (version_compare(PHP_VERSION, $minPhpVersion, '<')) { + $message = sprintf( + 'Your PHP version must be %s or higher to run CodeIgniter. Current version: %s', + $minPhpVersion, + PHP_VERSION, + ); + + exit($message); +} + +// We want errors to be shown when using it from the CLI. +error_reporting(E_ALL); +ini_set('display_errors', '1'); + +/* + *--------------------------------------------------------------- + * SET THE CURRENT DIRECTORY + *--------------------------------------------------------------- + */ + +// Path to the front controller +define('FCPATH', __DIR__ . DIRECTORY_SEPARATOR . 'public' . DIRECTORY_SEPARATOR); + +// Ensure the current directory is pointing to the front controller's directory +chdir(FCPATH); + +/* + *--------------------------------------------------------------- + * BOOTSTRAP THE APPLICATION + *--------------------------------------------------------------- + * This process sets up the path constants, loads and registers + * our autoloader, along with Composer's, loads our constants + * and fires up an environment-specific bootstrapping. + */ + +// LOAD OUR PATHS CONFIG FILE +// This is the line that might need to be changed, depending on your folder structure. +require FCPATH . '../app/Config/Paths.php'; +// ^^^ Change this line if you move your application folder + +$paths = new Paths(); + +// LOAD THE FRAMEWORK BOOTSTRAP FILE +require $paths->systemDirectory . '/Boot.php'; + +exit(Boot::bootSpark($paths)); diff --git a/tests/.htaccess b/tests/.htaccess new file mode 100644 index 0000000..3462048 --- /dev/null +++ b/tests/.htaccess @@ -0,0 +1,6 @@ + + Require all denied + + + Deny from all + diff --git a/tests/README.md b/tests/README.md new file mode 100644 index 0000000..fc40e44 --- /dev/null +++ b/tests/README.md @@ -0,0 +1,118 @@ +# Running Application Tests + +This is the quick-start to CodeIgniter testing. Its intent is to describe what +it takes to set up your application and get it ready to run unit tests. +It is not intended to be a full description of the test features that you can +use to test your application. Those details can be found in the documentation. + +## Resources + +* [CodeIgniter 4 User Guide on Testing](https://codeigniter.com/user_guide/testing/index.html) +* [PHPUnit docs](https://phpunit.de/documentation.html) +* [Any tutorials on Unit testing in CI4?](https://forum.codeigniter.com/showthread.php?tid=81830) + +## Requirements + +It is recommended to use the latest version of PHPUnit. At the time of this +writing, we are running version 9.x. Support for this has been built into the +**composer.json** file that ships with CodeIgniter and can easily be installed +via [Composer](https://getcomposer.org/) if you don't already have it installed globally. + +```console +> composer install +``` + +If running under macOS or Linux, you can create a symbolic link to make running tests a touch nicer. + +```console +> ln -s ./vendor/bin/phpunit ./phpunit +``` + +You also need to install [XDebug](https://xdebug.org/docs/install) in order +for code coverage to be calculated successfully. After installing `XDebug`, you must add `xdebug.mode=coverage` in the **php.ini** file to enable code coverage. + +## Setting Up + +A number of the tests use a running database. +In order to set up the database edit the details for the `tests` group in +**app/Config/Database.php** or **.env**. +Make sure that you provide a database engine that is currently running on your machine. +More details on a test database setup are in the +[Testing Your Database](https://codeigniter.com/user_guide/testing/database.html) section of the documentation. + +## Running the tests + +The entire test suite can be run by simply typing one command-line command from the main directory. + +```console +> ./phpunit +``` + +If you are using Windows, use the following command. + +```console +> vendor\bin\phpunit +``` + +You can limit tests to those within a single test directory by specifying the +directory name after phpunit. + +```console +> ./phpunit app/Models +``` + +## Generating Code Coverage + +To generate coverage information, including HTML reports you can view in your browser, +you can use the following command: + +```console +> ./phpunit --colors --coverage-text=tests/coverage.txt --coverage-html=tests/coverage/ -d memory_limit=1024m +``` + +This runs all of the tests again collecting information about how many lines, +functions, and files are tested. It also reports the percentage of the code that is covered by tests. +It is collected in two formats: a simple text file that provides an overview as well +as a comprehensive collection of HTML files that show the status of every line of code in the project. + +The text file can be found at **tests/coverage.txt**. +The HTML files can be viewed by opening **tests/coverage/index.html** in your favorite browser. + +## PHPUnit XML Configuration + +The repository has a ``phpunit.xml.dist`` file in the project root that's used for +PHPUnit configuration. This is used to provide a default configuration if you +do not have your own configuration file in the project root. + +The normal practice would be to copy ``phpunit.xml.dist`` to ``phpunit.xml`` +(which is git ignored), and to tailor it as you see fit. +For instance, you might wish to exclude database tests, or automatically generate +HTML code coverage reports. + +## Test Cases + +Every test needs a *test case*, or class that your tests extend. CodeIgniter 4 +provides one class that you may use directly: +* `CodeIgniter\Test\CIUnitTestCase` + +Most of the time you will want to write your own test cases that extend `CIUnitTestCase` +to hold functions and services common to your test suites. + +## Creating Tests + +All tests go in the **tests/** directory. Each test file is a class that extends a +**Test Case** (see above) and contains methods for the individual tests. These method +names must start with the word "test" and should have descriptive names for precisely what +they are testing: +`testUserCanModifyFile()` `testOutputColorMatchesInput()` `testIsLoggedInFailsWithInvalidUser()` + +Writing tests is an art, and there are many resources available to help learn how. +Review the links above and always pay attention to your code coverage. + +### Database Tests + +Tests can include migrating, seeding, and testing against a mock or live database. +Be sure to modify the test case (or create your own) to point to your seed and migrations +and include any additional steps to be run before tests in the `setUp()` method. +See [Testing Your Database](https://codeigniter.com/user_guide/testing/database.html) +for details. diff --git a/tests/_support/Database/Migrations/2020-02-22-222222_example_migration.php b/tests/_support/Database/Migrations/2020-02-22-222222_example_migration.php new file mode 100644 index 0000000..a73356d --- /dev/null +++ b/tests/_support/Database/Migrations/2020-02-22-222222_example_migration.php @@ -0,0 +1,37 @@ +forge->addField('id'); + $this->forge->addField([ + 'name' => ['type' => 'varchar', 'constraint' => 31], + 'uid' => ['type' => 'varchar', 'constraint' => 31], + 'class' => ['type' => 'varchar', 'constraint' => 63], + 'icon' => ['type' => 'varchar', 'constraint' => 31], + 'summary' => ['type' => 'varchar', 'constraint' => 255], + 'created_at' => ['type' => 'datetime', 'null' => true], + 'updated_at' => ['type' => 'datetime', 'null' => true], + 'deleted_at' => ['type' => 'datetime', 'null' => true], + ]); + + $this->forge->addKey('name'); + $this->forge->addKey('uid'); + $this->forge->addKey(['deleted_at', 'id']); + $this->forge->addKey('created_at'); + + $this->forge->createTable('factories'); + } + + public function down(): void + { + $this->forge->dropTable('factories'); + } +} diff --git a/tests/_support/Database/Seeds/ExampleSeeder.php b/tests/_support/Database/Seeds/ExampleSeeder.php new file mode 100644 index 0000000..619fc27 --- /dev/null +++ b/tests/_support/Database/Seeds/ExampleSeeder.php @@ -0,0 +1,41 @@ + 'Test Factory', + 'uid' => 'test001', + 'class' => 'Factories\Tests\NewFactory', + 'icon' => 'fas fa-puzzle-piece', + 'summary' => 'Longer sample text for testing', + ], + [ + 'name' => 'Widget Factory', + 'uid' => 'widget', + 'class' => 'Factories\Tests\WidgetPlant', + 'icon' => 'fas fa-puzzle-piece', + 'summary' => 'Create widgets in your factory', + ], + [ + 'name' => 'Evil Factory', + 'uid' => 'evil-maker', + 'class' => 'Factories\Evil\MyFactory', + 'icon' => 'fas fa-book-dead', + 'summary' => 'Abandon all hope, ye who enter here', + ], + ]; + + $builder = $this->db->table('factories'); + + foreach ($factories as $factory) { + $builder->insert($factory); + } + } +} diff --git a/tests/_support/Libraries/ConfigReader.php b/tests/_support/Libraries/ConfigReader.php new file mode 100644 index 0000000..0bb4a8f --- /dev/null +++ b/tests/_support/Libraries/ConfigReader.php @@ -0,0 +1,19 @@ +findAll(); + + // Make sure the count is as expected + $this->assertCount(3, $objects); + } + + public function testSoftDeleteLeavesRow(): void + { + $model = new ExampleModel(); + $this->setPrivateProperty($model, 'useSoftDeletes', true); + $this->setPrivateProperty($model, 'tempUseSoftDeletes', true); + + /** @var stdClass $object */ + $object = $model->first(); + $model->delete($object->id); + + // The model should no longer find it + $this->assertNull($model->find($object->id)); + + // ... but it should still be in the database + $result = $model->builder()->where('id', $object->id)->get()->getResult(); + + $this->assertCount(1, $result); + } +} diff --git a/tests/index.html b/tests/index.html new file mode 100644 index 0000000..b702fbc --- /dev/null +++ b/tests/index.html @@ -0,0 +1,11 @@ + + + + 403 Forbidden + + + +

Directory access is forbidden.

+ + + diff --git a/tests/session/ExampleSessionTest.php b/tests/session/ExampleSessionTest.php new file mode 100644 index 0000000..33242a4 --- /dev/null +++ b/tests/session/ExampleSessionTest.php @@ -0,0 +1,17 @@ +set('logged_in', 123); + $this->assertSame(123, $session->get('logged_in')); + } +} diff --git a/tests/unit/HealthTest.php b/tests/unit/HealthTest.php new file mode 100644 index 0000000..b3e480f --- /dev/null +++ b/tests/unit/HealthTest.php @@ -0,0 +1,49 @@ +assertTrue(defined('APPPATH')); + } + + public function testBaseUrlHasBeenSet(): void + { + $validation = service('validation'); + + $env = false; + + // Check the baseURL in .env + if (is_file(HOMEPATH . '.env')) { + $env = preg_grep('/^app\.baseURL = ./', file(HOMEPATH . '.env')) !== false; + } + + if ($env) { + // BaseURL in .env is a valid URL? + // phpunit.xml.dist sets app.baseURL in $_SERVER + // So if you set app.baseURL in .env, it takes precedence + $config = new App(); + $this->assertTrue( + $validation->check($config->baseURL, 'valid_url'), + 'baseURL "' . $config->baseURL . '" in .env is not valid URL', + ); + } + + // Get the baseURL in app/Config/App.php + // You can't use Config\App, because phpunit.xml.dist sets app.baseURL + $reader = new ConfigReader(); + + // BaseURL in app/Config/App.php is a valid URL? + $this->assertTrue( + $validation->check($reader->baseURL, 'valid_url'), + 'baseURL "' . $reader->baseURL . '" in app/Config/App.php is not valid URL', + ); + } +} diff --git a/writable/.htaccess b/writable/.htaccess new file mode 100644 index 0000000..3462048 --- /dev/null +++ b/writable/.htaccess @@ -0,0 +1,6 @@ + + Require all denied + + + Deny from all + diff --git a/writable/cache/index.html b/writable/cache/index.html new file mode 100644 index 0000000..b702fbc --- /dev/null +++ b/writable/cache/index.html @@ -0,0 +1,11 @@ + + + + 403 Forbidden + + + +

Directory access is forbidden.

+ + + diff --git a/writable/debugbar/index.html b/writable/debugbar/index.html new file mode 100644 index 0000000..b702fbc --- /dev/null +++ b/writable/debugbar/index.html @@ -0,0 +1,11 @@ + + + + 403 Forbidden + + + +

Directory access is forbidden.

+ + + diff --git a/writable/index.html b/writable/index.html new file mode 100644 index 0000000..b702fbc --- /dev/null +++ b/writable/index.html @@ -0,0 +1,11 @@ + + + + 403 Forbidden + + + +

Directory access is forbidden.

+ + + diff --git a/writable/logs/index.html b/writable/logs/index.html new file mode 100644 index 0000000..b702fbc --- /dev/null +++ b/writable/logs/index.html @@ -0,0 +1,11 @@ + + + + 403 Forbidden + + + +

Directory access is forbidden.

+ + + diff --git a/writable/session/index.html b/writable/session/index.html new file mode 100644 index 0000000..b702fbc --- /dev/null +++ b/writable/session/index.html @@ -0,0 +1,11 @@ + + + + 403 Forbidden + + + +

Directory access is forbidden.

+ + + diff --git a/writable/tmp_check_ai_settings.php b/writable/tmp_check_ai_settings.php new file mode 100644 index 0000000..1e3d83a --- /dev/null +++ b/writable/tmp_check_ai_settings.php @@ -0,0 +1,36 @@ +table('hospital_setting') + ->select('s_name, s_value') + ->whereIn('s_name', $keys) + ->get() + ->getResultArray(); + +$map = []; +foreach ($rows as $row) { + $map[$row['s_name']] = trim((string) ($row['s_value'] ?? '')); +} + +foreach ($keys as $key) { + $value = $map[$key] ?? ''; + $len = strlen($value); + if ($len === 0) { + $show = ''; + } elseif ($len <= 8) { + $show = str_repeat('*', $len); + } else { + $show = substr($value, 0, 4) . str_repeat('*', $len - 8) . substr($value, -4); + } + + echo $key . '=' . $show . PHP_EOL; +} diff --git a/writable/uploads/index.html b/writable/uploads/index.html new file mode 100644 index 0000000..b702fbc --- /dev/null +++ b/writable/uploads/index.html @@ -0,0 +1,11 @@ + + + + 403 Forbidden + + + +

Directory access is forbidden.

+ + +