

<script>

    function checkserail()
    {
        var serail = document.getElementById("voucher").value;
//alert(serail);
//alert('clientPayedDeptControllerAjax.php.php?do=checkserail&serail='+serail);

        $.ajax({
            url: 'supplierPayedDeptControllerAjax.php?do=checkserail&serail=' + serail,
            success: function (x) {
                //alert(x);

                if (x == '1')
                {

                    alert('عفوا هذا الرقم موجود من قبل');
                    document.getElementById("voucher").value = document.getElementById("oldvoucher").value;
                    //document.getElementById("subbtn").style.display='none';

                } else
                {
                    //document.getElementById("subbtn").style.display='block'
                }

            }
        });

    }



</script>
<div class="row">
    <div class="container">
        <ol class="breadcrumb">
            <li><a href="supplierPayedDeptController.php">خصائص عامة</a></li>
            <li><a href="supplierPayedDeptController.php?do=show">الموردين</a> </li>
            <!--<li><a href="clientPayedDeptController.php?do=show">العملاء</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"> {literal}
                <form id="mySupPayForm" class="form-horizontal" action="supplierPayedDeptController.php?do=add" method="post">
                    <!--validate the form before checking name-->
                    {/literal}
                    <div class="form-group" style="display:none">
                        <label  class="col-lg-2 control-label">اختر  عميل اومورد </label>
                        <div class="col-lg-4">
                            <input type="radio" class="clientorsupplier" id="supplier" name="clientorsupplier" value="1" checked>
                            <label for="supplier">مورد</label>
                            <input type="radio" class="clientorsupplier" id="client" name="clientorsupplier" value="2">
                            <label for="client">عميل  </label>

                        </div>
                    </div>
                    <div class="form-group supplierform">
                        <label class="col-lg-2 control-label">اسم المورد</label>
                        <div class="col-lg-4">
                            <select name="supplierid" id="supplierid" data-placeholder="اختر اسم المورد:" class="select2 wdt100">
                                <option value="-1"> اختر مورد</option>
                                {foreach $suppliersData as $data }
                                <option value="{$data->supplierid}">{$data->suppliername}</option>
                                {/foreach}
                            </select>
                            <div id="suppError" style="display:none;"></div>
                        </div>
                    </div>
                    <div class="form-group clientform"  style="display: none;">
                        <label for="partnerid" class="col-lg-2 control-label">العميل</label>
                        <div class="col-lg-4">
                            <select class="select2Supp wdt100" name="clientid" id="clientid">
                                <option value="-1">اختر عميل</option>
                                {foreach $clientsData as $data }
                                <option value="{$data->clientid}" data-mobile="{$data->clientmobile}">{$data->clientname}</option>
                                {/foreach}
                            </select>
                            <div id="clientError" style="display:none;"></div>

                        </div>

                    </div>
                    <div class="form-group" {if $Programsettingdata->costcenter eq 0} {else} style="display:none" {/if}  >
                        <label class="col-lg-2 control-label">مركز التكلفه</label>
                        <div class="col-lg-4">
                            <select class="select2 wdt100" name="Costcenterid" id="Costcenterid" >
                                <option value="-1" >اختر مركز التكلفه</option>
                                {foreach $allCostcenter as $myallCostcenter}
                                <option value="{$myallCostcenter->id}" {if $myallCostcenter->id eq $projectid}selected=""{/if}>{$myallCostcenter->name}</option>
                                {/foreach}
                            </select>
                        </div>
                    </div>

                    <div class="form-group saveorbankform">
                        <label class="col-lg-2 control-label">اختر خزنه او بنك </label>
                        <div class="col-lg-4">
                            <input type="radio" class="saveorbank" name="saveorbank" value="1"
                                   checked>
                            <label for="client">خزنه</label>
                            <input type="radio" class="saveorbank" name="saveorbank" value="2">
                            <label for="supplier">بنك</label>
                        </div>
                    </div>

                    <div class="saveshow">
                        {if $userData->searchinonesave eq 0}
                        <div class="form-group">
                            <label class="col-lg-2 control-label">الخزنة</label>
                            <div class="col-lg-4">
                                <select class="select2 wdt100" name="saveid" id="saveid">
                                    {foreach $allSave as $data}
                                    <option value="{$data->saveid}" data-curr="{$data->currencyId}" {if $userData->saveid == $data->saveid}selected{/if}>{$data->savename} {if $Programsettingdata->showCurrency == 1}- {$data->currencyName}{/if}</option>
                                    {/foreach}
                                </select>
                            </div>
                        </div>
                        {else}
                        <div class="form-group">
                            <label for="inputEmail1" class="col-lg-2 control-label">الخزنة</label>
                            <div class="col-lg-4">
                                {foreach $allSave as $data}
                                {if $userData->saveid == $data->saveid}{$data->savename} {if $Programsettingdata->showCurrency == 1}- {$data->currencyName}{/if}{/if}
                                <input type="hidden" name="saveid" id="saveid" value="{$userData->saveid}"/>
                                {/foreach}

                            </div>
                        </div>
                        {/if}
                        <div class="form-group">
                            <label for="lastDate" class="col-lg-2 control-label">رقم الايصال </label>
                            <div class="col-lg-4">
                                <input type="text" name="voucher" id="voucher" readonly=""  onkeyup="checkserail();" value="{$todayx}" class="form-control" />
                                <div id="voucherError" style="display:none;"></div>
                            </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"  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="{$today}"  class="form-control {if $Programsettingdata->allowdateedit != 1}awdatepicker{/if}" autocomplete="off"  {if $Programsettingdata->allowdateedit == 1}readonly="readonly"{/if} data-date-format="yyyy-mm-dd"  //>-->
                                {if $Programsettingdata->allowdateedit != 1}
                                <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="{$today}" name="currentDate" id="currentDate" 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>
                                {else}
                                <input name="currentDate" id="currentDate" type="text" value="{$today}"  class="form-control" autocomplete="off" readonly="readonly" />
                                {/if}
                            </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" class="form-control"/>
                                    <span class="input-group-addon">{$currency}</span> </div>
                            </div>
                        </div>

                        <!--==============================-->
                        <div class="form-group"  {if $Programsettingdata->showCurrency != 1}style="display:none;"{/if}>
                            <label class="col-lg-2 control-label">العملة</label>
                            <div class="col-lg-4">
                                <span id="spryselect1">
                                    <select class="select2" name="currencyId" id="currencyId">
                                        {foreach $allCurrency as $data}
                                        <option value="{$data->id}" data-cfactor="{$data->conversionFactor}" data-othercfactor="{$data->otherconversionFactor}">{$data->name}</option>
                                        {/foreach}
                                    </select>
                                    <span class="selectRequiredMsg">*</span></span>
                            </div>
                        </div>
                        <div class="form-group"  {if $Programsettingdata->showCurrency != 1}style="display:none;"{/if}>
                            <label class="col-lg-2 control-label">معامل التحويل</label>
                            <div class="col-lg-4">
                                <input type="text" name="cFactor" id="cFactor" class="form-control positivefloat calcOther" onkeyup="populateDebtAfter();" style="display: inline-block;width: 35%"/>
                                =
                                <div class="input-group" style="display: inline;">
                                    <input type="text" name="otherCFactor" id="otherCFactor" class="form-control positivefloat calcOther" style="display: inline-block;width: 35%"/>
                                    <span class="input-group-addon" style="display: inline-block;width: 24%">{$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="payedDeptCurr" id="payedDeptCurr"  onkeyup="populateDebtAfter('payedDeptCurr');" class="{if $suplliernegative==1}numberinput{else}positivefloat{/if} form-control"  />
                                    <span class="input-group-addon" id="currencyText">{$currency}</span>
                                </div>
                                <div id="valueError" style="display:none;"></div>
                            </div>
                        </div>
                        <div class="form-group"  {if $Programsettingdata->showCurrency != 1}style="display:none;"{/if}>
                            <label class="col-lg-2 control-label">المدفوع بالعملة الرئيسية</label>
                            <div class="col-lg-4">
                                <div class="input-group">
                                    <input type="text" name="payedDept" id="payedDept" onkeyup="populateDebtAfter('payedDept');"  class="{if $suplliernegative==1}numberinput{else}positivefloat{/if} 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">
                                    <input type="text" name="debtAfter" disabled id="debtAfter" class="form-control" />
                                    <span class="input-group-addon">{$currency}</span> </div>
                            </div>
                        </div>

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


                        <div class="form-group clientform" style="display:none;">
                            <label class="col-lg-2 control-label">المندوب</label>
                            <div class="col-lg-4">
                                <select class="select2 wdt100" name="seller" id="seller">
                                    <option value=""></option>
                                    {foreach $sellers as $data}
                                    <option value="{$data->userid}">{$data->employeename}</option>
                                    {/foreach}
                                </select>
                            </div>
                        </div>

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


                        <div class="form-group">
                            <label for="debtAfter" class="col-lg-2 control-label">التعليق</label>
                            <div class="col-lg-4">
                                <div class="input-group">
                                    <textarea style="width: 358px;" name="comment" cols="50" rows="5"  class="form-control"></textarea>
                                </div>
                            </div>
                        </div>
                    </div>
                    <!--end Save-->

                    <!--bank-->
                    <div class="bankshow" style="display: none;">
                        <div class="form-group">
                            <label for="ddlBank" class="col-lg-2 control-label">البنك</label>

                            <div class="col-lg-4">

                                <select class="select2 wdt100" name="ddlBank" id="ddlBank"
                                        onchange="loadAccount(this.value);">
                                    <option value="-1">اختر بنك</option>

                                    {foreach $bank as $b}
                                    <option value="{$b->bankid}">{$b->bankname}</option>
                                    {/foreach}

                                </select>
                                <div id="bankerror">

                                </div>
                            </div>
                            <div class="col-lg-1">
                                <span class="requiredField">*</span>
                            </div>
                        </div>

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


                        <div class="form-group">
                            <label for="accountbeginingbalanceDis" class="col-lg-2 control-label">دين المورد</label>
                            <div class="col-lg-4">
                                <div class="input-group">
                                    <input type="text" name="debtBeforebank" id="debtBeforebank"
                                           class="form-control numberinput" readonly="readonly" value="0"
                                           placeholder="دين المورد"/>

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


                        <div class="form-group">
                            <label for="accountid" class="col-lg-2 control-label">اسم الحساب</label>

                            <div class="col-lg-4">
                                <div id="accountName">

                                    <select class="select2 wdt100" name="accountid" id="accountid">
                                        <option value="-1">اختر حساب</option>

                                    </select>

                                </div>

                                <div id="counterror">

                                </div>
                            </div>
                            <div class="col-lg-1">
                                <span class="requiredField">*</span>
                            </div>
                        </div>


                        <div class="form-group">
                            <label class="col-lg-2 control-label">التاريخ </label>
                            <div class="col-lg-4"> <span id="sprydate">
                                    <input type="text" class="form-control awdatepicker" autocomplete="off"
                                           data-date-format="yyyy-mm-dd" placeholder="التاريخ" value="{$today}"
                                           name="checkdate" id="bn">
                                    <span class="textfieldRequiredMsg">*</span></span>
                            </div>
                            <div class="col-lg-1">
                                <span class="requiredField">*</span>
                            </div>
                        </div>

                        <div id="accountnumber">
                            <!-- =================================================   -->


                            <div class="form-group">
                                <label for="accountnumberDis" class="col-lg-2 control-label">رقم الحساب</label>
                                <div class="col-lg-4">
                                    <input name="txtPhone" type="text" id="accountnumberDis" name="accountnumberDis"
                                           class="numberinput form-control" placeholder="رقم الحساب"
                                           readonly="readonly"/>

                                    <input type="hidden" name="accountnumber" id="accountnumber"/>

                                </div>
                            </div>

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

                            <div class="form-group">
                                <label for="accountbeginingbalanceDis" class="col-lg-2 control-label">رصيد
                                    سابق</label>
                                <div class="col-lg-4">
                                    <div class="input-group">
                                        <input type="text" name="accountbeginingbalanceDis"
                                               id="accountbeginingbalanceDis" class="form-control numberinput"
                                               readonly="readonly" value="0" placeholder="رصيد سابق"/>

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

                                    <input type="hidden" name="accountbeginingbalance" id="accountbeginingbalance"/>
                                </div>
                            </div>

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

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


                        <div class="form-group">
                            <label for="txtAmount" class="col-lg-2 control-label">قيمة السحب</label>
                            <div class="col-lg-4">
                                <div class="input-group">
                                    <input type="text" name="txtAmount" id="txtAmountxx"
                                           class="form-control {if $suplliernegative==1}numberinput{else}positivefloat{/if}"
                                           placeholder="قيمة السحب"/>
                                    <span class="input-group-addon">{$currency}</span>
                                    <div id="chekamount">

                                    </div>
                                </div>
                                <div id="chekamountError">

                                </div>

                            </div>
                            <div class="col-lg-1">
                                <span class="requiredField">*</span>
                            </div>
                        </div>
                        <!--==============================-->
                        <div class="form-group">
                            <label for="txtcheckNum" class="col-lg-2 control-label">رقم عملية السحب</label>
                            <div class="col-lg-4">

                                <input type="text" name="txtcheckNum" id="txtcheckNum"
                                       class="form-control numberinput positivefloat"
                                       placeholder="رقم عملية السحب"/>
                                <div id="chekerror">

                                </div>
                                <div id="chekerror2">

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

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


                        <div class="form-group">
                            <label for="txtUser" class="col-lg-2 control-label">اسم المستفيد</label>
                            <div class="col-lg-4">

                                <input type="text" name="txtUser" id="txtUser" class="form-control "
                                       placeholder="اسم المستفيد"/>

                                <div id="userdiv">

                                </div>

                            </div>
                        </div>


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


                        <div class="form-group">
                            <label for="textNote" class="col-lg-2 control-label">تفاصيل اخرى</label>
                            <div class="col-lg-4">

                                <textarea class="form-control" rows="3" id="textNote" name="textNote"></textarea>

                            </div>
                        </div>

                    </div>
                    <!--end Bank-->



                    <!--==============================-->
                    <input type="hidden" name="add_print" id="add_print" value="0"/>

                    <div class="form-group">
                        <div class="col-lg-offset-2 col-lg-4">
                            <button name="saveSupPayBtn" type="button" id="saveSupPayBtn" class="btn btn-primary ">حفظ</button>
                            <button type="button"  id="add_print_btn" class="btn btn-success">حفظ وطباعة</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}