<div class="row">
    <div class="container">

        <ol class="breadcrumb">
            <li><a href="#">نظام المطالبة</a></li>
            <li><a href="claimdebtController.php?do=show">عرض  تحصيلات المطالبات</a></li>
            <li class="active">تعديل </li>
        </ol>
        <div class="panel panel-default panel-m">
            <div class="panel-heading">
                <h3 class="panel-title">تعديل </h3>
            </div>
            <div class="panel-body">
                {literal}
                <form class="form-horizontal" action="claimdebtController.php" id="claimformajax" method="post"
                    enctype="multipart/form-data" data-dosave="?do=savedata" data-direction="">

                    {/literal}


                    <div class="form-group">
                        <label for="txtName" class="col-lg-2 control-label">المطالبات </label>
                        <div class="col-lg-4">
                            <input id="claimid" type="text"  name="claimid" class="getselectjoin claimid"  data-placeholder=" اختر     "   data-table="claims" data-tableid="id"   disabled=""
                            data-join="  "  data-filter=" and claims.del < 2 and claims.stoptrue = 1 and claims.debttrue = 0 "
                            data-parent="" data-itr=""  data-search="id,'/',claim_number,'/',claim_value"/>  
                            <input type="hidden" class="selectedit" data-id="{$claim->id}" data-text="{$claim->id}/{$claim->claim_number}/{$claim->claim_value}"  data-table="claimid" />
                             <input type="hidden" name="claimid" value="{$claim->id}" />
                          
                        </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"  name="paymethod" id="pmsave" class="pmethod" type="radio" {if 0 == $claimdebt->paymethod}checked="checked"{/if} />خزنة </label>
                            </div>
                            <div class="radio-inline">
                                <label>
                                    <input value="1" name="paymethod" id="pmbank" class="pmethod" type="radio"
                                    {if 1  == $claimdebt->paymethod}checked="checked"{/if}  />بنك</label>
                            </div>
                        </div>
                    </div>


                    <div id="save-div" {if $claimdebt->paymethod == 1} style="display: none;"  {/if} >
                        {if $searchinonesave == 1}
                        <input type="hidden" name="saveid" id="saveid" value="{$allSave}" />
                        {else}
                        <div class="form-group">
                            <label class="col-lg-2 control-label">خزنة</label>
                            <div class="col-lg-4">
                                <select name="saveid" id="saveid" class="select2">
                                    <option value="-1">اختر</option>
                                    {foreach $allSave as $data}
                                    <option value="{$data.saveid}" {if  $claimdebt->saveid == $data.saveid}selected{/if}>{$data.savename}</option>
                                    {/foreach}
                                </select>
                            </div>
                        </div>
                        {/if}
                    </div>  

                    <div id="bank-div" {if $claimdebt->paymethod == 0} style="display: none;"  {/if} >
                        <div class="form-group">
                            <label class="col-lg-2 control-label">بنك</label>
                            <div class="col-lg-4">
                                <span id="spryselect4">
                                    <select name="bankid"  id="bankid" class="select2" data-placeholder="اختر البنك">
                                        <option value="-1">اختر</option>
                                        {foreach $banks as $data}
                                        <option value="{$data.bankid}"  {if $claimdebt->bankid == $data.bankid}selected{/if}>{$data.bankname}</option>
                                        {/foreach}
                                    </select>
                                    <span class="selectInvalidMsg">{$smarty.const.EXPENSES_CHOOSE_ELBANK}</span></span>
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-lg-2 control-label">الحساب</label>
                            <div class="col-lg-4">
                                <span id="spryselect5">

                                    <input id="bankaccountid" type="text"  name="bankaccountid" class="getselectjoin bankaccountid"  data-placeholder=" اختر الحساب     "   data-table=" bankaccount" data-tableid="accountid"  data-join=""  data-filter=" and bankaccount.conditions = 0 "  data-parent="bankid" data-itr=""  data-search="accountname,'/',accountnumber" value="{$claimdebt->bankaccountid}" />  
                                   
                                    <span class="selectInvalidMsg">{$smarty.const.EXPENSES_CHOOSE_ACCOUNT}</span></span>
                            </div>
                        </div>
                    </div>




                    <div class="form-group">
                        <label for="txtName" class="col-lg-2 control-label">قيمة المطالبة    </label>
                        <div class="col-lg-4"> <span id="sprydate">
                                <input required="required" type="text" name="claim_value" 
                                class="form-control  nummbers" placeholder="" readonly 
                                data-table="claims" id="claim_value" data-tableid="" data-parentid=""
                                data-parentcol="" value="{$claimdebt->claim_value}" />
                                <span class="textfieldRequiredMsg">*</span></span>
                        </div>
                    </div>


                    <div class="form-group">
                        <label for="txtName" class="col-lg-2 control-label">رقم المعملة     </label>
                        <div class="col-lg-4"> <span id="sprydate">
                                <input required="required" type="text" name="transaction_number" 
                                class="form-control  checkcolumn nummbers" placeholder="" 
                                data-table="claimdebts" id="transaction_number" data-tableid="" data-parentid=""
                                data-parentcol="" value="{$claimdebt->transaction_number}"  />
                                <span class="textfieldRequiredMsg">*</span></span>
                        </div>
                    </div>


                    <div class="form-group">
                        <label for="txtName" class="col-lg-2 control-label">الخصم    </label>
                        <div class="col-lg-4"> <span id="sprydate">
                                <input required="required" type="text" name="direct_debit" 
                                class="form-control  nummbers" placeholder=""  
                                data-table="claimdebts" id="direct_debit" data-tableid="" data-parentid=""
                                data-parentcol="" value="{$claimdebt->direct_debit}" />
                                <span class="textfieldRequiredMsg">*</span></span>
                        </div>
                    </div>

                     <div class="form-group">
                        <label for="txtName" class="col-lg-2 control-label">نسبة الضريبه    </label>
                        <div class="col-lg-4"> <span id="sprydate">
                                <input required="required" type="text" name="tax_rate" 
                                class="form-control  nummbers" placeholder=""  
                                data-table="claimdebts" id="tax_rate" data-tableid="" data-parentid=""
                                data-parentcol="" value="{$claimdebt->tax_rate}" />
                                <span class="textfieldRequiredMsg">*</span></span>
                        </div>
                    </div>

                     <div class="form-group">
                        <label for="txtName" class="col-lg-2 control-label">الضريبة    </label>
                        <div class="col-lg-4"> <span id="sprydate">
                                <input required="required" type="text" name="direct_tax" 
                                class="form-control  nummbers" placeholder=""   readonly="" 
                                data-table="claimdebts" id="direct_tax" data-tableid="" data-parentid=""
                                data-parentcol="" value="{$claimdebt->direct_tax}" />
                                <span class="textfieldRequiredMsg">*</span></span>
                        </div>
                    </div>

                    <div class="form-group">
                        <label for="txtName" class="col-lg-2 control-label">التعليق</label>
                        <div class="col-lg-4">
                            <textarea class="form-control" name="claim_debtcomment" rows="2" placeholder="">{$claimdebt->claim_debtcomment}</textarea>
                        </div>
                    </div>


                    <input type="hidden" name="claimdebtid" id="claimdebtid" value="{$claimdebt->id}" />
                  <!--   {if $charitydata->del neq 5}
                    <input type="hidden" class="deldata" value="{$charitydata->del}" />
                    {/if} -->



                    {if $claimdebt->del lt 2}
                    <div class="form-group">
                        <div class="col-lg-offset-2 col-lg-4">
                            <button type="button" class="btn btn-primary pull-left saveformajax" data-form="claimformajax" data-action="0">تعديل </button>
                        </div>
                    </div>
                    {/if}
                </form>
            </div>
        </div>
    </div>
</div>
<script type="text/javascript">
    $(document).ready(function () {
        // deldata();
        // selecteditMulti();
          selectedit2();

        $('.pmethod').live('change', function () {
            if ($(this).val() == 0) {
                $('#save-div').show();
                 $('#bank-div').hide();
            } else {
                $('#save-div').hide();
                 $('#bank-div').show();
            }
        });

        
        $('#tax_rate').live('change', function () {
            var claim_value = Number($('#claim_value').val());
            var direct_debit = Number($('#direct_debit').val());
            var tax_rate = Number($(this).val());
            $('#direct_tax').val(((claim_value - direct_debit) * tax_rate) / 100);
        });
    });
</script>