

<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=updatebuy" class="nameToBeChecked form-horizontal" enctype="multipart/form-data">
                    <input name="searchvalue" id="searchvalue"  type="hidden" value="{$Programsettingdata->searchvalue}" />
                    <input name="buyoptic" id="buyoptic"  type="hidden" value="1" />
                    <div id="printAll">
                        <div class="form-group">
                            <label class="col-lg-2 control-label">اسم المورد </label>
                            <div class="col-lg-4">
                                <select name="client" id="client" data-placeholder="اختر"  class="select2 wdt100 buy" >
                                    <option value="-1"> اختر </option>
                                    {foreach $clientData as $client}
                                    <option value="{$client->supplierid}" {if $bill->clientid == $client->supplierid} selected {/if}>{$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="{$bill->receivedate}" 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="{$bill->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">{$bill->comment}</textarea>
                            </div>
                        </div>

                        <div class="form-group">
                            <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="{$bill->billdate}" 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" value="{$bill->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" {if $bill->pricetype == 1 } selected {/if}>تجزئة</option>
                                        <option value="2" {if $bill->pricetype == 2 } selected {/if}>نصف جملة</option>
                                        <option value="0" {if $bill->pricetype == 0 } selected {/if}>جملة</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">
                                    <p class="form-control-static"> {if $bill->kashftype == 1} خارجى {else} داخلى  {/if}</p>
                                    <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>
                        {if $bill->kashftype == 1}
                        <div class="form-group" style="display: none">
                            <label class="col-lg-2 control-label">مكان الكشف  </label>
                            <div class="col-lg-4">
                                <input name="kashfplace" id="kashfplace" type="text"  class="form-control" value="{$bill->kashfplace}" />
                            </div>

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

                        <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="externalKashf" 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"  name="D_Lsphere"  value="{$kashf->ldsphere}"  class="form-control"   {if $bill->kashftype == 1}  {else} disabled  {/if}  /> </td>

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

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

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

                                            <td style="border: 1px solid black;"> <input   type="text" name="D_Lva"  value="{$kashf->ldva}"   class="form-control"  {if $bill->kashftype == 1}  {else} disabled  {/if}   /> </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"   value="{$kashf->lnsphere}"  class="form-control"  {if $bill->kashftype == 1}  {else} disabled  {/if}   /> </td>

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

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

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

                                            <td style="border: 1px solid black;"> <input   type="text" name="N_Lva"   value="{$kashf->lnva}"    class="form-control"  {if $bill->kashftype == 1}  {else} disabled  {/if}   /> </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"   value="{$kashf->rdsphere}"  class="form-control"  {if $bill->kashftype == 1}  {else} disabled  {/if}   /> </td>
                                            <td style="border: 1px solid black;">  <input   type="text" name="D_Rcylinder"  value="{$kashf->rdcylinder}"    class="form-control"  {if $bill->kashftype == 1}  {else} disabled  {/if}   /></td>
                                            <td style="border: 1px solid black;"> <input   type="text" name="D_Raxis"   value="{$kashf->rdaxis}"   class="form-control"   {if $bill->kashftype == 1}  {else} disabled  {/if}  /> </td>
                                            <td style="border: 1px solid black;"> <input   type="text" name="D_Rprism"   value="{$kashf->rdprism}"  class="form-control"   {if $bill->kashftype == 1}  {else} disabled  {/if}  /> </td>
                                            <td style="border: 1px solid black;">  <input   type="text" name="D_Rva"   value="{$kashf->rdva}"   class="form-control"   {if $bill->kashftype == 1}  {else} disabled  {/if}  /> </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"    value="{$kashf->rnsphere}"   class="form-control"   {if $bill->kashftype == 1}  {else} disabled  {/if}  /> </td>
                                            <td style="border: 1px solid black;">  <input   type="text" name="N_Rcylinder"   value="{$kashf->rncylinder}"  class="form-control"   {if $bill->kashftype == 1}  {else} disabled  {/if}  /> </td>
                                            <td style="border: 1px solid black;"> <input   type="text" name="N_Raxis"   value="{$kashf->rnaxis}"   class="form-control"  {if $bill->kashftype == 1}  {else} disabled  {/if}   /> </td>
                                            <td style="border: 1px solid black;"> <input   type="text" name="N_Rprism"   value="{$kashf->rnprism}"   class="form-control"  {if $bill->kashftype == 1}  {else} disabled  {/if}   /> </td>
                                            <td style="border: 1px solid black;">   <input   type="text" name="N_Rva"  value="{$kashf->rnva}"    class="form-control"   {if $bill->kashftype == 1}  {else} disabled  {/if}   /> </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"   {if $bill->kashftype == 1}  {else} disabled  {/if}   value="{$kashf->ladd}"   class="form-control" /></td>
                                            <td style="border: 1px solid black;"> <input   type="text" name="lbiofocal" id="lbiofocal"   {if $bill->kashftype == 1}  {else} disabled  {/if}    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"   {if $bill->kashftype == 1}  {else} disabled  {/if}   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"   {if $bill->kashftype == 1}  {else} disabled  {/if}   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"   {if $bill->kashftype == 1}  {else} disabled  {/if}   value="{$kashf->radd}"   class="form-control" /></td>
                                            <td style="border: 1px solid black;"> <input   type="text" name="rbiofocal" id="rbiofocal"   {if $bill->kashftype == 1}  {else} disabled  {/if}   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"  {if $bill->kashftype == 1}  {else} disabled  {/if}  name="notes" id="notes" value="{$kashf->notes}"    class="form-control" /></td>
                                        </tr>

                                    </table>
                                </div>
                            </div>
                        </div>
                        <div class="row">
                            <div class="row">
                                <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>

                            <input name="hidden_itr" id="hidden_itr" type="hidden" value="{$billProductsCount}" />
                            <input name="billId" id="billId" type="hidden" value="{$bill->id}" />
                            <!-- end of title row-->
                            <div class="table-responsive bd-gr">
                                <table class="table billtable table-bordered table-blacka" >
                                    <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">
                                        {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" {if $product->service == "single vision"} selected{/if}> single vision</option>
                                                    <option value="Hi - index" {if $product->service == "Hi - index"} selected{/if}>Hi - index </option>
                                                    <option value="Bi / Multi focal / Progressive" {if $product->service == "Bi / Multi focal / Progressive"} selected{/if}>Bi / Multi focal / Progressive </option>
                                                    <option value="Contact Lenses" {if $product->service == "Contact Lenses"} selected{/if}> Contact Lenses</option>
                                                    <option value="Frame" {if $product->service == "Frame"} selected{/if}> Frame</option-->
                                                    <option value="Single vision" {if $product->service == "Single vision"} selected{/if}>Single vision</option>
                                                    <option value="polycarbonate" {if $product->service == "polycarbonate"} selected{/if}>polycarbonate</option>
                                                    <option value="Contact lenses Plano" {if $product->service == "Contact lenses Plano"||$product->service == "Contact Lenses"} selected{/if}>Contact lenses Plano</option>
                                                    <option value="Contact lenses power" {if $product->service == "Contact lenses power"||$product->service == "Contact Lenses"} selected{/if}>Contact lenses power</option>
                                                    <option value="Sunglasses"  {if $product->service == "Sunglasses"} selected{/if}>Sunglasses</option>
                                                    <option value="Medical frame" {if $product->service == "Medical frame"||$product->service == "Frame"} selected{/if}>Medical frame</option>
                                                    <option value="Reading" {if $product->service == "Reading"} selected{/if}>Reading</option>
                                                    <option value="Accessories" {if $product->service == "Accessories"} selected{/if}>Accessories</option>
                                                    <option value="Bifocal" {if $product->service == "Bifocal"} selected{/if}>Bifocal</option>
                                                    <option value="Multifocal/Progressive" {if $product->service == "Multifocal/Progressive"||$product->service == "Bi / Multi focal / Progressive"} selected{/if}>Multifocal/Progressive</option>
                                                </select>

                                            </td>
                                            <td>
                                                <div id="productdiv{$i}">
                                                    <input type="hidden" id="product{$i}" name="product{$i}"  class="productchange wdt100" data-itr="{$i}"  data-placeholder="اختر منتج"  tabindex="7" />
                                                    <input name="billProductId{$i}" id="billProductId{$i}" type="hidden" value="{$product->id}" />
                                                    <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">{$product->note}</textarea>
                                            </td>

                                            <td>
                                                <input name="pronum{$i}" id="pronum{$i}" value="{$product->productno}"  data-itr="{$i}"  class="form-control txt-nonraduis changePrice positivefloat" placeholder="العدد" type="text" tabindex="7" />
                                                <input name="pronumOld{$i}" id="pronumOld{$i}" type="hidden" value="{$product->productno}" />
                                            </td>
                                            <td>
                                                <input name="proprice{$i}" id="proprice{$i}" placeholder="السعر"  data-itr="{$i}" value="{$product->productprice}" 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}"> {$product->producttotalprice}</span> <span> {$currency}</span></div>
                                                <input name="totalProductPrice{$i}" id="totalProductPrice{$i}" type="hidden" value="{$product->producttotalprice}" />
                                            </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}
                                    </tbody>
                                </table>
                            </div>
                            <button type="button" class="btn btn-primary pull-left ft-nor"> إجمالي المشتريات <span class="badge wht-clo">
                                    <div id="buyBillTotal">{$bill->productstotalprice}</div>
                                </span></button>

                            <input name="totalBillPrice" id="totalBillPrice" type="hidden" value="{$bill->productstotalprice}" />

                        </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">{$bill->kashfvalue}</p>
                                        <input class="form-control" name="kashfValue" id="kashfValue"   type="hidden" value="{$bill->kashfvalue}"  />
                                    </div>
                                    <label class="col-lg-2 control-label"> الخصم</label>
                                    <div class="col-lg-2">
                                        <p class="form-control-static mg-tp10" id="kashDiscValueP">{$bill->kashfdiscount}</p>
                                        <input name="kashDiscValue" id="kashDiscValue"  class="form-control" type="hidden" value="{$bill->kashfdiscount}" />
                                    </div>
                                </div>

                                <div class="form-group " style="display: none">
                                    <label class="col-lg-2 control-label bg-yel">الاجمالى  </label>
                                    <div class="col-lg-6 bg-yel">
                                        <p class="form-control-static mg-tp10" id="netBillValueP">{$bill->netbillvalue}</p>
                                        <input class="form-control" name="netBillValue" id="netBillValue"   type="hidden" value="{$bill->netbillvalue}"  />
                                    </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" {if $bill->discounttype == 1} selected {/if}>مباشر</option>
                                            <option  value="2" {if $bill->discounttype == 2} selected {/if}>نسبة</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="{$bill->discountvalue}" />
                                    </div>
                                </div>
                                <div class="form-group ">
                                    <label class="col-lg-2 control-label bg-yel">الصافى </label>
                                    <div class="col-lg-6 bg-yel">
                                        <p class="form-control-static mg-tp10" id="netValueP">{$bill->finalnetbillvalue}</p>
                                        <input class="form-control" name="netValue" id="netValue"   type="hidden" value="{$bill->finalnetbillvalue}"  />
                                    </div>
                                </div>
                            </div>
                            <div class="col-lg-12">

                                <div class="form-group">
                                    <label class="col-lg-2 control-label"> طريقة الدفع   </label>
                                    <div style="display: none">
                                        <div class="col-lg-1">
                                            <h6 class="inline-st"><label>
                                                    <input type="checkbox" {if $bill->insurance == 1}  checked  {/if}  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">


                                            {if $bill->insurance == 1}
                                            <select name="insuranceCompanies"  id="insuranceCompanies" data-placeholder="اختر" data-itr="1"  class="select2 wdt100" >
                                                <option value="-1"> اختر </option>
                                                {foreach $insuranceCompanies as $company}
                                                <option value="{$company->id}" {if $bill->insurancecompanyid == $company->id} selected{/if}>{$company->name} </option>
                                                {/foreach}
                                            </select>
                                            {else}
                                            <select name="insuranceCompanies" disabled="disabled" id="insuranceCompanies" data-placeholder="اختر" data-itr="1"  class="select2 wdt100" >
                                                <option value="-1"> اختر </option>
                                                {foreach $insuranceCompanies as $company}
                                                <option value="{$company->id}">{$company->name} </option>
                                                {/foreach}
                                            </select>
                                            {/if}
                                            <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" {if $bill->insurance == 1 && $bill->insurancecompanyid != -1} {else} style="display: none;" {/if}></span>
                                        </div>
                                    </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"     type="text"  {if $bill->insurance == 1}   value="{$bill->customerpercent}" {else} value="0" disabled="disabled" {/if}   />
                                    </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"     type="text" {if $bill->insurance == 1}   value="{$bill->customermax}" {else} value="0" disabled="disabled" {/if}   />
                                    </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"    type="text"  {if $bill->insurance == 1}   value="{$bill->customercarry}" {else} value="0" disabled="disabled" {/if}  />
                                    </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"     type="text"  {if $bill->insurance == 1}   value="{$bill->companyaccept}" {else} value="0" disabled="disabled" {/if}  />
                                    </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"   type="text" {if $bill->insurance == 1}   value="{$bill->companycarry}" {else} value="0" disabled="disabled" {/if}  />
                                    </div>

                                    <label class="col-lg-1 control-label wds13">رقم الموافقة </label>
                                    <div class="col-lg-1">
                                        <input class="form-control" name="approvalNo" id="approvalNo"    type="text" {if $bill->insurance == 1}   value="{$bill->approvalno}" {else} value="" disabled="disabled" {/if} />
                                    </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" {if $bill->insurance != 1}disabled="disabled"{/if}/>
                                        <span id="attatchError" class=" alert-block alert-danger fade in" style="padding: 1px 5px 5px 5px;display: none;">اختر الصورة</span>
                                        <input type="hidden" name="oldattatch" id="oldattatch"  value="{$bill->attatch}" />
                                        {if $bill->attatch !=""}<a href="../views/default/images/billsattatch/{$bill->attatch}" style="color: blue;" target="_blank"><u>عرض الصورة</u></a>{/if}
                                    </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" {if $bill->card == 1}  checked  {/if} 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">
                                        {if $bill->card == 1}
                                        <select name="paymentNetworks"  id="paymentNetworks" data-placeholder="اختر" data-itr="1"  class="select2 wdt100" >
                                            <option value="-1"> اختر </option>
                                            {foreach $bankData as $network}
                                            <option value="{$network->bankid}" {if $bill->paymentnetworkid == $network->bankid} selected{/if}>{$network->bankname} </option>
                                            {/foreach}
                                        </select>
                                        {else}
                                        <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>
                                        {/if}

                                        <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"   type="text"{if $bill->card == 1}   value="{$bill->cardvalue}" {else} value="0" disabled="disabled" {/if}   />
                                    </div>

                                </div>

                                <div class="form-group">
                                    <label class="col-lg-3 control-label">  </label>
                                    <div class="col-lg-4 wds43" id="accountDiv">
                                        {if $bill->card == 1}
                                        <select class="select2 wdt100" name="accountid" id="accountid">
                                            <option value="-1">اختر حساب</option>
                                            {foreach $accountsData as $account}
                                            <option value="{$account->accountid}" {if $bill->netdiscountpercent == $account->accountid} selected{/if}>{$account->accountname} </option>
                                            {/foreach}
                                        </select>
                                        {else}
                                        <select class="select2 wdt100" name="accountid" id="accountid" disabled="disabled">
                                            <option value="-1">اختر حساب</option>
                                        </select>
                                        {/if}
                                        <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" {if $bill->cash == 1}  checked  {/if}  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" {if $bill->cash == 1}   value="{$bill->cashvalue}" {else} value="0" disabled="disabled" {/if} name="cashValue" id="cashValue"   type="text"   />
                                    </div>


                                </div>

                                <div class="form-group ">
                                    <label class="col-lg-2 control-label bg-yel">الأجل</label>
                                    <div class="col-lg-6 bg-yel">
                                        <p class="form-control-static mg-tp10" id="waitValueP">{$bill->waitvalue}</p>
                                        <input class="form-control" name="waitValue" id="waitValue"   type="hidden" value="{$bill->waitvalue}"  />
                                    </div>
                                </div>


                            </div>


                        </div>





                    </div>




                    <div class="form-group">
                        <div class="col-lg-12">
                            <input name="new" id="new" type="hidden" value="0" />
                            <input name="edit" id="edit" type="hidden" value="1" />
                            <input name="controllName" id="controllName" type="hidden" value="bills" />
                            <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>


<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">{$bill->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">{$instruction}</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>

</div></div>

