

<div class="row">
    <div class="container">
         <ol class="breadcrumb">
            <li><a href="#">نظام العقارات والوحدات </a></li>
            <li><a href="realestateunits.php?do=show"> العقارات والوحدات </a></li>
            <li class="active">عرض   </li>
        </ol>

        <div class="panel panel-default panel-m">
            <!-- Default panel contents -->
            <div class="panel-heading" style="padding:5px 15px 15px">
                <h3 class="panel-title" style="display: inline-block;"> عرض       </h3>
                <a href="realestateunits.php" class="hidden-print"><input type="button"  id="submit" style="margin-left: 12px" class="btn btn-primary pull-left " value="إضافة جديد"/></a>
            </div>
            
            <hr/>
            <form class="form-inline hidden-print" id="searchdata"  method="post" action="realestateunits.php?do=show">
                    <div class="form-group">
                        <label class="sr-only">من التاريخ</label>
                        <input type="text" class="form-control awdatepicker searchdata" autocomplete="off"   data-date-format="yyyy-mm-dd"  id="start_date" name="start_date" value="{$date}">
                    </div>
                    <div class="form-group">
                        <label class="sr-only">إلى التاريخ</label>
                        <input type="text" class="form-control awdatepicker searchdata" autocomplete="off"   data-date-format="yyyy-mm-dd"  id="end_date" name="end_date" value="{$date}">
                    </div>
                     <div class="form-group"  >
                        <label class="sr-only">العقارات</label>
                        <div style="width: 300px;">
                            <input id="select2realestates" type="text" name="realestateid" class="searchdata getselectjoin"  data-placeholder="اختر  العقار"   data-table="realestates" 
                            data-join=""   data-filter="" data-parent="" data-itr=""  
                            data-search="realestatename"/> 
                        </div> 
                    </div>
                     <div class="form-group"  >
                        <label class="sr-only">الوحدات</label>
                        <div style="width: 300px;">
                            <input id="select2realestatesunits" type="text" name="realestateunitid" class="searchdata getselectjoin"  data-placeholder="اختر  الوحده"   data-table="realestatesunits" 
                            data-join=""   data-filter="" data-parent="realestateid" data-itr=""  
                            data-search="unitname"/> 
                        </div> 
                    </div>
                    <div class="form-group">
                        <label class="sr-only">المحذوف</label>
                        <div style="text-align: center;">
                          <input type="checkbox" class="form-control searchdata" id="del"  value="1" style="    width: 23px;">  
                        </div>
                    </div>

                    <div class="form-group">
                        <div class="radio-inline">
                            <label> <input value="0" class="searchdata"  name="savaible"   type="radio" checked="checked"  />
                            متاح للتاجير </label>
                        </div>
                        <div class="radio-inline">
                            <label> <input value="1" class="searchdata"  name="savaible"   type="radio"  />
                                غير متاح   </label>
                        </div>
                    </div>
                    <div class="form-group">
                        <div class="radio-inline">
                            <label> <input value="0" class="searchdata"  name="cavaible"   type="radio" checked="checked"  />
                                متاح للاستأجر   </label>
                        </div>
                        <div class="radio-inline">
                            <label> <input value="1" class="searchdata"  name="cavaible"   type="radio" />
                                    غير متاح     </label>
                        </div>
                    </div>
                        
                 
                </form>
            <hr/>
            <table class="table table-black" id="getajaxdata" 
            data-controll="realestateunits.php?do=showajax">
                <thead>
                    <tr>
                        <th style="width:50px;">م</th>
                        <th>العقار</th>
                        <th>الوحدات</th>
                        <th>التاريخ</th>
                        <th>المستخدم</th>
                        <th class="noprint">تعديل</th>
                        <th class="noprint">حذف</th>
                    </tr>
                </thead>
                <tbody>

                </tbody>
            </table>
            <div class="clearfix"></div>
        </div>
    </div>
</div>
{literal}
<script type="text/javascript">
$(document).ready(function () {
        var formatResult;
        formatResult = function (data) {return  data.text;}
        $("#select2realestates").select2({
            placeholder: "إسم  المشروع",
            multiple: false,
            quietMillis: 100,
            ajax: {
                url: "realestateunits.php?do=select2realestates",
                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);
            }
        });
        $("#select2realestatesunits").select2({
            placeholder: "الوحده",
            multiple: false,
            quietMillis: 100,
            ajax: {
                url: "realestateunits.php?do=select2realestatesunits",
                type: "post",
                dataType: 'json',
                data: function (term, page) {
                    var select2realestates = Number($('#select2realestates').val());
                     if (!select2realestates) {
                        alert('يجب اختيار العقار اولا');
                        return false;
                     }
                    return {
                        searchTerm: term,
                        realestateid: select2realestates,
                    };
                },
                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);
            }
        });
        deldata();
});  
</script>
{/literal}
