

<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=addbuybill" class="nameToBeChecked form-horizontal" enctype="multipart/form-data">
                    <input name="isProductRequest" id="isProductRequest"  type="hidden" value="{$isProductRequest}" />
                    <input name="searchvalue" id="searchvalue"  type="hidden" value="{$Programsettingdata->searchvalue}" />
                    <input name="buyoptic" id="buyoptic"  type="hidden" value="1" />
                    <input name="addview2" id="addview2"  type="hidden" value="1" />
                    {if $isProductRequest == 1 }
                    <input name="productRequestIds" id="productRequestIds"  type="hidden" value="{$productRequestIds}" />
                    {/if}
                    <input type="hidden" name="bill_type" id="bill_type" value="buybill"/>
                    <div id="printAll">
                        <div class="form-group">
                            <label class="col-lg-2 control-label">اسم المورد </label>
                            <div class="col-lg-4">
                                <select name="client" id="clientx" data-placeholder="اختر"  class="select2 wdt100 buy" >
                                    <option value="-1"> اختر </option>
                                    {foreach $clientData as $client}
                                    <option value="{$client->supplierid}">{$client->suppliername} </option>
                                    {/foreach}
                                </select>
                                <span id="nameError" class=" alert-block alert-danger fade in" style="padding: 5px 5px 5px 5px; display: none ;">اختر اسم المورد أولا</span>
                            </div>

                            <label class="col-lg-2 control-label">تاريخ الاستلام  </label>
                            <div class="col-lg-4">
                                <div  class="input-group date form_datetime col-md-5" data-date="" data-date-format="yyyy-mm-dd  h:i:s" data-link-field="dtp_input1">
                                    <input class="form-control" size="16" type="text" value="{$now}" name="receivedate" id="receivedate" readonly="">
                                    <span class="input-group-addon "><span class=" glyphicon glyphicon-remove col-lg-4"></span></span>
                                    <span class="input-group-addon"><span class="glyphicon glyphicon-th col-lg-4"></span></span>
                                </div>
                            </div>
                        </div>

                        <div class="form-group">
                            <label class="col-lg-2 control-label">رقم الفاتورة </label>
                            <div class="col-lg-4">
                                <input name="billno" id="billno" type="text"  class="form-control positiveNo" value="{$billNo}" />
                                <input name="createdBillNo" id="createdBillNo" type="hidden"   value="{$billNo}" />
                                <span id="billError" class=" alert-block alert-danger fade in" style="padding: 5px 5px 5px 5px; display: none ;"></span>
                            </div>

                            <label class="col-lg-2 control-label">التعليق</label>
                            <div class="col-lg-4">
                                <textarea class="form-control" rows="2" name="comment" id="comment"></textarea>
                            </div>

                        </div>

                        <div class="form-group">
                            <label class="col-lg-2 control-label">تاريخ الفاتورة   </label>
                            <div class="col-lg-4">
                                <!--input name="billdate" id="billdate" readonly=""    class="form-control awdatepicker" autocomplete="off"  data-date-format="yyyy-mm-dd" type="text" /-->
                                <div  class="input-group date form_datetime col-md-5" data-date="" data-date-format="yyyy-mm-dd  h:i:s" data-link-field="dtp_input1">
                                    <input class="form-control" size="16" type="text" value="{$now}" name="billdate" id="billdate" readonly="">
                                    <span class="input-group-addon "><span class=" glyphicon glyphicon-remove col-lg-4"></span></span>
                                    <span class="input-group-addon"><span class="glyphicon glyphicon-th col-lg-4"></span></span>
                                </div>

                            </div>
                            <label class="col-lg-2 control-label">الحد الأقصى للسداد </label>
                            <div class="col-lg-4">
                                <input name="allowedDays" id="allowedDays" type="text"  style="display: inline;"  class="form-control wds94 positiveNo" />
                                <span> يوم </span>
                            </div>
                            <div style="display: none">
                                <label class="col-lg-2 control-label">نوع السعر </label>
                                <div class="col-lg-4">
                                    <select name="pricetype" id="pricetype" data-placeholder="اختر"  class="select2 wdt100" >
                                        <option  value="1">تجزئة</option>
                                        <option value="2">نصف جملة</option>
                                        <option value="0">جملة</option>
                                    </select>
                                </div>
                            </div>

                        </div>

                        <div class="form-group">
                            <div style="display:none">
                                <label class="col-lg-2 control-label">نوع الكشف </label>
                                <div class="col-lg-4">
                                    <div class="radio-inline">
                                        <label>
                                            <input value="0" class="kashftype"  name="kashftype"   type="radio" checked="checked"    />

                                            داخلى  </label>
                                    </div>
                                    <div class="radio-inline">
                                        <label>
                                            <input value="1"  class="kashftype" name="kashftype"  type="radio" />
                                            خارجى </label>
                                    </div>
                                    <span id="kashfError" class=" alert-block alert-danger fade in" style="padding: 5px 5px 5px 5px;display: none;">لا يوجد كشوفات سابقة لهذا المورد</span>
                                    <input name="kashfExist" id="kashfExist" type="hidden" value="1" />
                                </div>
                            </div>


                        </div>

                        <div class="form-group">
                            <label class="col-lg-2 control-label">المخزن </label>
                            <div class="col-lg-4">
                                <select class="select2 wdt100" name="storeid" id="storeid">
                                    {foreach $storeData as $store}
                                    <option value="{$store->storeId}">{$store->storeName}</option>
                                    {/foreach}
                                </select>
                            </div>
        
<!--                            {if $userdata->userstoreid  eq 0}
                            <label class="col-lg-2 control-label">المخزن </label>
                            <div class="col-lg-4">
                                <select class="select2 wdt100" name="storeid" id="storeid">
                                    {foreach $storeData as $store}
                                    <option value="{$store->storeId}">{$store->storeName}</option>
                                    {/foreach}
                                </select>
                            </div>

                            {else}
                            <input name="storeid" id="storeid"  type="hidden" value="{$userdata->userstoreid}" />
                            {/if}-->


                        </div>

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

                        <div id="externalKashfFixed" style="display: none;">

                            <div class="form-group" >

                                <div class="col-lg-6" style="border: 1px solid #ccc;">


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

                                            <td style="padding-right: 259px;padding-top: 30px;font-size: 20px;padding-bottom: 13px;" colspan="6"> <label class="sr-only">Left Eye</label> </td>

                                        </tr>
                                        <tr>

                                            <td></td>
                                            <td style="padding-right: 22px;" >   <label class="sr-only">Lsphere</label> </td>
                                            <td style="padding-right: 22px;" > <label class="sr-only">Lcylinder</label> </td>
                                            <td style="padding-right: 36px;" > <label class="sr-only">Laxis</label> </td>
                                            <td style="padding-right: 36px;" > <label class="sr-only">Lprism</label> </td>
                                            <td style="padding-right: 36px;" > <label class="sr-only">Lva</label> </td>


                                        </tr>
                                        <tr>


                                            <td style="border: 1px solid black;"> <label class="sr-only">المسافة</label> </td>
                                            <td style="border: 1px solid black;"> <input  type="text"  id="D_Lsphere" disabled="" readonly="" value="{$kashf->ldsphere}"  class="form-control" /> </td>

                                            <td style="border: 1px solid black;"> <input   type="text" id="D_Lcylinder"  disabled="" readonly="" value="{$kashf->ldcylinder}"  class="form-control" /> </td>

                                            <td style="border: 1px solid black;"> <input   type="text" id="D_Laxis"  disabled="" readonly="" value="{$kashf->ldaxis}"    class="form-control" /> </td>

                                            <td style="border: 1px solid black;"> <input   type="text" id="D_Lprism" disabled="" readonly="" value="{$kashf->ldprism}"    class="form-control" /> </td>

                                            <td style="border: 1px solid black;"> <input   type="text" id="D_Lva" disabled="" readonly="" value="{$kashf->ldva}"   class="form-control" /> </td>

                                        </tr>
                                        <tr>


                                            <td style="border: 1px solid black;"> <label class="sr-only">القراءة</label> </td>
                                            <td style="border: 1px solid black;"> <input   type="text" id="N_Lsphere"  disabled="" readonly="" value="{$kashf->lnsphere}"  class="form-control" /> </td>

                                            <td style="border: 1px solid black;"> <input   type="text" id="N_Lcylinder"  disabled="" readonly="" value="{$kashf->lncylinder}"   class="form-control" /></td>

                                            <td style="border: 1px solid black;"> <input   type="text" id="N_Laxis" disabled="" readonly="" value="{$kashf->lnaxis}"    class="form-control" /> </td>

                                            <td style="border: 1px solid black;"> <input   type="text" id="N_Lprism"  disabled="" readonly="" value="{$kashf->lnprism}"   class="form-control" /> </td>

                                            <td style="border: 1px solid black;"> <input   type="text" id="N_Lva"  disabled="" readonly="" value="{$kashf->lnva}"    class="form-control" /> </td>

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


                                <div class="col-lg-6" style="border: 1px solid #ccc;">



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

                                            <td  style="padding-right: 194px;padding-top: 30px;font-size: 20px;padding-bottom: 13px;" colspan="6"> <label class="sr-only">Right Eye</label>  </td>

                                        </tr>
                                        <tr>


                                            <td style="padding-right: 22px;" > <label class="sr-only">Rsphere</label> </td>
                                            <td style="padding-right: 22px;" > <label class="sr-only">Rcylinder</label> </td>
                                            <td style="padding-right: 36px;" > <label class="sr-only">Raxis</label> </td>
                                            <td style="padding-right: 36px;" > <label class="sr-only">Rprism</label> </td>
                                            <td style="padding-right: 36px;" > <label class="sr-only">Rva</label> </td>
                                            <td></td>

                                        </tr>
                                        <tr>


                                            <td style="border: 1px solid black;"> <input   type="text" id="D_Rsphere"  disabled="" readonly="" value="{$kashf->rdsphere}"  class="form-control" /> </td>
                                            <td style="border: 1px solid black;">  <input   type="text" id="D_Rcylinder" disabled="" readonly="" value="{$kashf->rdcylinder}"    class="form-control" /></td>
                                            <td style="border: 1px solid black;"> <input   type="text" id="D_Raxis"  disabled="" readonly="" value="{$kashf->rdaxis}"   class="form-control" /> </td>
                                            <td style="border: 1px solid black;"> <input   type="text" id="D_Rprism"  disabled="" readonly="" value="{$kashf->rdprism}"  class="form-control" /> </td>
                                            <td style="border: 1px solid black;">  <input   type="text" id="D_Rva"  disabled="" readonly="" value="{$kashf->rdva}"   class="form-control" /> </td>
                                            <td style="border: 1px solid black;"> <label style="    margin-left: 21px;" class="sr-only">Distance</label> </td>
                                        </tr>
                                        <tr>


                                            <td style="border: 1px solid black;">  <input   type="text" id="N_Rsphere"   disabled="" readonly="" value="{$kashf->rnsphere}"   class="form-control" /> </td>
                                            <td style="border: 1px solid black;">  <input   type="text" id="N_Rcylinder"  disabled="" readonly="" value="{$kashf->rncylinder}"  class="form-control" /> </td>
                                            <td style="border: 1px solid black;"> <input   type="text" id="N_Raxis"  disabled="" readonly="" value="{$kashf->rnaxis}"   class="form-control" /> </td>
                                            <td style="border: 1px solid black;"> <input   type="text" id="N_Rprism"  disabled="" readonly="" value="{$kashf->rnprism}"   class="form-control" /> </td>
                                            <td style="border: 1px solid black;">   <input   type="text" id="N_Rva" disabled="" readonly="" value="{$kashf->rnva}"   class="form-control" /> </td>
                                            <td style="border: 1px solid black;"> <label style="    margin-right: 24px;" class="sr-only">Near</label> </td>

                                        </tr>
                                    </table>



                                </div>


                                <div class="col-lg-5" style="padding-left: 0px;">
                                    <table style="border: 1px solid black;margin-right:52px;width: 85%;">
                                        <tr>
                                            <td style="padding-right: 70px;padding-top: 10px;border: 1px solid black;" ><label class="sr-only">Add</label> </td>
                                            <td style="padding-right: 70px;padding-top: 10px;border: 1px solid black;" > <label class="sr-only">Biofocal</label> </td>
                                        </tr>
                                        <tr>
                                            <td style="border: 1px solid black;"> <input   type="text" name="ladd"  id="ladd" disabled value="{$kashf->ladd}"   class="form-control" /></td>
                                            <td style="border: 1px solid black;"> <input   type="text" name="lbiofocal" id="lbiofocal" disabled  value="{$kashf->lbiofocal}"   class="form-control" /></td>
                                        </tr>
                                    </table>
                                </div>

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

                                <div class="col-lg-4">
                                    <table style="border: 1px solid black;margin-left: 76px;margin-right: -5px;">
                                        <tr>
                                            <td style="padding-right: 45px;padding-top: 10px;border: 1px solid black;" ><label class="sr-only">Add</label> </td>
                                            <td style="padding-right: 45px;padding-top: 10px;border: 1px solid black;" > <label class="sr-only">Biofocal</label> </td>
                                        </tr>
                                        <tr>
                                            <td style="border: 1px solid black;"> <input   type="text" name="radd" id="radd" disabled value="{$kashf->radd}"   class="form-control" /></td>
                                            <td style="border: 1px solid black;"> <input   type="text" name="rbiofocal" id="rbiofocal" disabled value="{$kashf->rbiofocal}"    class="form-control" /></td>
                                        </tr>
                                    </table>
                                </div>

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

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

                        <div id="externalKashf" style="display: none;">
                            <div class="form-group">
                                <label class="col-lg-2 control-label">مكان الكشف  </label>
                                <div class="col-lg-4">
                                    <input name="kashfplace" id="kashfplace" type="text"  class="form-control" value="" />
                                </div>

                                <label class="col-lg-2 control-label">تاريخ الكشف  </label>
                                <div class="col-lg-4">
                                    <input name="kashfdate" id="kashfdate" readonly="" value="{$today}"    class="form-control awdatepicker" autocomplete="off"  data-date-format="yyyy-mm-dd" type="text" />
                                </div>
                            </div>

                            <div class="form-group" >

                                <div class="col-lg-6" style="border: 1px solid #ccc;">


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

                                            <td style="padding-right: 259px;padding-top: 30px;font-size: 20px;padding-bottom: 13px;" colspan="6"> <label class="sr-only">Left Eye</label> </td>

                                        </tr>
                                        <tr>

                                            <td></td>
                                            <td style="padding-right: 22px;" >   <label class="sr-only">Lsphere</label> </td>
                                            <td style="padding-right: 22px;" > <label class="sr-only">Lcylinder</label> </td>
                                            <td style="padding-right: 36px;" > <label class="sr-only">Laxis</label> </td>
                                            <td style="padding-right: 36px;" > <label class="sr-only">Lprism</label> </td>
                                            <td style="padding-right: 36px;" > <label class="sr-only">Lva</label> </td>


                                        </tr>
                                        <tr>


                                            <td style="border: 1px solid black;"> <label class="sr-only">المسافة</label> </td>
                                            <td style="border: 1px solid black;"> <input  type="text"  name="D_Lsphere"   class="form-control positivefloat" /></td>

                                            <td style="border: 1px solid black;"> <input   type="text" name="D_Lcylinder"   class="form-control positivefloat" /></td>

                                            <td style="border: 1px solid black;"> <input   type="text" name="D_Laxis"     class="form-control positivefloat" /></td>

                                            <td style="border: 1px solid black;"> <input   type="text" name="D_Lprism"    class="form-control positivefloat" /></td>

                                            <td style="border: 1px solid black;"> <input   type="text" name="D_Lva"   class="form-control positivefloat" /></td>

                                        </tr>
                                        <tr>


                                            <td style="border: 1px solid black;"> <label class="sr-only">القراءة</label> </td>
                                            <td style="border: 1px solid black;"> <input   type="text" name="N_Lsphere"   class="form-control positivefloat" /></td>

                                            <td style="border: 1px solid black;"> <input   type="text" name="N_Lcylinder"    class="form-control positivefloat" /></td>

                                            <td style="border: 1px solid black;"> <input   type="text" name="N_Laxis"    class="form-control positivefloat" /></td>

                                            <td style="border: 1px solid black;"> <input   type="text" name="N_Lprism"    class="form-control positivefloat" /></td>

                                            <td style="border: 1px solid black;"> <input   type="text" name="N_Lva"     class="form-control positivefloat" /></td>

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

                                <div class="col-lg-6" style="border: 1px solid #ccc;">



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

                                            <td  style="padding-right: 194px;padding-top: 30px;font-size: 20px;padding-bottom: 13px;" colspan="6"> <label class="sr-only">Right Eye</label>  </td>

                                        </tr>
                                        <tr>


                                            <td style="padding-right: 22px;" > <label class="sr-only">Rsphere</label> </td>
                                            <td style="padding-right: 22px;" > <label class="sr-only">Rcylinder</label> </td>
                                            <td style="padding-right: 36px;" > <label class="sr-only">Raxis</label> </td>
                                            <td style="padding-right: 36px;" > <label class="sr-only">Rprism</label> </td>
                                            <td style="padding-right: 36px;" > <label class="sr-only">Rva</label> </td>
                                            <td></td>

                                        </tr>
                                        <tr>


                                            <td style="border: 1px solid black;"> <input   type="text" name="D_Rsphere"   class="form-control positivefloat" /></td>
                                            <td style="border: 1px solid black;">  <input   type="text" name="D_Rcylinder"    class="form-control positivefloat" /></td>
                                            <td style="border: 1px solid black;"> <input   type="text" name="D_Raxis"    class="form-control positivefloat" /></td>
                                            <td style="border: 1px solid black;">  <input   type="text" name="D_Rprism"   class="form-control positivefloat" /></td>
                                            <td style="border: 1px solid black;">  <input   type="text" name="D_Rva"    class="form-control positivefloat" /></td>
                                            <td style="border: 1px solid black;"> <label style="    margin-left: 21px;" class="sr-only">Distance</label> </td>
                                        </tr>
                                        <tr>


                                            <td style="border: 1px solid black;">  <input   type="text" name="N_Rsphere"     class="form-control positivefloat" /></td>
                                            <td style="border: 1px solid black;">  <input   type="text" name="N_Rcylinder"   class="form-control positivefloat" /></td>
                                            <td style="border: 1px solid black;"> <input   type="text" name="N_Raxis"    class="form-control positivefloat" /></td>
                                            <td style="border: 1px solid black;"> <input   type="text" name="N_Rprism"   class="form-control positivefloat" /></td>
                                            <td style="border: 1px solid black;">   <input   type="text" name="N_Rva"   class="form-control positivefloat" /></td>
                                            <td style="border: 1px solid black;"> <label style="    margin-right: 24px;" class="sr-only">Near</label> </td>

                                        </tr>
                                    </table>



                                </div>


                                <div class="col-lg-5" style="padding-left: 0px;">
                                    <table style="border: 1px solid black;margin-right:52px;width: 85%;">
                                        <tr>
                                            <td style="padding-right: 70px;padding-top: 10px;border: 1px solid black;" ><label class="sr-only">Add</label> </td>
                                            <td style="padding-right: 70px;padding-top: 10px;border: 1px solid black;" > <label class="sr-only">Biofocal</label> </td>
                                        </tr>
                                        <tr>
                                            <td style="border: 1px solid black;"> <input   type="text" name="ladd"   class="form-control" /></td>
                                            <td style="border: 1px solid black;"> <input   type="text" name="lbiofocal"    class="form-control" /></td>
                                        </tr>
                                    </table>
                                </div>

                                <div class="col-lg-3">
                                    <table style="border: 1px solid black; margin-top: 5px;width: 100%;">
                                        <tr>
                                            <td style="border: 1px solid black;">  <input   type="text" name="pd"    class="form-control" /></td>
                                            <td style="border: 1px solid black;text-align: left;"> <label style="margin: 5px;" class="sr-only">PD</label> </td>
                                        </tr>
                                        <tr>
                                            <td style="border: 1px solid black;">  <input   type="text" name="bvd"   class="form-control" /></td>
                                            <td style="border: 1px solid black; text-align: left;"> <label style="margin: 5px;" class="sr-only">BVD</label> </td>
                                        </tr>
                                    </table>
                                </div>

                                <div class="col-lg-4">
                                    <table style="border: 1px solid black;margin-left: 76px;margin-right: -5px;">
                                        <tr>
                                            <td style="padding-right: 45px;padding-top: 10px;border: 1px solid black;" ><label class="sr-only">Add</label> </td>
                                            <td style="padding-right: 45px;padding-top: 10px;border: 1px solid black;" > <label class="sr-only">Biofocal</label> </td>
                                        </tr>
                                        <tr>
                                            <td style="border: 1px solid black;"> <input   type="text" name="radd"   class="form-control" /></td>
                                            <td style="border: 1px solid black;"> <input   type="text" name="rbiofocal"    class="form-control" /></td>
                                        </tr>
                                    </table>
                                </div>

                                <div class="col-lg-12">
                                    <table style="margin-top: 5px;width: 100%;border: 1px solid black;">
                                        <tr>
                                            <td style="border: 1px solid black;"> <label style="margin: 5px;" class="sr-only">ملاحظات</label> </td>
                                            <td style="border: 1px solid black;">  <input   type="text" name="notes"    class="form-control" /></td>
                                        </tr>

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


                        <div class="row">
                            <div class="row">
                                <hr/>
                                <div class="col-lg-6">
                                    <h4></h4>
                                </div>
                                <div class="col-lg-6">
                                    <button type="button" name="addNewPro" id="addNewPro" class="btn btn-primary pull-left ft-nor"> اضافة جديد</button>
                                </div>
                            </div>

                            {if $isProductRequest == 1 }
                            <input name="hidden_itr" id="hidden_itr" type="hidden" value="{$billProductsCount}" />
                            {else}
                            <input name="hidden_itr" id="hidden_itr" type="hidden" value="1" />
                            {/if}



                            <!-- end of title row-->
                            <div class="table-responsive bd-gr">
                                <table class="table billtable table-bordered table-black" >
                                    <thead>
                                        <tr>
                                            <th class="wdt240">الخدمة </th>
                                            <th style="width: 50%">اسم المنتج</th>
                                            <th class="wdt240">ملاحظات</th>
                                            <th class="wdt100n">العدد</th>
                                            <th class="wdt80">السعر</th>
                                            <th style="display: none;">الخصم</th>
                                            <th class="wdt100n">الاجمالى</th>
                                            <th>حذف</th>
                                        </tr>
                                    </thead>
                                    <tbody id="productsTable">
                                        {if $isProductRequest == 1 }
                                        {assign var=i value=1}
                                        {foreach $billProducts as $product}
                                        <tr>
                                            <td>
                                                <select name="service{$i}" id="service{$i}" data-placeholder="اختر" data-itr="{$i}"  class="select2 wdt100 opticService" >
                                                    <option value="-1"> اختر </option>
                                                    <!--option value="single vision"> single vision</option>
                                                    <option value="Hi - index">Hi - index </option>
                                                    <option value="Bi / Multi focal / Progressive">Bi / Multi focal / Progressive </option>
                                                    <option value="Contact Lenses"> Contact Lenses</option>
                                                    <option value="Frame"> Frame</option-->
                                                    <option value="Single vision">Single vision</option>
                                                    <option value="polycarbonate">polycarbonate</option>
                                                    <option value="Hi index">Hi index</option>
                                                    <option value="Contact lenses Plano">Contact lenses Plano</option>
                                                    <option value="Contact lenses power">Contact lenses power</option>
                                                    <option value="Sunglasses">Sunglasses</option>
                                                    <option value="Medical frame">Medical frame</option>
                                                    <option value="Reading">Reading</option>
                                                    <option value="Accessories">Accessories</option>
                                                    <option value="Bifocal">Bifocal</option>
                                                    <option value="Multifocal/Progressive">Multifocal/Progressive</option>
                                                </select>

                                            </td>
                                            <td>
                                                <div id="productdiv{$i}">
                                                    <input type="hidden" id="product{$i}" name="product{$i}"  class="productchange wdt100" data-newR="1"  data-itr="{$i}"  data-placeholder="اختر منتج"  tabindex="7" />
                                                    <input name="productId{$i}" id="productId{$i}" type="hidden" value="{$product->productid}" />
                                                    <input name="billProductText{$i}" id="billProductText{$i}" type="hidden" value="{$product->productName}" />
                                                </div>
                                            </td>


                                            <td>
                                                <textarea class="form-control txt-nonraduis" rows="1" name="note{$i}" id="note{$i}"  tabindex="7"></textarea>
                                            </td>

                                            <td>
                                                <input name="pronum{$i}" id="pronum{$i}" value="{$product->productnoaccept}"  data-itr="{$i}"  class="form-control txt-nonraduis proNumChange changePrice positivefloat" placeholder="العدد" type="text" tabindex="7" />
                                                <input name="pronumOld{$i}" id="pronumOld{$i}" type="hidden" value="0" />
                                            </td>
                                            <td>
                                                <input name="proprice{$i}" id="proprice{$i}" placeholder="السعر"  data-itr="{$i}" value="0" class="form-control txt-nonraduis positivefloat changePrice" type="text"   tabindex="7"/>
                                            </td>
                                            <td style="display: none;">
                                                <input name="discount{$itr}" id="discount{$itr}" placeholder="الخصم" value="0" data-itr="{$itr}" class="form-control positivefloat  txt-nonraduis change_discount" type="text"   tabindex="7"/>
                                            </td>
                                            <td class="aw_totalprice">
                                                <div  class="aw_mt form-control-static"><span id="prototal{$i}"> 0</span> <span> {$currency}</span></div>
                                                <input name="totalProductPrice{$i}" id="totalProductPrice{$i}" type="hidden" value="0" />
                                            </td>
                                            <td>
                                                <button type="button" id="remove{$i}" class="removeproduct close flt-none" aria-hidden="true">&times;</button>
                                            </td>
                                        </tr>
                                        {capture assign=i}{$i+1}{/capture}
                                        {/foreach}
                                        {else}
                                        <tr>
                                            <td>
                                                <select name="service1" id="service1" data-placeholder="اختر" data-itr="1"  class="select2 wdt100 opticService" >
                                                    <option value="-1"> اختر </option>
                                                    <!--option value="single vision"> single vision</option>
                                                    <option value="Hi - index">Hi - index </option>
                                                    <option value="Bi / Multi focal / Progressive">Bi / Multi focal / Progressive </option>
                                                    <option value="Contact Lenses"> Contact Lenses</option>
                                                    <option value="Frame"> Frame</option-->
                                                    <option value="Single vision">Single vision</option>
                                                    <option value="polycarbonate">polycarbonate</option>
                                                    <option value="Hi index">Hi index</option>
                                                    <option value="Contact lenses Plano">Contact lenses Plano</option>
                                                    <option value="Contact lenses power">Contact lenses power</option>
                                                    <option value="Sunglasses">Sunglasses</option>
                                                    <option value="Medical frame">Medical frame</option>
                                                    <option value="Reading">Reading</option>
                                                    <option value="Accessories">Accessories</option>
                                                    <option value="Bifocal">Bifocal</option>
                                                    <option value="Multifocal/Progressive">Multifocal/Progressive</option>
                                                </select>

                                            </td>
                                            <td>
                                                <div style="display: inline">
                                                    <select class="select2 productCat productCat1" style="width:30%;display: inline" data-level="0" data-itr ="1" name="productCatId0_1" id="productCatId0_1" >
                                                        <option value="-1">اختر تصنيف</option>
                                                        {foreach $catDataReport as $data}
                                                        <option value="{$data->productCatId}">{$data->productCatName}</option>
                                                        {/foreach}
                                                    </select>
                                                </div>
                                                <input type="hidden" id="level_1" data-itr ="1" name="level_1" value="0">
                                                <div id="manyParents_1"  data-itr ="1" style="display: inline">

                                                </div>
                                                <!--div id="productdiv1">
                                                    <input type="hidden" id="product1" name="product1"  class="productchange wdt100" data-newR="0"  data-itr="1"  data-placeholder="اختر منتج"  tabindex="7" />
                                                </div-->
                                            </td>


                                            <td>
                                                <textarea class="form-control txt-nonraduis" rows="1" name="note1" id="note1"  tabindex="7"></textarea>
                                            </td>

                                            <td>
                                                <input name="pronum1" id="pronum1" value="1"  data-itr="1"  class="form-control txt-nonraduis proNumChange changePrice positivefloat" placeholder="العدد" type="text" tabindex="7" />
                                                <input name="pronumOld1" id="pronumOld1" type="hidden" value="0" />
                                            </td>
                                            <td>
                                                <input name="proprice1" id="proprice1" placeholder="السعر"  data-itr="1" value="0" class="form-control txt-nonraduis positivefloat changePrice" type="text"   tabindex="7"/>
                                            </td>
                                            <td style="display: none;">
                                                <input name="discount1" id="discount1" placeholder="الخصم" value="0" data-itr="{$itr}" class="form-control positivefloat  txt-nonraduis change_discount" type="text"   tabindex="7"/>
                                            </td>
                                            <td class="aw_totalprice">
                                                <div  class="aw_mt form-control-static"><span id="prototal1"> 0</span> <span> {$currency}</span></div>
                                                <input name="totalProductPrice1" id="totalProductPrice1" type="hidden" value="0" />
                                            </td>
                                            <td>
                                                <button type="button" id="remove1" class="removeproduct close flt-none" aria-hidden="true">&times;</button>
                                            </td>
                                        </tr>
                                        {/if}
                                    </tbody>
                                </table>
                            </div>
                            <button type="button" class="btn btn-primary pull-left ft-nor"> إجمالي المشتريات <span class="badge wht-clo">
                                    <div id="buyBillTotal">0</div>
                                </span></button>

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

                        </div>

                        <div class="row">
                            <div class="col-lg-12">
                                <div class="form-group" style="display: none;">

                                    <label class="col-lg-2 control-label">قيمة الكشف </label>
                                    <div class="col-lg-2">
                                        <p class="form-control-static mg-tp10" id="kashfValueP">0</p>
                                        <input class="form-control" name="kashfValue" id="kashfValue"   type="hidden" value="0"  />
                                    </div>
                                    <label class="col-lg-2 control-label"> الخصم</label>
                                    <div class="col-lg-2">
                                        <p class="form-control-static mg-tp10" id="kashDiscValueP">0</p>
                                        <input name="kashDiscValue" id="kashDiscValue"  class="form-control" type="hidden" value="0" />
                                    </div>
                                </div>

                                <div class="form-group "  style="display: none;">
                                    <label class="col-lg-2 control-label bg-total">الاجمالى  </label>
                                    <div class="col-lg-6 bg-yel bg-total">
                                        <p class="form-control-static mg-tp10" id="netBillValueP">0</p>
                                        <input class="form-control" name="netBillValue" id="netBillValue"   type="hidden" value="0"  />
                                    </div>
                                </div>

                            </div>

                            <div class="col-lg-12">
                                <div class="form-group">
                                    <label class="col-lg-2 control-label">نوع الخصم </label>
                                    <div class="col-lg-2">
                                        <select id="discType" name="discType"  class="select2 wdt100 changeDiscount">
                                            <option  value="1">مباشر</option>
                                            <option  value="2">نسبة</option>
                                        </select>
                                    </div>

                                    <label class="col-lg-2 control-label">قيمة الخصم</label>
                                    <div class="col-lg-2">
                                        <input name="discValue" id="discValue"  class="form-control changeDiscount" type="text" value="0" />
                                    </div>
                                </div>
                                <div class="form-group ">
                                    <label class="col-lg-2 control-label bg-yel bg-total">الصافى </label>
                                    <div class="col-lg-6 bg-yel bg-total">
                                        <p class="form-control-static mg-tp10" id="netValueP">0</p>
                                        <input class="form-control" name="netValue" id="netValue"   type="hidden" value="0"  />
                                    </div>
                                </div>
                            </div>
                            <div class="col-lg-12">

                                <div class="form-group">
                                    <label class="col-lg-2 control-label"> طريقة الدفع   </label>
                                    <div class="col-lg-1" style="display: none">
                                        <h6 class="inline-st"><label>
                                                <input type="checkbox" name="paymentamethods[]" data-id1="insuranceCompanies" data-id2="insuranceValue"  id="insuranceChecked"  class="choosenItem productItem changePayment" value="insurance"/>
                                                تأمين
                                            </label></h6>
                                    </div>
                                    <div class="col-lg-7 wds43" style="display: none">
                                        <select name="insuranceCompanies" disabled="disabled" id="insuranceCompanies" data-placeholder="اختر" data-itr="1"  class="select2" >
                                            <option value="-1"> اختر </option>
                                            {foreach $insuranceCompanies as $company}
                                            <option value="{$company->id}">{$company->name} </option>
                                            {/foreach}
                                        </select>

                                        <span id="insuranceError" class=" alert-block alert-danger fade in" style="padding: 5px 5px 5px 5px;display: none;">اختر شركة التأمين</span>

                                    </div>
                                    <div class="col-lg-1"><span id="insuranceInst" class="questionicon" style="display: none;" ></span>
                                    </div>

                                </div>

                                <div class="form-group" style="display: none">
                                    <label class="col-lg-3 control-label">  </label>
                                    <label class="col-lg-1 control-label wds13">نسبة  العميل (%)   </label>
                                    <div class="col-lg-1">
                                        <input class="form-control positivefloat calClientCarry" name="clientPercent" id="clientPercent" disabled="disabled"    type="text"  value="0"/>
                                    </div>
                                    <label class="col-lg-1 control-label wds13">بحد  أقصى   </label>
                                    <div class="col-lg-1">
                                        <input class="form-control positivefloat  calClientCarry" name="clientMax" id="clientMax" disabled="disabled"    type="text" value="0" />
                                    </div>
                                    <label class="col-lg-1 control-label wds13">يتحمل  العميل   </label>
                                    <div class="col-lg-1">
                                        <input class="form-control positivefloat calcInsValue" name="clientCarry" id="clientCarry" disabled="disabled"   type="text" value="0" />
                                    </div>
                                </div>

                                <div class="form-group" style="display: none">
                                    <label class="col-lg-3 control-label">  </label>
                                    <label class="col-lg-1 control-label wds13">موافقة شركة التأمين   </label>
                                    <div class="col-lg-1">
                                        <input class="form-control positivefloat calcInsValue" name="insAccept" id="insAccept" disabled="disabled"    type="text" value="0" />
                                    </div>
                                    <label class="col-lg-1 control-label wds13">تتحمل  شركة التأمين</label>
                                    <div class="col-lg-1">
                                        <input class="form-control positivefloat calcBillRest" name="insuranceValue" id="insuranceValue" disabled="disabled"   type="text" value="0"/>
                                    </div>

                                    <label class="col-lg-1 control-label wds13">رقم الموافقة </label>
                                    <div class="col-lg-1">
                                        <input class="form-control" name="approvalNo" id="approvalNo" disabled="disabled"   type="text" value=""/>
                                    </div>
                                </div>
                                <div class="form-group" style="display: none">
                                    <label class="col-lg-3 control-label">  </label>
                                    <label class="col-lg-1 control-label wds13">ارفاق صورة</label>
                                    <div class="col-lg-4">
                                        <input type="file" id="attatch" name="attatch" disabled="disabled"/>
                                        <span id="attatchError" class=" alert-block alert-danger fade in" style="padding: 2px 5px 5px 5px;display: none;">اختر الصورة</span>
                                    </div>
                                </div>

                                <div class="form-group">
                                    <label class="col-lg-2 control-label"></label>
                                    <div class="col-lg-1">
                                        <h6 class="inline-st"><label>
                                                <input type="checkbox" name="paymentamethods[]" data-id1="paymentNetworks" data-id2="cardValue" id="cardChecked"  class="choosenItem productItem changePayment" value="card"/>
                                                بنك
                                            </label></h6>
                                    </div>
                                    <div class="col-lg-4 wds43">
                                        <select name="paymentNetworks" disabled="disabled" id="paymentNetworks" data-placeholder="اختر" data-itr="1"  class="select2 wdt100" >
                                            <option value="-1"> اختر </option>
                                            {foreach $bankData as $network}
                                            <option value="{$network->bankid}">{$network->bankname} </option>
                                            {/foreach}
                                        </select>
                                        <span id="cardError" class=" alert-block alert-danger fade in" style="padding: 5px 5px 5px 5px;display: none;">اختر بنك</span>
                                    </div>
                                    <label class="col-lg-1 control-label" style="width: 12.7%;">القيمة      </label>
                                    <div class="col-lg-1">
                                        <input class="form-control positivefloat calcBillRest"  name="cardValue" id="cardValue" disabled="disabled"  type="text" value="0"  />
                                    </div>
                                </div>
                                <div class="form-group">
                                    <label class="col-lg-3 control-label">  </label>
                                    <div class="col-lg-4 wds43" id="accountDiv">
                                        <select class="select2 wdt100" name="accountid" id="accountid" disabled="disabled">
                                            <option value="-1">اختر حساب</option>
                                        </select>
                                        <span id="accountError" class=" alert-block alert-danger fade in" style="padding: 5px 5px 5px 5px;display: none;">اختر حساب</span>
                                    </div>
                                </div>



                                <div class="form-group">
                                    <label class="col-lg-2 control-label"></label>
                                    <div class="col-lg-1 wds51">
                                        <h6 class="inline-st"><label>
                                                <input type="checkbox" name="paymentamethods[]" id="cashChecked" data-id2="cashValue"  class="choosenItem productItem changePayment" value="cash"/>
                                                كاش
                                            </label></h6>
                                    </div>
                                    <label class="col-lg-1 control-label wds13">القيمة      </label>
                                    <div class="col-lg-1">
                                        <input class="form-control positivefloat calcBillRest" name="cashValue" id="cashValue" disabled="disabled"  type="text" value="0"  />
                                    </div>


                                </div>

                                <div class="form-group ">
                                    <label class="col-lg-2 control-label bg-total color-white">الأجل</label>
                                    <div class="col-lg-6 bg-yel bg-total">
                                        <p class="form-control-static mg-tp10" id="waitValueP">0</p>
                                        <input class="form-control" name="waitValue" id="waitValue"   type="hidden" value="0"  />
                                    </div>
                                </div>


                            </div>


                        </div>

                    </div>


                    <div class="alert alert-danger"> <span class="color-white"> البضاعة المباعة لا ترد - العدسات لا ترد ولا تستبدل - المحل غير مسئول عن بقاء البضاعة لأكثر من ثلاث أشهر </span> </div>

                    <div class="form-group">
                        <div class="col-lg-12">
                            <input name="new" id="new" type="hidden" value="0" />
                            <button type="button"  data-new="1" id="saveBillNew" class="btn btn-success pull-left saveBill" >تسجيل وجديد </button>
                            <button type="button"  data-new="0" id="saveBillOnly" class="btn btn-primary pull-left saveBill">تسجيل  </button>
                        </div>

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

<!-- Modal -->
<div class="modal fade" id="myModal1" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close pull-left savemodel2" data-dismiss="modal" aria-hidden="true">&times;</button>
                <h4 class="modal-title">تعليمات شركة التأمين </h4>
            </div>
            <div class="modal-body">
                <form id="clientInfo" action="#" method="post" class="form-horizontal">
                    <div class="form-group">
                        <label for="newclientName" class="col-lg-4 control-label">اسم الشركة </label>
                        <div class="col-lg-4">
                            <p id="companyName"></p>
                        </div>
                    </div>




                    <div class="form-group">
                        <label for="clientaddress" class="col-lg-4 control-label">التعليمات</label>
                        <div class="col-lg-4">
                            <p id="instructionP"></p>
                        </div>
                    </div>



                </form>
            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-default" data-dismiss="modal">اغلاق </button>
            </div>
        </div>
        <!-- /.modal-content -->
    </div>
    <!-- /.modal-dialog -->
</div>



{literal}
<script>





</script>

{/literal}


