<table class="table table-hover portlet light bg-inverse" id="repTable">
    <thead>
        <tr>
        <tr>
            <th style="width: 10px !important;">#</th>
            <td>  Rec. No. </td>
            <th>   Patient Name</th>
            <th>   Patient No.</th>
            <th>   Type</th>
            <th>   Total      </th>
            <th>   Discount   </th>
            <th>   Cash </th>
            <th>   Visa  </th>
            <th>   Debt </th>

            <th>RFC</th>
            <th>Doctor</th>
            <th>Visit Doctor</th>


            <th>   Notes    </th>
            <th>   User name  </th>
            <th>   Visit Date</th>
        </tr>
    </thead>
    <tbody>
        {assign var="i" value="1"}
        {foreach $allData as $data}
        <tr class="odd " {if $data.detectionid == 9999} style="background-color: #efc9cc;"  {/if}>
            <td>{$i}</td>
            <td>{$data.printserial}</td>
            <td>
                <a href="{$hosturl}/controllers/patienthistory.php?ac=show&patientid={$data.patientid}" target="_new">
                    {if  $data.for_husband == 1 }
                    {$data.husdandname}
                    {else}
                    {$data.wifename}
                    {/if}
                </a>
            </td>
            <td>{$data.statusno}</td>
            <td>{$data.type}</td>
            <td>
                {$data.totaldetectionvalue}
            </td>
            <td>
                {$data.discount}
            </td>
            <td>
                {$data.detectionvalue_cash}
            </td>
            <td>
                {$data.detectionvalue_visa}
            </td>
            <td>
                {$data.restdetectionvalue}
            </td>


            {if  $data.for_husband == 1 }
            <td>  
                {$data.rfc}
            </td>
            <td>
                {$data.h_doctor}
            </td>
            {else}
            <td>
                {$data.wrfc}
            </td>
            <td>
                {$data.doctor}
            </td>
            {/if}

            <td> {$data.visitDoctor}</td>

            <td>
                {$data.vnotes}
            </td>

            <td>
                {$data.insert_user}
            </td>
            <td>{$data.visitdate}</td>

        </tr>
        {assign var="i" value={$i+1}}
        {/foreach}
    </tbody>
</table>

<div id="totalDiv">
    {if !empty($allData)}
    <table class="table table-hover portlet light bg-inverse ">
        <tr>
        <tr>
            <th class="wds15"> </th>
            <th class="wds17"> Cost</th>
            <th class="wds17"> Discount</th>
            <th class="wds17"> Cash</th>
            <th class="wds17"> Visa</th>
            <th class="wds17"> Debt</th>
        </tr>
        </tr>
        <tr>
            <td>New Visits</td>
            <th> {$totalCost}</th>
            <th> {$totalDiscount}</th>
            <th> {$totalCash}</th>
            <th> {$totalVisa}</th>
            <th> {$totalDept}</th>
        </tr>
        <tr>
            <td>Old Debts</td>
            <th> </th>
            <th> </th>
            <th> {$totalOldCash}</th>
            <th> {$totalOldVisa}</th>
            <th></th>
        </tr>
        <tr  style="background-color: #efc9cc;"  >
            <td>Refund</td>
            <td> </td>
            <td> </td>
            <td> {$totalRefundCash}</td>
            <td> {$totalRefundVisa}</td>
            <td></td>
        </tr>
        <tr>
            <td>Total</td>
            <th> </th>
            <th> </th>
            <th> {$totalC}</th>
            <th>{$totalV} </th>
            <th> </th>
        </tr>
    </table>
    {/if}
</div>


<div id="long" class="modal fade modal-scroll" tabindex="-1" data-replace="true">
    <div class="modal-dialog wds75">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close hidden-print" data-dismiss="modal" aria-hidden="true"></button>
                <h4 class="modal-title"></h4>
            </div>
            <div class="modal-body printtable" id="printd">
                <center><h4 class="modal-title">Financial Report</h4></center>
                <center><h5 class="modal-title">{$fdate}</h5></center>
                <table class="table table-hover portlet light bg-inverse" id="controllprop">
                    <thead>
                        <tr>
                            <th>Patient Number</th>
                            <th>
                                Patient Name
                            </th>
                            <th>Type</th>
                            <th>
                                User name
                            </th>
                            <th>
                                Cost
                            </th>
                        </tr>
                    </thead>
                    <tbody>
                        {assign var="i" value="1"}
                        {foreach $allData as $data}
                        <tr class="odd gradeX">
                            <td>{$data.patientid}</td>
                            <td>
                                {$data.wifename}
                            </td>
                            <td>{$data.type}</td>
                            <td>
                                {$data.insert_user}
                            </td>
                            <td>
                                {$data.detectionvalue}
                            </td>
                        </tr>
                        {assign var="i" value={$i+1}}
                        {/foreach}
                        {if !empty($allData)}
                        <tr class="odd gradeX">
                            <th colspan="2">Total Cost</th>
                            <td>{$totalCost}</td>
                        </tr>
                        {/if}
                    </tbody>
                </table>
            </div>
        </div>
    </div>
</div>



{literal}
<script type="text/javascript" >
    $('#repTable').dataTable({
        dom: 'Blfrtip',
        buttons: [
            {
                extend: 'print',
                title: 'Financial Report',
                customize: function (win) {
                    var total = $('#totalDiv').html();
                    $(win.document.body).append(total); //after the table
                    //    $(win.document.body).prepend('<html elements here>'); //before the table
                }
            }
        ],
        "scrollX": true
    });


</script>
{/literal}