
<div class="row">
    <div class="container">
        <ol class="breadcrumb">
            <li><a href="#">ايصالات دفع</a></li>
            <li><a href="#">تعديل ايصال دفع</a></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"> {literal}
                <form class="form-horizontal" action="?do=update" method="post">
                    <!--validate the form before checking name-->
                    {/literal}

                    <input type="hidden" name="supplierdebtchangeid" value="{$supplierdebtchangeData->supplierdebtchangeid}"/>


                    <input type="hidden" name="supPayId" value="{$supPayData->id}"/>


                    <input type="hidden" name="oldSupplierId" value="{$supplierdebtchangeData->supplierid}"/>
                    <input type="hidden" name="oldSupplierAmount" value="{$supplierdebtchangeData->supplierdebtchangeamount}"/>
                    <input type="hidden" name="oldSupplierAfter" value="{$supplierdebtchangeData->supplierdebtchangeafter}"/>


                    <div class="form-group">

                        <label class="col-lg-2 control-label">اسم المورد</label>
                        <div class="col-lg-4"> <span id="spryselect1">
                                <select name="supplierid" id="supplierid" data-placeholder="اختر اسم المورد:" class="select2 wdt100">
                                    <option value="-1"> اختر مورد</option>





                                    {foreach $suppliersData as $data }

                                    {if $data->supplierid eq $supplierdebtchangeData->supplierid }
                                    <option value="{$data->supplierid}" selected>{$data->suppliername}</option>
                                    {else}

                                    <option value="{$data->supplierid}">{$data->suppliername}</option>

                                    {/if}
                                    {/foreach}




                                </select>
                                <span class="selectInvalidMsg">اختر اسم المورد</span><span class="selectRequiredMsg">اختر اسم المورد.</span></span> </div>
                    </div>

                    <!--==============================-->

                    <div class="form-group">
                        <label class="col-lg-2 control-label">تاريخ سداد اخر عمليه</label>
                        <div class="col-lg-4">



                            <input name="lastDate" type="text" id="lastDate" readonly="readonly" value="{foreach $suppliersData as $data }{if $data->supplierid eq $supplierdebtchangeData->supplierid }{$data->supplierdate} {/if}{/foreach}"  class="form-control" />




                        </div>
                    </div>

                    <!--==============================-->

                    <div class="form-group">
                        <label class="col-lg-2 control-label">تاريخ السداد الحالى</label>
                        <div class="col-lg-4">
                            <input name="currentDate" id="currentDate" type="text" value="{$supplierdebtchangeData->supplierdebtchangedate}"  class="form-control awdatepicker" autocomplete="off"   data-date-format="yyyy-mm-dd"  //>
                        </div>
                    </div>

                    <!--==============================-->
                    <input name="suplliernegative" type="hidden" value="{$suplliernegative}"  id="suplliernegative"/>
                    <div class="form-group">
                        <label class="col-lg-2 control-label">الدين السابق</label>
                        <div class="col-lg-4">
                            <div class="input-group">

                                <input name="debtBefore" id="debtBefore" type="text" readonly="readonly" value="{$supplierdebtchangeData->supplierdebtchangebefore}" class="form-control"/>

                                <span class="input-group-addon">{$currency}</span> </div>
                        </div>
                    </div>

                    <!--==============================-->

                    <div class="form-group">
                        <label class="col-lg-2 control-label">المدفوع</label>
                        <div class="col-lg-4">
                            <div class="input-group"> <span id="sprytextfield3">
                                    <input type="text" name="payedDept" id="payedDept" value="{$supplierdebtchangeData->supplierdebtchangeamount}" onkeyup="populateDebtAfter();
                                            submitform();" class="numberinput form-control"  />
                                    <span class="textfieldRequiredMsg">*</span><span class="textfieldInvalidFormatMsg">ادخل رقم</span></span> <span class="input-group-addon">{$currency}</span> </div>
                        </div>
                    </div>

                    <!--==============================-->

                    <div class="form-group">
                        <label class="col-lg-2 control-label">الدين الحالى</label>
                        <div class="col-lg-4">
                            <div class="input-group">
                                <input type="text" name="debtAfter"  value="{$supplierdebtchangeData->supplierdebtchangeafter}" id="debtAfter" class="form-control" />
                                <span class="input-group-addon">{$currency}</span> </div>
                        </div>
                    </div>

                    <!--==============================-->
                    <input type="hidden" name="Add" value="1"/>

                    <!--==============================-->

                    <div class="form-group">
                        <label class="col-lg-2 control-label">نوع الصرف </label>
                        <div class="col-lg-4">

                            <div class="radio-inline">

                                <label>
                                    <input name="paytype" type="radio" id="paytype1" value="0" onChange="getdata();" {if $supPayData->paytype  eq 0 } checked="checked" {/if}/>
                                    خزنة </label>
                            </div>

                            <div class="radio-inline">


                                <label>
                                    <input name="paytype" type="radio"  id="paytype2"  value="1"  onchange="getdata();"{if $supPayData->paytype  eq 1 } checked="checked" {/if}/>
                                    شيك </label>

                            </div>

                        </div>

                    </div>

                    <!--==============================-->
                    <!--===============  Start checkdata div  ===============-->
                    <div id="checkdata" {if $supPayData->paytype  eq 0 } style="display:none" {/if} >

                        <!--==============================-->
                        <div class="form-group">
                            <label class="col-lg-2 control-label">سحب على بنك</label>
                            <div class="col-lg-4">
                                <input type="text" value="{$supPayData->senderbank}" name="sendBank" {if $supPayData->paytype  eq 1} required {/if} id="sendBank"  class=" form-control"/>
                            </div>
                        </div>

                        <!--==============================-->
                        <div class="form-group">
                            <label class="col-lg-2 control-label">إسم البنك</label>
                            <div class="col-lg-4">
                                <div id="bankdiv">
                                    <select name="ddlBank" id="ddlBank" onChange="load1();"  class="select2 wdt100">
                                        <option value="-1">اختر بنك</option>





                                        {foreach $bank as $b}


                                        <option value="{$b->bankid}" {if $b->bankid eq $supPayData->bankid}selected{/if}>{$b->bankname}</option>
                                        {/foreach}


                                    </select>
                                </div>
                            </div>
                        </div>
                        <!--==============================-->

                        <div class="form-group">
                            <label class="col-lg-2 control-label">إسم الحساب </label>
                            <div class="col-lg-4"> <span id="spryselect3">
                                    <div id="sss">
                                        <label for="ddlAccount"></label>
                                        <select name="accountid" id="ddlAccount" class="select2 wdt100">
                                            {foreach $bankaccount as $acc}
                                            {if $acc->bankid eq $supPayData->bankid}
                                            <option value="{$acc->accountid}"{if $acc->accountid eq $supPayData->accountid }selected {/if}>{$acc->accountname}</option>
                                            {/if}



                                            {/foreach}

                                        </select>
                                        <!--<p id="result">&nbsp;</p>-->
                                    </div>
                                </span> <span> <span class="selectInvalidMsg">يرجى إختيار حساب</span><span class="selectRequiredMsg">يرجى إختيار حساب</span></span> </div>
                        </div>

                        <!--==============================-->

                        <!--===============  Start ddd div  ===============-->
                        <div id="ddd">
                            <div class="form-group">

                                <label class="col-lg-2 control-label">رقم الحساب</label>
                                <div class="col-lg-4">
                                    {foreach $bankaccount as $acc}
                                    {if $acc->accountid eq $supPayData->accountid}
                                    <input type="text" value="{$acc->accountnumber}"  name="accountnumberDis" id="accountnumberDis"  class=" form-control" readonly="readonly"/>
                                    <input type="hidden" value="{$acc->accountnumber}" name="accountnumber" id="accountnumber"/>

                                    {/if}
                                    {/foreach}


                                </div>
                            </div>

                            <!--==============================-->
                            <div class="form-group">
                                <label class="col-lg-2 control-label">رصيد سابق</label>
                                <div class="col-lg-4">
                                    <div class="input-group">
                                        {foreach $bankaccount as $acc}
                                        {if $acc->accountid eq $supPayData->accountid}
                                        <input type="text" value="{$acc->accountbeginingbalance}" name="accountbeginingbalanceDis" id="accountbeginingbalanceDis" class=" form-control" readonly/>
                                        <span class="input-group-addon">{$currency}</span>
                                        <input type="hidden" value="{$acc->accountbeginingbalance}" name="accountbeginingbalance" id="accountbeginingbalance"/>
                                        {/if}
                                        {/foreach}
                                    </div>
                                </div>
                            </div>

                            <!--==============================-->

                        </div>
                        <!--===============  End ddd div  ===============-->
                        <div class="form-group">
                            <label class="col-lg-2 control-label">رقم الشيك</label>
                            <div class="col-lg-4"> <span id="sprytextfield5">
                                    <input type="hidden"  name="txtcheckNum" id="txtcheckNum" class="form-control"/>
                                    <input type="text"  value="{$supPayData->checkno}" name="txtcheckNum" id="txtcheckNum" class="form-control"/>
                                    <span class="textfieldRequiredMsg">*</span><span class="textfieldInvalidFormatMsg">يرجى إدخال قيمة صحيحة</span></span> </div>
                        </div>

                        <!--==============================-->


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

                        <!--==============================-->

                        <div class="form-group">
                            <label for="email" class="col-lg-2 control-label">صورة الشيك</label>
                            <div class="col-lg-4">
                                <input type="file" name="logo" id="logo" value="{$supPayData->chckimage}" class="form-control"  />
                                <input type="hidden" name="oldlogo" id="logo" value="{$supPayData->chckimage}" class="form-control" />

                            </div>
                        </div>

                        <!--==============================-->

                        <div class="form-group">
                            <label class="col-lg-2 control-label">إسم المستفيد</label>
                            <div class="col-lg-4">
                                <input type="text" value="{$supPayData->beneficiaryname}" name="txtUser" id="txtUser"  class=" form-control"/>
                            </div>
                        </div>

                        <!--==============================-->

                        <div class="form-group">
                            <label class="col-lg-2 control-label">رصيد الحساب بعد التحصيل</label>
                            <div class="col-lg-4">
                                <div class="input-group">
                                    {foreach $bankaccount as $acc}
                                    {if $acc->accountid eq $supPayData->accountid}
                                    <input type="text" readonly value=" {$acc->accountbeginingbalance + $supplierdebtchangeData->supplierdebtchangeamount}"  name="txtAmount" id="txtAmount"  class=" form-control"/>

                                    {/if}
                                    {/foreach}
                                    <span class="input-group-addon">{$currency}</span> </div>
                            </div>
                        </div>

                        <!--==============================-->

                        <div class="form-group">
                            <label class="col-lg-2 control-label">وذلك لقيمة</label>
                            <div class="col-lg-4">
                                <textarea name="textNote"   id="textNote" class=" form-control" cols="45" rows="5">{$supPayData->details}</textarea>
                            </div>
                        </div>

                        <!--==============================-->

                    </div>

                    <div class="form-group">
                        <div class="col-lg-offset-2 col-lg-4">
                            <button name="btnAdd" type="submit" id="btnAdd" class="btn btn-primary pull-left">تعديل</button>
                        </div>
                    </div>
                </form>
            </div>
        </div>
    </div>
</div>
{literal}
<script type="text/javascript">
    var sprytextfield1 = new Spry.Widget.ValidationTextField("sprytextfield1");
    var sprytextfield2 = new Spry.Widget.ValidationTextField("sprytextfield2", "real");
    var spryselect1 = new Spry.Widget.ValidationSelect("spryselect1", {invalidValue: "-1"});
    var sprytextfield3 = new Spry.Widget.ValidationTextField("sprytextfield3", "real");
    var spryselect2 = new Spry.Widget.ValidationSelect("spryselect2", {invalidValue: "-1"});
</script>
{/literal}

{literal}
<script type="text/javascript">
    jQuery(function () {
        $("form").submit(function () {
// submit more than once return false
            $(this).submit(function () {
                return false;
            });
// submit once return true
            return true;
        });
    });
</script>
{/literal}