<div class="page-content-wrapper">
    <div class="page-content">
        <div class="row">
            <div class="col-md-12">
                <!-- BEGIN EXAMPLE TABLE PORTLET-->
                <div class="portlet box blue">
                    <div class="portlet-title">
                        <div class="caption">
                            <i class="fa fa-users"></i>Financial Report
                        </div>
                    </div>
                    <div class="portlet-body all">
                        <input type="hidden" id="reportPage" value="1"/>
                        <input type="hidden" id="tdate" value="{$today}">
                        <input type="hidden" id="controllName" value="financialreport"/>
                        <!--Begin Semen-->

                        <div class="row">
                            <div class="row clinick posre">
                                <div class="col-md-2">
                                    <div class="form-group form-md-line-input form-md-floating-label has-info">
                                        <input type="text" class="form-control datepicker txtc finSearch" id="findate" value="{$today}"/>
                                        <label for="form_control_1">Date From </label>
                                    </div>
                                </div>

                                <div class="col-md-2">
                                    <div class="form-group form-md-line-input form-md-floating-label has-info">
                                        <input type="text" class="form-control datepicker txtc finSearch" id="tofindate" value="{$today}"/>
                                        <label for="form_control_1">Date To </label>
                                    </div>
                                </div>

                                <div class="col-md-4">
                                    <div class="form-group">
                                        <label class="control-label ls2">Patient No</label>
                                        <input type="text" name="search" id="statusNo" 
                                               class="form-control searchPat txtc sbystno" >
                                    </div>
                                </div>


                                <div class="col-md-4">
                                    <div class="form-group">
                                        <label class="control-label ls2">Patient Name</label>

                                        <select class="form-control searchFin finSearch" id="patientName">
                                            <option value="">choose</option>
                                            {foreach  $allPatients as $data}
                                            <option value="{$data->id}" >{$data->wifename}</option>
                                            {/foreach}
                                        </select>

                                    </div>
                                </div>

                                <div class="col-md-4">
                                    <div class="form-group">
                                        <label class="control-label ls2">Husband Name</label>

                                        <select class="form-control searchFin finSearch" id="husband">
                                            <option value="">choose</option>
                                            {foreach  $allPatients as $data}
                                            <option value="{$data->husdandname}" >{$data->husdandname}</option>
                                            {/foreach}
                                        </select>

                                    </div>
                                </div>

                                <div class="col-md-4">
                                    <div class="form-group">
                                        <label class="control-label ls2">User Name</label>

                                        <select class="form-control select2h finSearch" id="userId">
                                            <option value="">choose</option>
                                            {foreach  $recep_users as $data}
                                            <option value="{$data.user_id}" >{$data.name}</option>
                                            {/foreach}
                                        </select>

                                    </div>
                                </div>

                                <div class="col-md-4">
                                    <div class="form-group">
                                        <label class="control-label ls2">Department </label>

                                        <select class="form-control searchFin finSearch" id="fordepartment">
                                            <option value="">choose</option>
                                            {foreach $py_all_departs as $row}
                                            <option value="{$row->id}">{$row->name}</option>
                                            {/foreach}
                                        </select>

                                    </div>
                                </div> 

                            </div>

                            <div class="clearfix"></div>

                            <div class="portlet box white">
                                <div class="portlet-title">
                                    <div class="actions">
                                        <a class="btn btn-default btn-sm" id="printfi" >
                                            <i class="fa fa-print"></i> Print </a>

                                    </div>
                                </div>

                                <div class="portlet-body form" id="financialDiv">
                                    <table class="table table-hover portlet light bg-inverse dataTableX ">
                                        <thead>
                                            <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>
                                                <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>
                                                <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>
                            </div>
                        </div>

                    </div>

                    <!--End Semen-->


                    <div class="clearfix"></div>

                </div>
            </div>
        </div>
    </div>
</div>

<div class="clearfix"></div>
<div id="financialPrint"></div>


