<style>
    .bg-full{
        direction: ltr
    }

    .select2-container .select2-choice .select2-arrow {

        left: auto!important;
        right: 0!important;
    }
    .select2-container .select2-choice > .select2-chosen {
        margin-right: 26px!important;
        margin-left: auto!important
    }
    .col-lg-1, .col-lg-2, .col-lg-3, .col-lg-4, .col-lg-5, .col-lg-6, .col-lg-7, .col-lg-8, .col-lg-9, .col-lg-10, .col-lg-11, .col-lg-12 {
        float:left!important
    }
    .form-horizontal .control-label {
        text-align: left!important;
    }
    .form-control {
        text-align: left!important;
    }
    .select2-results .select2-result-label {

        text-align: left!important;
    }
    .input-group-addon:last-child {
        border: 1px solid #ccc;
    }
</style>
<script>

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

        $.ajax({
            url: 'clientPayedDeptControllerAjax.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>
<script src="{$path}/SpryAssets/SpryValidationTextField.js" type="text/javascript"></script>
<link href="{$path}/SpryAssets/SpryValidationTextField.css" rel="stylesheet" type="text/css" />

<div class="bg-full row">
    <div class="container">
        <ol class="breadcrumb">
            <li><a href="#"> general features</a></li>
            <li><a href="clientPayedDeptController.php?do=show">Clients</a></li>
            <li class="active">  a customer repayment receipt </li>
        </ol>
        <div class="panel panel-default panel-m">
            <div class="panel-heading">
                <h3 class="panel-title">  Add a customer repayment receipt</h3>
            </div>
            <div class="panel-body">
                <form id="myform" class="form-horizontal" role="form" action="clientPayedDeptController.php?do=add" method="post">
                    <div class="form-group">
                        <label for="partnerid" class="col-lg-2 control-label">Client</label>
                        <div class="col-lg-4"><span id="spryselect1">
                                <select class="select2Supp wdt100" name="clientid" id="clientid">
                                    <option value="-1"> Add Client</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>
                    <!-- =================================================   -->
                    {if $userData->searchinonesave eq 0}
                    <div class="form-group">
                        <label class="col-lg-2 control-label">Save</label>
                        <div class="col-lg-4">
                            <select class="select2 wdt100" name="saveid" id="saveid">
                                {foreach $allSave as $data}
                                <option value="{$data->saveid}" {if $userData->saveid == $data->saveid}selected{/if}>{$data->savename}</option>
                                {/foreach}
                            </select>
                        </div>
                    </div>
                    {else}
                    <div class="form-group">
                        <label for="inputEmail1" class="col-lg-2 control-label">Save</label>
                        <div class="col-lg-4">
                            {foreach $allSave as $data}
                            {if $userData->saveid == $data->saveid}{$data->savename}{/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">Receipt number  </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>


                    <input name="oldvoucher"  id="oldvoucher" type="hidden" value="{$todayx}" />
                    <!-- =================================================   -->

                    <div class="form-group">
                        <label for="lastDate" class="col-lg-2 control-label">   Date of previous payment</label>
                        <div class="col-lg-4">
                            <input type="text" name="lastDate" id="lastDate" readonly="readonly" class="form-control" />
                        </div>
                    </div>
                    <input name="clientnegative" id="clientnegative" type="hidden" value="{$clientnegative}" />
                    <!-- =================================================   -->

                    <div class="form-group">
                        <label for="currentDate" class="col-lg-2 control-label">   Date of Next payment</label>
                        <div class="col-lg-4">
                            <!--<input type="text" name="currentDate" id="currentDate" class="form-control {if $Programsettingdata->allowdateedit != 1}awdatepicker{/if}" autocomplete="off"  {if $Programsettingdata->allowdateedit == 1}readonly="readonly"{/if} data-date-format="yyyy-mm-dd" value="{$today}" />-->
                            {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 id="dateError" style="display:none;"></div>
                        </div>
                    </div>

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

                    <div class="form-group">
                        <label for="debtBefore" class="col-lg-2 control-label">previous payment </label>
                        <div class="col-lg-4">
                            <div class="input-group">
                                <input type="text" name="debtBefore" id="debtBefore"  class="form-control" readonly="readonly" />
                                <span class="input-group-addon">{$currency}</span> </div>
                        </div>
                    </div>


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

                    {if $Programsettingdata->earlyrepayment == 1}
                    <div class="form-group">
                        <label for="debtBefore" class="col-lg-2 control-label">Early repayment discount</label>
                        <div class="col-lg-4">
                            <div class="input-group">
                                <input type="text" name="earlyRepayment" id="earlyRepayment" value="0" onKeyUp="populateDebtAfter();"  class="form-control" />
                                <span class="input-group-addon">{$currency}</span> </div>
                        </div>
                    </div>
                    {/if}

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

                    <div class="form-group">
                        <label for="payedDept" class="col-lg-2 control-label">paid up</label>
                        <div class="col-lg-4">
                            <div class="input-group">
                                <input type="text" name="payedDept" id="payedDept" value="0" onKeyUp="populateDebtAfter();"  class="form-control {if $clientnegative==1}numberinput{else}positivefloat{/if}" placeholder="paid up"/>
                                <span class="input-group-addon">{$currency}</span>
                            </div>
                            <div id="payedDeptError" style="display:none;"></div>

                        </div>
                    </div>

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

                    <div class="form-group">
                        <label for="debtAfter" class="col-lg-2 control-label">Next Payment </label>
                        <div class="col-lg-4">
                            <div class="input-group">
                                <input type="text" name="debtAfter" id="debtAfter"  class="form-control" readonly="readonly" />
                                <span class="input-group-addon">{$currency}</span> </div>
                        </div>
                    </div>

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


                    <div class="form-group">
                        <label for="debtAfter" class="col-lg-2 control-label">Comment</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>

                    <!-- =================================================   -->
                    <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 type="button" id="saveBtn" class="btn btn-primary">Save </button>
                            <button type="button"  id="add_print_btn" class="btn btn-success">Save and Print </button>

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


