

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

         <ol class="breadcrumb">
            <li><a href="#">مشاريع خارجيه</a></li>
            <li><a href="executors.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="executors.php?do=add"   method="post"  enctype="multipart/form-data" >
                    {/literal}

                    <div class="form-group">
                        <label for="txtName" class="col-lg-2 control-label">العملاء</label>
                        <div class="col-lg-4">
                            <input type="text" name="executorsclientid" required="required" class="wdt100" id="select2client" data-placeholder="اختر " />
                         </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="executorssellid" required="required" class="wdt100" id="select2sellbill" data-placeholder="اختر " />
                         </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="executorsuserids" multiple required="required" class="wdt100" id="select2user" data-placeholder="اختر " />
                         </div>
                    </div>



                    <div class="form-group">
                        <div class="col-lg-offset-2 col-lg-4">
                            <button type="submit" class="btn btn-primary pull-left" >حفظ </button>
                        </div>
                    </div>
                </form>
            </div>
        </div>
    </div>
</div>
{literal}
<script type="text/javascript">


    $(document).ready(function () {
        var formatResult;
        formatResult = function (data) {
            return  data.text;
        }


        $("#select2client").select2({
            placeholder: "إسم  المشروع",
            multiple: false,
            quietMillis: 100,
            ajax: {
                url: "executors.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);
            }
        });

        $("#select2user").select2({
            placeholder: "إسم  المشروع",
            multiple: true,
            quietMillis: 100,
            ajax: {
                url: "executors.php?do=select2user",
                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);
            }
        });


        $("#select2sellbill").select2({
            placeholder: "إسم  المشروع",
            multiple: false,
            quietMillis: 100,
            ajax: {
                url: "executors.php?do=select2sellbill",
                type: "post",
                dataType: 'json',
                data: function (term, page) {
                     var select2client = Number($('#select2client').val());
                     if (!select2client) {
                        alert('يجب اختيار العميل اولا');
                        return false;
                     }
                    return {
                        searchTerm: term,
                        clientid: select2client,
                    };
                },
                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);
            }
        });


        $('body').on('click', '.addappend', function () {
            var itr = Number($('#taskscommentsitr').val());
            $.post('tasksController.php?do=appendcomment', {itr: itr}, function (result) {
                $('.taskscommentscontainer').append(result);
                $('#taskscommentsitr').val(itr + 1);
            });
        });

    });
</script>
{/literal}


