<?php 
include('inc/header.php');
include('inc/sidebar.php');
 
$manage_address = new website();
 
@$edit_id = $_GET['edit'];
 
if(isset($_POST['submit']) && $edit_id!=0)
{
    $manage_address->update_address($_POST,$edit_id);
}
if($edit_id!=0)
{
    $get_address_info = $manage_address->fetch_rows("tbl_address","where id=$edit_id");
}
  
?>

<div class="container">


 <div class="row">
                        <div class="col-xl-7 mx-auto">

                            <h6 class="mb-0 text-uppercase">Address Form</h6>
                            <hr/>
                            
                            <div class="card border-top border-0 border-4 border-primary">
                                <div class="card-body p-5">
                                    <div class="card-title d-flex align-items-center">
                                        <div><i class="fa fa-ticket"></i>
                                        </div>
                                        <h5 class="mb-0 text-primary">Add Address</h5>
                                    </div>
                                    <hr>
                                    <form class="row g-3" method="post" enctype="multipart/form-data">
                                        <div class="col-md-6">
                                            <label for="inputFirstName" class="form-label">Phone 1</label>
                                            <input type="text"  name="phone1" class="form-control" id="inputFirstName"  value="<?=$get_address_info['phone1']?>">
                                        </div>

                                        <div class="col-md-6">
                                            <label for="inputFirstName" class="form-label">Phone 2</label>
                                            <input type="text"  name="phone2" class="form-control" id="inputFirstName"  value="<?=$get_address_info['phone2']?>">
                                        </div>

                                         <div class="col-md-6">
                                            <label for="inputFirstName" class="form-label">Email 1</label>
                                            <input type="text"  name="email1" class="form-control" id="inputFirstName"  value="<?=$get_address_info['email1']?>">
                                        </div>

                                        <div class="col-md-6">
                                            <label for="inputFirstName" class="form-label">Facebook link</label>
                                            <input type="text"  name="fb" class="form-control" id="inputFirstName"  value="<?=$get_address_info['fb']?>">
                                        </div>

                                          <div class="col-md-6">
                                            <label for="inputFirstName" class="form-label">Twitter link</label>
                                            <input type="text"  name="twitter" class="form-control" id="inputFirstName"  value="<?=$get_address_info['twitter']?>">
                                        </div>

                                          <div class="col-md-6">
                                            <label for="inputFirstName" class="form-label">Youtube link</label>
                                            <input type="text"  name="youtube" class="form-control" id="inputFirstName"  value="<?=$get_address_info['youtube']?>">
                                        </div>

                                          <div class="col-md-12">
                                            <label for="inputFirstName" class="form-label">Instagram link</label>
                                            <input type="text"  name="insta" class="form-control" id="inputFirstName"  value="<?=$get_address_info['insta']?>">
                                        </div>

                                        <div class="col-md-12">
                                            <label for="inputFirstName"  class="form-label">Address</label>
                                           <textarea id="editor" class="form-control" name="address"><?=$get_address_info['address']?></textarea>
                                        </div>

                                        


                                         <div class="col-md-12">
                                            <label for="inputFirstName" class="form-label">Logo</label>
                                            <input type="file" class="form-control" name="image"><br>
                                             <?php
                                    if($edit_id!=0)
                                    {
                                        if($get_address_info['image']!='')
                                        {
                                            ?>
                                            <img src="../images/main_img/<?=$get_address_info['image']?>" style="height:100px;width:100px; ">
                                            <?php
                                        }
                                    }
                                    ?>
                                        </div>
                              
                                        <div class="col-12">
                                            <button type="submit" class="btn btn-primary px-5" name="submit">Submit</button>
                                        </div>
                                    </form>
                                </div>
                            </div>
                           
                        </div>
                    </div>

 
</div>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<script type="text/javascript">
$("#mobile_no").on("keypress", function(evt) {
  var keycode = evt.charCode || evt.keyCode;
  if (keycode == 46) {
    return false;
  }
});
 

    CKEDITOR.replace('editor', {
        filebrowserUploadUrl: 'ck_upload.php',
        filebrowserUploadMethod: 'form'
    });
    /*CKEDITOR.replace('editor2', {
        filebrowserUploadUrl: 'ck_upload.php',
        filebrowserUploadMethod: 'form'
    });
    */
    
    </script>
 <?php 
include "inc/footer.php";
    ?>

