<?php $this->load->view('includes/header'); ?> 
<div class="page-title">
  <h2><span><?php echo $heading_title; ?></span></h2><div class="buttons">
    <a href="javascript:void(0);" onclick="history.back();" class="btn btn-primary pull-right">Cancel</a>  
  </div>
</div>   
<div class="page-content-wrap">                

  <div class="row">

    <div class="col-md-12">
      <div class="panel panel-default">
        <div class="panel-body">
          <?php
          $bann_arr = $this->config->item('bannersz');
          $processing_result = validation_errors();
          if ($processing_result != '') {
            ?>
            <div class="validation">
              <div style="margin-bottom:6px;">
                <strong><span class="red">ERROR!</span>
                  <br>
                  Please correct the invalid enteries in form given below.</strong>
              </div>
              <?php echo $processing_result; ?>
            </div>
            <?php
          }
          ?>
          <?php echo form_open_multipart('sitepanel/banners/add/', 'class="form-horizontal"'); ?>

          <div class="form-group">
            <label class="col-md-3 col-xs-12 control-label"><span class="required">*</span>Section</label>
            <div class="col-md-6 col-xs-12">
              <select class="form-control" name="section"  onchange="change_ban_postions(this.value);">
                <option value="">Select Section</option>
                <?php
                foreach ($this->config->item('bannersections') as $key => $val) {
                  $sel = ($this->input->post('section') == $key ) ? "selected" : "";
                  ?> 
                  <option value="<?php echo $key; ?>" <?php echo $sel; ?> ><?php echo $val; ?></option> 
                  <?php
                }
                ?>  
              </select>
            </div>
          </div>
          
          <div class="form-group">
            <label class="col-md-3 col-xs-12 control-label"><span class="required">*</span>Banner Position</label>
            <div class="col-md-6 col-xs-12">
              <div id="ban_postion">
                <?php echo banner_postion_drop_down('banner_position', $this->input->post('banner_position'), $this->input->post('section'), 'class="form-control"'); ?>
              </div>
            </div>
          </div>
          
          <div class="form-group">
            <label class="col-md-3 col-xs-12 control-label"><span class="required">*</span>Banner Image</label>
            <div class="col-md-6 col-xs-12">
              <a class="file-input-wrapper btn btn-default  fileinput btn-primary"><span>Browse file</span><input type="file" class="fileinput btn-primary" name="image1" id="image1" title="Browse file" accept="image/*"></a>
            </div>
          </div>
          
          <div class="form-group">
            <label class="col-md-3 col-xs-12 control-label"><span class="required">*</span>Banner URL</label>
            <div class="col-md-6 col-xs-12">                                                                                          <input type="text" name="url" id="url" class="form-control" value="<?php echo set_value('url') ?>" /> (e.g http://wwww.google.co.in)                                                    
            </div>
          </div>

          <div class="form-group">
            <label class="col-md-3 col-xs-12 control-label"><span class="required">*</span>Start Date</label>
            <div class="col-md-3 col-xs-12">
              <input type="date" name="start_date" class="form-control" value="" />
            </div>
          </div>
          
          <div class="form-group">
            <label class="col-md-3 col-xs-12 control-label"><span class="required">*</span>End Date</label>
            <div class="col-md-3 col-xs-12">
              <input type="date" name="end_date" class="form-control" value="" />
            </div>
          </div>
          
          <div class="form-group">
            <label class="col-md-3 col-xs-12 control-label">Keyword (if Any)</label>
            <div class="col-md-6 col-xs-12">
              <input type="text" placeholder="Keyword (comma seperated) to banner display in search .." name="keyword" class="form-control" value="" />
            </div>
          </div>
          
          <div class="form-group">
            <label class="col-md-3 col-xs-12 control-label">Company Name</label>
            <div class="col-md-3 col-xs-12">
              <select name="company_name" class="form-control">
                <option value="">--- Select Company ---</option>
              </select>
            </div>
          </div>
          
          <div class="form-group">
            <label class="col-md-3 col-xs-12 control-label">Choose Product Category</label>
            <div class="col-md-6 col-xs-12">
              <input id="dashkeyword" name="dashkeyword" placeholder="Type Keywords to Search Category.." value="<?php echo set_value('dashkeyword'); ?>" required type="text" class="form-control">
            </div>
            <div class="col-md-9 col-md-offset-3 col-xs-12">
              <div class="categoryList">
              </div>
            </div>
          </div>
          

          <div class="form-group">
            <div class="col-md-6 col-xs-12">
              <input type="submit" name="sub" value="Add Banner" class="btn btn-primary pull-right" />
              <input type="hidden" name="action" value="addbanner" />
            </div>
          </div>
          <?php echo form_close(); ?>
        </div>
      </div>
    </div>
  </div>
</div>

<script type="text/javascript">
  function change_ban_postions() {
    var section = $('[name="section"]').val();
    if (section != '' && section != 'undefined') {
      $.ajax({
        type: "POST",
        url: "<?php echo base_url(); ?>sitepanel/banners/ajx_ban_postions",
        data: {banner_section: section}
      }).done(function (data) {
        $('#ban_postion').html(data);
      });
    }
    return false;
  }

  $('#dashkeyword').keyup(function () {
    var key = $(this).val();
    if (key.length >= 3) {
      $.post('<?php echo site_url(); ?>category/category_search_banner', {keyword: key}, function (data) {
        //alert(data);
        $('.categoryList').html('');
        $('.categoryList').html(data);
      });
    }
  });
</script>
<?php $this->load->view('includes/footer'); ?>