<form  method="post" id="billForm" action="?do=add" 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}" />
    {if $isProductRequest == 1 }
    <input name="productRequestIds" id="productRequestIds"  type="hidden" value="{$productRequestIds}" />
    {/if}

    <div id="printAll">
        <div class="form-group">
            <label class="col-lg-2 control-label">اسم العميل </label>
            <div class="col-lg-4" id="clientDiv">
                <select name="client" id="client" data-placeholder="اختر"  class="select2 wdt100" >
                    <option value="-1"> اختر </option>
                    <option value="-2" class="newoption"> اضافه عميل </option>
                    {foreach $clientData as $client}
                    <option value="{$client->clientid}">{$client->clientname} </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">
                <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 class="form-group">

            <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>

            <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>

        <div class="form-group">
            {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: 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 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">R_sphere</label> </td>
                            <td style="padding-right: 22px;" > <label class="sr-only">R_cylinder</label> </td>
                            <td style="padding-right: 36px;" > <label class="sr-only">R_axis</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_va</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: 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 style="border: 1px solid black;"> <label class="sr-only">المسافة</label> </td>
                            <td style="border: 1px solid black;">  <input   type="text" name="D_Lva"  required="required"  class=" checknumintfolat form-control  " /></td>
                            <td style="border: 1px solid black;"> <input   type="text" name="D_Lprism"  required="required"   class="form-control  checknumintfolat  " /></td>
                            <td style="border: 1px solid black;"> <input   type="text" name="D_Laxis"    required="required"  class="form-control checknumintfolat " /></td>
                            <td style="border: 1px solid black;"> <input   type="text" name="D_Lcylinder" required="required"  class="form-control checknumintfolat " /></td>
                            <td style="border: 1px solid black;"> <input  type="text"  name="D_Lsphere"  required="required"  class="form-control checknumintfolat " /></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_Lva"   required="required"  class="form-control checknumintfolat" /></td>

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

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

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

                            <td style="border: 1px solid black;"> <input   type="text" name="N_Lsphere" required="required"  class="form-control checknumintfolat" /></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: 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 style="border: 1px solid black;">  <input   type="text" name="D_Rva"    class="form-control   checknumintfolat" required="required" /> <div id="valueError" style="display:none;"></div></td>

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

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


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

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


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


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

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

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

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

                            <td style="border: 1px solid black;">  <input required="required"  type="text" name="N_Rsphere"     class="form-control checknumintfolat" /></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" required="required"  class="form-control checknumintfolat" /></td>
                            <td style="border: 1px solid black;"> <input   type="text" name="lbiofocal"  required="required"  class="form-control checknumintfolat" /></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"  required="required"   class="form-control  checknumintfolat" /></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" required="required"   class="form-control checknumintfolat" /></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"  required="required"  class="form-control checknumintfolat" /></td>
                            <td style="border: 1px solid black;"> <input   type="text" name="rbiofocal"   required="required"  class="form-control checknumintfolat" /></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  required="required"  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 class="wdt400">اسم المنتج</th>
                            <th class="wdt240">ملاحظات</th>
                            <th class="wdt100n">العدد</th>
                            <th class="wdt80">السعر</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 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 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 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">

                    <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 ">
                    <label class="col-lg-2 control-label bg-total color-white">الاجمالى  </label>
                    <div class="col-lg-6  color-white 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-total">الصافى </label>
                    <div class="col-lg-6 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">
                        <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">
                        <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">
                    <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">
                    <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">
                    <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 $paymentNetworks as $network}
                            <option value="{$network->id}">{$network->name} </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-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">الأجل</label>
                    <div class="col-lg-6 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" />
            <input name="directSave" id="directSave" type="hidden" value="0" />
            <button type="button"  data-new="1" data-direct="0" id="saveBillNew"  class="btn btn-success pull-left saveBill" >تسجيل وجديد </button>
            <button type="button"  data-new="0" data-direct="0" id="saveBillOnly" class="btn btn-primary pull-left saveBill">تسجيل  </button>
            {if $directSave == 1}
            <button type="button"  data-new="0" data-direct="1" id="saveBillNewDirect" onclick="if (Spry.Widget.Form.validate(this))" class="btn btn-primary pull-left saveBill" >حفظ مباشر</button>
            {/if}
        </div>

    </div>
</form>