<?php if(@$error): ?>
	<div class="alert alert-dismissible alert-danger">
		<button type="button" class="close" data-dismiss="alert">×</button>
		<strong>Hata!</strong> <?=$errorText?>
	</div>
<?php endif; ?>
<?php if(@$success): ?>
	<div class="alert alert-dismissible alert-success">
		<button type="button" class="close" data-dismiss="alert">×</button>
		<strong>Başarılı!</strong> <?=$success?>
	</div>
<?php endif; ?>
<a href="#" class="btn btn-success" style="margin-bottom:20px;" data-toggle="modal" data-target="#addApi">Yeni Sağlayıcı Ekle</a>
<div class="panel panel-default">
	<div class="panel-body" style="padding:0;">
		<table class="table" style="margin-bottom:0;">
			<thead>
				<tr>
					<th class="p-l" width="45%">Sağlayıcı</th>
					<th>Bakiye</th>
					<th></th>
				</tr>
			</thead>
			<tbody>
				<?php foreach($apis as $api): ?>
					<?php $api_balance = api_balance($api["api_url"], $api["api_key"]); ?>
					<tr>
						<td><?=$api["api_url"];?></td>
						<td><?=($api_balance != null) ? $api_balance["balance"]." ".$api_balance["currency"] : "---";?></td>
						<td>
							<div class="dropdown pull-right">
								<button class="btn btn-xs btn-default dropdown-toggle" type="button" id="dropdownMenu1" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">İşlemler<span class="caret"></span></button>
								<ul class="dropdown-menu" aria-labelledby="dropdownMenu1">
									<li><a href="#" data-toggle="modal" data-toggle="modal" data-target="#modalDefault" onclick="edit_provider(<?=$api["api_id"];?>)">Düzenle</a></li>
									<li><a href="#" onclick="delete_api(<?=$api["api_id"];?>)">Sil</a></li>
								</ul>
							</div>
						</td>
						<input type="hidden" name="privder_changes" value="privder_changes">
					</tr>
				<?php endforeach; ?>
			</tbody>
		</table>
	</div>
</div>
</div>

<div id="addApi" class="modal fade" role="dialog">
	<div class="modal-dialog">

		<!-- Modal content-->
		<div class="modal-content">
			<div class="modal-header">
				<button type="button" class="close" data-dismiss="modal">&times;</button>
				<h4 class="modal-title">Yeni Sağlayıcı Ekle</h4>
			</div>
			<div class="modal-body">
				<form id="add_api" onsubmit="return false;" data-reset="1">
					<div class="form-group">
						<div class="input-group">
							<span class="input-group-addon"><b>API URL</b></span>
							<input type="text" name="url" class="form-control"required>
						</div>
					</div>
					<div class="form-group">
						<div class="input-group">
							<span class="input-group-addon"><b>API KEY</b></span>
							<input type="text" name="key" class="form-control"required>
						</div>
					</div>
					<div class="form-group text-right">
						<button type="button" class="btn btn-default" data-dismiss="modal">Vazgeç</button>
						<button type="submit" class="btn btn-success">Ekle</button>
					</div>
				</form>
			</div>
		</div>

	</div>
</div>