<?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 SMS Marketing
        <!-- <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="#">SMS Marketing</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'] == 'nonmasking' || $var['type']  == 'masking'){
            $link = site_url('Welcome/sms_marketing');
          }
      ?>

      <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 SMS Marketing 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/SmsMarketing/submitSmsPackage'); ?>">
                  <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="masking">Masking</option>
                          <option value="nonmasking">Non Masking</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{ ?>
      <div class="box">
        <div class="box-header with-border">
          <h3 class="box-title">Edit SMS Marketing 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/SmsMarketing/updateSmsMarketing'); ?>">
              <?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="masking" <?php if($result['type'] == 'masking'){ echo "selected"; } ?> >Masking</option>
                          <option value="nonmasking" <?php if($result['type'] == 'nonmasking'){ echo "selected"; } ?> >Non Masking</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="smspackageid" value="<?= $result['smspackageid']; ?>">
                  <?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');

?>  