<?php
/**
 * This is a core PHP file. For customization, create a file in the folder /custom/.
 * Files with the same filename in this folder will automatically be loaded instead of the current file
 */
?>
<div class="sidebar-column p-t-1">

	<?php
	$search = Cache::get('filter-list-group-vps');
	?>
	<form class="m-b-2 form-list-search" role="search" action="<?php echo __SITE_URL . '/' . __('vps', 'url'); ?>">
		<input type="text" class="form-control" placeholder="<?php echo __('search'); ?>" value="<?php if($search){ echo normalize($search); } ?>" id="list-search">
	</form>

	<?php
	if(!empty($vps_list))
	{
		?>
		<div id="list-items">

			<h3 class="m-b-1 m-t-2">
				<a class="hidden-lg-up" data-toggle="collapse" href="#list-group-vps" aria-controls="list-group-vps">
					<?php echo __('vps services'); ?>
				</a>
				<span class="hidden-md-down"><?php echo __('vps services'); ?></span>
				<span class="tag tag-default tag-pill pull-xs-right result-count"><?php echo ($vps_list) ? count($vps_list) : 0; ?></span>
			</h3>

			<div class="list-group full-width collapse collapse-md-up row scrollable-list" id="list-group-vps">
				<?php
				// Button for new VPS...
				if(Settings_Model::get('CLIENTAREA_VPS_ORDERFORM') && Settings_Model::get('CLIENTAREA_VPS_ORDERFORM') > 0)
				{
					// Normal link, which will open in client area
					?>
					<a href="<?php echo __SITE_URL . '/' . __('vps', 'url') . '/' . __('orderNew', 'url'); ?>" class="list-group-item list-group-item-action text-truncate text-xs-center hidden-sm-down <?php if(get_url_string() == 'vps.orderNew'){ echo ' active'; } ?>">
						<span class="fas fa-plus"></span> <?php echo __('order new vps'); ?>
					</a>
					<?php
					// And a responsive link, which opens in new tab
					?>
					<a href="<?php echo Settings_Model::get('ORDERFORM_URL') . '?cart=' . Settings_Model::get('CLIENTAREA_VPS_ORDERFORM'); ?>" class="list-group-item list-group-item-action text-truncate text-xs-center hidden-md-up" target="_blank">
						<span class="fas fa-plus"></span> <?php echo __('order new vps'); ?>
					</a>
					<?php
				}

				if(is_array($vps_list))
				{
					foreach($vps_list as $_item)
					{
						$active = (isset($service->id) && $_item['Identifier'] == $service->id) ? 'active' : '';
						?>
						<a href="<?php echo __SITE_URL . '/' . __('vps', 'url') . '/' . __('view', 'url') . '/' . $_item['Identifier']; ?>" class="list-group-item list-group-item-action <?php echo $active; ?>" data-search-term="<?php echo strtolower(normalize($_item['Hostname'])); ?>">
							<?php
							if(isset($_item['Termination']) && $_item['Termination'])
							{
								?>
								<s><?php echo normalize($_item['Hostname']); ?></s>
								<div class="clearfix">
									<small class="text-muted"><?php echo sprintf(__('service list termination at'), rewrite_date_db2site($_item['Termination']['Date'])); ?></small>
								</div>
								<?php
							}
							else
							{
								echo normalize($_item['Hostname']);
							}
							?>
						</a>
						<?php
					}
				}
				?>
				<a id="list-search-noresult" class="list-group-item hide"><?php echo __('no search results found'); ?></a>
			</div>
		</div>
		<?php
	}
	?>


</div>