{{ header }}{{ column_left }}
<div id="content">
  <div class="page-header">
    <div class="container-fluid">
	  <div class="pull-right">
	    <a href="{{ add }}" data-toggle="tooltip" title="{{ button_add }}" class="btn btn-primary"><i class="fa fa-plus"></i></a>
        <button type="button" data-toggle="tooltip" title="{{ button_delete }}" class="btn btn-danger" onclick="confirm('{{ text_confirm }}') ? $('#form-review').submit() : false;"><i class="fa fa-trash-o"></i></button>
      </div>
      <h1>{{ heading_title }}</h1>
      <ul class="breadcrumb">
        {% for breadcrumb in breadcrumbs %}
        <li><a href="{{ breadcrumb.href }}">{{ breadcrumb.text }}</a></li>
        {% endfor %}
      </ul>
    </div>
  </div>
  <div class="container-fluid">
    {% if error_warning %}
    <div class="alert alert-danger alert-dismissible"><i class="fa fa-exclamation-circle"></i> {{ error_warning }}
      <button type="button" class="close" data-dismiss="alert">&times;</button>
    </div>
    {% endif %}
    {% if success %}
    <div class="alert alert-success alert-dismissible"><i class="fa fa-check-circle"></i> {{ success }}
      <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"><i class="fa fa-list"></i> {{ text_list }}</h3>
      </div>
      <div class="panel-body">
        <div class="maxy-backdrop"></div>
	    <div class="messages-body"></div>
        <form action="{{ delete }}" method="post" enctype="multipart/form-data" id="form-review">
          <div class="table-responsive">
            <table class="table table-bordered table-hover">
              <thead>
                <tr class="table-pagination">
				  <td colspan="8">
					<div class="pull-left">{{ pagination }}</div>
					{% if pagination %}
					  <div class="pull-right pagination-text">{{ results }}</div>
					  {% else %}
					  <div class="pull-right">{{ results }}</div>
					{% endif %}
				  </td>
				</tr>
				<tr>
                  <td style="width: 1px;" class="text-center"><input type="checkbox" onclick="$('input[name*=\'selected\']').prop('checked', this.checked);" /></td>
                  <td class="text-left">{% if sort == 'pd.name' %} <a href="{{ sort_product }}" class="{{ order|lower }}">{{ column_product }}</a> {% else %} <a href="{{ sort_product }}">{{ column_product }}</a> {% endif %}</td>
                  <td class="text-left">{% if sort == 'r.author' %} <a href="{{ sort_author }}" class="{{ order|lower }}">{{ column_author }}</a> {% else %} <a href="{{ sort_author }}">{{ column_author }}</a> {% endif %}</td>
                  <td class="text-center">{% if sort == 'r.rating' %} <a href="{{ sort_rating }}" class="{{ order|lower }}">{{ column_rating }}</a> {% else %} <a href="{{ sort_rating }}">{{ column_rating }}</a> {% endif %}</td>
				  <td class="text-center" style="width: 80px; min-width: 80px;">{{ column_text }}</td>
                  <td class="text-center" style="width: 150px; min-width: 150px;">{% if sort == 'r.date_added' %} <a href="{{ sort_date_added }}" class="{{ order|lower }}">{{ column_date_added }}</a> {% else %} <a href="{{ sort_date_added }}">{{ column_date_added }}</a> {% endif %}</td>
				  <td class="text-center" style="width: 80px; min-width: 80px;">{% if sort == 'r.status' %} <a href="{{ sort_status }}" class="{{ order|lower }}">{{ column_status }}</a> {% else %} <a href="{{ sort_status }}">{{ column_status }}</a> {% endif %}</td>
                  <td class="text-center" style="width: 80px; min-width: 80px;">{{ column_action }}</td>
                </tr>
                <tr class="table-filter">
				  <td></td>
				  <td class="text-left"><input type="text" name="filter_product" value="{{ filter_product }}" class="form-control" /></td>	
				  <td class="text-left"><input type="text" name="filter_author" value="{{ filter_author }}" class="form-control" /></td>
				  <td class="text-center">
				    <select onchange="filter();" name="filter_rating" class="form-control">
					  {% for key, value in select_rating %}
						{% if key == filter_rating %}
						  <option value="{{ key }}" selected="selected">{{ value }}</option>
						  {% else %}
						  <option value="{{ key }}">{{ value }}</option>
					    {% endif %}
					  {% endfor %}
				    </select>
				  </td>
				  <td></td>
				  <td class="text-center">
				    <div class="input-group date">
					  <input type="text" name="filter_date_added" value="{{ filter_date_added }}" data-date-format="YYYY-MM-DD" class="form-control" />
					  <span class="input-group-btn"><button type="button" class="btn btn-default"><i class="fa fa-calendar"></i></button></span>
					</div>
				  </td>
				  <td class="text-center">
				    <select onchange="filter();" name="filter_status" class="form-control">
					  <option value="*"></option>
					  {% if filter_status == '1' %}
						<option value="1" selected="selected">{{ text_enabled }}</option>
						{% else %}
						<option value="1">{{ text_enabled }}</option>
					  {% endif %}
					  {% if filter_status == '0' %}
						<option value="0" selected="selected">{{ text_disabled }}</option>
						{% else %}
						<option value="0">{{ text_disabled }}</option>
					  {% endif %}
					</select>
				  </td>
				  <td class="text-center"><button type="button" onclick="filter();" data-toggle="tooltip" title="{{ button_filter }}" class="btn btn-info btn-sm"><i class="fa fa-search"></i></button></td>
				</tr>
			  </thead>
			  <tbody>
				{% if reviews %}
                  {% for review in reviews %}
					<tr>
					  <td class="text-center">
					    {% if review.review_id in selected %}
                          <input type="checkbox" name="selected[]" value="{{ review.review_id }}" checked="checked" />
                          {% else %}
                          <input type="checkbox" name="selected[]" value="{{ review.review_id }}" />
                        {% endif %}
					  </td>
					  <td class="text-left">
						{% if review_product %}
						  <a data-toggle="popover-maxy" data-target="#review-name-{{ review.review_id }}" data-placement="right right-top" id="review-name{{ review.review_id }}" class="btn-hover-list">{{ review.name }}</a>
						  {% else %}
						  {{ review.name }}
						{% endif %}
					  </td>
					  <td class="text-left">
						{% if review_author %}
						  <a data-toggle="popover-maxy" data-target="#review-author-{{ review.review_id }}" data-placement="right right-top" id="review-author{{ review.review_id }}" class="btn-hover-list">{{ review.author }}</a></td>
						  {% else %}
						  {{ review.author }}
						{% endif %}
					  </td>
					  {% if review_rating %}
						<td class="text-center">
						  <a data-toggle="popover-maxy" data-target="#review-rating-{{ review.review_id }}" data-placement="right right-top" id="review-rating{{ review.review_id }}" class="btn btn-link btn-sm">
							<span class="rating">
							  {% for i in 1..5 %}
							    {% if review.rating < i %}
								  <span class="fa fa-stack"><i class="fa fa-star-o fa-stack-2x"></i></span>
								  {% else %}
								  <span class="fa fa-stack"><i class="fa fa-star fa-stack-2x"></i><i class="fa fa-star-o fa-stack-2x"></i></span>
								{% endif %}
							  {% endfor %}
							</span>
						  </a>
						</td>
						{% else %}
						<td class="text-center">
						  <span class="rating">
							{% for i in 1..5 %}
							  {% if review.rating < i %}
								<span class="fa fa-stack"><i class="fa fa-star-o fa-stack-2x"></i></span>
								{% else %}
								<span class="fa fa-stack"><i class="fa fa-star fa-stack-2x"></i><i class="fa fa-star-o fa-stack-2x"></i></span>
							  {% endif %}
							{% endfor %}
						  </span>
						</td>
					  {% endif %}
					  <td class="text-center">
						{% if review_text %}
						  <a data-toggle="popover-maxy" data-target="#review-text-{{ review.review_id }}" data-placement="left left-top" class="btn btn-primary btn-sm"><i class="fa fa-edit"></i></a>
						  {% else %}
						  <span class="btn btn-link btn-sm" data-toggle="tooltip" title="{{ review.text }}"><i class="fa fa-eye"></i></span>
					    {% endif %}
					  </td>
					  <td class="text-center">{{ review.date_added }}</td>
					  <td class="text-center">
					    {% if review_status %}
						  <a class="ajax-status" id="status-{{ review.review_id }}">{{ review.status }}</a>
						  {% else %}
						  {{ review.no_status }}
						{% endif %}
					  </td>
					  <td class="text-center"><a href="{{ review.edit }}" data-toggle="tooltip" title="{{ button_edit }}" class="btn btn-primary btn-sm"><i class="fa fa-pencil"></i></a></td>
					</tr>
				  {% endfor %}
                  {% else %}
                  <tr>
                    <td class="text-center" colspan="8">{{ text_no_results }}</td>
                  </tr>
                {% endif %}
              </tbody>
			  <tfoot>
			    <tr>
                  <td style="width: 1px;" class="text-center"><input type="checkbox" onclick="$('input[name*=\'selected\']').prop('checked', this.checked);" /></td>
                  <td class="text-left">{% if sort == 'pd.name' %} <a href="{{ sort_product }}" class="{{ order|lower }}">{{ column_product }}</a> {% else %} <a href="{{ sort_product }}">{{ column_product }}</a> {% endif %}</td>
                  <td class="text-left">{% if sort == 'r.author' %} <a href="{{ sort_author }}" class="{{ order|lower }}">{{ column_author }}</a> {% else %} <a href="{{ sort_author }}">{{ column_author }}</a> {% endif %}</td>
                  <td class="text-center">{% if sort == 'r.rating' %} <a href="{{ sort_rating }}" class="{{ order|lower }}">{{ column_rating }}</a> {% else %} <a href="{{ sort_rating }}">{{ column_rating }}</a> {% endif %}</td>
				  <td class="text-center">{{ column_text }}</td>
                  <td class="text-center">{% if sort == 'r.date_added' %} <a href="{{ sort_date_added }}" class="{{ order|lower }}">{{ column_date_added }}</a> {% else %} <a href="{{ sort_date_added }}">{{ column_date_added }}</a> {% endif %}</td>
				  <td class="text-center">{% if sort == 'r.status' %} <a href="{{ sort_status }}" class="{{ order|lower }}">{{ column_status }}</a> {% else %} <a href="{{ sort_status }}">{{ column_status }}</a> {% endif %}</td>
                  <td class="text-center">{{ column_action }}</td>
                </tr>
				<tr class="table-pagination">
				  <td colspan="8">
					<div class="pull-left">{{ pagination }}</div>
					{% if pagination %}
					  <div class="pull-right pagination-text">{{ results }}</div>
					  {% else %}
					  <div class="pull-right">{{ results }}</div>
					{% endif %}
				  </td>
				</tr>
			  </tfoot>
            </table>
          </div>
        </form>
      </div>
    </div>
  </div>
  <input type="hidden" name="permission" value="{{ permission }}" id="review-permission" />
  <input type="hidden" name="error_permission" value="{{ error_permission }}" id="review-error-permission" />
  {% if reviews %}
    {% for review in reviews %}
	  <div id="review-name-{{ review.review_id }}" class="popover popover-primary popover-md animate littleFadeInRight">
	    <div class="arrow"></div><h3 class="popover-title">{{ column_product }}
	    <a id="close-name-{{ review.review_id }}" data-dismiss="popover-maxy" class="btn btn-default btn-xs"><i class="fa fa-close"></i></a></h3>
	    <div class="popover-content">
		<input type="text" name="product" value="{{ review.name }}" placeholder="{{ column_product }}" id="input-name{{ review.review_id }}" class="form-control" /><input id="input-product{{ review.review_id }}" type="hidden" name="product_id" value="{{ review.product_id }}" />
	    </div>
	    <div class="popover-footer">
		  <a onclick="editReviewProduct('{{ review.review_id }}');" class="btn btn-primary btn-sm"><i class="fa fa-save fa-fw"></i></a><a onclick="nameClear('{{ review.review_id }}');" class="btn btn-danger btn-sm"><i class="fa fa-eraser fa-fw"></i></a>
	    </div>
	  </div>
	  <div id="review-author-{{ review.review_id }}" class="popover popover-primary popover-sm animate littleFadeInRight">
	    <div class="arrow"></div><h3 class="popover-title">{{ column_author }}
	    <a id="close-author-{{ review.review_id }}" data-dismiss="popover-maxy" class="btn btn-default btn-xs"><i class="fa fa-close"></i></a></h3>
	    <div class="popover-content">
		  <input type="text" name="author" value="{{ review.author }}" placeholder="{{ column_author }}" id="input-author{{ review.review_id }}" class="form-control" />
	    </div>
	    <div class="popover-footer">
		  <a onclick="editReviewAuthor('{{ review.review_id }}');" class="btn btn-primary btn-sm"><i class="fa fa-save fa-fw"></i></a><a onclick="authorClear('{{ review.review_id }}');" class="btn btn-danger btn-sm"><i class="fa fa-eraser fa-fw"></i></a>
	    </div>
	  </div>
	  <div id="review-text-{{ review.review_id }}" class="popover popover-primary popover-lg animate littleFadeInLeft">
	    <div class="arrow"></div><h3 class="popover-title">{{ column_text }}
	    <a id="close-text-{{ review.review_id }}" data-dismiss="popover-maxy" class="btn btn-default btn-xs"><i class="fa fa-close"></i></a></h3>
	    <div class="popover-content">
		  <textarea name="text" rows="8" placeholder="{{ column_text }}" id="input-text{{ review.review_id }}" class="form-control">{{ review.text }}</textarea>
	    </div>
	    <div class="popover-footer">
		  <a onclick="editReviewText('{{ review.review_id }}');" class="btn btn-primary btn-sm"><i class="fa fa-save fa-fw"></i></a><a onclick="textClear('{{ review.review_id }}');" class="btn btn-danger btn-sm"><i class="fa fa-eraser fa-fw"></i></a>
	    </div>
	  </div>
	  <div id="review-rating-{{ review.review_id }}" class="popover popover-primary animate littleFadeInRight">
	    <div class="arrow"></div><h3 class="popover-title">{{ column_rating }}
	    <a id="close-rating-{{ review.review_id }}" data-dismiss="popover-maxy" class="btn btn-default btn-xs"><i class="fa fa-close"></i></a></h3>
	    <div class="popover-content text-center">
		  <input value="{{ review.rating }}" type="number" class="rating" id="input-rating{{ review.review_id }}" min="0" max=5 step="1" data-size="lg" data-language="{{ datepicker }}">
	    </div>
	    <div class="popover-footer">
		  <a onclick="editReviewRating('{{ review.review_id }}');" class="btn btn-primary btn-sm"><i class="fa fa-save fa-fw"></i></a>
	    </div>
	  </div>
	{% endfor %}
  {% endif %}
  <script type="text/javascript"><!--
$('.date').datetimepicker({
	language: '{{ datepicker }}',
	pickTime: false
});
//--></script></div>
{{ footer }}