

<div class="row">
    <div class="container">
        
        <ol class="breadcrumb">
            <li><a href="#"> العملاء</a></li>
            <li><a href="customerAccountMatching.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="customerAccountMatching.php?do=savedata"  id="submitformajax"  method="post"  enctype="multipart/form-data" data-dosave="?do=savedata" data-direction="?do=show" data-print="">

                    {/literal}


                    <div class="form-group">
                        <label class="col-lg-2 control-label"> مطابق او غير مطابق     </label>
                        <div class="col-lg-4">
                            <div class="radio-inline">
                                <label>
                                    <input value="1" class="noradioR identical" name="identical" type="radio" {if $editdata->identical eq 1} checked="checked" {/if}>
                                    مطابق </label>
                            </div>
                            <div class="radio-inline">
                                <label>
                                    <input value="2" class="radioR identical" name="identical" type="radio"
                                    {if $editdata->identical eq 2} checked="checked" {/if}>
                                    غير مطابق  </label>
                            </div>

                        </div>
                    </div>
                    <div class="form-group">
                        <label for="txtName" class="col-lg-2 control-label">العملاء </label>
                        <div class="col-lg-4">
                            <input type="text" name="clientid" class=" wdt100" id="select2client" 
                             data-placeholder="اختر "  data-text="{$editdata->clientname}" data-id="{$editdata->clientid}" />
                            
                        </div>
                    </div>
                    <div id="identical" {if $editdata->identical eq 1} style="display: none;" {/if}>
                        <div class="form-group">
                            <label for="txtName" class="col-lg-2 control-label">القيمه </label>
                            <div class="col-lg-4">
                                <input type="text" name="newclientdebt" class="form-control"  
                                 data-placeholder="القيمه " value="{$editdata->newclientdebt}" />
                                
                            </div>
                        </div>
                        <div class="form-group">
                            <label for="txtName" class="col-lg-2 control-label">التعليق </label>
                            <div class="col-lg-4">
                                <textarea rows="3" class="form-control" name="comment">{$editdata->comment}</textarea>
                            </div>
                        </div>

                    </div>



                    


                     

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


                    <div class="form-group">
                        <div class="col-lg-offset-2 col-lg-4">
                             <button type="submit" class="btn btn-primary pull-left submitformajax" >تعديل الامر</button>
                        </div>
                    </div>




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




    </div>
</div>





{literal}
<script type="text/javascript">
$(document).ready(function () {
        var formatResult;
        formatResult = function (data) {return  data.text;}
     
            $('body').on('click', '.addappend', function () {
                var itr = Number($("#productsitr").val()) + 1;
                $("#productsitr").val(itr);
              $.post('mechandiseReturnRequest.php?do=appendproduct', {itr: itr}, function (result) {
                $("#products").append(result);
                products(itr);
                

              });
            });

            $('body').on('click', '.removeappend', function () {
                var id = Number($(this).attr('data-id'));
                var edit = Number($(this).attr('data-edit'));
                if(edit == 1){
                    $.post('mechandiseReturnRequest.php?do=removeappend', {id: id}, function (result) {
                        $("#products1"+id).remove();
                    });
                }else{
                    $("#products"+edit+id).remove();

                }
                
            });

       
          
          function products($i){
            $("#select2product" + $i).select2({
            placeholder: "إسم  المشروع",
            multiple: false,
            quietMillis: 100,
            ajax: {
                url: "mechandiseReturnRequest.php?do=select2product",
                type: "post",
                dataType: 'json',
                data: function (term, page) {
                    return {
                        searchTerm: term,
                    };
                },
                results: function (data) {
                    return {results: data};
                }
            },
            formatResult: formatResult,
            initSelection: function (element, callback) {
                var item = element.val().split(':');
                var data = {id: item[0], text: item[1]};
                callback(data);
            }
        });
          }
          $(".select2product").each(function( ) {
            var itr = Number($(this).attr('data-itr'));
            products(itr);
                var ids = Number($(this).attr('data-id'));
                var texts = $(this).attr('data-text');
                $(this).select2("data", {id: ids, text: texts});
            });



         $("#select2client").select2({
            placeholder: "إسم  المشروع",
            multiple: false,
            quietMillis: 100,
            ajax: {
                url: "mechandiseReturnRequest.php?do=select2client",
                type: "post",
                dataType: 'json',
                data: function (term, page) {
                    return {
                        searchTerm: term,
                    };
                },
                results: function (data) {
                    return {results: data};
                }
            },
            formatResult: formatResult,
            initSelection: function (element, callback) {
                var item = element.val().split(':');
                var data = {id: item[0], text: item[1]};
                callback(data);
            }
        });




        $("#select2client").select2("data", {id: $('#select2client').attr('data-id'), text: $('#select2client').attr('data-text')});

});  
</script>
{/literal}
