<?php echo $header;?>
<div id="dashboard">
	<div class="container">
<div class="row"><br/></div>
<div class="panel">

	<div class="panel-header">

				<?php echo $LANG["WBS_ADVERTISER_KEYWORDS_MANAGE_AD_KEYWORDS"];?>
			<span class="pull-right">


		<?php if ( $ad['0']['aau_type'] == '1' ) { ?>
			<a href="<?php echo HTTP_MASTER ?>dashboard/advertiser/ad?id=<?php echo $ad['0']['aau_id'];?>"><?php echo $LANG["WBS_ADVERTISER_KEYWORDS_EDIT_AD"];?></a>
		<?php } else { ?>
			<a href="<?php echo HTTP_MASTER ?>dashboard/advertiser/ad/banner?id=<?php echo $ad['0']['aau_id'];?>"><?php echo $LANG["WBS_ADVERTISER_KEYWORDS_EDIT_AD"];?></a>
		<?php }?>

		</span>
			<div class="row"></div>
	</div>

<div class="panel-content">
<div class="row"><br/></div>

<input id="adv-max-value" type="text" value="<?php echo ( $advertiser['0']['adv_profile_deposits'] - $advertiser['0']['adv_profile_spent'] );?>" style="display:none;"/>
<input id="ad-ad_id" type="text" value="<?php echo $ad['0']['aau_id'];?>" style="display:none;"/>



<?php if ( $ad['0']['aau_type'] == '1' ) { ?>
<div class="col-md-12">
	<div style="width:460px;" class="pull-left adPreviewKeywords">
			<div id="title_1" class="title"><?php echo $ad['0']['aau_title'];?></div>
			<div id="url_1" class="url"><?php echo $ad['0']['aau_url'];?></div>
			<div id="description_1" class="description"><?php echo $ad['0']['aau_summary'];?> <?php echo $ad['0']['aau_summary_2'];?></div>
	</div>
	<div class="row"></div>
	<div class="pull-left adPreviewKeywords2">
			<div id="title_2" class="title"><?php echo $ad['0']['aau_title'];?></div>
			<div id="url_2" class="url"><?php echo $ad['0']['aau_url'];?></div>
			<div id="description_2_1"class="description"><?php echo $ad['0']['aau_summary'];?></div>
			<div id="description_2_2" class="description"><?php echo $ad['0']['aau_summary_2'];?></div>
	</div>
</div>
<?php } else { ?>
<div class="col-md-12">
	<div id="adPreviewImage" class="pull-left">
		<img src="<?php echo HTTP_SERVER_WEBSITE_UPLOADS_BANNER_ADS;?><?php echo $ad['0']['aau_file'];?>"/>
	</div>
</div>
<?php } ?>


<div class="row"><br/></div>




<div class="col-md-12">
<legend><?php echo $LANG["WBS_ADVERTISER_KEYWORDS_LIST"];?></legend>


<?php if ( $ad['0']['aau_status'] == '3' ) { ?>

	<div class="alert alert-danger" role="alert"><?php echo $LANG["WBS_ADVERTISER_KEYWORDS_AD_DISABLED"];?></div>

<?php } else { ?>


<label><?php echo $LANG["WBS_ADVERTISER_KEYWORDS_ADD_NEW_KEYWORD"];?></label>

<div class="row"><div class="col-md-12" id="ad-value-error"></div></div>
<div class="input-group">
	<div class="col-md-6 pull-left">
		<input placeholder="Enter your keyword" class="form-control" type="text" id="ad-keyword" name="ad-keyword">
	</div>
	<div class="input-group col-md-6 pull-left">
		<?php if ( MONEY_ALIGN == 'LEFT' ) { ?>
						<span class="input-group-addon"><?php echo MONEY_SYMBOL;?></span>
		<?php } ?>
			<input placeholder="Enter your keyword value, minimum : <?php echo COST_MIN_CLICK;?>" class="form-control number" type="text" id="ad-value" name="ad-value">
		<?php if ( MONEY_ALIGN == 'RIGHT' ) { ?>
						<span class="input-group-addon"><?php echo MONEY_SYMBOL;?></span>
		<?php } ?>
	</div>

		<span class="input-group-btn">
			<button id="adv-add-keyword" class="btn btn-default theme-btn" type="submit"><?php echo $LANG["WBS_ADVERTISER_KEYWORDS_SUBMIT"];?></button>
		</span>
</div>

<?php } ?>

<table id="keywords-list" class="table table-hover">
      <thead>
        <tr>
          <th><?php echo $LANG["WBS_ADVERTISER_KEYWORDS_KEYWORD"];?></th>
          <th><?php echo $LANG["WBS_ADVERTISER_KEYWORDS_VALUE"];?></th>
          <th><?php echo $LANG["WBS_ADVERTISER_KEYWORDS_RECOMMENDED_VALUE"];?></th>
          <th></th>
        </tr>
      </thead>
      <tbody>

<?php if ( !empty ( $ky ) ) { ?>

<?php foreach($ky as $k): ?>

	<tr id="keword-<?php echo $k['aauk_id'];?>">
		<td class="col-md-4">
			<?php echo $k['aauk_keyword'];?>
		</td>
		<td class="col-md-3">
			<div class="input-group">

<?php if ( MONEY_ALIGN == 'LEFT' ) { ?>
				<span class="input-group-addon"><?php echo MONEY_SYMBOL;?></span>
<?php } ?>
				
				<input id="adv-keyword-<?php echo $k['aauk_id'];?>" type="text" class="form-control number" placeholder="" value="<?php echo $k['aauk_price'];?>">

<?php if ( MONEY_ALIGN == 'RIGHT' ) { ?>
				<span class="input-group-addon"><?php echo MONEY_SYMBOL;?></span>
<?php } ?>


			</div>
		</td>
		<td class="col-md-2">

		<?php
			$price	=	$db->Query("select `aauk_price` from advertisers_ad_units_keywords where aauk_keyword=? and aauk_ad_id!=?","ss",$k['aauk_keyword'],$ad['0']['aau_id']);
		?>
		<?php if ( empty ( $price ) ) { ?>
			???
		<?php } else { ?>
			<?php echo $price['0']['aauk_price'] + INCREASE_VALUE; ?>
		<?php } ?>

		</td>
		<td class="col-md-3">
			<button id="keyword-update-button-<?php echo $k['aauk_id'];?>" data-id="<?php echo $k['aauk_id'];?>" type="button" class="btn btn-default btn-sm keyword-update"><span class="glyphicon glyphicon-pencil"></span> <?php echo $LANG["WBS_ADVERTISER_AD_KEYWORD_UPDATE"];?></button>&nbsp;&nbsp;<button id="keyword-remove-button-<?php echo $k['aauk_id'];?>" data-id="<?php echo $k['aauk_id'];?>" type="button" class="btn btn-default btn-sm keyword-remove"><span class="glyphicon glyphicon-trash"></span> <?php echo $LANG["WBS_ADVERTISER_AD_KEYWORD_REMOVE"];?></button>
		</td>
	</tr>

<?php endforeach; ?>

<?php } ?>

      </tbody>
</table>



</div>







<div class="row"><br/></div>
</div>

</div>
</div>
</div>
<?php echo $footer;?>