

<div class="row">
    <div class="container">
        <ol class="breadcrumb">
            <li><a href="#">الفواتير </a></li>
            <li><a href="#">فواتير </a></li>
            <li class="active">عرض  فاتورة </li>
        </ol>
        <div class="panel panel-default panel-m">
            <!-- Default panel contents -->
            <div class="panel-heading">
                <h3 class="panel-title">عرض  فاتورة</h3>
            </div>
            <div class="panel-body">

                <!-- end box / title -->

                <form  method="post" id="billForm" action="?do=add" class="nameToBeChecked form-horizontal" >

                    <div id="printAll">
                        <div class="form-group">
                            <label class="col-lg-2 control-label">اسم العميل </label>
                            <div class="col-lg-4">
                                <p class="form-control-static"> {$bill->clientname} </p>
                            </div>



                            <label class="col-lg-2 control-label">تاريخ الاستلام  </label>
                            <div class="col-lg-4">              <p class="form-control-static"> {$bill->receivedate} </p>            </div>
                        </div>

                        <div class="form-group">
                            <label class="col-lg-2 control-label">رقم الفاتورة </label>
                            <div class="col-lg-4">              <p class="form-control-static"> {$bill->billno} </p>            </div>

                            <label class="col-lg-2 control-label">التعليق</label>
                            <div class="col-lg-4">              <p class="form-control-static"> {$bill->comment} </p>            </div>
                        </div>

                        <div class="form-group">
                            <label class="col-lg-2 control-label">تاريخ الفاتورة   </label>
                            <div class="col-lg-4">              <p class="form-control-static"> {$bill->billdate} </p>            </div>
                            <label class="col-lg-2 control-label">نوع الكشف</label>
                            <div class="col-lg-4">              <p class="form-control-static"> {if $bill->kashftype == 1} خارجى  {elseif $bill->kashftype == 0} داخلى   {elseif $bill->kashftype == -1} بدون كشف  {else} كشف{/if}</p>            </div>

                        </div>

                        <div class="form-group">
                            <label class="col-lg-2 control-label">الحد الأقصى للسداد</label>
                            <div class="col-lg-4">              <p class="form-control-static"> {$bill->alloweddays} </p>            </div>
                            <label class="col-lg-2 control-label">نوع السعر</label>
                            <div class="col-lg-4">              <p class="form-control-static"> {if $bill->pricetype == 1} تجزئة {else if $bill->pricetype == 2} نصف جملة  {else if $bill->kashftype == 0} جملة  {/if}</p>            </div>

                        </div>

                        <div class="form-group">
                            <label class="col-lg-2 control-label">رقم الفرع  </label>
                            <div class="col-lg-4">
                                <p class="form-control-static"> {$Branch->branchNo} </p>
                            </div>
                            <label class="col-lg-2 control-label">تليفون الفرع  </label>
                            <div class="col-lg-4">
                                <p class="form-control-static"> {$Branch->mobile} </p>
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-lg-2 control-label">اسم الدكتور </label>
                            <div class="col-lg-4">
                                <p class="form-control-static"> {$doctor_name} </p>
                            </div>
                        </div>


                        {if $bill->kashftype == 1}

                        <div class="form-group">
                            <label class="col-lg-2 control-label">مكان الكشف</label>
                            <div class="col-lg-4">              <p class="form-control-static"> {$bill->kashfplace} </p>            </div>
                            <label class="col-lg-2 control-label">تاريخ الكشف</label>
                            <div class="col-lg-4">              <p class="form-control-static"> {$bill->kashfdate}</p>            </div>

                        </div>
                        {/if}

                        <div class="row">
                            <hr/>
                            <div class="col-lg-6">
                                <h4></h4>
                            </div>
                            <div class="col-lg-6">
                                <h4></h4>
                            </div>
                        </div>


                        {if $bill->kashftype != -1}
                        <div id="externalKashf">

                            <div class="form-group" >

                                <div class="col-lg-6 " >


                                    <table class='table-black'>
                                        <tr>

                                            <td colspan="6" class="bg-head"> <label class="sr-only">Left Eye</label> </td>

                                        </tr>
                                        <tr>

                                            <td></td>
                                            <td style="padding-right: 36px;" > <label class="sr-only">L-va</label> </td>

                                            <td style="padding-right: 36px;" > <label class="sr-only">L-prism</label> </td>

                                            <td style="padding-right: 36px;" > <label class="sr-only">L-axis</label> </td>

                                            <td style="padding-right: 22px;" > <label class="sr-only">L-cylinder</label> </td>

                                            <td style="padding-right: 22px;" >   <label class="sr-only">L-sphere</label> </td>


                                        </tr>
                                        <tr>


                                            <td> <label class="sr-only">المسافة</label> </td>




                                            <td> <input   type="text" name="D_Lva" disabled="" readonly="" value="{if $kashf->ldva > 0}{/if}{$kashf->ldva}"   class="form-control" /> </td>

                                            <td> <input   type="text" name="D_Lprism" disabled="" readonly="" value="{if $kashf->ldprism > 0}{/if}{$kashf->ldprism}"    class="form-control" /> </td>

                                            <td> <input   type="text" name="D_Laxis"  disabled="" readonly="" value="{$kashf->ldaxis}"    class="form-control" /> </td>

                                            <td> <input   type="text" name="D_Lcylinder"  disabled="" readonly="" value="{if $kashf->ldcylinder > 0}{/if}{$kashf->ldcylinder}"  class="form-control" /> </td>

                                            <td> <input  type="text"  name="D_Lsphere" disabled="" readonly="" value="{if $kashf->ldsphere > 0}{/if}{$kashf->ldsphere}"  class="form-control" /> </td>

                                        </tr>
                                        <tr>


                                            <td> <label class="sr-only">القراءة</label> </td>




                                            <td> <input   type="text" name="N_Lva"  disabled="" readonly="" value="{if $kashf->lnva > 0}{/if}{$kashf->lnva}"    class="form-control" /> </td>

                                            <td> <input   type="text" name="N_Lprism"  disabled="" readonly="" value="{if $kashf->lnprism > 0}{/if}{$kashf->lnprism}"   class="form-control" /> </td>


                                            <td> <input   type="text" name="N_Laxis" disabled="" readonly="" value="{$kashf->lnaxis}"    class="form-control" /> </td>

                                            <td> <input   type="text" name="N_Lcylinder"  disabled="" readonly="" value="{if $kashf->lncylinder > 0}{/if}{$kashf->lncylinder}"   class="form-control" /></td>

                                            <td> <input   type="text" name="N_Lsphere"  disabled="" readonly="" value="{if $kashf->lnsphere > 0}{/if}{$kashf->lnsphere}"  class="form-control" /> </td>

                                        </tr>
                                    </table>
                                </div>


                                <div class="col-lg-6">



                                    <table class='table-black'>
                                        <tr>

                                            <td colspan="6" class="bg-head"> <label class="sr-only">Right Eye</label>  </td>

                                        </tr>
                                        <tr>


                                            <td style="padding-right: 36px;" > <label class="sr-only">R-va</label> </td>
                                            <td style="padding-right: 36px;" > <label class="sr-only">R-prism</label> </td>

                                            <td style="padding-right: 36px;" > <label class="sr-only">R-axis</label> </td>

                                            <td style="padding-right: 22px;" > <label class="sr-only">R-cylinder</label> </td>

                                            <td style="padding-right: 22px;" > <label class="sr-only">R-sphere</label> </td>

                                            <td></td>

                                        </tr>
                                        <tr>


                                            <td>  <input   type="text" name="D_Rva"  disabled="" readonly="" value="{if $kashf->rdva > 0}{/if}{$kashf->rdva}"   class="form-control" /> </td>

                                            <td> <input   type="text" name="D_Rprism"  disabled="" readonly="" value="{if $kashf->rdprism > 0}{/if}{$kashf->rdprism}"  class="form-control" /> </td>

                                            <td > <input   type="text" name="D_Raxis"  disabled="" readonly="" value="{$kashf->rdaxis}"   class="form-control" /> </td>

                                            <td>  <input   type="text" name="D_Rcylinder" disabled="" readonly="" value="{if $kashf->rdcylinder > 0}{/if}{$kashf->rdcylinder}"    class="form-control" /></td>

                                            <td > <input   type="text" name="D_Rsphere"  disabled="" readonly="" value="{if $kashf->rdsphere > 0}{/if}{$kashf->rdsphere}"  class="form-control" /> </td>

                                            <td> <label style="    margin-left: 21px;" class="sr-only">Distance</label> </td>
                                        </tr>
                                        <tr>



                                            <td>   <input   type="text" name="N_Rva" disabled="" readonly="" value="{if $kashf->rnva > 0}{/if}{$kashf->rnva}"   class="form-control" /> </td>

                                            <td> <input   type="text" name="N_Rprism"  disabled="" readonly="" value="{if $kashf->rnprism > 0}{/if}{$kashf->rnprism}"   class="form-control" /> </td>


                                            <td > <input   type="text" name="N_Raxis"  disabled="" readonly="" value="{$kashf->rnaxis}"   class="form-control" /> </td>

                                            <td >  <input   type="text" name="N_Rcylinder"  disabled="" readonly="" value="{if $kashf->rncylinder > 0}{/if}{$kashf->rncylinder}"  class="form-control" /> </td>

                                            <td >  <input   type="text" name="N_Rsphere"   disabled="" readonly="" value="{if $kashf->rnsphere > 0}{/if}{$kashf->rnsphere}"   class="form-control" /> </td>

                                            <td> <label style="    margin-right: 24px;" class="sr-only">Near</label> </td>

                                        </tr>
                                    </table>



                                </div>
                                <br>
                                <div class="col-lg-5" style="padding-left: 0px;">
                                    <table class="table-black mT10 mB6" style="margin-right:52px;width: 85%;">
                                        <tr>
                                            <td class="bg-head"><label class="sr-only">Add</label> </td>
                                            <td class="bg-head" > <label class="sr-only">Biofocal</label> </td>
                                        </tr>
                                        <tr>
                                            <td> <input   type="text" name="ladd"  id="ladd"   disabled="" readonly=""   value="{if $kashf->ladd > 0}{/if}{$kashf->ladd}"   class="form-control" /></td>
                                            <td> <input   type="text" name="lbiofocal" id="lbiofocal"   disabled="" readonly=""    value="{if $kashf->lbiofocal > 0}{/if}{$kashf->lbiofocal}"   class="form-control" /></td>
                                        </tr>
                                    </table>
                                </div>

                                <div class="col-lg-3">
                                    <table class="table-black mT10 mB6" style="width: 100%;">
                                        <tr>
                                            <td>  <input   type="text" name="pd" id="pd"   disabled="" readonly=""   value="{$kashf->pd}"   class="form-control" /></td>
                                            <td style="text-align: left;" class="bg-head"> <label style="margin: 5px;" class="sr-only">PD</label> </td>
                                        </tr>
                                        <tr>
                                            <td>  <input   type="text" name="bvd" id="bvd"   disabled="" readonly=""   value="{$kashf->bvd}"   class="form-control" /></td>
                                            <td style=" text-align: left;" class="bg-head"> <label style="margin: 5px;" class="sr-only">BVD</label> </td>
                                        </tr>
                                    </table>
                                </div>

                                <div class="col-lg-4">
                                    <table class="table-black mT10 mB6" style="margin-left: 76px;margin-right: -5px;">
                                        <tr>
                                            <td class="bg-head"><label class="sr-only">Add</label> </td>
                                            <td class="bg-head"> <label class="sr-only">Biofocal</label> </td>
                                        </tr>
                                        <tr>
                                            <td> <input   type="text" name="radd" id="radd"   disabled="" readonly=""   value="{if $kashf->radd > 0}{/if}{$kashf->radd}"   class="form-control" /></td>
                                            <td> <input   type="text" name="rbiofocal" id="rbiofocal"   disabled="" readonly=""   value="{if $kashf->rbiofocal > 0}{/if}{$kashf->rbiofocal}"    class="form-control" /></td>
                                        </tr>
                                    </table>
                                </div>

                                <div class="col-lg-12">
                                    <table class="table-black" style="margin-top: 5px;width: 100%">
                                        <tr>
                                            <td class="bg-head"> <label style="margin: 5px;" class="sr-only">ملاحظات</label> </td>
                                            <td>  <input   type="text"  disabled="" readonly=""  name="notes" id="notes" value="{$kashf->notes}"    class="form-control" /></td>
                                        </tr>

                                    </table>
                                </div>
                            </div>
                        </div>
                        {/if}
                        <div class="row">
                            <div class="row">
                                <hr/>
                                <div class="col-lg-6">
                                    <h4></h4>
                                </div>
                                <div class="col-lg-6">
                                </div>
                            </div>
                            <input name="hidden_itr" id="hidden_itr" type="hidden" value="1" />
                            <!-- end of title row-->
                            <div class="table-responsive bd-gr">
                                <table class="table billtable table-bordered table-black" >
                                    <thead>
                                        <tr>
                                            {if {$bill->payType} == 'ins'}
                                            <th class="wdt400">كود التامين</th>
                                            {/if}
                                            <th class="wdt400">الخدمة</th>
                                            <th class="wdt400">اسم المنتج</th>
                                            <th class="wdt240">ملاحظات</th>
                                            <th class="wdt100n">العدد</th>
                                            <th class="wdt80">السعر</th>
                                            <th class="wdt80">الخصم</th>
                                            <th class="wdt100n">الاجمالى</th>

                                        </tr>
                                    </thead>
                                    <tbody id="productsTable">
                                        {foreach $billProducts as $product}
                                        <tr>
                                              {if {$bill->payType} == 'ins'}
                                            <td>
                                                <p class="form-control-static"> {$product->productcode} </p>

                                            </td>
                                            {/if}
                           
                                            <td>
                                                <p class="form-control-static"> {if $product->service == -1}لا يوجد{else}{$product->service}{/if} </p>

                                            </td>
                                            <td>
                                                <p class="form-control-static"> {$product->productName} </p>

                                            </td>
                                            <td>
                                                <p class="form-control-static"> {$product->note}  </p>
                                            </td>

                                            <td>
                                                <p class="form-control-static"> {$product->productno}  </p>
                                            </td>
                                            <td>
                                                <p class="form-control-static"> {$product->productprice}  </p>
                                            </td>
                                            <td>
                                                <p class="form-control-static"> {($product->productprice*$product->productno)-$product->producttotalprice}  </p>
                                            </td>
                                            <td class="aw_totalprice">
                                                <div  class="aw_mt form-control-static"><span id="prototal1">{$product->producttotalprice}</span> <span> {$currency}</span></div>
                                            </td>

                                        </tr>

                                        {/foreach}
                                    </tbody>
                                </table>
                            </div>
                            <button type="button" class="btn btn-primary pull-left ft-nor"> إجمالي المشتريات <span class="badge wht-clo">
                                    <div id="buyBillTotal">{$bill->productstotalprice}</div>
                                </span></button>

                            <input name="totalBillPrice" id="totalBillPrice" type="hidden" value="0" />

                        </div>

                        <div class="form-group">
                            <label class="col-lg-2 control-label">قيمة الكشف </label>
                            <div class="col-lg-2">
                                <p class="form-control-static"> {$bill->kashfvalue} </p>
                            </div>

                            <label class="col-lg-1 control-label">الخصم  </label>
                            <div class="col-lg-2">
                                <p class="form-control-static"> {$bill->kashfdiscount} </p>
                            </div>

                            <label class="col-lg-1 control-label">الاجمالى  </label>
                            <div class="col-lg-2">
                                <p class="form-control-static"> {$bill->netbillvalue} </p>
                            </div>
                        </div>

                        <div class="form-group">
                            <label class="col-lg-2 control-label">نوع الخصم </label>
                            <div class="col-lg-2">
                                <p class="form-control-static"> {if $bill->discounttype == 1} مباشر {else if $bill->discounttype == 2}نسبة{/if} </p>
                            </div>

                            <label class="col-lg-1 control-label">قيمة الخصم  </label>
                            <div class="col-lg-2">
                                <p class="form-control-static"> {$bill->discountvalue} </p>
                            </div>

                            <label class="col-lg-1 control-label">الصافى  </label>
                            <div class="col-lg-2">
                                <p class="form-control-static"> {$bill->finalnetbillvalue} </p>
                            </div>
                        </div>


                        <div class="form-group">
                            <label class="col-lg-2 control-label">طريقة الدفع  </label>
                        </div>


                        <table class="table billtable table-bordered table-black table-ccc" >
                            {if $bill->insurance == 1}

                            <thead>
                                <tr>
                                    <th colspan="7" >تأمين </th>
                                </tr>
                            </thead>
                            <tbody>

                                <tr>
                                    <td>
                                        <p class="form-control-static"> اسم الشركة  </p>
                                    </td>
                                    <td colspan="5">
                                        <p class="form-control-static"> {$bill->companyname}  </p>
                                    </td>
                                </tr>
                                <tr>
                                    <td class="table-ccc table-black">
                                        <p class="form-control-static"> نسبة  العميل (%)   </p>
                                    </td>
                                    <td>
                                        <p class="form-control-static"> {$bill->customerpercent}  </p>
                                    </td>
                                    <td class="table-ccc table-black">
                                        <p class="form-control-static"> بحد  أقصى  </p>
                                    </td>
                                    <td>
                                        <p class="form-control-static"> {$bill->customermax}  </p>
                                    </td>
                                    <td  class="table-ccc table-black">
                                        <p class="form-control-static"> يتحمل  العميل   </p>
                                    </td>
                                    <td>
                                        <p class="form-control-static"> {$bill->customercarry}  </p>
                                    </td>
                                </tr>
                                <tr>
                                    <td  class="table-ccc table-black">
                                        <p class="form-control-static"> موافقة شركة التأمين     </p>
                                    </td>
                                    <td>
                                        <p class="form-control-static"> {$bill->companyaccept}  </p>
                                    </td>
                                    <td class="table-ccc table-black">
                                        <p class="form-control-static"> تتحمل  شركة التأمين</p>
                                    </td>
                                    <td>
                                        <p class="form-control-static"> {$bill->companycarry}  </p>
                                    </td>
                                    <td  class="table-ccc table-black">
                                        <p class="form-control-static"> رقم الموافقة </p>
                                    </td>
                                    <td>
                                        <p class="form-control-static"> {$bill->approvalno}  </p>
                                    </td>
                                </tr>
                                <tr>
                                    <td  class="table-ccc table-black">
                                        <p class="form-control-static"> الصورة المرفقة    </p>
                                    </td>
                                    <td>
                                        <p class="form-control-static"> <a href="../views/default/images/billsattatch/{$bill->attatch}" style="color: blue;" target="_blank"><u>عرض الصورة</u></a>  </p>
                                    </td>
                            
                                </tr>
                            </tbody>
                            {/if}
                            {if $bill->card == 1}

                            <thead>
                                <tr>
                                    <th colspan="7">شبكة </th>
                                </tr>
                            </thead>
                            <tbody>
                                <tr>
                                    <td  class="table-ccc table-black">
                                        <p class="form-control-static"> اسم الشبكة  </p>
                                    </td>
                                    <td colspan="3">
                                        <p class="form-control-static"> {$bill->networkname}  </p>
                                    </td>
                                    <td  class="table-ccc table-black">
                                        <p class="form-control-static">  القيمة   </p>
                                    </td>
                                    <td colspan="2">
                                        <p class="form-control-static"> {$bill->cardvalue}  </p>
                                    </td>
                                </tr>
                            </tbody>
                            {/if}
                            {if $bill->cash == 1}
                            <thead>
                                <tr>
                                    <th colspan="7">كاش </th>
                                </tr>
                            </thead>
                            <tbody>
                                <tr>
                                    <td  class="table-ccc table-black">
                                        <p class="form-control-static">  القيمة   </p>
                                    </td>
                                    <td colspan="5">
                                        <p class="form-control-static"> {$bill->cashvalue}  </p>
                                    </td>
                                </tr>
                            </tbody>
                            {/if}
                            <thead>
                                <tr>
                                    <th colspan="7">أجل </th>
                                </tr>
                            </thead>
                            <tbody>
                                <tr>
                                    <td  class="table-ccc table-black">
                                        <p class="form-control-static">  القيمة   </p>
                                    </td>
                                    <td colspan="5">
                                        <p class="form-control-static"> {$bill->waitvalue}  </p>
                                    </td>
                                </tr>
                            </tbody>
                        </table>

                    </div>




                    <div class="form-group">
                        <div class="col-lg-12">
                            <a href="bills.php?do=exportexcel&id={$bill->id}&go=no&type=0" style="color: white;" target="_blank" type="button" class="btn btn-success hidden-print pull-left"> اكسل</a>
                            <a href="bills.php?do=print&id={$bill->id}&go=no&type=0" style="color: white;" target="_blank" type="button" class="btn btn-primary hidden-print pull-left"> طباعة</a>
                           
                            {if $bill->insurance == 1}
                            <a href="bills.php?do=print&id={$bill->id}&go=no&type=1&lens=1" style="color: white;" target="_blank" type="button" class="btn btn-success hidden-print pull-left">طباعة لشركة التأمين بمقاسات العدسات</a>
                            <a href="bills.php?do=print&id={$bill->id}&go=no&type=1" style="color: white;" target="_blank" type="button" class="btn btn-success hidden-print pull-left">طباعة لشركة التأمين بدون مقاسات العدسات</a>
                            {/if}
                        </div>

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



