<?php $this->load->view('element/head');?>
  <!-- Content Wrapper. Contains page content -->
  <div class="content-wrapper" xmlns="http://www.w3.org/1999/html">
    <!-- Content Header (Page header) -->
    <section class="content-header">
      <h1>
        Register Form
        <small>List Register</small>
      </h1>
      <ol class="breadcrumb">
        <li><a href="#"><i class="fa fa-dashboard"></i> Register Form</a></li>
        <li class="active">Here</li>
      </ol>
    </section>

    <!-- Main content -->
    <section class="content">
	
      <div class="row">
        <div class="col-xs-12">
          <ul class="nav nav-tabs">
            <li role="presentation" class="active"><a href="<?php echo site_url('register/create');?>">Input Register</a></li>
            <li role="presentation"><a href="<?php echo site_url('register');?>">List Register</a></li>
          </ul>
		  <div class="box box-info">
            <div class="box-header with-border">
              <h3 class="box-title">Register</h3>
              <?php if($this->session->flashdata('form_false')){?>
                <div class="alert alert-danger text-center">
                  <strong><?php echo $this->session->flashdata('form_false');?></strong>
                </div>
              <?php } ?>
            </div>
            <!-- /.box-header -->
            <!-- form start -->
            <?php if(!empty($register)){?>
            <form class="form-horizontal" method="POST" action="<?php echo site_url('register/save').'/'.$register['id'];?>">
            <?php }else{?>
            <form class="form-horizontal" method="POST" action="<?php echo site_url('register/save');?>">
            <?php } ?>
              <div class="box-body">
                <div class="col-md-6">
                  <div class="form-group" style="display: none;">
                    <label class="col-sm-4 control-label" for="username">Username</label>
                    <div class="col-sm-8">
                      <input type="text" value="<?php echo !empty($register) ? $register['username'] : '';?>" id="username" name="username" class="form-control" placeholder="Username"/>
                    </div>
                  </div>
                  <div class="form-group">
                    <label class="col-sm-4 control-label" for="voucher">Voucher</label>
                    <div class="col-sm-8">
                      <input type="text" value="<?php echo !empty($register) ? $register['voucher'] : '';?>" name="voucher" placeholder="Voucher" id="voucher" class="form-control" required/>
                    </div>
                  </div>
                  <div class="form-group">
                    <label class="col-sm-4 control-label" for="item_name">Item Name</label>
                    <div class="col-sm-8">
                      <input type="text" value="<?php echo !empty($register) ? $register['item_name'] : '';?>" name="item_name" placeholder="Item Name" id="item_name" class="form-control" required/>
                    </div>
                  </div>
                  <div class="form-group">
                    <label class="col-sm-4 control-label" for="id_image">Item Value</label>
                    <div class="col-sm-8">
                      <select name="id_image" id="id_image" class="form-control">
                      <option value="">== CHOOSE VALUE ==</option>
                        <?php if(isset($item) && is_array($item)){?>
                          <?php foreach($item as $item){?>
                            <option value="<?php echo $item->id;?>" <?php if(!empty($register) && $item->id == $register['id_image']) echo 'selected="selected"';?>>
                              <?php echo $item->value;?>
                            </option>
                          <?php }?>
                          <?php }?>
                      </select>
                    </div>
                  </div>
                </div>
                <div class="col-md-6">
                <div class="form-group">
                    <label class="col-sm-4 control-label" for="used">Used</label>
                    <div class="col-sm-8">
                    <select name="used" id="used" class="form-control">
                      <?php if (isset($register['used'])) {?>
                      <?php $r = $register['used']; if ($register['used'] == 0) {echo "<option value='$r' selected='selected'>Voucher is vailable"."<option value='1'>Voucher is used";}else{echo "<option value='$r' selected='selected'>Voucher is used"."<option value='0'>Voucher is vailable";}?>
                      <?php } else { ?>
                      <option value="0">Voucher is available</option>
                      <option value="1">Voucher is used</option>
                      <?php } ?>
                      </select>
                    </div>
                  </div>
                  <div class="form-group" style="display: none;">
                    <label class="col-sm-4 control-label" for="date_first">Date Expired</label>
                    <div class="col-sm-8">
                    <div class="input-group">
                    <div class="input-group-addon">
                    <i class="fa fa-clock-o"></i>
                    </div>
                    <input type="text" name="date" value="<?php echo !empty($register) ? $register['date_first']." - ".$register['date_last'] : '';?>" class="datetime form-control pull-right" id="reservationtime">
                    </div>
                    </div>
                  </div>
                </div>
              </div>
              <!-- /.box-body -->
              <div class="box-footer">
                <div class="col-md-3 col-md-offset-4">
                  <a class="btn btn-default" href="<?php echo site_url('register');?>">Cancel</a>
                  <button class="btn btn-info pull-right" type="submit">Save</button>
                </div>
              </div>
              <!-- /.box-footer -->
            </form>
          </div>
		</div>
        <!-- /.col -->
      </div>
	  <!-- row -->
    </section>
    <!-- /.content -->
  </div>
  <!-- /.content-wrapper -->
<?php $this->load->view('element/footer');?>