<?php

    $this->load->view('master/header');
    $this->load->view('master/sidebar');

?>  


  <!-- Content Wrapper. Contains page content -->
  <div class="content-wrapper">
    <!-- Content Header (Page header) -->
    <section class="content-header">
      <h1>
        Add Other Hosting
        <!-- <small>it all starts here</small> -->
      </h1>
      <ol class="breadcrumb">
        <li><a href="#"><i class="fa fa-dashboard"></i> Home</a></li>
        <li><a href="#">Other Hosting Packages</a></li>
        <li class="active">Add Packages</li>
      </ol>
    </section>

    <!-- Main content -->
    <section class="content">

      <?php 
        if($this->session->flashdata('success')){ 

          $var = $this->session->flashdata('success');

          if($var['type'] == 'shared_hosting' || $var['type']  == 'wordpress_hosting'){
            $link = site_url('Welcome/shared_hosting');
          }
          elseif($var['type'] == 'fb_packages'){
            $link = site_url('Welcome/facebook_marketing');
          }
          elseif($var['type'] == 'email_marketing'){
            $link = site_url('Welcome/email_marketing');
          }
          elseif($var['type'] == 'google_adwords'){
            $link = site_url('Welcome/google_adwords');
          }
          else{
            $link = site_url('Welcome/web_packages');
          }
      ?>

      <div class="alert alert-success alert-dismissible">
        <button type="button" class="close" data-dismiss="alert" aria-hidden="true">×</button>
        <h4><i class="icon fa fa-check"></i> Alert!</h4>
        <?php echo $var['s_msg']; ?>. <a href="<?php echo $link; ?>" target="_blank">View Page</a>
      </div>

      <?php } ?>

      <?php if($this->session->flashdata('error')){ ?>

      <div class="alert alert-danger alert-dismissible">
        <button type="button" class="close" data-dismiss="alert" aria-hidden="true">×</button>
        <h4><i class="icon fa fa-ban"></i> Alert!</h4>
        <?php echo $this->session->flashdata('error'); ?>.
      </div>

      <?php } ?>
      
      <?php if(!isset($edit)){ ?>
      <!-- Default box -->
      <div class="box">
        <div class="box-header with-border">
          <h3 class="box-title">Add Package</h3>

          <div class="box-tools pull-right">
            <button type="button" class="btn btn-box-tool" data-widget="collapse" data-toggle="tooltip"
                    title="Collapse">
              <i class="fa fa-minus"></i></button>
            <button type="button" class="btn btn-box-tool" data-widget="remove" data-toggle="tooltip" title="Remove">
              <i class="fa fa-times"></i></button>
          </div>
        </div>
        <div class="box-body">
          <div class="row">
            <div class="col-md-12">
                <form class="form-vertical" method="post" action="<?= site_url('user/HostingPackage/submitHostingPackage'); ?>">
                  <div class="form-group">
                    <input class="form-control" name="title" type="text" placeholder="Title">
                  </div>
                  <div class="row">
                    <div class="col-md-6">
                      <div class="form-group">
                        <input class="form-control" name="price" type="text" placeholder="Price">
                      </div>
                    </div>
                    <div class="col-md-6">
                      <div class="form-group">
                        <select class="form-control" name="type" id="">
                          <option value="shared_hosting">Shared Hosting</option>
                          <option value="wordpress_hosting">Wordpress Hosting</option>
                          <option value="fb_packages">FB Packages</option>
                          <option value="email_marketing">Email Marketing</option>
                          <option value="google_adwords">Google Adwords</option>
                          <option value="web_packages">Web Packages</option>
                        </select>
                      </div>
                    </div>
                  </div>
                  <div class="form-group">
                    <textarea id="editor1" name="description" class="form-control" placeholder="Description"></textarea>
                  </div>
                  <div class="form-group">
                    <button class="btn btn-success">Save</button>
                  </div>
                </form>
            </div>

          </div>
        </div>
        <!-- /.box-body -->
      </div>
      <!-- /.box -->
      <?php }else{ ?>

      <!-- Default box -->
      <div class="box">
        <div class="box-header with-border">
          <h3 class="box-title">Edit Package</h3>

          <div class="box-tools pull-right">
            <button type="button" class="btn btn-box-tool" data-widget="collapse" data-toggle="tooltip"
                    title="Collapse">
              <i class="fa fa-minus"></i></button>
            <button type="button" class="btn btn-box-tool" data-widget="remove" data-toggle="tooltip" title="Remove">
              <i class="fa fa-times"></i></button>
          </div>
        </div>
        <div class="box-body">
          <div class="row">
            <div class="col-md-12">
                <form class="form-vertical" method="post" action="<?= site_url('user/HostingPackage/updateHostingPackage'); ?>">

                  <?php foreach($results as $result){ ?>
                  <div class="form-group">
                    <input class="form-control" name="title" type="text" value="<?= $result['title']; ?>" placeholder="Title">
                  </div>
                  <div class="row">
                    <div class="col-md-6">
                      <div class="form-group">
                        <input class="form-control" name="price" type="text" value="<?= $result['price']; ?>" placeholder="Price">
                      </div>
                    </div>
                    <div class="col-md-6">
                      <div class="form-group">
                        <select class="form-control" name="type" id="">
                          <option value="shared_hosting" <?php if($result['type'] == "shared_hosting" ){ echo "selected"; } ?> >Shared Hosting</option>
                          <option value="wordpress_hosting" <?php if($result['type'] == "wordpress_hosting" ){ echo "selected"; } ?> >Wordpress Hosting</option>
                          <option value="fb_packages" <?php if($result['type'] == "fb_packages" ){ echo "selected"; } ?> >FB Packages</option>
                          <option value="email_marketing" <?php if($result['type'] == "email_marketing" ){ echo "selected"; } ?> >Email Marketing</option>
                          <option value="google_adwords" <?php if($result['type'] == "google_adwords" ){ echo "selected"; } ?> >Google Adwords</option>
                          <option value="web_packages" <?php if($result['type'] == "web_packages" ){ echo "selected"; } ?> >Web Packages</option>
                        </select>
                      </div>
                    </div>
                  </div>
                  <div class="form-group">
                    <textarea id="editor1" name="description" class="form-control" placeholder="Description"><?= $result['description']; ?></textarea>
                  </div>
                  <input type="hidden" name="packageid" value="<?= $result['packageid']; ?>">
                  <?php } ?>
                  <div class="form-group">
                    <button class="btn btn-success">Save</button>
                  </div>
                </form>
            </div>

          </div>
        </div>
        <!-- /.box-body -->
      </div>
      <!-- /.box -->
      <?php } ?>


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

<?php

    $this->load->view('master/footer');

?>  