<?php
    $errors = $this->session->userdata('errors');
    if (isset($errors)) {
        ?>
        <script>
            swal ( "Oops" ,  "<?php echo $errors ?>" ,  "error" )
        </script>
        <?php echo $errors ?>
        <?php
        $this->session->unset_userdata('errors');
    }
    $error = $this->session->userdata('error');
    if (isset($error)) {
        ?>
         <script>
            swal ( "Oops" ,  "<?php echo $error ?>" ,  "error" )
        </script>
        <?php
        $this->session->unset_userdata('error');
    }
    $success = $this->session->userdata('success');
    if (isset($success)) {
        ?>
         <script>
            swal({
          title: "Done!",
          text: "<?php echo $success ?>",
          icon: "success",
        });
        </script>
        <?php
        $this->session->unset_userdata('success');
    }
    ?>
  <!-- Content Wrapper. Contains page content -->
  <div class="content-wrapper">
    <!-- Content Header (Page header) -->
    <section class="content-header">
      <div class="container-fluid">
        <div class="row mb-2">
          <div class="col-sm-6">
            <h1>Stacks</h1>
          </div>
          <div class="col-sm-6">
            <ol class="breadcrumb float-sm-right">
              <li class="breadcrumb-item"><a href="<?php echo admin_url() ?>admin">Home</a></li>
              <li class="breadcrumb-item active">Stacks</li>
            </ol>
          </div>
        </div>
      </div><!-- /.container-fluid -->
    </section>

    <section class="content">
      <div class="container-fluid">
        <div class="row">
          <div class="col-sm-12">
            <div class="card card-default">
              <div class="card-header">
                <h4>Update Section Heading & Sub-Heading</h4>
              </div>
              <!-- /.card-header -->
              <?php echo form_open(base_url().'admin/lab_page/update_section_4_content_i'); ?>
              <div class="card-body">
                <div class="row">
                  <div class="col-md-12">
                    <div class="form-group">
                      <label>Heading 1<span class="required">*</span></label>
                      <input type="text" name="heading_1" class="form-control" placeholder="Enter Heading 1" required="" value="<?php echo $section_4_i->heading_1; ?>">
                    </div>
                  </div>

                  <div class="col-md-12">
                    <div class="form-group">
                      <label>Heading 2<span class="required">*</span></label>
                      <input type="text" name="heading_2" class="form-control" placeholder="Enter Heading 2" required="" value="<?php echo $section_4_i->heading_2; ?>">
                    </div>
                  </div>

                  <div class="col-md-12">
                    <div class="form-group">
                      <label>Description<span class="required">*</span></label>
                      <textarea type="text" name="sub_heading" class="form-control" placeholder="Enter Description" required=""><?php echo $section_4_i->sub_heading; ?></textarea>
                    </div>
                  </div>
                 
                  <div class="col-md-12">
                    <div class="form-group">
                      <button class="btn btn-info" type="submit" style="float: right">Update</button>
                    </div>
                  </div>
                  <?php echo form_close(); ?>
                </div>
              </div>
            </div>
          </div>
      </div>
    </section>

    <!-- Main content -->
    <section class="content">
      <div class="container-fluid">
        <div class="row">
          <div class="col-sm-4">
            <div class="card card-default">
              <div class="card-header">
                <h4>Add New Content</h4>
                
              </div>
              <!-- /.card-header -->
              <?php echo form_open_multipart(base_url().'admin/lab_page/add_new_section_4_content_ii'); ?>
              <div class="card-body">
                <div class="row">
                  <div class="col-md-12">
                    <div class="form-group">
                      <label>Image<span class="required">*</span></label>
                      <input type="file" name="image" class="form-control" placeholder="Enter Content" required="">
                    </div>
                  </div>

                  <div class="col-md-12">
                    <div class="form-group">
                      <label>Title<span class="required">*</span></label>
                      <input type="text" name="title" class="form-control" placeholder="Enter Title" required="">
                    </div>
                  </div>

                  <div class="col-md-12">
                    <div class="form-group">
                      <label>Description<span class="required">*</span></label>
                      <input type="text" name="description" class="form-control" placeholder="Enter description" required="">
                    </div>
                  </div>

                  <div class="col-md-12">
                    <div class="form-group">
                      <label>Price<span class="required">*</span></label>
                      <input type="number" name="price" class="form-control" placeholder="Enter price" required="">
                    </div>
                  </div>

                  <div class="col-md-12">
                    <div class="form-group">
                      <label>Content<span class="required">*</span></label>
                      <input type="text" name="content" class="form-control" placeholder="Enter content" required="">
                    </div>
                  </div>
                 
                  <div class="col-md-12">
                    <div class="form-group">
                      <button class="btn btn-info" type="submit" style="float: right">Add</button>
                    </div>
                  </div>
                  <?php echo form_close(); ?>
                </div>
              </div>
            </div>
          </div>
          
          <div class="col-sm-8">
            <div class="card card-default">
              <div class="card-header">
                <h4>View Content</h4>
                
              </div>
                <div class="card-body">
                  <table id="example" class="table table-bordered table-striped">
                    <thead>
                    <tr>
                      <th>id</th>
                      <th>Image</th>
                      <th>Title</th>
                      <th>Description</th>
                      <th>Price</th>
                      <th>Content</th>
                      <th></th>
                    </tr>
                    </thead>
                    <tbody>
                    <?php $i=1; foreach ($section_4_ii as $key => $stacks):?>
                    <tr>
                      <td><?php echo $i ?></td>
                      <td><img src="<?php echo base_url()?><?php echo $stacks->image ?>" width="50px"></td>
                      <td><?php echo $stacks->title ?></td>
                      <td><?php echo $stacks->description ?></td>
                      <td><?php echo $stacks->price ?></td>
                      <td><?php echo $stacks->content ?></td>
                      <td><a href="" class="btn btn-info btn-sm" data-toggle="modal" data-target="#update-stacks<?php echo $stacks->id ?>"><i class="fa fa-edit" aria-hidden="true"></i></a>
                        <a class="btn btn-danger btn-sm" onclick="return confirm('Are you sure?')" href="<?php echo base_url() ?>admin/lab_page/delete_section_4_content_ii/<?php echo $stacks->id ?>"><i class="fa fa-trash" aria-hidden="true"></i></a></td>
                    </tr>
                    <?php $i++; ?>
                    <?php endforeach; ?>
                    </tbody>
                    
                  </table>
                </div>
              </div>
            </div>
          </div>
      </div>
    </section>
    <!-- /.content -->
  </div>
<?php $i=1; foreach ($section_4_ii as $key => $stacks):?>
<div class="modal fade" id="update-stacks<?php echo $stacks->id ?>" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel" aria-hidden="true">
  <div class="modal-dialog" role="document">
    <div class="modal-content">
      <div class="modal-header">
        <h5 class="modal-title" id="exampleModalLabel">Update Content</h5>
        <button type="button" class="close" data-dismiss="modal" aria-label="Close">
          <span aria-hidden="true">&times;</span>
        </button>
      </div>
      <div class="modal-body">
        <?php echo form_open_multipart(base_url().'admin/lab_page/update_section_4_content_ii'); ?>
          <div class="col-md-12">
            <div class="form-group">
              <label>Image</label>
              <input type="file" name="image" class="form-control" placeholder="Enter Content">
            </div>
          </div>

          <div class="col-md-12">
            <div class="form-group">
              <label>Image<span class="required">*</span></label>
              <img src="<?php echo base_url()?><?php echo $stacks->image ?>" width="100px">
            </div>
          </div>

          <div class="col-md-12">
            <div class="form-group">
              <label>Title<span class="required">*</span></label>
              <input type="text" name="title" class="form-control" placeholder="Enter Title" required="" value="<?php echo $stacks->title; ?>">
            </div>
          </div>

          <div class="col-md-12">
            <div class="form-group">
              <label>Description<span class="required">*</span></label>
              <input type="text" name="description" class="form-control" placeholder="Enter description" required="" value="<?php echo $stacks->description; ?>">
            </div>
          </div>

          <div class="col-md-12">
            <div class="form-group">
              <label>Price<span class="required">*</span></label>
              <input type="number" name="price" class="form-control" placeholder="Enter price" required="" value="<?php echo $stacks->price; ?>">
            </div>
          </div>

          <div class="col-md-12">
            <div class="form-group">
              <label>Content<span class="required">*</span></label>
              <input type="text" name="content" class="form-control" placeholder="Enter content" required="" value="<?php echo $stacks->content; ?>">
            </div>
          </div>
        </div>
        <input type="hidden" name="id" class="form-control" value="<?php echo $stacks->id ?>">
      <div class="modal-footer">
        <button type="button" class="btn btn-secondary" data-dismiss="modal">Close</button>
        <button type="submit" class="btn btn-primary">Update</button>
      </div>
      <?php echo form_close(); ?>
    </div>
  </div>
</div>
<?php endforeach; ?>