Skip to content

Commit

Permalink
Itemized Invoice (openemr#5735)
Browse files Browse the repository at this point in the history
* Itemized Invoice

* Itemized Invoice

* Itemized Invoice

* PHP styling fixed

* Update front_payment.php

* itemized invoice undo require changes

* revert changes to require_once()

* php styling fix

* Remove unused comment
  • Loading branch information
omegasystemsgroup authored Dec 6, 2022
1 parent 8176e29 commit 8dd17c6
Show file tree
Hide file tree
Showing 2 changed files with 333 additions and 113 deletions.
227 changes: 183 additions & 44 deletions interface/patient_file/front_payment.php
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,8 @@ function calcTaxes($row, $amount)
"i.pid = p.pid AND i.type = 'primary' " .
"WHERE p.pid = ? ORDER BY i.date DESC LIMIT 1", array($pid));

$invoice_refno = BillingUtilities::updateInvoiceRefNumber();

$alertmsg = ''; // anything here pops up in an alert box

// If the Save button was clicked...
Expand All @@ -191,6 +193,12 @@ function calcTaxes($row, $amount)
$patdata = getPatientData($form_pid, 'fname,mname,lname,pubpid');
$NameNew = $patdata['fname'] . " " . $patdata['lname'] . " " . $patdata['mname'];

//Update the invoice_refno
sqlStatement(
"update form_encounter set invoice_refno=? where encounter=? and pid=? ",
array($invoice_refno, $encounter, $form_pid)
);

if ($_REQUEST['radio_type_of_payment'] == 'pre_payment') {
$payment_id = sqlInsert(
"insert into ar_session set " .
Expand Down Expand Up @@ -505,65 +513,196 @@ function toencounter(enc, datestr, topframe) {
display: none;
}
}
.main-section {
display: grid;
grid-template-columns: 50% auto;
grid-template-areas: "section-2 section-1";
}
.section-1 {
grid-area: section-1;
height: fit-content;
align-self: center;
padding-left: 208px;
margin-top: -7em;
}
.section-2 {
grid-area: section-2;
text-align: left;
}
table,td,th {
border: 1px solid black; text-align: left;
}
table {
border-collapse: collapse; width: 100%;
}
th,td {
padding: 7px;
}
.table td {
padding: 7px;
}
.mini_table {
width: 100%;
}
table.mini_table>tbody>tr>th {
background-color: var(--secondary);
text-align: center;
}
body>table.mini_table>tbody>tr>td {
text-align: center;
}
body>table.mini_table>tbody>tr>td {
border: 1px solid #fff;
}
body>table.mini_table>tbody>tr>th {
border: 1px solid var(--secondary);
}
.bg-color {
background-color: var(--secondary);
padding: 2px;
font-weight: 600;
-webkit-print-color-adjust: exact;
}
.bg-color-w {
background-color: var(--secondary);
font-weight: 600;
-webkit-print-color-adjust: exact!important; }
@media print {
body {
-webkit-print-color-adjust: exact !important;
}

tr.bg-color-w{
background-color: var(--secondary)!important;
-webkit-print-color-adjust: exact;
}
tr.bg-color{
background-color: var(--secondary) !important;
-webkit-print-color-adjust: exact;
}
}
</style>
</head>
<body>
<div class="container mt-3">
<div class="row">
<div class="col-12 text-center">
<h2><?php echo xlt('Receipt for Payment'); ?></h2>
<p>
<?php echo text($frow['name']) ?>
<br />
<?php echo text($frow['street']) ?>
<br />
<?php echo text($frow['city'] . ', ' . $frow['state']) . ' ' . text($frow['postal_code']) ?>
<br />
<?php echo text($frow['phone']) ?>
</p>

<div class="table-responsive">
<table class="table table-borderless">
<tr>
<td><?php echo xlt('Date'); ?>:</td>
<td><?php echo text(oeFormatSDFT(strtotime($payrow['dtime']))) ?></td>
</tr>
<tr>
<td><?php echo xlt('Patient'); ?>:</td>
<td><?php echo text($patdata['fname']) . " " . text($patdata['mname']) . " " .
text($patdata['lname']) . " (" . text($patdata['pubpid']) . ")" ?></td>
</tr>
<tr>
<td><?php echo xlt('How Paid'); ?>:</td>
<td><?php echo generate_display_field(array('data_type' => '1', 'list_id' => 'payment_method'), $payrow['method']); ?></td>
</tr>
<tr>
<td><?php echo xlt('Check or Reference Number'); ?>:</td>
<td><?php echo text($payrow['source']) ?></td>
</tr>
<tr>
<td><?php echo xlt('Amount for This Visit'); ?>:</td>
<td><?php echo text(oeFormatMoney($payrow['amount1'])) ?></td>
</tr>
<tr>
<td>
<!-- Omega -->
<div class="col-12 justify-content-center">
<h2 class="text-center"><?php echo xlt('Receipt for Payment'); ?></h2>
<div class="main-section mb-5 mt-10">
<div class="section-2">
<p style="font-weight:600;">
<bold class="bg-color"><?php echo text($frow['name']) ?></bold> <br /> <br />
<?php echo text($frow['street']) ?><br />
<?php echo text($frow['city'] . ', ' . $frow['state']) . ' ' . text($frow['postal_code']) ?><br />
<?php echo text("[Phone]" . $frow['phone']) ?><br />
<?php echo text("[Email] " . $frow['email']) ?><br />


<br />
<?php echo xlt('How Paid'); ?>:
<?php echo generate_display_field(array('data_type' => '1', 'list_id' => 'payment_method'), $payrow['method']); ?>

<br />
<?php echo xlt('Check or Reference Number'); ?>:
<?php echo text($payrow['source']); ?>

<br />
<?php
if ($_REQUEST['radio_type_of_payment'] == 'pre_payment') {
echo xlt('Pre-payment Amount');
} else {
echo xlt('Amount for Past Balance');
}
?>
:</td>
<td><?php echo text(oeFormatMoney($payrow['amount2'])) ?></td>
?>:
<?php echo text(oeFormatMoney($payrow['amount2'])); ?>

<br />
<?php echo xlt('Amount for This Visit'); ?>:
<?php echo text(oeFormatMoney($payrow['amount1'])); ?>

<br />
<?php echo xlt('Received By'); ?>:
<?php echo text($payrow['user']); ?>
</p>

</div>
<div class="section-1">
<img src=<?php echo $GLOBALS['OE_SITE_WEBROOT'] . "/images/logo_1.png" ?> alt="facility_logo" class="img-fluid">

<table class="mini_table text-center">
<tr>
<th><?php echo xlt('Invoice No.'); ?></th>
<th><?php echo xlt('Date'); ?></th>
</tr>
<tr class="text-center">
<td class="text-center"><?php echo text($invoice_refno); ?></td>
<td class="text-center"><?php echo text(oeFormatSDFT(strtotime($payrow['dtime']))); ?></td>
</tr>
</table>
</div>
</div>

<div class="table-responsive">

<table>
<!-- Omega Itemized Invoice -->
<tr class="bg-color-w">
<th><?php echo xlt('Description'); ?></th>
<th><?php echo xlt('Price'); ?></th>
<th><?php echo xlt('Qty'); ?></th>
<th><?php echo xlt('Total'); ?></th>
</tr>
<!-- Omega Itemized Invoice -->
<?php
$row_data = sqlStatement(
"SELECT * FROM billing WHERE " .
"pid = ? AND encounter = ? AND " .
// "code_type != 'COPAY' AND activity = 1 AND fee != 0 " .
"code_type != 'COPAY' AND activity = 1 " .
"ORDER BY id",
array($pid,$encounter)
);
while ($each_row = sqlFetchArray($row_data)) {
?>
<tr>
<td><?php echo text($each_row['code_text']); ?></td>
<td><?php echo text($each_row['fee']); ?></td>
<td><?php echo text($each_row['units']); ?></td>
<td><?php echo text($each_row['fee'] * $each_row['units']); ?></td>
</tr>
<?php } ?>

<?php
$query = "SELECT s.sale_id, s.sale_date, s.prescription_id, s.fee, " .
"s.quantity, s.encounter, s.drug_id, d.name, r.provider_id " .
"FROM drug_sales AS s " .
"LEFT JOIN drugs AS d ON d.drug_id = s.drug_id " .
"LEFT OUTER JOIN prescriptions AS r ON r.id = s.prescription_id " .
"WHERE s.pid = ? AND s.encounter = ? AND s.billed = 0 " .
"ORDER BY s.encounter DESC, s.sale_id ASC";
$dres = sqlStatement($query, array($pid, $encounter));
while ($myproducts = sqlFetchArray($dres)) {
?>
<tr>
<td><?php echo text($myproducts['name']); ?></td>
<td><?php echo text($myproducts['fee']); ?></td>
<td><?php echo text($myproducts['quantity']); ?></td>
<td><?php echo text($myproducts['fee'] * $myproducts['quantity']); ?></td>
</tr>
<?php } ?>

<tr>
<td><?php echo xlt('Received By'); ?>:</td>
<td><?php echo text($payrow['user']) ?></td>
<td style="border-right-color:white !important;"></td>
<td ></td>
<td class="text-right bg-color-w"><?php echo text("Total"); ?></td>
<td class="text-left bg-color-w"><?php echo text(oeFormatMoney($payrow['amount1'])); ?></td>
</tr>

</table>

</div>
<div id='hideonprint'>
<div id='hideonprint' class="text-center pt-4">
<button type="button" class="btn btn-primary btn-print" value='<?php echo xla('Print'); ?>' id='printbutton'>
<?php echo xlt('Print'); ?>
</button>
Expand All @@ -584,7 +723,7 @@ function toencounter(enc, datestr, topframe) {
</button>
<?php } ?>
</div>
<div class='mt-3' id='showonprint'>
<div class='mt-3 text-center' id='showonprint'>
<button type="button" class="btn btn-secondary btn-cancel" value='<?php echo xla('Exit'); ?>' id='donebutton' onclick="closeHow(event)">
<?php echo xlt('Exit'); ?>
</button>
Expand Down
Loading

0 comments on commit 8dd17c6

Please sign in to comment.