<?php /* Smarty version Smarty-3.1.11, created on 2023-10-28 21:02:53
         compiled from "../views/obgy/reports/financialsearch.html" */ ?>
<?php /*%%SmartyHeaderCode:1492732234653d5add0b70a5-15965118%%*/if(!defined('SMARTY_DIR')) exit('no direct access allowed');
$_valid = $_smarty_tpl->decodeProperties(array (
  'file_dependency' => 
  array (
    'f83b529eecc53e4d2876c83b609495ced0cc1414' => 
    array (
      0 => '../views/obgy/reports/financialsearch.html',
      1 => 1665067304,
      2 => 'file',
    ),
  ),
  'nocache_hash' => '1492732234653d5add0b70a5-15965118',
  'function' => 
  array (
  ),
  'variables' => 
  array (
    'login_role' => 0,
    'share' => 0,
    'allData' => 0,
    'data' => 0,
    'i' => 0,
    'hosturl' => 0,
    'drDeptName' => 0,
    'totalCost' => 0,
    'totalDiscount' => 0,
    'totalCash' => 0,
    'totalVisa' => 0,
    'totalDept' => 0,
    'totalOldCash' => 0,
    'totalOldVisa' => 0,
    'totalRefundCash' => 0,
    'totalRefundVisa' => 0,
    'totalC' => 0,
    'totalV' => 0,
  ),
  'has_nocache_code' => false,
  'version' => 'Smarty-3.1.11',
  'unifunc' => 'content_653d5add148187_11270926',
),false); /*/%%SmartyHeaderCode%%*/?>
<?php if ($_valid && !is_callable('content_653d5add148187_11270926')) {function content_653d5add148187_11270926($_smarty_tpl) {?><table class="table table-hover portlet light bg-inverse" id="repTable" style="width: 100%;">
    <thead>
        <tr>
            <th style="width: 10px !important;">#</th>
            <td>  Rec. No. </td>
            <th>   Patient Name</th>
            <th >   Patient No.</th>
            <th class="hide_me">   Wife National No.</th>
            <th class="hide_me">   Husband National No.</th>
            <th class="hide_me">   Dept.</th>
            <th>   Type</th>

            <?php if ($_smarty_tpl->tpl_vars['login_role']->value!=19){?>
            <th>   Total      </th>
            <th>   Discount   </th>
            <th>   Cash </th>
            <th>   Visa  </th>
            <th>   Debt </th>
            <?php }?>

            <?php if ($_smarty_tpl->tpl_vars['share']->value==1){?>
            <th>RFC</th>
            <th>Refer Dr.</th>
            <th>Doctor</th>
            <?php }?>


            <th>Visit Doctor</th>


            <th>   Notes    </th>
            <th>   User name  </th>
            <th>   Visit Date</th>
            <?php if ($_smarty_tpl->tpl_vars['share']->value==2){?>  <th>   Visit Hour</th> <?php }?>
        </tr>
    </thead>
    <tbody>
        <?php $_smarty_tpl->tpl_vars["i"] = new Smarty_variable("1", null, 0);?>
        <?php  $_smarty_tpl->tpl_vars['data'] = new Smarty_Variable; $_smarty_tpl->tpl_vars['data']->_loop = false;
 $_from = $_smarty_tpl->tpl_vars['allData']->value; if (!is_array($_from) && !is_object($_from)) { settype($_from, 'array');}
foreach ($_from as $_smarty_tpl->tpl_vars['data']->key => $_smarty_tpl->tpl_vars['data']->value){
$_smarty_tpl->tpl_vars['data']->_loop = true;
?>
        <tr class="odd " <?php if ($_smarty_tpl->tpl_vars['data']->value['detectionid']==9999||$_smarty_tpl->tpl_vars['data']->value['billType']==1){?> style="background-color: #efc9cc;" <?php }elseif($_smarty_tpl->tpl_vars['data']->value['customer_add']==1){?> style="background-color: #f1f16d;"    <?php }?> >
            <td><?php echo $_smarty_tpl->tpl_vars['i']->value;?>
</td>
            <td><?php echo $_smarty_tpl->tpl_vars['data']->value['printserial'];?>
</td>
            <td>
                <a href="<?php echo $_smarty_tpl->tpl_vars['hosturl']->value;?>
/controllers/patienthistory.php?ac=show&patientid=<?php echo $_smarty_tpl->tpl_vars['data']->value['patientid'];?>
" target="_new">
                    <?php if ($_smarty_tpl->tpl_vars['data']->value['for_husband']==1){?>
                    <?php echo $_smarty_tpl->tpl_vars['data']->value['husdandname'];?>

                    <?php }elseif($_smarty_tpl->tpl_vars['data']->value['for_husband']==2){?>
                    طفل    /  <?php echo $_smarty_tpl->tpl_vars['data']->value['wifename'];?>

                    <?php }else{ ?>
                    <?php echo $_smarty_tpl->tpl_vars['data']->value['wifename'];?>

                    <?php }?>
                </a>
            </td>
            <td><?php echo $_smarty_tpl->tpl_vars['data']->value['statusno'];?>
</td>
            <td class="hide_me"><?php echo $_smarty_tpl->tpl_vars['data']->value['wifenationalid'];?>
</td>
            <td class="hide_me"><?php echo $_smarty_tpl->tpl_vars['data']->value['husbandnationalid'];?>
</td>
            <td class="hide_me"><?php echo $_smarty_tpl->tpl_vars['data']->value['deptName'];?>
</td>
            <td><?php echo $_smarty_tpl->tpl_vars['data']->value['type'];?>
</td>

            <?php if ($_smarty_tpl->tpl_vars['login_role']->value!=19){?>
            <td>
                <?php echo $_smarty_tpl->tpl_vars['data']->value['totaldetectionvalue'];?>

            </td>
            <td>
                <?php echo $_smarty_tpl->tpl_vars['data']->value['discount'];?>

            </td>
            <td>
                <?php echo $_smarty_tpl->tpl_vars['data']->value['detectionvalue_cash'];?>

            </td>
            <td>
                <?php echo $_smarty_tpl->tpl_vars['data']->value['detectionvalue_visa'];?>

            </td>
            <td>
                <?php echo $_smarty_tpl->tpl_vars['data']->value['restdetectionvalue'];?>

            </td>
            <?php }?>

            <?php if ($_smarty_tpl->tpl_vars['share']->value==1){?>
            <td>  
                <?php echo $_smarty_tpl->tpl_vars['data']->value['rfc'];?>

            </td>
            <td>
                <?php echo $_smarty_tpl->tpl_vars['data']->value['refer'];?>

            </td>
            <?php if ($_smarty_tpl->tpl_vars['data']->value['for_husband']==1){?>
            <td>
                <?php echo $_smarty_tpl->tpl_vars['data']->value['h_doctor'];?>

            </td>
            <?php }else{ ?>
            <td>
                <?php echo $_smarty_tpl->tpl_vars['data']->value['doctor'];?>

            </td>
            <?php }?>

            <?php }?>

            <td> <?php echo $_smarty_tpl->tpl_vars['data']->value['visitDoctor'];?>
  <?php if ($_smarty_tpl->tpl_vars['drDeptName']->value==1){?>  -   <?php echo $_smarty_tpl->tpl_vars['data']->value['deptName'];?>
  <?php }?>  </td>

            <td>
                <?php echo $_smarty_tpl->tpl_vars['data']->value['vnotes'];?>

            </td>

            <td>
                <?php echo $_smarty_tpl->tpl_vars['data']->value['insert_user'];?>

            </td>
            <td><?php echo $_smarty_tpl->tpl_vars['data']->value['visitdate'];?>
</td>
            <?php if ($_smarty_tpl->tpl_vars['share']->value==2){?>
            <td><?php echo $_smarty_tpl->tpl_vars['data']->value['visitHour'];?>
</td>
            <?php }?>

        </tr>
        <?php ob_start();?><?php echo $_smarty_tpl->tpl_vars['i']->value+1;?>
<?php $_tmp1=ob_get_clean();?><?php $_smarty_tpl->tpl_vars["i"] = new Smarty_variable($_tmp1, null, 0);?>
        <?php } ?>
    </tbody>
</table>

<?php if ($_smarty_tpl->tpl_vars['login_role']->value!=19){?>
<div id="totalDiv">
    <?php if (!empty($_smarty_tpl->tpl_vars['allData']->value)){?>
    <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 id="totalCost"> <?php echo $_smarty_tpl->tpl_vars['totalCost']->value;?>
</th>
            <th  id="totalDiscount"> <?php echo $_smarty_tpl->tpl_vars['totalDiscount']->value;?>
</th>
            <th  id="totalCash"> <?php echo $_smarty_tpl->tpl_vars['totalCash']->value;?>
</th>
            <th  id="totalVisa"> <?php echo $_smarty_tpl->tpl_vars['totalVisa']->value;?>
</th>
            <th  id="totalDept"> <?php echo $_smarty_tpl->tpl_vars['totalDept']->value;?>
</th>
        </tr>
        <tr>
            <td  id="totalCost">Old Debts</td>
            <th> </th>
            <th> </th>
            <th  id="totalOldCash"> <?php echo $_smarty_tpl->tpl_vars['totalOldCash']->value;?>
</th>
            <th  id="totalOldVisa"> <?php echo $_smarty_tpl->tpl_vars['totalOldVisa']->value;?>
</th>
            <th></th>
        </tr>
        <tr  style="background-color: #efc9cc;"  >
            <td>Refund</td>
            <td> </td>
            <td> </td>
            <td  id="totalRefundCash"> <?php echo $_smarty_tpl->tpl_vars['totalRefundCash']->value;?>
</td>
            <td  id="totalRefundVisa"> <?php echo $_smarty_tpl->tpl_vars['totalRefundVisa']->value;?>
</td>
            <td></td>
        </tr>
        <tr>
            <td>Total</td>
            <th> </th>
            <th> </th>
            <th  id="totalC"> <?php echo $_smarty_tpl->tpl_vars['totalC']->value;?>
</th>
            <th  id="totalV"><?php echo $_smarty_tpl->tpl_vars['totalV']->value;?>
 </th>
            <th> </th>
        </tr>
    </table>
    <?php }?>
</div>
<?php }?>



<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
                }
                , exportOptions: {
                    columns: ':not(.hide_me)',
                }
            }
            , {
                extend: 'excel'
                , text: 'excel '
                , title: 'Financial Report'

                , customize: function (xlsx) {
                    var sheet = xlsx.xl.worksheets['sheet1.xml'];
                    var clRow = $('row', sheet);
                    var newIndex = 5 + clRow.length;



                    function Addrow(newIndex, data) {
                        row = '  <row r="' + newIndex + '"> ';
                        row += '  <c t="inlineStr" r="C' + newIndex + '"><is><t>' + data[0] + '</t></is></c> ';
                        row += ' <c t="inlineStr" r="D' + newIndex + '"><is><t>' + data[1] + ' </t></is></c>  ';
                        row += '  <c t="inlineStr" r="E' + newIndex + '"><is><t>' + data[2] + ' </t></is></c> ';
                        row += '  <c t="inlineStr" r="F' + newIndex + '"><is><t>' + data[3] + ' </t></is></c> ';
                        row += '  <c t="inlineStr" r="G' + newIndex + '"><is><t>' + data[4] + ' </t></is></c> ';
                        row += '  <c t="inlineStr" r="H' + newIndex + '"><is><t>' + data[5] + ' </t></is></c> ';
                        row += ' </row>  ';
                        $('sheetData', sheet).append(row);
                    }

                    Addrow(newIndex, [' ', 'Cost', 'Discount', 'Cash', 'Visa', 'Debt']);
                    newIndex = 1 + newIndex;
                    Addrow(newIndex, ['New Visits', $('#totalCost').html(), $('#totalDiscount').html(), $('#totalCash').html()
                                , $('#totalVisa').html(), $('#totalDept').html()]);
                    newIndex = 1 + newIndex;
                    Addrow(newIndex, ['Old Debts', ' ', ' ', $('#totalOldCash').html(), $('#totalOldVisa').html(), ' ']);
                    newIndex = 1 + newIndex;
                    Addrow(newIndex, [' Refund', ' ', ' ', $('#totalRefundCash').html(), $('#totalRefundVisa').html(), ' ']);
                    //    $('row:first c', sheet).attr('s', '39');
                    newIndex = 1 + newIndex;
                    Addrow(newIndex, [' Total', ' ', ' ', $('#totalC').html(), $('#totalV').html(), ' ']);
                }

            }
        ],
        "scrollX": true
    });


</script>
<?php }} ?>