<html dir="rtl">

<head>

    <meta http-equiv="content-type" content="text/html; charset=utf-8" />
    <title>GT4</title>
    <style type="text/css">
    </style>
    <style>
        @media print {
            @page {
                size: 100mm 200mm landscape;
                /* landscape */
                /* you can also specify margins here: */
                margin: 0mm;
                margin-right: 0mm;
                /* for compatibility with both A4 and Letter */
                /* size: 139mm 215mm;
  height: 215mm;
  width: 139mm; */
            }

            #printdiv {
                margin-top: {
                    $billsettingsData[82]->billsettingsvalue
                }

                mm;
                /* user margin */
            }

            td {
                font-weight: bolder !important;
            }
        }

        table.info tr {
            width: 100%;
        }



        .body {
            direction: rtl
        }

        td {
            margin: 0
        }

        .table-black1 tbody>tr>td {

            vertical-align: middle;
            text-align: center;
            border: 1px solid #000;
        }

        .result,
        .result tr,
        .result tr td {
            border: 1px solid #000
        }

        .td td {
            border-right-widtd: 1px;
            border-bottom-widtd: 1px;
            border-left-widtd: 0px;
            border-top-style: none;
            border-right-style: dotted;
            border-bottom-style: solid;
            border-left-style: none;
            border-bottom-color: #999;
            font-size: 17px;
            border-right-color: #999;
        }

        .NEE {
            font-size: 14px;
        }

        .newdesign {
            font-size: 14px;
        }

        .copywrites {
            font-size: 11px;
        }

        td {
            margin: 0 !important
        }

        .hidden {
            display: none;
        }
    </style>


</head>
<script src="../views/default/assets/js/jquery.js"></script>


{literal}

<script language="javascript" type="text/javascript">
    /*$(document).ready(function() {
     //window.print();

     // printDiv();
     });*/
    function printDiv() {

        var divId = document.getElementById('printdiv');
        divId.setAttribute("className", "print_section print");
        divId.setAttribute("class", "print_section print");
        window.print();
        setTimeout(window.close, 0);

        // window.close();
    }
</script>
<style>
    td {
        font-size: 15px;
        font-weight: 200;
        padding: 0 2px
    }

    .td td {
        border-right-width: 1px;
        border-bottom-width: 1px;
        border-left-width: 0px;
        border-top-style: none;
        border-right-style: dotted;
        border-bottom-style: solid;
        border-left-style: none;
        border-bottom-color: #999;
        font-size: 17px;
        border-right-color: #999;
        padding: 0 2px
    }

    .NEE {
        font-size: 14px;
    }

    .newdesign {
        font-size: 14px;
    }

    .copywrites {
        font-size: 11px;
    }
</style>
<style>
    .td td {
        border-right-width: 1px;
        border-bottom-width: 1px;
        border-left-width: 0px;
        border-top-style: none;
        border-right-style: dotted;
        border-bottom-style: solid;
        border-left-style: none;
        border-bottom-color: #999;
        font-size: 18px;
        border-right-color: #999;
        padding: 0 2px
    }

    .NEE {
        font-size: 14px;
    }

    .newdesign {
        font-size: 14px;
    }

    .copywrites {
        font-size: 11px;
    }

    .style2 {
        font-family: tahoma
    }

    .style4 {
        font-family: tahoma;
        font-size: 14px;
        font-weight: bold;
        border: 1px solid #999 !important;
    }

    .serial {
        background-color: #C8C8C8;
        height: 20px;
        width: 150px;
        padding: 5px;
        margin: 5px;
        border: medium double #000000;
        text-align: center;
    }

    .style1 {
        font-size: 15px
    }

    .style-num {
        font-size: 12px
    }

    table.data td {
        border: 1px solid #000;
        text-align: center
    }

    td {
        font-size: 13px;
        padding: 0 2px
    }

    .table-last td {
        border: 1px solid #444;
        text-align: center
    }
</style>
{/literal}

<body onLoad="printDiv()">
    <div id="printdiv">
        <b>
            <table width="97%" align="center" cellpadding="0" cellspacing="0">
                <tr>
                    <td width="142" align="center" valign="top" {if $billsettingsData[72]->billsettingsvalue ==
                        2}style="display:none;"{/if}><p><strong>

                                {if $billsettingsData[72]->billsettingsvalue == 0||$userData->branchId == 0 ||
                                $userData->branchId == -1}
                                <img src="../views/default/images/upload/{$Programsettingdata->logo}" alt="" width="122"
                                    height="50"><br>
                                {else}
                                <img src="../views/default/images/branch_image/{$branchData->logo}" alt="" width="122"
                                    height="50"><br>
                                {/if}

                    </td>
                </tr>
            </table>
            <!--start title -->
            <div></div>
            <h2 style="  text-align:center" class="style1">فاتورة حساب مريض بالأقسام الداخلية</h2>
            <h2 style="  text-align:center" class="style1">الجهة الكفيلة:
                {if $billsettingsData[121]->billsettingsvalue eq 1}التأمين الصحي{elseif $billsettingsData[121]->billsettingsvalue eq 2}نفقة
                دولة{else}أهالي{/if}</h2>
    </div>
    <!-- end title -->
    <div style="clear:both"></div>
    <table style="width:55%;float:right;margin-top: 7px">
        {if {$billsettingsData[18]->billsettingsvalue} eq 0}
        {if $sellbillData->sellbilltotalpayed neq 0 || $sellbillData->sellbilltotaldeptbefor neq 0}
        <tr>
            <td align="right">
                {if $Usergroupdata->hideBillPrices != 1}
                <span> الدين قبل:</span>
                <span>{$sellbillData->sellbilltotaldeptbefor} </span>
                {/if}
            </td>

        </tr>
        {/if}
        {/if}

        <tr {if {$billsettingsData[16]->billsettingsvalue} eq 0} {else} style="display:none !important" {/if}>
            <td align="right">
                <span> اسم العميل :</span>
                <span>{$sellbillData->tempclientName}</span>
            </td>

        </tr>

        <tr {if {$billsettingsData[39]->billsettingsvalue} eq 0} {else} style="display:none !important" {/if}>

            <td dir="rtl">
                <span>عنوان العميل:</span>
                <span>{$clientdata->clientaddress}</span>
            </td>

        </tr>
        <tr {if {$billsettingsData[3]->billsettingsvalue} eq 0} {else} style="display:none" {/if}>
            <td align="right">
                <span> اسم الطبيب:</span>
                <span>{$sellbillData->employeename}</span>
            </td>

        </tr>
        <tr>
            <td align="right">
                <span> تاريخ الدخول:</span>
                <span>{$sellbillData->sellbilldate}</span>
            </td>
        </tr>
        <tr>
            <td align="right">
                <span> تاريخ الخروج:</span>
                <span>{$sellbillData->datestarting}</span>
            </td>
        </tr>
    </table>
    <table style="width:45%;float:left">
        <tr>
            <td dir="rtl">
                <span>الرقم الموحد</span>
                <span>{$clientdata->clientid}</span>
            </td>
        </tr>

        <tr {if {$billsettingsData[39]->billsettingsvalue} eq 0} {else} style="display:none !important" {/if}>

            <td dir="rtl">
                <span>تليفون العميل:</span>
                <span>{$clientdata->clientphone} {if $clientdata->clientmobile != ''} -
                    {$clientdata->clientmobile}{/if}</span>
            </td>

        </tr>

        <tr {if {$billsettingsData[39]->billsettingsvalue} eq 0} {else} style="display:none !important" {/if}>

            <td dir="rtl">
                <span> كود العميل :</span>
                <span>{$clientdata->clientcode}</span>
            </td>

        </tr>

        {if $Programsettingdata->clientserial eq 1}
        <tr>

            <td align="right">
                <span>رقم تسلسل الفاتورة :</span>
                <span>{if $sellbillData->taxBillNumber >
                    0}{$sellbillData->taxBillNumber}{else}{$sellbillData->sellbillid}{/if}</span>
            </td>
            <td> </td>
        </tr>
        {/if}




        {*if {$Programsettingdata->saveprinting} eq 1*}

        <!--المخزن -->
        {if {$billsettingsData[27]->billsettingsvalue} eq 0 && $manyStores neq 1}

        <tr>
            <td align="right">
                <span> اسم المخزن:</span>
                <span> {$sellbillData->storeName}</span>
            </td>
        </tr>
        {/if}

        <tr>
            <td align="right">
                <span>اسم المستخدم:</span>
                <span> {$billUserData->employeename}</span>
            </td>
        </tr>

        {if {$billsettingsData[101]->billsettingsvalue} eq 0}
        <tr>
            <td align="right">
                <span> عملية الفاتورة:</span>
                <span> {$sellbillData->billoperationName}</span>
            </td>
        </tr>
        {/if}
        {if {$billsettingsData[22]->billsettingsvalue} eq 0}
        <tr>
            <td align="right">
                <span> التشخيص:</span>
                <span> {$sellbillData->comment}</span>
            </td>
        </tr>
        {/if}

    </table>
    <div style="clear:both"></div>
    <table style="width:100%">
        <h4 style="text-align: center;margin: 0">فاتورة حساب</h4>
    </table>
    <div style="clear:both"></div>

    <table class="data" width="100%" cellpadding="0" cellspacing="0" dir="rtl">

        <tr>
            <td align="center" bgcolor="#E8E8E8">م</td>

            <td align="center" bgcolor="#E8E8E8" {if {$billsettingsData[20]->billsettingsvalue} eq 0} {else}
                style="display:none" {/if} class="wdt120">الباركود</td>

            <td align="center" bgcolor="#E8E8E8" c>البيان</td>

            {if {$billsettingsData[26]->billsettingsvalue} eq 0 && $billsettingsData[108]->billsettingsvalue eq
            0}
            <td align="center" bgcolor="#E8E8E8">المخزن</td>
            {/if}

            <td align="center" bgcolor="#E8E8E8" {if {$billsettingsData[7]->billsettingsvalue} eq 0} {else}
                style="display:none !important" {/if} >التعليق</td>

            <td align="center" bgcolor="#E8E8E8" {if {$billsettingsData[21]->billsettingsvalue} eq 0} {else}
                style="display:none !important" {/if} >الوحدة</td>
            <td align="center" bgcolor="#E8E8E8" {if {$billsettingsData[46]->billsettingsvalue} eq 0 &&
                {$billsettingsData[121]->billsettingsvalue} neq 0} {else}
                style="display:none !important" {/if}>العدد</td>
            <td align="center" bgcolor="#E8E8E8" {if {$Programsettingdata->scunitname} eq '0'} hidden {/if}
                >{$Programsettingdata->scunitname}</th>
            <td class="{if $Usergroupdata->hideBillPrices == 1 || $billsettingsData[116]->billsettingsvalue eq 0 || {$billsettingsData[121]->billsettingsvalue} eq 0}hidden{/if}"
                align="center" bgcolor="#E8E8E8">
                السعر قبل الخصم</td>

            <td class="{if $billsettingsData[116]->billsettingsvalue eq 0 || {$billsettingsData[121]->billsettingsvalue} eq 0}hidden{/if}"
                align="center" bgcolor="#E8E8E8">
                خصم المصنع</td>
            <td class="{if $Usergroupdata->hideBillPrices == 1 || {$billsettingsData[121]->billsettingsvalue} eq 0}hidden{/if}"
                align="center" bgcolor="#E8E8E8">
                السعر</td>
            <td class="{if $Usergroupdata->hideBillPrices == 1}hidden{/if}" align="center" bgcolor="#E8E8E8" {if
                {$billsettingsData[23]->billsettingsvalue} eq 0} {else} style="display:none" {/if}
                >الخصم</td>
            <td class="{if $Usergroupdata->hideBillPrices == 1}hidden{/if}" align="center" bgcolor="#E8E8E8" {if
                {$billsettingsData[114]->billsettingsvalue} eq 1} {else} style="display:none" {/if}>
                الاجمالى قبل الخصم</td>
            <td class="{if $Usergroupdata->hideBillPrices == 1}hidden{/if}" align="center" bgcolor="#E8E8E8">
                الاجمالى</td>


        </tr>



        {foreach $sellbilldetailData as $sellbilldetail}
        <tr>
            <td align="center">{$sellbilldetail@index+1}</td>
            <td align="center" {if {$billsettingsData[20]->billsettingsvalue} eq 0} {else} style="display:none
                !important" {/if}>

                {$sellbilldetail->parcode}

            </td>


            <td align="center" dir="ltr">

                {if $sellbilldetail->soldSerialsInDetails != ""} (sn: {$sellbilldetail->soldSerialsInDetails})
                {/if}


                {$sellbilldetail->productName}{if {$billsettingsData[60]->billsettingsvalue} eq 0}/
                {$sellbilldetail->productCatName}{/if}
                {if {$billsettingsData[79]->billsettingsvalue} eq 0}
                {if isset($sellbilldetail->sizeName) && $sellbilldetail->sizeName
                !=""}/{$sellbilldetail->sizeName}{/if}
                {if isset($sellbilldetail->colorName) && $sellbilldetail->colorName
                !=""}/{$sellbilldetail->colorName}{/if}
                {/if}


            </td>

            {if {$billsettingsData[26]->billsettingsvalue} eq 0 && $billsettingsData[108]->billsettingsvalue eq
            0}
            {if {$sellbilldetail->storeName} <> ""}
                <td align="center" dir="ltr">
                    <div id="productparcode1">
                        <p class="form-control-static"> {$sellbilldetail->storeName} </p>
                    </div>
                </td>
                {else}
                <td align="center" dir="ltr">
                    <div id="productparcode1">
                        <p class="form-control-static">

                            {$sellbillData->storeName}
                        </p>
                    </div>
                </td>
                {/if}
                {/if}


                <td align="center" {if {$billsettingsData[7]->billsettingsvalue} eq 0} {else}
                    style="display:none
                    !important" {/if}>

                    {$sellbilldetail->note}

                </td>


                <td align="center" {if {$billsettingsData[21]->billsettingsvalue} eq 0} {else}
                    style="display:none
                    !important" {/if}>

                    {$sellbilldetail->unitName}

                </td>


                <td align="center" {if {$billsettingsData[46]->billsettingsvalue} eq 0 &&
                    {$billsettingsData[121]->billsettingsvalue} neq 0} {else}
                    style="display:none
                    !important" {/if}>

                    {$sellbilldetail->sellbilldetailquantity + 0}

                </td>
                <td align="center" {if {$Programsettingdata->scunitname} eq
                    '0'||$billsettingsData[67]->billsettingsvalue} hidden {/if}>
                    {$sellbilldetail->otherdetailquantity + 0}
                </td>

                <td class="{if $Usergroupdata->hideBillPrices == 1 || $billsettingsData[116]->billsettingsvalue eq 0}hidden{/if}"
                    align="center">
                    {$sellbilldetail->sellbilldetailprice + $sellbilldetail->categorydiscount + 0}
                </td>

                <td class="{if $billsettingsData[116]->billsettingsvalue eq 0}hidden{/if}" align="center">
                    {$sellbilldetail->categorydiscount + 0}
                </td>

                <td class="{if $Usergroupdata->hideBillPrices == 1 || {$billsettingsData[121]->billsettingsvalue} eq 0}hidden{/if}"
                    align="center">

                    {$sellbilldetail->sellbilldetailprice + 0}
                    <!-- {$currency} -->

                </td>




                <td class="{if $Usergroupdata->hideBillPrices == 1}hidden{/if}" align="center" {if
                    {$billsettingsData[23]->billsettingsvalue} eq 0} {else} style="display:none !important"
                    {/if}>


                    {$sellbilldetail->discountvalue + 0}

                </td>
                <td class="{if $Usergroupdata->hideBillPrices == 1 || {$billsettingsData[121]->billsettingsvalue} eq 0}hidden{/if}"
                    align="center" {if {$billsettingsData[114]->billsettingsvalue} eq 1} {else} style="display:none
                    !important"
                    {/if}>
                    {$sellbilldetail->sellbilldetailtotalprice + $sellbilldetail->discountvalue}
                </td>

                <td class="{if $Usergroupdata->hideBillPrices == 1}hidden{/if}">

                    {$sellbilldetail->sellbilldetailtotalprice + 0}

                </td>





        </tr>

        {/foreach}

    </table>
    {if {$billsettingsData[121]->billsettingsvalue} eq 2}
    <table align="right" cellpadding="0" cellspacing="0" style="margin-top: 5px" dir="rtl" class="table-last">
        <tr>
            <td>رقم القرار</td>
            <td>{$sellbillData->decisionNo}</td>
        </tr>
        <tr>
            <td>قيمة القرار :</td>
            <td>{$sellbillData->decisionValue}</td>
        </tr>
    </table>
    {/if}
    <table align="left" cellpadding="0" cellspacing="0" style="margin-top: 5px" dir="rtl"
        class="table-last {if $Usergroupdata->hideBillPrices == 1}hidden{/if}">
        {if {$billsettingsData[121]->billsettingsvalue} neq 0}
        <tr {if {$billsettingsData[58]->billsettingsvalue} eq 0} {else} style="display:none" {/if}>
            <td>اجمالي القطع</td>
            <td>
                {if {$sellbillData->sellQuantity} <= 0} {$quantity} {else} {$sellbillData->sellQuantity}
                    {/if}
            </td>
        </tr>
        {/if}
        <tr {if {$billsettingsData[28]->billsettingsvalue} eq 0 && $sellbillData->sellbillaftertotalbill !=
            $sellbillData->sellbilltotalbill} {else} style="display:none" {/if}>
            <td>الصافى</td>
            <td>{$sellbillData->sellbillaftertotalbill} {$currency}</td>
        </tr>
        {if {$billsettingsData[117]->billsettingsvalue} eq 1 && $sellbillData->totalprodiscount > 0}
        <tr>
            <td>إجمالي خصومات المنتج</td>
            <td>
                {$sellbillData->totalprodiscount}</td>
        </tr>
        {/if}

        <tr>
            <td>اجمالي الفاتوره</td>
            <td>{$sellbillData->sellbilltotalbill}</td>
        </tr>

        {if $sellbillData->extraDiscountVal > 0 && $billsettingsData[90]->billsettingsvalue == 1 &&
        $billnameAddData->extraDiscountPlace == 1}
        <tr>
            <td>خصم اضافى</td>
            <td>{$sellbillData->extraDiscountVal}</td>
        </tr>
        {/if}

        <tr {if {$sellbillData->sellbilldiscount} > 0 && {$billsettingsData[47]->billsettingsvalue} eq 0} {else}
            style="display:none" {/if}>
            <td>قيمه الخصم</td>
            <td> {$discountvalue}{if $sellbillData->sellbilldiscounttype eq
                2}(%{$sellbillData->sellbilldiscount}){/if}</td>
        </tr>
        {if $sellbillData->extraDiscountVal > 0 && $billsettingsData[90]->billsettingsvalue == 1 &&
        $billnameAddData->extraDiscountPlace == 0}
        <tr>
            <td>خصم اضافى</td>
            <td>{$sellbillData->extraDiscountVal}</td>
        </tr>
        {/if}

        {if {$billsettingsData[31]->billsettingsvalue} eq 0 && $taxvalue > 0}
        <tr>
            <td>ضريبه القيمة المضافة</td>
            <td> {$taxvalue} {$Programsettingdata->currancy} ({$sellbillData->tax}%)</td>
        </tr>
        {/if}

        {if $billnameAddData->taxOfDiscountPrint eq 0 && $sellbillData->taxOfDiscountVal > 0}
        <tr>
            <td>ضريبه خصم</td>
            <td> {$sellbillData->taxOfDiscountVal}</td>
        </tr>
        {/if}

        <tr>
            <td>قيمة المصروفات الإدارية </td>
            <td>{$sellbillData->manage_ex}</td>
        </tr>

        <tr>
            <td>قيمة الدمغة الطبية </td>
            <td>{$sellbillData->med_hallmark}</td>
        </tr>
        <tr>
            <td>المدفوع بالإيصال رقم {$sellbillData->pay_rec_no}</td>
            <td>{$sellbillData->pay_rec_val}</td>
        </tr>
        <tr>
            <td>المبلغ </td>
            <td>{$sellbillData->sellbillaftertotalbill}</td>
        </tr>
        {if {$billsettingsData[28]->billsettingsvalue} eq 0 && $sellbillData->sellbillaftertotalbill !=
        $sellbillData->sellbilltotalbill}


        <tr>
            <td>الصافى</td>
            <td> {$sellbillData->sellbillaftertotalbill} {$currency}</td>
        </tr>
        {/if}

        <tr{if {$billsettingsData[29]->billsettingsvalue} eq 0 && $sellbillData->sellbilltotalpayed !=
            $sellbillData->sellbilltotalbill} {else} style="display:none !important" {/if}>
            <td>المدفوع</td>
            <td> {$sellbillData->sellbilltotalpayed} {$currency}</td>
            </tr>

            {if {$billsettingsData[30]->billsettingsvalue} eq 0 && $sellbillData->sellbillfinalbill > 0}
            <tr>
                <td>المتبقى</td>
                <td>{$sellbillData->sellbillfinalbill} {$currency}</td>
            </tr>
            {/if}

            {if {$billsettingsData[18]->billsettingsvalue} eq 0}
            {if $sellbillData->sellbilltotalpayed neq 0 || $sellbillData->sellbilltotaldeptbefor neq 0}
            <tr>
                <td>المديونيه السابقة</td>
                <td>{$sellbillData->sellbilltotaldeptbefor} {$currency}</td>
            </tr>
            {/if}
            {/if}

            {if {$billsettingsData[19]->billsettingsvalue} eq 0}


            <tr {if {$sellbillData->sellbilltotaldeptafter} <> 0} {else} style="display:none !important" {/if}>
                    <td>إجمالى المديونيه</td>
                    <td>{$sellbillData->sellbilltotaldeptafter} {$currency}</td>
            </tr>
            {/if}
    </table>
    {if count($billPayments)>0}
    <!--<h4 style="text-align: center;margin: 0">دفعات على الفاتورة</h4>-->
    <table width="50%" cellpadding="0" cellspacing="0" style="margin-top: 5px;float:right"
        class="table-last {if $Usergroupdata->hideBillPrices == 1}hidden{/if}" dir="rtl"
        class="{if $Usergroupdata->hideBillPrices == 1}hidden{/if}">
        <tr>
            <td> م</td>
            <td> قيمة الفاتورة</td>
            <!--<td>  قيمة الدين قبل</td>-->
            <td> القيمة المدفوعة </td>
            <!--<td>  قيمة الدين بعد</td>-->
            <td> تاريخ الدفع</td>
            <td> طريقة الدفع</td>
        </tr>
        {foreach $billPayments as $data}
        <tr class="gradeA ">
            <td> {$data.itra}</td>
            <td> {$data.finalnetbillvalue} </td>
            <!--<td> {$data.wait_before}</td>-->
            <td> {$data.clientdebtchangeamount} </td>
            <!--<td> {$data.wait_after}</td>-->
            <td> {$data.date} </td>
            <td> {$data.paytype} </td>
        </tr>
        {/foreach}
    </table>
    {/if}
    <div style="clear:both"></div>
    <div style="bottom: 20px !important;">
        <table style="width: 98%;">

            <tr>

                <td style="width: 30%;">المراجع</td>
                <td style="width: 30%;">رئيس حسابات المرضى</td>
                <td style="width: 30%;">مدير المركز</td>
            </tr>

        </table>
    </div>
    <div style="clear:both"></div>
    <!-- footer -->

    {if $qrerp > 1}
    <div style="text-align: center;">
        {if $qrerp == 3 || $qrerp == 4}
        <img src="data:image/jpeg;base64,{$base64qr}" style="width:120px;height: 120px;" />
        {/if}
        {if $qrerp == 2 || $qrerp == 4}
        <img src="data:image/jpeg;base64,{$base64qrs}" style="width:120px;height: 120px;" />
        {/if}
    </div>
    {/if}

    <div style="
                     text-align: center;
                     {if $billsettingsData[81]->billsettingsvalue == 1}display:none{/if}">

        <p><span class="copywrites">تصميم شركة جي تي فور 01110070882</span></p>
    </div>

    </b>
    </div>
</body>