{{ header }}{{ column_left }}
<div id="content">
  <div class="page-header">
    <div class="container-fluid">
      <div class="pull-right">
        <button type="submit" form="form-call" data-toggle="tooltip" title="{{ button_save }}" class="btn btn-primary"><i class="fa fa-save"></i></button>
        <a href="{{ cancel }}" data-toggle="tooltip" title="{{ button_cancel }}" class="btn btn-default"><i class="fa fa-reply"></i></a></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">
	<div class="row">
      <div class="col-sm-12">
        <div class="panel panel-default">
      <div class="panel-heading">
        <h3 class="panel-title"><i class="fa fa-pencil"></i>{{ entry_status }}</h3>
      </div>
      <div class="panel-body">
        <form action="{{ action }}" method="post" enctype="multipart/form-data" id="form-call" class="form-horizontal">

          <fieldset>
            <div class="form-group">
              <div class="col-sm-12">
                <select name="call_status" id="input-status" class="form-control">
                  {% if call_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>
            </div>

        </form>
      </div>
    </div>
		<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="table-responsive">
              <table class="table table-bordered table-hover">
                <thead>
                  <tr>
                    <td class="text-left">№</td>
                    <td class="text-left">Данные</td>
					<td class="text-left">Время перезвона</td>
                    <td class="text-left">Статус заявки</td>
                    <td class="text-left">Комментарий менеджера</td>
                    <td class="text-left">Дата</td>
                    <td class="text-left">x</td>
                  </tr>
                </thead>
                <tbody>
                {% if calls %}
                {% for call in calls %}
                <tr id="bg{{ call.id }}" class="{{ call.manager_status == 0 ? 'red' : "" }}{{ call.manager_status == 1 ? 'green' : "" }}{{ call.manager_status == 2 ? 'blue' : "" }}">
                  <td class="text-left">{{ call.id }}</td>
                  <td class="text-left">
				  Телефон: {{ call.phone }}<br>
				  Имя: {{ call.name }}
				  
				  </td>
				  <td class="text-left">{{ call.time }}</td>
				  
                  <td class="text-left">
				  <select onchange="status(this, {{ call.id }})" name="manager_status" class="form-control">
                                 <option value="0" {{ call.manager_status == 0 ? 'selected="selected"' : "" }}>Необработан</option>
                                 <option value="1" {{ call.manager_status == 1 ? 'selected="selected"' : "" }}>Перезвонили</option>
                                 <option value="2" {{ call.manager_status == 2 ? 'selected="selected"' : "" }}>Недозвонились</option>
                              </select>
				  </td>
                  <td class="text-left"><textarea name="comm" placeholder="Комментарий" id="manager-comment{{ call.id }}" onblur="posting({{ call.id }})" class="form-control">{{ call.manager_comment }}</textarea></td>
                  <td class="text-left">{{ call.date_created }}</td>
                  <td class="text-right"><button type="button" data-toggle="tooltip" title="" class="btn btn-danger" onclick="del('{{ call.id }}')"><i class="fa fa-trash-o"></i></button></td>
                </tr>
                {% endfor %}
                {% else %}
                <tr>
                  <td colspan="7" class="text-center">{{ text_no_results }}</td>
                </tr>
                {% endif %}
                  </tbody>
                
              </table>
            </div>
            <div class="row">
              <div class="col-sm-6 text-left">{{ pagination }}</div>
          <div class="col-sm-6 text-right">{{ results }}</div>
            </div>
          </div>
        </div>
      </div>
    </div>
  </div>
  <script type="text/javascript"><!--
	function del(id) {      
				var r=confirm("варнинг");
				if (r==true) {
					$.ajax({
						url: 'index.php?route=madeshop/call/del&user_token={{ user_token }}',
						type: 'post',
						data: {'id': id},
						success: function(response) {
						$('#bg'+id).slideUp();
					}
				});
			 }
			}
			function posting(id) { 
                    var com = $('#manager-comment'+id).val();					
					$.ajax({
						url: 'index.php?route=madeshop/call/posting&user_token={{ user_token }}',
						type: 'post',						
						data: ({ 'manager_comment': com,'id': id }),
				});
			}
			function status(sval, id) {
		
		if ((sval.value)==0){
			$('#bg'+id).removeClass('green blue').addClass('red');			
		};
		if ((sval.value)==1){
			$('#bg'+id).removeClass('blue red').addClass('green');			
		};
		if ((sval.value)==2){
			$('#bg'+id).removeClass('green red').addClass('blue');			
		};
		
                $.ajax({
						url: 'index.php?route=madeshop/call/status&user_token={{ user_token }}',
						type: 'post',						
						data: ({ 'manager_status': sval.value,'id': id }),
				});
	
	}
//--></script> 
</div><style>
.blue{background: #ececf3;}
.red{background: #f3ecee;}
.green{background: #ecf3ef;}
</style>
{{ footer }}