<?php 
include('inc/header.php');
include('inc/sidebar.php');
 
$manage_about = new website();
@$edit_id = (int)$_GET['edit'];

if(isset($_POST['submit']) && $edit_id!=0)
{
    $manage_about->update_about($_POST,$edit_id);
}
if($edit_id!=0)
{
    $get_category_info = $manage_about->fetch_rows("tbl_about","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 method="post" enctype="multipart/form-data">
                            <div class="row"> 
                            
                            <div class="col-md-12">
                                    <div class="form-group">
                                        <label>Title *</label>
                                        <input type="text" class="form-control" placeholder="Enter Title" required name="title" id="title" value="<?=$get_category_info['title']?>">

                                        <div class="help-block with-errors"></div>
                                    </div>
                                </div>

                             
                                
                                <div class="col-md-12">
                                    <div class="form-group">
                                        <label>Metakey*</label>
                                        <textarea type="text" class="form-control" placeholder="Enter Metakey Here" name="metakey"><?=$get_category_info['meta_keyword']?></textarea>
                                        <div class="help-block with-errors"></div>
                                    </div>
                                </div> 
                                <div class="col-md-12">
                                    <div class="form-group">
                                        <label>Meta Description</label>
                                        <textarea type="text" class="form-control" placeholder="Enter Meta Description Here" name="metadesc"><?=$get_category_info['meta_description']?></textarea>
                                        <div class="help-block with-errors"></div>
                                    </div>
                                </div>  
                                 <div class="col-md-12">
                                    <div class="form-group">
                                        <label>Description</label>
                                        <textarea type="text" class="form-control" placeholder="Enter Description" id="editor" name="description"><?=$get_category_info['description']?></textarea>
                                        <div class="help-block with-errors"></div>
                                    </div>
                                </div>                               
                                <div class="col-md-12">
                                    <div class="form-group">
                                        <label>Image</label>
                                        <input type="file" class="form-control image-file" name="image" <?php if($edit_id==0) echo 'required'; ?>>
                                    </div>
                                    <?php
                                    if($edit_id!=0)
                                    {
                                        if($get_category_info['image']!='')
                                        {
                                            ?>
                                            <img src="../images/main_img/<?=$get_category_info['image']?>" style="height:100px;width:100px; ">
                                            <?php
                                        }
                                    }
                                    ?>
                                </div>


                              
                                                            
                            </div>                            
                            <button type="submit" class="btn btn-primary mr-2" name="submit"><?php if($edit_id!=0){ echo 'Edit Pages'; } else { echo 'Add Pages'; } ?></button>
                            <button type="reset" class="btn btn-danger">Reset</button>



                        </form>


                        </div>
                            </div>
                           
                        </div>
                    </div>


    <script type="text/javascript">

    CKEDITOR.replace('editor', {
        filebrowserUploadUrl: 'ck_upload.php',
        filebrowserUploadMethod: 'form'
    });
    /*CKEDITOR.replace('editor2', {
        filebrowserUploadUrl: 'ck_upload.php',
        filebrowserUploadMethod: 'form'
    });
    */
    $('#category_name').on('input',function(){
           var cat = $('#category_name').val();
           var cat = cat.replace(/ /gi,"-");
           $('#cat_url').val(cat.toLowerCase());
    });

    </script>
   <?php
    include('inc/footer.php'); ?>