<!-- Main Content -->
<div class="page-wrapper">
   <div class="container-fluid pt-25">
      <div class="row">
         <div class="alert alert-success alert-dismissible" role="alert" <?php if ($this->session->flashdata('message') == '') { ?> style="display:none" <?php } ?>>
            <button type="button" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">&times;</span></button>
            <?php echo $this->session->flashdata('message'); ?>
         </div>
         <div class="alert alert-warning alert-dismissible" role="alert" <?php if ($this->session->flashdata('emessage') == '') { ?> style="display:none" <?php } ?>>
            <button type="button" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">&times;</span></button>
            <?php echo $this->session->flashdata('emessage'); ?>
         </div>
      </div>
      <!-- Row -->
      <div class="row">
         <div class="col-sm-12">
            <div class="panel panel-default card-view">
               <div class="panel-heading">
                  <div class="pull-left">
                     <h6 class="panel-title txt-dark">Edit Recipes</h6>
                  </div>
                  <div class="clearfix"></div>
               </div>
               <div class="panel-wrapper collapse in">
                  <div class="panel-body">
                     <div class="form-wrap">
                        <form id="addTestimonialFrom" class="form-horizontal" action="<?php echo base_url(A . "/editRecipe"); ?>" enctype="multipart/form-data" method='post'>
                           <input type="hidden" name="id" value="<?php echo $post['id']; ?>" />
                           <div class="row">
                              <div class="col-md-6">
                                 <div class="form-group">
                                    <label class="col-sm-12">Title:</label>
                                    <div class="col-sm-12">
                                       <input type="text" name="title" class="form-control" value="<?php echo $post['title']; ?>" required>
                                    </div>
                                 </div>
                                 <div class="form-group">
                                    <label class="col-sm-12">Category:</label>
                                    <div class="col-sm-12">
                                       <select class="form-control" name="type">
                                          <?php if (isset($category) && !empty($category)) {
                                             foreach ($category as $key => $value) : ?>
                                                <option <?php echo ($post['type'] == $value['id']) ? 'selected' : ''; ?> value="<?php echo $value['id']; ?>"><?php echo $value['category']; ?></option>
                                          <?php endforeach;
                                          } ?>
                                       </select>
                                    </div>
                                 </div>
                                 <?php if ($post['image'] != '') { ?>
                                    <div class="form-group col-sm-12">
                                       <img src="<?php echo base_url($post['image']); ?>" alt="image" style="width:100px;">
                                    </div>
                                 <?php } ?>
                                 <div class="form-group">
                                    <label class="col-sm-12">Image (Image Size - 772x419 PX)</label>
                                    <div class="col-sm-12">
                                       <input type="file" name="image" class="form-control">
                                    </div>
                                 </div>
                                 <div class="form-group">
                                    <label class="col-sm-12">Title1:</label>
                                    <div class="col-sm-12">
                                       <input type="text" name="title1" class="form-control" value="<?php echo $post['title1']; ?>" placeholder="Enter Title">
                                    </div>
                                 </div>
                                 <div class="form-group">
                                    <label class="col-sm-12">Description1:</label>
                                    <div class="col-sm-12">
                                       <div class="fileUpload btn btn-default">
                                          <span>Add Media</span>
                                          <input id="file_1" type="file" name="" class="upload" />
                                       </div>
                                       <textarea name="description1" class="form-control ckeditor" id="ckeditor_1" placeholder="Enter Description"><?php echo $post['description1']; ?></textarea>
                                    </div>
                                 </div>
                              </div>
                           </div>
                           <div class="row">

                             
                              <div class="col-md-6">
                                 <div class="form-group">
                                    <label class="col-sm-12">Title2:</label>
                                    <div class="col-sm-12">
                                       <input type="text" name="title2" class="form-control" value="<?php echo $post['title2']; ?>" placeholder="Enter Title">
                                    </div>
                                 </div>
                                 <div class="form-group">
                                    <label class="col-sm-12">Description2:</label>
                                    <div class="col-sm-12">
                                       <div class="fileUpload btn btn-default">
                                          <span>Add Media</span>
                                          <input id="file_2" type="file" name="" class="upload" />
                                       </div>
                                       <textarea name="description2" class="form-control ckeditor" id="ckeditor_2" placeholder="Enter Description"><?php echo $post['description2']; ?></textarea>
                                    </div>
                                 </div>
                              </div>
                              <div class="col-md-6">
                                 <div class="form-group">
                                    <label class="col-sm-12">Title3:</label>
                                    <div class="col-sm-12">
                                       <input type="text" name="title3" class="form-control" value="<?php echo $post['title3']; ?>" placeholder="Enter Title">
                                    </div>
                                 </div>
                                 <div class="form-group">
                                    <label class="col-sm-12">Description3:</label>
                                    <div class="col-sm-12">
                                       <div class="fileUpload btn btn-default">
                                          <span>Add Media</span>
                                          <input id="file_3" type="file" name="" class="upload" />
                                       </div>
                                       <textarea name="description3" class="form-control ckeditor" id="ckeditor_3" placeholder="Enter Description"><?php echo $post['description3']; ?></textarea>
                                    </div>
                                 </div>
                              </div>
                              <div class="col-md-6">
                                 <div class="form-group">
                                    <label class="col-sm-12">Title4:</label>
                                    <div class="col-sm-12">
                                       <input type="text" name="title4" class="form-control" value="<?php echo $post['title4']; ?>" placeholder="Enter Title">
                                    </div>
                                 </div>
                                 <div class="form-group">
                                    <label class="col-sm-12">Description4:</label>
                                    <div class="col-sm-12">
                                       <div class="fileUpload btn btn-default">
                                          <span>Add Media</span>
                                          <input id="file_4" type="file" name="" class="upload" />
                                       </div>
                                       <textarea name="description4" class="form-control ckeditor" id="ckeditor_4" placeholder="Enter Description"><?php echo $post['description4']; ?></textarea>
                                    </div>
                                 </div>
                              </div>
                              <div class="col-md-6">
                                 <div class="form-group">
                                    <label class="col-sm-12">Title5:</label>
                                    <div class="col-sm-12">
                                       <input type="text" name="title5" class="form-control" value="<?php echo $post['title5']; ?>" placeholder="Enter Title">
                                    </div>
                                 </div>
                                 <div class="form-group">
                                    <label class="col-sm-12">Description5:</label>
                                    <div class="col-sm-12">
                                       <div class="fileUpload btn btn-default">
                                          <span>Add Media</span>
                                          <input id="file_5" type="file" name="" class="upload" />
                                       </div>
                                       <textarea name="description5" class="form-control ckeditor" id="ckeditor_5" placeholder="Enter Description"><?php echo $post['description5']; ?></textarea>
                                    </div>
                                 </div>
                              </div>
                              <div class="col-md-6">
                                 <div class="form-group">
                                    <label class="col-sm-12">Title6:</label>
                                    <div class="col-sm-12">
                                       <input type="text" name="title6" class="form-control" value="<?php echo $post['title6']; ?>" placeholder="Enter Title">
                                    </div>
                                 </div>
                                 <div class="form-group">
                                    <label class="col-sm-12">Description6:</label>
                                    <div class="col-sm-12">
                                       <div class="fileUpload btn btn-default">
                                          <span>Add Media</span>
                                          <input id="file_6" type="file" name="" class="upload" />
                                       </div>
                                       <textarea name="description6" class="form-control ckeditor" id="ckeditor_6" placeholder="Enter Description"><?php echo $post['description6']; ?></textarea>
                                    </div>
                                 </div>
                              </div>
                              <div class="col-md-12">
                                 <div class="form-group mb-0">
                                    <div class="col-sm-12">
                                       <button type="submit" class="btn btn-success btn-anim pull-right"><i class="icon-rocket"></i><span class="btn-text">Update</span></button>
                                    </div>
                                 </div>
                              </div>
                           </div>
                        </form>
                     </div>
                  </div>
               </div>
            </div>
         </div>
      </div>
      <!-- /Row -->
   </div>
   <script src="<?php echo base_url("assets/admin/vendors/ckeditor/ckeditor.js"); ?>"></script>
   <script src="<?php echo base_url("assets/admin/vendors/ckeditor/adapters/jquery.js"); ?>"></script>
   <style type="text/css">
      .ckeditor {
         min-height: 300px !important;
      }

      label {
         color: #000;
      }

      .fileUpload {
         position: relative;
         overflow: hidden;
         margin: 10px;
      }

      .fileUpload input.upload {
         position: absolute;
         top: 0;
         right: 0;
         margin: 0;
         padding: 0;
         font-size: 20px;
         cursor: pointer;
         opacity: 0;
         filter: alpha(opacity=0);
      }
   </style>
   <script type="text/javascript">
      $(function() {
         $('textarea.ckeditor').ckeditor({
            toolbarGroups: [
               /*{ name: "document",    groups: [ "mode", "document" ] },            // Displays document group with its two subgroups.
               { name: "basicstyles", groups: [ "basicstyles", "cleanup" ] },
               { name: 'insert', groups: [ 'insert' ] },
               { name: "links" },
               { name: 'colors' },
               { name: 'tools' },*/

               {
                  name: 'clipboard',
                  groups: ['clipboard', 'undo']
               },

               {
                  name: 'editing',
                  groups: ['find', 'selection', 'spellchecker']
               },

               {
                  name: 'links'
               },

               {
                  name: 'insert'
               },

               {
                  name: 'document',
                  groups: ['mode', 'document', 'doctools']
               },
               {
                  name: 'basicstyles',
                  groups: ['basicstyles', 'cleanup']
               },
               {
                  name: 'forms'
               },

               {
                  name: 'paragraph',
                  groups: ['list', 'indent', 'blocks', 'align', 'bidi']
               },


               {
                  name: 'tools'
               },

               {
                  name: 'others'
               },


               {
                  name: 'styles'
               },

               {
                  name: 'colors'
               },

               // { name: 'about' }
            ]
         });
      });
      var site_url = "<?php echo base_url(); ?>";
      var urlLink = "<?php echo A; ?>";
      $("#file_1").on("change", function() {
         var file_data = $("#file_1").prop('files')[0];
         var form_data = new FormData();
         form_data.append('file', file_data);
         $.ajax({
            url: site_url + urlLink + "/uploadPostImage",
            dataType: 'text',
            cache: false,
            contentType: false,
            processData: false,
            data: form_data,
            type: 'post',
            success: function(result) {
               var html = '<img src="' + site_url + 'assets/upload-image/' + result + '" style="width:200px;">';
               CKEDITOR.instances['ckeditor_1'].insertHtml(html);
            }
         });
      });
      $("#file_2").on("change", function() {
         var file_data = $("#file_2").prop('files')[0];
         var form_data = new FormData();
         form_data.append('file', file_data);
         $.ajax({
            url: site_url + urlLink + "/uploadPostImage",
            dataType: 'text',
            cache: false,
            contentType: false,
            processData: false,
            data: form_data,
            type: 'post',
            success: function(result) {
               var html = '<img src="' + site_url + 'assets/upload-image/' + result + '" style="width:200px;">';
               CKEDITOR.instances['ckeditor_2'].insertHtml(html);
            }
         });
      });
      $("#file_3").on("change", function() {
         var file_data = $("#file_3").prop('files')[0];
         var form_data = new FormData();
         form_data.append('file', file_data);
         $.ajax({
            url: site_url + urlLink + "/uploadPostImage",
            dataType: 'text',
            cache: false,
            contentType: false,
            processData: false,
            data: form_data,
            type: 'post',
            success: function(result) {
               var html = '<img src="' + site_url + 'assets/upload-image/' + result + '" style="width:200px;">';
               CKEDITOR.instances['ckeditor_3'].insertHtml(html);
            }
         });
      });
      $("#file_4").on("change", function() {
         var file_data = $("#file_4").prop('files')[0];
         var form_data = new FormData();
         form_data.append('file', file_data);
         $.ajax({
            url: site_url + urlLink + "/uploadPostImage",
            dataType: 'text',
            cache: false,
            contentType: false,
            processData: false,
            data: form_data,
            type: 'post',
            success: function(result) {
               var html = '<img src="' + site_url + 'assets/upload-image/' + result + '" style="width:200px;">';
               CKEDITOR.instances['ckeditor_4'].insertHtml(html);
            }
         });
      });
      $("#file_5").on("change", function() {
         var file_data = $("#file_5").prop('files')[0];
         var form_data = new FormData();
         form_data.append('file', file_data);
         $.ajax({
            url: site_url + urlLink + "/uploadPostImage",
            dataType: 'text',
            cache: false,
            contentType: false,
            processData: false,
            data: form_data,
            type: 'post',
            success: function(result) {
               var html = '<img src="' + site_url + 'assets/upload-image/' + result + '" style="width:200px;">';
               CKEDITOR.instances['ckeditor_5'].insertHtml(html);
            }
         });
      });
      $("#file_6").on("change", function() {
         var file_data = $("#file_6").prop('files')[0];
         var form_data = new FormData();
         form_data.append('file', file_data);
         $.ajax({
            url: site_url + urlLink + "/uploadPostImage",
            dataType: 'text',
            cache: false,
            contentType: false,
            processData: false,
            data: form_data,
            type: 'post',
            success: function(result) {
               var html = '<img src="' + site_url + 'assets/upload-image/' + result + '" style="width:200px;">';
               CKEDITOR.instances['ckeditor_6'].insertHtml(html);
            }
         });
      });
   </script>