{{ header }}{{ column_left }}
<div id="content">
  <div class="page-header">
   <div class="container-fluid">
          <div class="pull-right touragain">
            <a data-toggle="tooltip" title="Display Promotions Using Add Offers Page" class="btn btn-primary addoffers" target="_blank" href="{{ addoffers }}"><i class="fa fa-star"></i> {{ text_addoffers }}</a>
            <a data-toggle="tooltip" title="Learn how to use this combination" class="btn btn-primary documentation" target="_blank" href="http://blog.cartbinder.com/documentation/buy-x-products-and-get-y-offer-on-same-products/"><i class="fa fa-book"></i> Documentation</a>
            <a data-toggle="tooltip" title="Need help, create a ticket" class="btn btn-primary support" target="_blank" href="http://support.cartbinder.com/open.php"><i class="fa fa-life-ring"></i> Support Center</a>
         </div>
    </div>
    </div>
  <div class="page-header">
    <div class="container-fluid">
          <h2>{{ heading_title }}</h2>
          <br>
           <medium><i class="headerinfo3">{{ headerinfo3 }}</i></medium>
    </div>
  </div>
  <div class="page-header">
    <div class="container-fluid">
          <div class="pull-right">
        <a onclick="$('#form').submit();"  class="btn btn-success"><i class="fa fa-save"></i> save</a>
        <a onclick="location = '{{ cancel }}';" class="btn btn-danger"><i class="fa fa-reply"></i> cancel</a>
        </div>
    </div>
  </div>
  <div class="container-fluid">
    {% if error_warning %}
    <div class="alert alert-danger"><i class="fa fa-exclamation-circle"></i> {{ error_warning }}
      <button type="button" class="close" data-dismiss="alert">&times;</button>
    </div>
    {% endif %}
   <div class="panel panel-default">
     <div class="panel-heading">
        <h3 class="panel-title offerform"><i class="fa fa-list"></i> {{ headerinfo1 }}</h3>
      </div>
     <div class="panel-body">1256
    <form action="{{ action }}" method="post" enctype="multipart/form-data" id="form" class="form-horizontal">
       <div class="form-group">
         <label class="col-sm-12 control-label" for="input-sales" style="text-align:left;">{{ text_sales }}</label>
        </div>
        <div class="form-group">
         <label for="status" class="col-sm-2 control-label status" style="text-align:left;">{{ text_status }}</label>
         <div class="col-sm-2">
          <select id="status" name="status" class="form-control">
              {% if status %}
              <option value="1" selected="selected">{{ text_enabled }}</option>
              <option value="0">{{ text_disabled }}</option>
              {% else %}
              <option value="1">{{ text_enabled }}</option>
              <option value="0" selected="selected">{{ text_disabled }}</option>
              {% endif %}
            </select>
          </div>
          <label for="name"  class="col-sm-3 control-label">{{ text_nameform }}</label>
          <div class="col-sm-3">
          <input type="text" id="name" name="name" value="{{ name }}" placeholder="{{ text_offername }}" class="form-control name" />
          {% if error_name %}
             <div class="text-danger">{{ error_name }}</div>
          {% endif %}
          </div>
        </div>
        <div class="form-group">
         <label class="col-sm-5 control-label" for="input-new" style="text-align:left;">{{ text_new }}</label>
          <div class="col-sm-2">
         <input type="text" id="primaryquant" name="primaryquant" value="{{ primaryquant }}" class="form-control" />
         </div>
         <label class="col-sm-4  control-label" for="input-quantity" style="text-align:left;">{{ text_quantitybelow }}</label>
        </div>
        <div class="form-group primartyproducts">
          <div class="col-sm-12">
            <input type="text" name="productname" value="" placeholder="{{ text_primaryproducts }}" id="input-product" class="form-control primaryproduct" />
            <div id="product" class="well well-sm" style="height: 150px; overflow: auto;">
              {% for product in primaryproducts %}
              <div id="product{{ product.product_id }}"><i class="fa fa-minus-circle"></i> {{ product.name }}
                <input type="hidden" name="primaryproducts[]" value="{{ product.product_id }}" />
              </div>
              {% endfor %}
            </div>
          </div>
        </div>
        <div class="form-group">
         <label class="col-sm-3 control-label" for="input-free" style="text-align:left;">{{ text_free }}</label>
         <div class="col-sm-2">
         <input type="text" id="secondaryquant" name="secondaryquant" value="{{ secondaryquant }}" class="form-control" />
         </div>
         <label class="col-sm-4  control-label" for="input-quantity" style="text-align:left;">{{ text_quantitybelow2 }}</label>
          </div>
        <div class="form-group">
          <label class="col-sm-1 control-label" for="input-at" style="text-align:left;">{{ text_at }}</label>
         <div class="col-sm-2">
          <select id="type" name="type" class="form-control type">
              {% if type %}
              <option value="1" selected="selected">{{ text_fixed }}</option>
              <option value="0">{{ text_percentage }}</option>
              {% else %}
              <option value="1">{{ text_fixed }}</option>
              <option value="0" selected="selected">{{ text_percentage }}</option>
              {% endif %}
            </select>
          </div>
           <label class="col-sm-2 control-label" for="input-discount" style="text-align:left;">{{ text_discount }}</label>
           <div class="col-sm-1">
           <input type="text" id="discount" name="discount" value="{{ discount }}" class="form-control discount" />
         </div>
        </div>
        <div class="form-group axhide">
         <label class="col-sm-3 control-label" for="input-multidiscount" style="text-align:left;">{{ text_multidiscount }}</label>
         <div class="col-sm-9">
           <input type="text" id="multidiscount" name="multidiscount" value="{{ multidiscount }}" class="form-control multidiscount" placeholder="Format: Qty:Discount;Qty:Discount  EX: 2:10p;3:15p If you write p it means percentage" />
         </div>
        </div>
        <div class="form-group axhide">
         <label class="col-sm-12 control-label" for="input-conditions" style="text-align:left;">{{ text_conditions }}</label>
        </div>
        <div class="form-group customergroup axhide">
          <label class="col-sm-5 control-label" for="input-at" style="text-align:left;">{{ text_customergroup }}</label>
          <div class="col-sm-7">
            <div class="well well-sm" style="height: 150px; overflow: auto;">
              {% for customergroup in customergroups %}
              <div class="checkbox">
                <label>
                  {% if cids is not empty and customergroup.customer_group_id in cids %}
                  <input type="checkbox" name="cids[]" value="{{ customergroup.customer_group_id }}" checked="checked" />
                  {{ customergroup.name }}
                  {% else %}
                  <input type="checkbox" name="cids[]" value="{{ customergroup.customer_group_id }}" />
                  {{ customergroup.name }}
                  {% endif %}
                </label>
              </div>
              {% endfor %}
            </div>
          </div>
        </div>
        <div class="form-group maxquantity axhide">
          <label class="col-sm-5 control-label" for="input-maxquantity" style="text-align:left;">{{ text_maxquantity }}</label>
          <div class="col-sm-7">
                <input type="text" name="maxquantity" value="{{ maxquantity }}" placeholder="{{ help_maxquantity }}" id="input-maxquantity" class="form-control" />
          </div>
        </div>
        <div class="form-group daterange">
          <label class="col-sm-5 control-label" for="input-at" style="text-align:left;">{{ text_daterange }}</label>
          <div class="col-sm-3">
              <div class="input-group date">
                <input type="text" name="datestart" value="{{ datestart }}" placeholder="{{ text_datestart }}" data-date-format="YYYY-MM-DD" id="input-datestart" class="form-control" />
                <span class="input-group-btn">
                <button class="btn btn-default" type="button"><i class="fa fa-calendar"></i></button>
                </span></div>
                <div class="input-group date">
                <input type="text" name="dateend" value="{{ dateend }}" placeholder="{{ text_dateend }}" data-date-format="YYYY-MM-DD" id="input-dateend" class="form-control" />
                <span class="input-group-btn">
                <button class="btn btn-default" type="button"><i class="fa fa-calendar"></i></button>
                </span></div>
            </div>
        </div>
        <div class="form-group uses_customer">
           <label class="col-sm-5 control-label" for="input-uses-customer" style="text-align:left;"><span data-toggle="tooltip" title="The maximum number of times the coupon can be used by a single customer. Leave blank for unlimited">Uses Per Customer</span></label>
          <div class="col-sm-3">
             <input type="text" name="uses_customer" value="{{ uses_customer }}" placeholder="Uses Per Customer" id="input-uses-customer" class="form-control" />
            </div>
        </div>
         <div class="form-group">
          <label class="col-sm-5 control-label" for="input-at" style="text-align:left;">{{ text_salesoffer }}</label>
         <div class="col-sm-2">
          <select id="sales_offer_id" name="sales_offer_id" class="form-control type">
            <option value="">Please Select</option>
             {% for key,value in offerpages %}
              {% if value.salescombopge_id == sales_offer_id %}
              <option value="{{ value.salescombopge_id }}" selected="selected">{{ value.title }}</option>
              {% else %}
              <option value="{{ value.salescombopge_id }}">{{ value.title }}</option>
              {% endif %}
              {% endfor %}
            </select>
          </div>
        </div>
        <div class="form-group axhide">
          <label class="col-sm-5 control-label" for="input-showoffer" style="text-align:left;">{{ text_showoffer }}</label>
         <div class="col-sm-7">
          <select id="input-showoffer" name="showoffer" class="form-control">
              {% if showoffer %}
              <option value="1" selected="selected">{{ text_enabled }}</option>
              <option value="0">{{ text_disabled }}</option>
              {% else %}
              <option value="1">{{ text_enabled }}</option>
              <option value="0" selected="selected">{{ text_disabled }}</option>
              {% endif %}
            </select>
            <label class="col-sm-12 control-label" for="input-displaylocation" style="text-align:left;">{{ text_displaylocation }}</label>
            <div class="col-sm-12">
                  <label class="radio-inline">
                    {% if displaylocation == '0' %}
                    <input type="radio" name="displaylocation" value="0" checked="checked" />
                    {{ text_displaylocation1 }}
                    {% else %}
                    <input type="radio" name="displaylocation" value="0" />
                    {{ text_displaylocation1 }}
                    {% endif %}
                  </label>
                  <label class="radio-inline">
                    {% if displaylocation == '1' %}
                    <input type="radio" name="displaylocation" value="1" checked="checked" />
                    {{ text_displaylocation2 }}
                    {% else %}
                    <input type="radio" name="displaylocation" value="1" />
                    {{ text_displaylocation2 }}
                    {% endif %}
                  </label>
                </div>
               <label class="col-sm-12 control-label" for="input-bundle" style="text-align:left;">{{ text_bundle }}</label>
               <div class="col-sm-12">
                <select id="input-bundle" name="bundle" class="form-control">
                    {% if bundle %}
                    <option value="1" selected="selected">{{ text_enabled }}</option>
                    <option value="0">{{ text_disabled }}</option>
                    {% else %}
                    <option value="1">{{ text_enabled }}</option>
                    <option value="0" selected="selected">{{ text_disabled }}</option>
                    {% endif %}
                  </select>
                </div>
          </div>
        </div>
    </form>
  </div>
</div>
</div>
{{ footer }}
</div>
<link href='https://fonts.googleapis.com/css?family=Open+Sans' async rel='stylesheet' type='text/css'>
<script type="text/javascript">
$('input[name=\'productname\']').autocomplete({
  'source': function(request, response) {
    $.ajax({
     url: 'index.php?route=catalog/product/autocomplete&user_token={{ user_token }}&filter_name=' +  encodeURIComponent(request),
      dataType: 'json',
      success: function(json) {
        response($.map(json, function(item) {
          return {
            label: item.name,
            value: item.product_id
          }
        }));
      }
    });
  },
  'select': function(item) {
    $('input[name=\'productname\']').val('');

    $('#product' + item.value).remove();

    $('#product').append('<div id="product' + item.value + '"><i class="fa fa-minus-circle"></i> ' + item.label + '<input type="hidden" name="primaryproducts[]" value="' + item.value + '" /></div>');
  }
});

$('#product').delegate('.fa-minus-circle', 'click', function() {
  $(this).parent().remove();
});

</script>

<script type="text/javascript">
$('.date').datetimepicker({
  pickTime: false
});
</script>
