<style type="text/css">
.modal-header .close {
    margin-top: -24px;
    float: left;

}
h4{
    text-align: center;
    color: #0a0944;
    font-weight: 900;
    font-size: 18px;

}
.hrs {
    height: 3px;
        background-color: red;
        border: none;
        margin: 10px 200px;
}

</style>

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

        <ol class="breadcrumb">
            <li><a href="#">زيارات المندوبين   </a></li>
            <li><a href="visitsController.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="visitsController.php"  id="saveformajax" method="post"  enctype="multipart/form-data" data-dosave="?do=savedata" data-direction="visitsController.php?do=show">
                    {/literal}


                    <div class="form-group">
                        <label for="txtName" class="col-lg-2 control-label">الشركة - المنطقة  </label>
                        <div class="col-lg-4">
                              <input type="hidden" name="clientareaid" value="0" id="clientareaid"/>
                        </div>
                          <label for="txtName" class="col-lg-1 control-label"> تحديد الكل   </label>
                         <div class="col-lg-1">
                              <input   type="checkbox"  class="form-control checkalls"  value="{$client.clientid}" />   
                        </div>
                      <!--   <button type="button" class="btn btn-primary adddatamodal" data-table="client" data-tableid="clientid" data-toggle="modal" data-target="#Modalclientid" data-whatever="@client" data-formt="formclient" data-selectitr="">اضافة   عميل</button>
                        <button type="button" class="btn btn-primary editdatamodal"  data-model="#Modalclientid" data-table="client" data-name="clientid" data-tableid="clientid" data-join="" data-formt="formclient" data-selectitr="">تعديل   عميل</button> -->
                    </div>

                    <div id="allclient">
                         <ul class="list-group" id="allclient">
                                
                            </ul>
                        
                    </div>
                  <div class="clearfix"></div>

                  <!--   <div class="form-group">
                        <label for="txtName" class="col-lg-2 control-label">العملاء  </label>
                        <div class="col-lg-4">
                             <input id="clientid" type="text" name="client"  class="getselectjoin clientid "  data-placeholder=" العملاء   "   data-table="client" 
                              data-tableid="clientid"  data-join=""   data-filter="" data-parent="" data-itr=""  
                              data-search="clientname,'/',clientphone"/>
                             <input  type="hidden" name="clientid" class="selectedit" data-tableidname="clientid"  data-itr="" 
                             data-join="" data-table="client" data-tableid="clientid" data-search="clientname,'/',clientphone" value="" />
                        </div> -->
                      <!--   <button type="button" class="btn btn-primary adddatamodal" data-table="client" data-tableid="clientid" data-toggle="modal" data-target="#Modalclientid" data-whatever="@client" data-formt="formclient" data-selectitr="">اضافة   عميل</button>
                        <button type="button" class="btn btn-primary editdatamodal"  data-model="#Modalclientid" data-table="client" data-name="clientid" data-tableid="clientid" data-join="" data-formt="formclient" data-selectitr="">تعديل   عميل</button> -->
                    <!-- </div> -->

                    <div class="form-group">
                        <label for="txtName" class="col-lg-2 control-label">المندوبين  </label>
                        <div class="col-lg-4">
                             <input id="userid" type="text" name="delegateid"  class="getselectjoin userid "  data-placeholder=" المندوبين   "   data-table="user" 
                              data-tableid="userid"  data-join=""   data-filter=" and usergroupid = 2 " data-parent="" data-itr=""  
                              data-search="employeename"/>
                             <input  type="hidden" name="userid" class="selectedit" data-tableidname="userid"  data-itr="" 
                             data-join="" data-table="client" data-tableid="userid" data-search="employeename" value="" />
                        </div>
                      <!--   <button type="button" class="btn btn-primary adddatamodal" data-table="client" data-tableid="clientid" data-toggle="modal" data-target="#Modalclientid" data-whatever="@client" data-formt="formclient" data-selectitr="">اضافة   عميل</button>
                        <button type="button" class="btn btn-primary editdatamodal"  data-model="#Modalclientid" data-table="client" data-name="clientid" data-tableid="clientid" data-join="" data-formt="formclient" data-selectitr="">تعديل   عميل</button> -->
                    </div>
                    <div class="form-group">
                        <label for="txtName" class="col-lg-2 control-label">    تاريخ الزياره  </label>
                        <div class="col-lg-4">
                            <input    required="required"    type="text" name="dateofvisit" 
                            class="form-control awdatepicker" autocomplete="off"   data-date-format="yyyy-mm-dd"  placeholder=" التاريخ والوقت  "  
                            data-table="maintenances" data-filter="" 
                            data-tableid="" data-parentid="" data-parentcol="" value="{$date}" />
                            
                        </div>
                    </div>
              


                    
                    <div class="form-group">
                        <div class="col-lg-offset-2 col-lg-4">
                            <button type="button" class="btn btn-primary pull-left saveformajax" data-form="saveformajax">حفظ الامر</button>
                        </div>
                    </div>
                </form>
            </div>
        </div>
    </div>
</div>

{literal}
<script type="text/javascript">


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


         $('#clientareaid').select2({
            placeholder: "اختر الشركة  - المنطقة",
            ajax: {
                url: 'clientControllerAjax.php?do=getclientarea',
                dataType: 'json',
                type: "POST",
                data: function (term) {
                    return {
                        searchTerms: term,
                        //governmentid : $('#clientgovernmentid').val()
                    };
                },
                results: function (data) {
                    return {
                        results: data,
                    };
                }
            },
            formatResult: formatResult,
        });


         $('body').on('change', '#clientareaid', function () {
             var clientareaid = $.trim($(this).val());
              $.post('visitsController.php?do=allclient', {clientareaid: clientareaid }, function (result) {
                $('#allclient').html(result);

              });
             
        });



        // $("#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);
        //     }
        // });


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

       


        

        //  fetch_data($('#fromdate').val(), $('#todate').val(), $('#select2client').val(), $('#select2sellbill').val());
        // function fetch_data(fromdate = '', todate = '', data1 = '', data2 = '')
        // {

        //     var dataTable = $('#getajaxdata').DataTable({
        //         "lengthMenu": [[20, 40, 60, 80, 100, -1], [20, 40, 60, 80, 100, "All"]],
        //         dom: 'Bfrtip',
        //         buttons: [
        //             {
        //                 extend: 'copyHtml5',
        //                 exportOptions: {
        //                     columns: [0, 1, 2, 3, 4, 5, 6, 7]
        //                 }
        //             },
        //             {
        //                 extend: 'csvHtml5',
        //                 exportOptions: {
        //                     columns: [0, 1, 2, 3, 4, 5, 6, 7]
        //                 }
        //             },
        //             {
        //                 extend: 'print',
        //                 exportOptions: {
        //                     columns: [0, 1, 2, 3, 4, 5, 6, 7]
        //                 }
        //             },
        //             {
        //                 extend: 'excelHtml5',
        //                 exportOptions: {
        //                     columns: [0, 1, 2, 3, 4, 5, 6, 7]
        //                 }
        //             },
        //             {
        //                 extend: 'pdfHtml5',
        //                 exportOptions: {
        //                     columns: [0, 1, 2, 3, 4, 5, 6, 7]
        //                 }
        //             },
        //             'colvis'
        //         ],
        //         "dom": "<'row' <'col-md-12'B>><'row'<'col-md-6 col-sm-12'l><'col-md-6 col-sm-12'f>r><'table-scrollable't><'row'<'col-md-5 col-sm-12'i><'col-md-7 col-sm-12'p>>",
        //         "order": [[7, "asc"]],
        //         "displayLength": 20,
        //         "ajax": {
        //             url: 'executorsreport.php?do=showajax',
        //             type: "POST",
        //             data: {
        //                 fromdate: fromdate,
        //                 todate: todate,
        //                 data1: data1,
        //                 data2: data2,
        //             }
        //         },
        //         "fnRowCallback": function (nRow, aData, iDisplayIndex, iDisplayIndexFull) {
        //             if (aData[1] == "الكميه")
        //             {
        //                 $('td', nRow).css('background-color', '#c4f378');
        //             }
        //         },

        //     });

        // }


        // $('.searchdata').change(function () {
        //     var fromdate = $('#fromdate').val();
        //     var todate = $('#todate').val();
        //     var data1 = $('#select2client').val();
        //     var data2 = $('#select2sellbill').val();

        //     $('#getajaxdata').DataTable().destroy();
        //     fetch_data(fromdate, todate, data1, data2);

        // });

       






      

    });







</script>
{/literal}
