<?
	$this->title = 'Support';
	$this->titleicon = 'comments';
?>

<div class="container-fluid padded">
	<div class="row-fluid">
	<div id="issues">
		<i class="icon-spinner icon-spin"></i>
	</div>
	</div>
</div>

<div class="container-fluid padded">
	<div class="row-fluid">
		<div class="span6">
			<?php if( c::admin()->permission()->check( [ 'global', 'support-all', 'support-settings' ] ) ) { ?>
			<div class="box">
				<div class="box-header"><span class="title">Settings</span></div>

				<div class="box-content">
					<form class="fill-up">
						<ul class="box-list">
							<li class="input">
								<span>Num to call after 1AM</span>
								<span class="pull-right">
									<input type="text" placeholder="" name="support-phone-afterhours" id="support-phone-afterhours" value='<?=c::config()->site->config('support-phone-afterhours')->value?>'>
								</span>
							</li>
								<li class="input">
									<button type="button" class="btn btn-blue button-save-settings">Save changes</button>
								</li>
						</ul>
					</form>
				</div>

			</div>
			<?php } ?>
		</div>
	</div>
</div>

<div id="container-chats"></div>

<div class="modal hide fade" id="modal-sms" style="display: none; left: 50%;">
	<div class="modal-header">
		<button class="close" data-dismiss="modal" type="button">×</button>
		<h6 id="modal-sms-title"></h6>
	</div>
	<div class="modal-body" id="modal-sms-body"></div>
	<div class="modal-footer">
		<button class="btn btn-default" data-dismiss="modal">Close</button>
	</div>
</div>


<script type="text/javascript">

var status = 'open';
var type = 'all';

function load( url ){
	$.ajax( {
		url: url,
		complete: function( content ) {
			$( '#issues' ).html( content.responseText );
		}
	} );
};

$( function() {
	load( '/support/content?status=' + status + '&type=' + type );

	$('.button-save-settings').click(function() {
		var self = $(this);
		$(this).attr('disabled','disabled');

		$.ajax({
			type: 'POST',
			url: '/api/siteconfig',
			data: {
				key: 'support-phone-afterhours',
				value: $('[name="support-phone-afterhours"]').val()
			},
			complete: function(data) {
				self.removeAttr('disabled');
			}
		});
	});
});
</script>
<style type="text/css">
	.chat-title{
		cursor: pointer;
	}
	.chat-container{
		position:fixed;
		height:344px;
		width:250px;
		bottom:5px;
		z-index:1;
	}
	.chat-input{
		width: 241px;
		border: 1px solid #FFF;
	}
	.row-green{
		background: #cef5d7 !important;
	}
		.row-green-dark{
			background: #b4f0c2 !important;
		}
	.row-red{
		background: #ffbdbd !important;
	}
		.row-red-dark{
			background: #ffa3a3 !important;
		}
		.avatar{
			width: 20px;
		}
	.arrow-box-left{
		margin-left: 20px !important;
	}
	.arrow-box-right{
		margin-right: 20px !important;
	}
	.box-note-system, .box-note{
		-webkit-border-radius: 3px;
		-moz-border-radius: 3px;
		border-radius: 3px;
		background: #f0fff4;
		border: 1px solid #a8b3ab;
		padding:5px 15px;
		margin:15px 15px;
	}
	.box-note-system{
		color: #666;
		background: #F5F5F5;
		border: 1px solid #CCC;
	}
</style>
<script type="text/javascript" src="/assets/js/admin.support.js?v=<?=$_ENV['HEROKU_SLUG_COMMIT']?>"></script>