<style>

    #gmap {
        height: 400px;
        overflow: hidden;
        position: relative;
    }
    #gmap.map-single-page {
        height: 300px;
    }
    #gmap img {
        max-width: none;
    }
    #gmap .map-property {
        padding-bottom: 10px;
        width: 310px;
        font-family: "Droid Arabic Kufi","Montserrat",sans-serif;
    }
    #gmap .property-featured-image {
        float: left;
        margin-bottom: 10px;
        margin-right: 20px;
    }

</style>

<!--BEGIN CONTENT -->
<div class="page-content-wrapper">
    <div class="page-content">
        <!-- BEGIN PAGE HEADER-->
        <h3 class="page-title">
            {$shcontrollname}
        </h3>
        <div class="page-bar">
            <ul class="page-breadcrumb">
                {$breadcrumbs}
            </ul>
        </div>
        <!-- END PAGE HEADER-->
        <!-- BEGIN PAGE CONTENT-->
        <div class="row">
            <div class="col-md-12">
                <div class="portlet light bg-inverse">
                    <div class="portlet-title">
                        <div class="caption">
                            <i class="icon-equalizer font-red-sunglo"></i>
                            <span class="caption-subject font-red-sunglo bold uppercase">تعديل في {$shcontrollname}</span>
                        </div>
                        <div class="actions">
                            <a class="btn default btn-xs blue tooltips" href="{$hosturl}/{$controllname}/show" data-container="body" data-placement="top" data-original-title="Show">
                                <i class="icon-list"></i>
                                عرض البيانات
                            </a>
                        </div>
                    </div>
                    <div class="portlet-body form">
                        <!-- BEGIN FORM-->
                        <form action="{$hosturl}/{$controllname}/updateit" method="post" class="form-horizontal editForm" id="subjects_form" data-link="{$controllname}" enctype="multipart/form-data">
                            <div class="form-body">
                                <div class="alert alert-danger display-hide">
                                    <button class="close" data-close="alert"></button>
                                    لديك خطأ في إدخال البيانات, حاول مرة أخرى.
                                </div>
                                <div class="alert alert-success display-hide">
                                    <button class="close" data-close="alert"></button>
                                    لقد أدخلت بيانات صحيحة.
                                </div>
                                <div class="form-group">
                                    <label class="col-md-2 control-label" style="text-align: right">الاسم</label>
                                    <div class="col-md-8">
                                        <input type="text" class="form-control" placeholder="الاسم" name="title" id="title" maxlength="50" minlength="2" required data-edit="{$returnedData->title}" value="{$returnedData->title}">
                                    </div>
                                    <span class="help-block help-block-error" id="showerrortitle" style="color: #F3565D"></span>
                                </div>
                                <div class="form-group">
                                    <label class="col-md-2 control-label" style="text-align: right">Name </label>
                                    <div class="col-md-8">
                                        <input type="text" class="form-control" placeholder="Name" name="title_en" id="title_en" maxlength="50" minlength="2" required data-edit="{$returnedData->title_en}" value="{$returnedData->title_en}">
                                    </div>
                                    <span class="help-block help-block-error" id="showerrortitle_en" style="color: #F3565D"></span>
                                </div>

                                <div class="clearfix"></div>

                                <div class="form-group">
                                    <label class="col-md-2 control-label" style="text-align: right">العنوان </label>
                                    <div class="col-md-8">
                                        <input type="text" class="form-control" placeholder="العنوان" name="address" id="address" value="{$returnedData->address}" maxlength="50" minlength="2" required>
                                    </div>
                                    <span class="help-block help-block-error" id="showerrortitle" style="color: #F3565D"></span>
                                </div>
                                <div class="form-group">
                                    <label class="col-md-2 control-label" style="text-align: right">Address </label>
                                    <div class="col-md-8">
                                        <input type="text" class="form-control" placeholder="Address" name="address_en" id="address_en" value="{$returnedData->address_en}" maxlength="50" minlength="2" required>
                                    </div>
                                    <span class="help-block help-block-error" id="showerrortitle_en" style="color: #F3565D"></span>
                                </div>

                                <div class="clearfix"></div>

                                <div class="form-group">
                                    <label class="col-md-2 control-label" style="text-align: right">المنطقة </label>
                                    <div class="col-md-8">
                                        <select class="form-control select2me" name="regionid" id="regionid" required>
                                            <option value="">اختر المنطقة</option>
                                            <option value="1" {if $returnedData->regionid eq 1}selected{/if}>المنطقة الوسطى</option>
                                            <option value="2" {if $returnedData->regionid eq 2}selected{/if}>المنطقة الشرقية</option>
                                            <option value="3" {if $returnedData->regionid eq 3}selected{/if}>المنطقة الغربية</option>
                                            <option value="4" {if $returnedData->regionid eq 4}selected{/if}>المنطقة الجنوبية</option>
                                            <option value="5" {if $returnedData->regionid eq 5}selected{/if}>المنطقة الشمالية</option>
                                        </select>
                                    </div>
                                </div>

                                <div class="form-group">
                                    <label class="col-md-2 control-label" style="text-align: right">المدينة </label>
                                    <div class="col-md-8">
                                        <select class="form-control select2me" name="cityid" id="cityid" required>
                                            <option value="">اختر المدينة</option>
                                            {foreach $allCity as $city}
                                            <option value="{$city->id}" {if $city->id eq $returnedData->cityid}selected{/if}> {$city->title}</option>
                                            {/foreach}
                                        </select>
                                    </div>
                                </div>

                                <div class="form-group">
                                    <label class="col-md-2 control-label" style="text-align: right">رقم الهاتف </label>
                                    <div class="col-md-8">
                                        <input type="text" class="form-control" placeholder="رقم الهاتف" value="{$returnedData->phone}" name="phone" digits="true">
                                    </div>
                                </div>

                                <div class="clearfix"></div>

                                <div class="caption">
                                    <i class="icon-equalizer font-red-sunglo"></i>
                                    <span class="caption-subject font-red-sunglo bold uppercase">الاحداثيات</span>
                                </div>

                                <div class="form-group">
                                    <label class="col-md-2 control-label" style="text-align: right">خط الطول </label>
                                    <div class="col-md-8">
                                        <input type="number" class="form-control getLocation" placeholder="خط الطول" name="lat" value="{$returnedData->lat}" id="lat" required>
                                    </div>
                                    <span class="help-block help-block-error" id="showerrorlat" style="color: #F3565D"></span>
                                </div>

                                <div class="form-group">
                                    <label class="col-md-2 control-label" style="text-align: right">خط العرض </label>
                                    <div class="col-md-8">
                                        <input type="number" class="form-control getLocation" placeholder="خط العرض" name="long" value="{$returnedData->long}" id="long" required>
                                    </div>
                                    <span class="help-block help-block-error" id="showerrorlong" style="color: #F3565D"></span>
                                </div>
                                <div class="clearfix"></div>
                                <input type="hidden" id="id" name="id" value="{$returnedData->id}" />

                            </div>

                            <div>
                                <label class="control-label ">الموقع على الخريطة:</label>
                            </div>
                            <div class="clearfix" id="gmap"></div>
                            <div class="form-actions">
                                <div class="row">
                                    <div class="col-md-offset-3 col-md-4">
                                        <button type="submit" class="btn green">حفظ</button>
                                        <button type="button" class="btn default rtnshow" data-controll="{$controllname}">إلغاء</button>
                                    </div>
                                </div>
                            </div>
                        </form>
                        <!-- END FORM-->
                    </div>
                </div>
            </div>
        </div>
        <!-- END PAGE CONTENT-->
    </div>
</div>
<!-- END CONTENT-->
{literal}
<script>
    if (navigator.geolocation) {
        navigator.geolocation.getCurrentPosition(redirectToPosition);
    } else {
        alert("Geolocation is not supported by this browser.");
    }

    function redirectToPosition(position) {
        $("#lat").val(position.coords.latitude);
        $("#long").val(position.coords.longitude);
    }
</script>
{/literal}