<?php
if (isset($tpl['status']))
{
	$status = __('status', true);
	switch ($tpl['status'])
	{
		case 2:
			pjUtil::printNotice(NULL, $status[2]);
			break;
	}
} else {
	?>
	<div class="ui-tabs ui-widget ui-widget-content ui-corner-all b10">
		<ul class="ui-tabs-nav ui-helper-reset ui-helper-clearfix ui-widget-header ui-corner-all">
			<li class="ui-state-default ui-corner-top ui-tabs-active ui-state-active"><a href="<?php echo $_SERVER['PHP_SELF']; ?>?controller=pjAdminListings&amp;action=pjActionPayment&amp;id=<?php echo $_GET['id']; ?>"><?php __('lblListingExtend'); ?></a></li>
		</ul>
	</div>
	<?php
	pjUtil::printNotice(__('infoListingExtendTitle', true), __('infoListingExtendBody', true));
	?>
	<div class="form pj-form b10">
		<p>
			<label class="title"><?php __('lblListingTitle'); ?>:</label>
			<span class="left"><?php echo stripslashes($tpl['arr']['listing_title']); ?> / <a href="<?php echo PJ_INSTALL_URL; ?>index.php?controller=pjAdminListings&amp;action=pjActionUpdate&amp;id=<?php echo $tpl['arr']['id']; ?>"><?php echo $tpl['arr']['id']; ?></a></span>
		</p>
		<p>
			<label class="title"><?php __('lblListingExpire'); ?>:</label>
			<span class="left"><?php echo pjUtil::formatDate($tpl['arr']['expire'], 'Y-m-d', $tpl['option_arr']['o_date_format']); ?></span>
		</p>
	</div>
	<?php
	$dm = new pjDependencyManager(PJ_INSTALL_PATH, PJ_THIRD_PARTY_PATH);
	$dm->load(PJ_CONFIG_PATH . 'dependencies.php')->resolve();
	?>
	<link href="<?php echo PJ_INSTALL_URL;?>core/framework/libs/pj/css/pj.bootstrap.min.css" type="text/css" rel="stylesheet" />
	<script src="<?php echo PJ_INSTALL_URL . $dm->getPath('pj_jquery'); ?>pjQuery.min.js"></script>
	<script src="<?php echo PJ_INSTALL_URL . $dm->getPath('pj_bootstrap'); ?>pjQuery.bootstrap.min.js"></script>
	<table class="pj-table" cellpadding="0" cellspacing="0" style="width: 100%">
		<thead>
			<tr>
				<th><?php __('listing_payment_period'); ?></th>
				<th><?php __('listing_payment_price'); ?></th>
				<th></th>
			</tr>
		</thead>
		<tbody>
		<?php
		$pjPaypal = pjObject::getPlugin('pjPaypal') !== NULL;
		foreach ($tpl['period_arr'] as $i => $period)
		{
			if ((int) $period['days'] > 0)
			{
				if ((float) $period['price'] > 0)
				{
					?>
					<tr>
						<td><?php echo $period['days']; ?> <?php __('lblDays'); ?></td>
						<td><?php echo $period['price']; ?> <?php echo $tpl['option_arr']['o_currency']; ?></td>
						<td>
							<button type="button" class="pj-button btnListingPaymentRenew" data-listing_id="<?php echo $_GET['id'];?>" data-period_id="<?php echo $period['id'];?>"><?php __('listing_payment_renew_paypal');?></button>
						</td>
					</tr>
					<?php
				} else {
					?>
					<tr>
						<td><?php echo $period['days']; ?> <?php __('lblDays'); ?></td>
						<td><?php __('listing_payment_free'); ?></td>
						<td>
							<form action="<?php echo $_SERVER['PHP_SELF']; ?>?controller=pjAdminListings&amp;action=pjActionExtend" method="post">
			<input type="hidden" name="csrf_token" value="<?php echo pjAppController::getCsrfToken(); ?>">
								<input type="hidden" name="extend" value="1" />
								<input type="hidden" name="id" value="<?php echo $tpl['arr']['id']; ?>" />
								<input type="hidden" name="period_id" value="<?php echo $period['id']; ?>" />
								<input type="submit" value="<?php __('listing_payment_renew_free'); ?>" class="pj-button" />
							</form>
						</td>
					</tr>
					<?php
				}
			}
		}
		?>
		</tbody>
	</table>
	<div id="pjWrapperCarListing">
		<div class="paypalPaymentForm"></div>
	</div>
	<?php
}
?>