<!-- Content Wrapper. Contains page content -->
<div class="content-wrapper">
    <!-- Content Header (Page header) -->
    <section class="content-header">
        <h1>
            <?php
            echo isset($title) ? $title : NULL;
            ?>
        </h1>
    </section>
    <!-- Main content -->
    <section class="content">
        <div class="row">
            <form method="post" role="form">
                <div class="col-lg-6">
                    <div class="box box-primary">
                        <div class="box-header with-border">
                            <h3 class="box-title">Edit Website Setting</h3>
                        </div>
                        <!-- /.box-header -->
                        <div class="adminform">
                            <!-- form start -->

                            <?php
                            if (isset($message)) {
                                echo $message;
                            }
                            ?>
                            <div class="form-group">
                                <label for="WebSite-name">WebSite Name</label>
                                <input type="text" name="name" class="form-control"
                                       value="<?php echo $site_en['name'] ?>" id="WebSite-name"
                                       placeholder="Website Name">
                                <p class="help-block">WebSite Name</p>
                            </div>
                            <div class="form-group">
                                <label for="Company-mail">Email</label>
                                <input type="text" name="mail" class="form-control" value="<?php echo $site['mail']; ?>"
                                       id="Company-mail" placeholder="Company Email">
                                <p class="help-block">Add Company Email.</p>
                            </div>
                            <div class="form-group">
                                <label for="Company-description">Description</label>
                                <textarea name="description"
                                          class="form-control"><?php echo $site_en['description'] ?></textarea>
                                <p class="help-block">Add Website Description.</p>
                            </div>
                            <div class="form-group">
                                <label for="Company-phone"> Main Phone</label>
                                <input type="text" class="form-control" value="<?php echo $site['phone'] ?>"
                                       name="phone" placeholder="Company Phone" id="Company-phone">
                                <p class="help-block">Add Company Phone.</p>
                            </div>
                            <div class="form-group">
                                <label for="Company-phone">Another Phone</label>
                                <input type="text" class="form-control" value="<?php echo $site['another_phone'] ?>"
                                       name="another_phone" placeholder="Company Another Phone" id="Company-phone">
                                <p class="help-block">Add Company Another Phone.</p>
                            </div>
                            <div class="form-group">
                                <label for="Company-address">Address</label>
                                <input type="text" class="form-control" name="address"
                                       value="<?php echo $site_en['address'] ?>" placeholder="Company Address"
                                       id="Company-address">
                                <p class="help-block">Add Company Address.</p>
                            </div>
                            <div class="form-group">
                                <label for="Company-FaceBook">FaceBook</label>
                                <input type="text" class="form-control" name="facebook"
                                       value="<?php echo $site['facebook'] ?>" placeholder="Company FaceBook Link"
                                       id="Company-FaceBook">
                                <p class="help-block">Add Company FaceBook Page Link.</p>
                            </div>
                            <div class="form-group">
                                <label for="Company-Twitter">Twitter</label>
                                <input type="text" class="form-control" name="twitter"
                                       value="<?php echo $site['twitter'] ?>" placeholder="Company Twitter Link"
                                       id="Company-Twitter">
                                <p class="help-block">Add Company Twitter Page Link.</p>
                            </div>
                            <div class="form-group">
                                <label for="Company-Google">YouTube</label>
                                <input type="text" class="form-control" name="youtube"
                                       value="<?php echo $site['youtube'] ?>" placeholder="Company YouTube Link"
                                       id="Company-YouTube">
                                <p class="help-block">Add Company YouTube Page Link.</p>
                            </div>
                            <div class="form-group">
                                <label for="Company-Google">Instagram</label>
                                <input type="text" class="form-control" name="instagram"
                                       value="<?php echo $site['instagram'] ?>" placeholder="Company Instagram Link"
                                       id="Company-Instagram">
                                <p class="help-block">Add Company Instagram Page Link.</p>
                            </div>
                            <div class="form-group">
                                <label for="Company-Google">Google+</label>
                                <input type="text" class="form-control" name="google"
                                       value="<?php echo $site['google'] ?>" placeholder="Company Google Link"
                                       id="Company-Google">
                                <p class="help-block">Add Company Google+ Page Link.</p>
                            </div>
                            <div class="form-group">
                                <label for="Company-Google">Linkedin</label>
                                <input type="text" class="form-control" name="linkedin"
                                       value="<?php echo $site['linkedin'] ?>" placeholder="Company linkedin Link"
                                       id="Company-Google">
                                <p class="help-block">Add Company Linkedin Page Link.</p>
                            </div>
                            <div class="form-group">
                                <label for="Company-Google">Snap Chat</label>
                                <input type="text" class="form-control" name="snapchat"
                                       value="<?php echo $site['snapchat'] ?>" placeholder="Company linkedin Link"
                                       id="Company-snapchat">
                                <p class="help-block">Add Company snapchat Page Link.</p>
                            </div>
                            <div class="form-group">
                                <label for="Company-Google">Pinterest</label>
                                <input type="text" class="form-control" name="pinterest"
                                       value="<?php echo $site['pinterest'] ?>" placeholder="Company pinterest Link"
                                       id="Company-Google">
                                <p class="help-block">Add Company Pinterest Page Link.</p>
                            </div>
                            <div class="form-group">
                                <label for="Company-Google">Vk</label>
                                <input type="text" class="form-control" name="vk" value="<?php echo $site['vk'] ?>"
                                       placeholder="Company Vk Link" id="Company-Google">
                                <p class="help-block">Add Company Vk Page Link.</p>
                            </div>

                            <div class="form-group">
                                <label for="Company-Location">Location</label>
                                <input type="text" class="form-control" name="location" value="<?php echo $site['location'] ?>" placeholder="Company Location Link" id="Company-Location">
                                <p class="help-block">Add Company Location Page Link.</p>
                            </div>


                            <div class="form-group">
                                <label for="website-logo">Logo</label>
                                <img src="<?php echo UPLOAD_LINK . $site['logo'] ?>" data-toggle="modal"
                                     data-target="#update-img" class="img-responsive change-logo"/>
                                <p class="help-block">Change Website Logo</p>
                            </div>
                            <div class="form-group">
                                <label for="status" class="set-block">Status</label>
                                <div class="radio radio-info  radio-inline">
                                    <input type="radio" id="inlineRadio1" value="1"
                                           name="status" <?php if ($site['status'] == 1) echo "checked"; ?>>
                                    <label for="inlineRadio1"> Publish </label>
                                </div>
                                <div class="radio radio-info  radio-inline">
                                    <input type="radio" id="inlineRadio2" value="2"
                                           name="status" <?php if ($site['status'] == 2) echo "checked"; ?>>
                                    <label for="inlineRadio2"> Un Publish </label>
                                </div>
                                <p class="help-block">Select Website Status .</p>
                            </div>

                            <input type="submit" class="btn btn-primary" name="editSetting" value="Edit Setting"/>
                        </div>
                    </div>
                    <!-- /.box -->
                </div>
                <div class="col-lg-6 arab_dir">
                    <div class="box box-primary">
                        <div class="box-header with-border">
                            <h3 class="box-title">تعديل اعدادات الموقع</h3>
                        </div>
                        <!-- /.box-header -->
                        <!-- form start -->
                        <div class="box-body">
                            <div class="form-group">
                                <label for="exampleInputEmail1">أسم الموقع</label>
                                <input type="text" name="name_ar" value="<?php echo $site_ar['name'] ?>"
                                       class="form-control" id="exampleInputEmail1" placeholder="أدخل أسم الموقع">
                                <p class="help-block">أدخل عنوان الخبر باللغة العربية
                                <p>
                            </div>
                            <div class="form-group">
                                <label for="exampleInputEmail1">وصف الموقع</label>
                                <textarea class="form-control"
                                          name="description_ar"><?php echo $site_ar['description'] ?></textarea>
                                <p class="help-block">أضف وصف الموقع
                                <p>
                            </div>
                            <div class="form-group">
                                <label for="exampleInputEmail1">عنوان الشركة</label>
                                <input type="text" name="address_ar" value="<?php echo $site_ar['address'] ?>"
                                       class="form-control" id="exampleInputEmail1" placeholder="أدخل عنوان الشركة">
                                <p class="help-block">أدخل عنوان الشركة باللغة العربية
                                <p>
                            </div>

                        </div>
                        <!-- /.box-body -->
                    </div>
                    <!-- /.box -->
                </div>


            </form>

        </div>
    </section><!-- /.content -->
</div><!-- /.content-wrapper -->


<!-- Start edit Wwbsite Logo Modal -->
<div class="modal fade" id="update-img" role="dialog">
    <div class="modal-dialog modal-md">
        <!-- Modal content-->
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal">&times;</button>
                <h4 class="modal-title">Edit WebSite Logo</h4>
            </div>
            <div class="modal-body">
                <div id="updateImageResult"></div>
                <div class="row">
                    <div class="col-lg-10 pull-left">
                        <form id="updateImage" method="post" enctype="multipart/form-data">
                            <div class="form-group">
                                <label for="category-image"> Image</label>
                                <input type="file" name="image_name" id="image_name">
                                <p class="help-block">Change WebSite Logo.</p>
                            </div>
                            <input type="submit" class="btn btn-primary updatebtn" name="editImage" value="Save"/>
                            <span class="loadingImage">
                                <img src="customize\backend\images\Preloader_61.gif"/>
                             </span>
                        </form>
                    </div>
                    <div class="col-lg-2 pull-right">
                        <img src="" alt="" title="Edit Image" class="img-responsive old-image"/>
                    </div>
                </div>
            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
            </div>
        </div>
    </div>
</div>
<!--End Edit Website Logo Modal-->


<script>
    $(document).ready(function () {
        // start edit website logo
        $(".change-logo").click(function () {
            $("#updateImageResult").html("");
            // get image
            var image = $(this).attr("src");
            // set image into model
            $(".old-image").attr("src", image);
            $("#updateImage").submit(function () {
                $.ajax({
                    url: "<?php echo BASE_URL . "Setting/update_image"; ?>",
                    type: "POST",
                    data: new FormData(this), // Data sent to server, a set of key/value pairs (i.e. form fields and values)
                    contentType: false,       // The content type used when sending data to the server.
                    processData: false,
                    beforeSend: function () {
                        $(".loadingImage").show();
                    },
                    statusCode: {
                        404: function () {
                            alert("page not found");
                        },
                    },
                    success: function (valdata) {
                        $(".loadingImage").hide();
                        var da = jQuery.parseJSON(valdata);
                        if (da['status'] == "success") {
                            $(".loadingImage").hide();
                            $("#updateImageResult").html('<div class="alert alert-success" role="alert"><strong>Success </strong> Image Updated Successfuly </div>');
                            $('#update-img').modal('hide');
                            $('.change-logo').attr("src", "<?php echo UPLOAD_LINK; ?>" + da['newImage']);

                        } else {
                            $("#updateImageResult").html('<div class="alert alert-danger" role="alert"><strong> Error ! </strong> Error Update Your Image (Not Allowed Image Extension Or You Did Not Choose Image)</div>');
                        }
                    }
                });
                return false;
            });
        });
        // end edit website logo
    });
</script>
